chip_0
Explorer
Most users of unix systems will have encountered software that are provided as their source code, and which use a Makefile to automate their build and install process. Now, the problem with this is that uninstalling the software is not so easy, especially if you have deleted the source code directory. It would require hunting and deleting each file manually. Easy enough when the whole software is a single binary, not so trivial if it contains several libraries, shared files, man pages and binaries.
So here are two methods which will not only enable easy uninstallation, but will also integrate the software with your distribution's package manager.
1. checkinstall
This is a very convenient and useful tool which will keep track of all files installed by "make install" (or any other install script), and will create a Slackware tgz, Debian, or RPM package out of them. Get more information, and the program itself, at -
http://asic-linux.com.mx/~izto/checkinstall/
2. The second method
This will do exactly the same thing as checkinstall, so if that doesn't work for you, read on. I find it a more elegant and flexible method, although it makes you do some work.
This method basically will install the files in a temporary directory (say /tmp/pkg) which can later be converted into a package for your distribution. If the files were to go into /usr/local, now they would be placed in /tmp/pkg/usr/local/.
So, here we go ...
1. Compile the software, which can usually done by typing "./configure" followed by "make".
2. Instead of running "make install", type -
make DESTDIR=/tmp/pkg/ install
This should carried out as root user, to make sure that all the files created are owned by root.
3. Check that the directory /tmp/pkg contains the relevant files in their correct locations.
4. Convert the directory /tmp/pkg to a package for your distribution. Here are ways to create popular package formats -
Slackware (tgz) - cd to /tmp/pkg and run "makepkg <name_of_package.tgz>". Read "man makepkg" for more info.
RPM - http://erizo.ucdavis.edu/~dmk/notes/RPMs/Creating_RPMs.html
Debian - http://www.tldp.org/HOWTO/html_single/Debian-Binary-Package-Building-HOWTO
Arch Linux - The Arch Build System does exactly this, in a very elegant manner. Read the Arch package making HOW TO for details.
Notes -
1. Not all makefiles recognise the variable DESTDIR. In this case, you will have to look through the file "Makefile" present in the main source directory, and look about for anything that could be changed for the purpose.
A variable "prefix" is also very commonly used, this controls the exact location of the files to be installed (/usr/local is used by default in most cases), so running
make prefix=/tmp/pkg/usr/local/ install
should give the same result.
In case you don't either variable, search the file for /usr/local (or whatever location the software was to be installed to) and change its occurance to /tmp/pkg/usr/local. This should be done after compiling the program with "make".
2. Of course, all this could have been avoided by simple running the configure script with /tmp/pkg/usr/local as the install location. The problem is that this location would be coded into the binary files, and hence, even after you copy the files to their final location, the binaries would still be looking in /tmp/pkg for some data.
3. If you want to run the make install process as a non-root user, do so, but remember to chown the ownership of all files in /tmp/pkg to root. Basically, you will have to run -
chown -R root:root /tmp/pkg
So here are two methods which will not only enable easy uninstallation, but will also integrate the software with your distribution's package manager.
1. checkinstall
This is a very convenient and useful tool which will keep track of all files installed by "make install" (or any other install script), and will create a Slackware tgz, Debian, or RPM package out of them. Get more information, and the program itself, at -
http://asic-linux.com.mx/~izto/checkinstall/
2. The second method
This will do exactly the same thing as checkinstall, so if that doesn't work for you, read on. I find it a more elegant and flexible method, although it makes you do some work.
This method basically will install the files in a temporary directory (say /tmp/pkg) which can later be converted into a package for your distribution. If the files were to go into /usr/local, now they would be placed in /tmp/pkg/usr/local/.
So, here we go ...
1. Compile the software, which can usually done by typing "./configure" followed by "make".
2. Instead of running "make install", type -
make DESTDIR=/tmp/pkg/ install
This should carried out as root user, to make sure that all the files created are owned by root.
3. Check that the directory /tmp/pkg contains the relevant files in their correct locations.
4. Convert the directory /tmp/pkg to a package for your distribution. Here are ways to create popular package formats -
Slackware (tgz) - cd to /tmp/pkg and run "makepkg <name_of_package.tgz>". Read "man makepkg" for more info.
RPM - http://erizo.ucdavis.edu/~dmk/notes/RPMs/Creating_RPMs.html
Debian - http://www.tldp.org/HOWTO/html_single/Debian-Binary-Package-Building-HOWTO
Arch Linux - The Arch Build System does exactly this, in a very elegant manner. Read the Arch package making HOW TO for details.
Notes -
1. Not all makefiles recognise the variable DESTDIR. In this case, you will have to look through the file "Makefile" present in the main source directory, and look about for anything that could be changed for the purpose.
A variable "prefix" is also very commonly used, this controls the exact location of the files to be installed (/usr/local is used by default in most cases), so running
make prefix=/tmp/pkg/usr/local/ install
should give the same result.
In case you don't either variable, search the file for /usr/local (or whatever location the software was to be installed to) and change its occurance to /tmp/pkg/usr/local. This should be done after compiling the program with "make".
2. Of course, all this could have been avoided by simple running the configure script with /tmp/pkg/usr/local as the install location. The problem is that this location would be coded into the binary files, and hence, even after you copy the files to their final location, the binaries would still be looking in /tmp/pkg for some data.
3. If you want to run the make install process as a non-root user, do so, but remember to chown the ownership of all files in /tmp/pkg to root. Basically, you will have to run -
chown -R root:root /tmp/pkg