git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Installing git binaries on a non-default directory (Ubuntu)
@ 2015-04-10 16:34 Gianpaolo Macario
  2015-04-13  6:05 ` Junio C Hamano
  0 siblings, 1 reply; 4+ messages in thread
From: Gianpaolo Macario @ 2015-04-10 16:34 UTC (permalink / raw)
  To: git

Hello,

I need to distribute a set of programs - including a recent version of git - 
to a large set of users.

The users are running different versions of Linux (Ubuntu from 10.04 
onwards) and are not supposed to know how to build the programs from 
sources.
Also they should be able to choose where to install the binaries.

My idea was to build git on the oldest supported machine (Ubuntu 10.04.4 32-
bit), then create a tarball incluing the installation directory which was 
created by git "make install":

By some googling and after reading the git sources and the commit logs I 
assumed that the `RUNTIME_PREFIX` option
(see <https://github.com/git/git/blob/master/exec_cmd.c>) was designed for 
that purpose, so I did the following:

    $ mkdir -p ~/tmp
    $ cd ~/tmp
    $ wget http://kernel.org/pub/software/scm/git/git-2.3.5.tar.gz
    $ tar -xvzf git-2.3.5.tar.gz
    $ cd git-2.3.5
    $ ./configure --prefix=$HOME/git-install \
    --with-curl --with-openssl --without-tcltk \
    CFLAGS="${CFLAGS} -DRUNTIME_PREFIX=1 `pkg-config --static --libs 
libcurl`"
    $ make
    $ make install
    $ cd $HOME/git-install
    $ tar -cvzf ~/git-install-2.3.5.tar.gz .
    $ cd
    $ rm -rf ~/tmp/git-2.3.5
    $ rm -rf $HOME/git-install

Everything seems OK as long as the tarball is extracted under the same
directory where the binaries where installed by `make install`
(in my case, `/home/gmacario/git-install`):

    gmacario@alm-gm-oipbuild05:~$ ~/git-install/bin/git --version
    git version 2.3.5
    gmacario@alm-gm-oipbuild05:~$ ~/git-install/bin/git --exec-path
    /home/gmacario/git-install/libexec/git-core
    gmacario@alm-gm-oipbuild05:~$

However if the user chooses to install it somewhere else - for instance

    $ sudo mkdir -p /opt/tools
    $ sudo chown $USER /opt/tools
    $ cd /opt/tools
    $ tar -xvzf ~/git-install-2.3.5.tar.gz

command `git --exec-path` still returns the directory where
the binaries were installed by `make install`:

    gmacario@alm-gm-oipbuild05:~$ /opt/tools/bin/git --exec-path
    /home/gmacario/git-install/libexec/git-core
    gmacario@alm-gm-oipbuild05:~$

As a result non-builtin commands such as "git clone https://xxx" will not 
work.
Also the templates cannot be found as shown below:

    gmacario@alm-gm-oipbuild05:~$ /opt/tools/bin/git clone 
https://github.com/gmacario/hello.git
    Cloning into 'hello'...
    warning: templates not found /home/gmacario/git-install/share/git-
core/templates
    fatal: Unable to find remote helper for 'https'
    gmacario@alm-gm-oipbuild05:~$

Even though it is a nuisance I was able to work around the wrong "--exec-
path"
by setting the "GIT_EXEC_PATH" environment variable, but I still cannot
understand how to have the templates found in the proper directory.

According to 
<https://github.com/git/git/commit/35fb0e8633217f602360a9987af51c4b960e7850>
I am afraid that relocatable binaries is only half-baked in Unix:

  Note that RUNTIME_PREFIX only works on Windows, though adding
  support on Unix should not be too hard.  The implementation
  requires argv0_path to be set to an absolute path.  argv0_path must
  point to the directory of the executable.  We use assert() to
  verify this in debug builds.  On Windows, the wrapper for main()
  (see compat/mingw.h) guarantees that argv0_path is correctly
  initialized.  On Unix, further work is required before
  RUNTIME_PREFIX can be enabled.

Has anybody tried to do the same? Do you have any advices to give me?

Thanks,

Gianpaolo Macario

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-04-23 20:17 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-04-10 16:34 Installing git binaries on a non-default directory (Ubuntu) Gianpaolo Macario
2015-04-13  6:05 ` Junio C Hamano
2015-04-13 11:10   ` Macario, Gianpaolo
2015-04-23 20:17     ` Jeff King

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).