Linux – Using symbolic links and git to manage build versions

librarieslinuxmanpackage-managementsymlink

In general I follow the following workflow when I build any program (e.g. emacs, tmux, etc.)

/home/opt/[name of the program]/builds/[version]/

bin
lib
share

For example for a program like tmux I have the following:

/my_local_opt/tmux/builds/1.7.-227/

bin
lib
share

I then create sym links in /home/bin/ pointing to the the specific builds that I have, and I never have to touch my PATH variable, since I fix it to include /home/bin.

E.g. For the example above, I would

  • Create a sym link: from: /home/bin/tmux to: /my_local_opt/tmux/builds/1.7.-227/bin/tmux
  • Have PATH only include /home/bin

However, I am not sure I can follow a similar approach for the man (MANPATH) and lib (LD_LIBRARY_PATH) paths.

  1. For example, after I build tmux I notice that it creates:

    .. /share/man/man1/tmux.1

    so I tried creating a symlink to this file from a place like /home/share and then fixing MANPATH to include this path. But when I typed man tmux it didn't work (it said "No manual entry for tmux"). Why?

  2. How about lib? I thought I could perhaps fix LD_LIBRARY_PATH to a specific directory for each program, and then use sym links to control which version gets included. Would this be a good idea?

More generally, is it a good idea to manage versions in a system using sym links? In the long run I am hoping to leave the sym links in a git repository to keep track of multiple configurations.

I don't have admin privileges in the machine where I build software, so I am hoping to use this as a way easily organize and manage my builds (without having to constantly edit my environment variables holding paths)

Best Answer

Your objective is very similar to the Gentoo Prefix system; it however doesn't keep the built applications seperately, nor store the symlinks in Git.

It will however fix your manpage and library needs (with the caveat that either LD_LIBRARY_PATH needs to be set, or the configure & binaries have a specific path hard-coded).

Seperately, the git-of-symlinks model in itself is similar in concept to OverlayFS/AUFS model, with more mix & match in place.

Related Question