LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This 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


Reply
  Search this Thread
Old 12-04-2015, 08:04 PM   #1
rng
Senior Member
 
Registered: Aug 2011
Posts: 1,198

Rep: Reputation: 47
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.
 
Old 12-04-2015, 09:23 PM   #2
John VV
LQ Muse
 
Registered: Aug 2005
Location: A2 area Mi.
Posts: 17,624

Rep: Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651
READ the output of the command ,simple !
 
Old 12-04-2015, 10:51 PM   #3
rng
Senior Member
 
Registered: Aug 2011
Posts: 1,198

Original Poster
Rep: Reputation: 47
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.
 
Old 12-05-2015, 09:57 AM   #4
GazL
LQ Veteran
 
Registered: May 2008
Posts: 6,897

Rep: Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019
Then you're going to have to read the input (makefile). If you're looking for a silver bullet, there isn't one.
 
Old 12-05-2015, 11:14 AM   #5
maples
Member
 
Registered: Oct 2013
Location: IN, USA
Distribution: Arch, Debian Jessie
Posts: 814

Rep: Reputation: 265Reputation: 265Reputation: 265
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.

Last edited by maples; 12-05-2015 at 11:15 AM.
 
Old 12-05-2015, 11:41 AM   #6
dugan
LQ Guru
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 11,223

Rep: Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320
Test it by installing it to a user-level temporary directory. Do the test with user-level privileges, not with root privileges.

Code:
mkdir $HOME/uninstall_test
make install DESTDIR=$HOME/uninstall_test
make uninstall
 
Old 12-05-2015, 11:49 AM   #7
DavidMcCann
LQ Veteran
 
Registered: Jul 2006
Location: London
Distribution: PCLinuxOS, Debian
Posts: 6,140

Rep: Reputation: 2314Reputation: 2314Reputation: 2314Reputation: 2314Reputation: 2314Reputation: 2314Reputation: 2314Reputation: 2314Reputation: 2314Reputation: 2314Reputation: 2314
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.
 
Old 12-05-2015, 07:28 PM   #8
rng
Senior Member
 
Registered: Aug 2011
Posts: 1,198

Original Poster
Rep: Reputation: 47
Thank you all for very helpful tips. I also found checkinstall (http://asic-linux.com.mx/~izto/checkinstall/) which is very useful for this kind of problem.

Last edited by rng; 12-05-2015 at 08:18 PM.
 
Old 12-14-2015, 05:21 AM   #9
ruario
Senior Member
 
Registered: Jan 2011
Location: Oslo, Norway
Distribution: Slackware
Posts: 2,557

Rep: Reputation: 1761Reputation: 1761Reputation: 1761Reputation: 1761Reputation: 1761Reputation: 1761Reputation: 1761Reputation: 1761Reputation: 1761Reputation: 1761Reputation: 1761
Make and install (as your normal user) to a temporary, "staging directory":
Code:
./configure
make  
make install DESTDIR="$PWD/staging"
Create a simple uninstall script:
Code:
cd staging
mkdir -p usr/local/bin
printf '#!/bin/sh -e\nwhile read f; do\n  if [ -e "$f" -o -h "$f" ]; then\n    rm -v "$f"\n  fi\ndone << EOF\n' > usr/local/bin/uninstall-packagename
find . ! -type d | grep -Fv "usr/local/bin/uninstall-packagename" | sed 's/^\.//' >> usr/local/bin/uninstall-packagename
printf "/usr/local/bin/uninstall-packagename\nEOF\n" >> usr/local/bin/uninstall-packagename
chmod 755 usr/local/bin/uninstall-packagename
(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.
 
Old 12-14-2015, 06:03 AM   #10
ruario
Senior Member
 
Registered: Jan 2011
Location: Oslo, Norway
Distribution: Slackware
Posts: 2,557

Rep: Reputation: 1761Reputation: 1761Reputation: 1761Reputation: 1761Reputation: 1761Reputation: 1761Reputation: 1761Reputation: 1761Reputation: 1761Reputation: 1761Reputation: 1761
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):
Code:
sudo find /etc /opt /usr -cmin -5 ! -type d -print0 > packagename-files.log
If you ever want to check the contents of the log, issue:
Code:
xargs -0I{} echo "{}" < packagename-files.log
To remove all installed files listed in the log:
Code:
sudo xargs -0I{} rm -v "{}" < packagename-files.log
 
Old 12-14-2015, 06:26 AM   #11
smallpond
Senior Member
 
Registered: Feb 2011
Location: Massachusetts, USA
Distribution: Fedora
Posts: 4,140

Rep: Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263
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.
 
Old 12-14-2015, 06:45 AM   #12
ruario
Senior Member
 
Registered: Jan 2011
Location: Oslo, Norway
Distribution: Slackware
Posts: 2,557

Rep: Reputation: 1761Reputation: 1761Reputation: 1761Reputation: 1761Reputation: 1761Reputation: 1761Reputation: 1761Reputation: 1761Reputation: 1761Reputation: 1761Reputation: 1761
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
 
  


Reply

Tags
staging



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: How to Make the Steam Controller Work Correctly on Linux LXer Syndicated Linux News 0 10-17-2015 07:05 PM
[SOLVED] Make *** No rule to make target 'uninstall' error Dornith Linux - Software 6 07-19-2012 05:23 AM
make Xconfig doesn't work, make menuconfig does work Debian/KDE bucovaina78 Linux - Kernel 1 10-15-2008 01:26 PM
1st time installing redhat - Make and Make Install does not work runlikeanantelope Linux - Newbie 4 02-19-2007 03:58 PM
How to make rule for make install and make uninstall melinda_sayang Programming 1 06-14-2004 05:58 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 03:12 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration