graft: Install and Configure package management
Graft is a great little tool for package management on UNIX systems such as Linux. The tool itself allows you to keep a package isolated in it’s own directory, and uses symlinks to combine them in with the rest of the operating system.
An example would be a new tool that has one binary and one shared library:
/usr/local/PACKAGES/somenewtool-1.0
/usr/local/PACKAGES/somenewtool-1.0/bin
/usr/local/PACKAGES/somenewtool-1.0/bin/newtool
/usr/local/PACKAGES/somenewtool-1.0/lib
/usr/local/PACKAGES/somenewtool-1.0/lib/libnewtool.so
Using the graft tool, we can install the binary and the library in with the rest of our OS using a simple command like:
graft -i /usr/local/PACKAGES/somenewtool-1.0
With the appropriate configuration, this would create these symlinks:
/usr/local/bin/newtool -> /usr/local/PACKAGES/somenewtool-1.0/bin/newtool
/usr/local/lib/libnewtool.so -> /usr/local/PACKAGES/somenewtool-1.0/lib/libnewtool.so
Removing these symlinks is also really simple like this:
graft -d /usr/local/PACKAGES/somenewtool-1.0
Now you can see the usefulness of this tool to remove one version, and install a new one. Anyway, let’s look at the install process for graft.
1) Setup environment
mkdir -p /usr/local/PACKAGES
mkdir -p /usr/local/PKG_BUILD
cd /usr/local/PKG_BUILD
2) Download and Install Graft
Graft can be found at: http://www.gormand.com.au/peters/tools/
wget http://www.gormand.com.au/peters/tools/graft/graft-2.4.tar.gz
tar -xvzf graft-2.4.tar.gz
cd graft-2.4
make -f Makefile.dist
edit the Makefile file and change these lines:
PACKAGEDIR = /usr/local/PACKAGES
TARGETDIR = /usr/local
PERL = /usr/bin/perl
Now let’s make it:
make
make install
/usr/local/PACKAGES/graft-2.4/bin/graft -i /usr/local/PACKAGES/graft-2.4
And that’s it! Graft is now installed (in fact we just used it to install itself!). Now to get the most out of graft, I recommend adding the line “/usr/local/lib” into your /etc/ld.so.conf file, and running “ldconfig”.