git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Installing git binaries on a non-default directory (Ubuntu)

From
GMGianpaolo Macario <gianpaolo_macario@mentor.com>
Date
Apr 10, 2015, 16:34 UTC
Message-ID
<loom.20150410T183218-536@post.gmane.org>
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
Next: Junio C Hamano
Message 1 of 4 in “Installing git binaries on a non-default directory (Ubuntu)”
  1. Gianpaolo MacarioApr 10, 2015
  2. Junio C HamanoApr 13, 2015
  3. Macario, GianpaoloApr 13, 2015
  4. Jeff KingApr 23, 2015

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.