How to make sure that 'make uninstall' will work correctly?
Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
How to make sure that 'make uninstall' will work correctly?
While installing software from source tar.gz file using commands ./configure, make and sudo make install, how can one make sure that 'make uninstall' will work correctly to remove software later, if needed? Thanks for your answers.
I want to know about this BEFORE installing the software. I want to install only that software by this method where I can be sure that, if needed, I will be able to remove it later on.
Maybe look at the whole filesystem before installation and after uninstallation? It won't assure you of anything beforehand, but it will tell you if anything gets left behind. Of course, if you do anything else, that will show up as well.
Code:
find / -type f | grep -v proc > filelist-before.txt
# do stuff
find / -type f | grep -v proc > filelist-after.txt
diff filelist-before.txt filelist-after.txt
You might want to exclude other directories, like home and tmp.
It's not a total disaster if it doesn't work. I've had software with no uninstall option, so I just uninstalled manually by working my way through the install instructions and undoing what they'd done.
(Only regular files and symlinks are recorded in the uninstall script. This is because directories are often shared between applications.)
Fix file ownership:
Code:
sudo chown -R root:root .
Transfer the contents of the staged directory to the final install locations:
Code:
find . ! -type d | tar cf - -T- | sudo tar xvf - -C/
(Only files are transferred. This avoids updating or adjusting permissions and timestamps on shared directories. New directories will be created as needed with default permissions.)
If this is too much to type all the time, here is a script to automate creating the uninstall script, fixing ownership and transferring the package contents. It also strips binaries, compresses man pages and fixes some potential permissions issues. This reduces the steps to:
Code:
./configure
make
make install DESTDIR="$PWD/staging"
sudo transfer-staged-package packagename
A bit more detail and background on this technique, why I prefer it to tracking software like checkinstall and some tips for backing up and querying packages on my blog.
If you are happy with simply tracking the "make install" (or equivalent command), then issue the following (very shortly afterwards) to find all files that have been installed into common installation directories, within the last five minutes:
Code:
sudo find /etc /opt /usr -cmin -5 ! -type d
If it looks correct, make a null delimited list of these files (used for uninstall later):
The problem is config files which already existed on your system and are modified by make install. If the install is well-behaved it will create backup files for any that it changes.
See my first reply. Not the later one, which is for those who are too lazy to use a staging directory.
If you do use a staging directory, it is still not really a problem IMHO. Just run a find command on this directory. You can see what files will clash, you can also diff them against on the ones on the system. Adjust things as you see fit, prior to the transfer.
P.S. On my blog post I actually mentioned checking the files and adjusting them as needed prior to transfer
Quote:
Originally Posted by ruario
Within this staging directory, you can now move files around to avoid clashes with pre-existing files (if needed), strip binaries, compress man pages, adjust permissions, etc. or make any other adjustments as you see fit. At the very least run a find command to see the contents of the package
Last edited by ruario; 12-14-2015 at 06:59 AM.
Reason: added .P.S. and quote
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.