4

How can you uninstall software that was built and installed from source? (Using make install?)

Quinma
  • 209
  • 4
  • 11
  • The easy way would be to compile PHP 5.5 and install it over 5.4. The RPM likely installs to a different folder. –  Jun 19 '13 at 19:12
  • If you haven't already deleted the directory where you built from source, and if you let make install choose the target directory, it might have ended up in /usr/local/bin, which usually has precedence over /usr/bin, hence you still use the first php binary found in your PATH. You could try make -n install and see where and what it wants to install stuff, and remove by hand. Untested and dangerous, of course. – dawud Jun 19 '13 at 19:14
  • @dawud Yes, i actually ended up doing it this way. I was just wondering if for future reference there might be a better, safer way – Quinma Jun 19 '13 at 19:16
  • 1
    If the Makefile provides the means, then yes. Always generate packages, even for upstream built sources. – dawud Jun 19 '13 at 19:18
  • I don't understand the off-topic votes. I've had to do this more than a few times myself but had to figure it out the hard way. – Aaron Copley Jun 19 '13 at 19:21
  • 1
    OP, I blew away your question as it was asked to make it trigger less votes to close. It was a legitimate question masked behind a lot of extra words.. – Aaron Copley Jun 19 '13 at 19:28

4 Answers4

5

Do you still have the source package? You can parse the Makefile for install commands, or you can install it again (with another $PREFIX) to capture a list of installed files. Also, it is printed to STDOUT. You could then remove those files from the directory where they were installed originally.

Edit:

I just dug up my notes on making an uninstaller script. Bear with me, I am paraphrasing here.

After you build and install to a temporary target directory, do the following. (Where $PREFIX is whatever you used with ./configure.)

cd $PREFIX
find . -type f | cut -b 1 --complement | sed 's/^/rm -f \/usr\/local/g' > uninstall.sh
find . -type d | cut -b 1 --complement | sed 's/^/rmdir --ignore-fail-on-non-empty \/usr\/local/g' >> uninstall.sh

The output will look like:

rm -f /usr/local/lib/somelib.so
rm -f /usr/local/bin/somebin
rm -f /usr/local/include/someapp/someheaders.h
rmdir --ignore-fail-on-non-empty /usr/local/share
rmdir --ignore-fail-on-non-empty /usr/local/bin
rmdir --ignore-fail-on-non-empty /usr/local/include/someapp
...

This doesn't actually remove the critical system directories (/usr/local/bin, etc) because they'll be non-empty. Also, you'll want to confirm that your ./configure script uses /usr/local as the default $PREFIX. Adjust the sed command as necessary.

  • 1
    Damn Linux. I really should start using a different prefix for each program isntead of /usr/local – mxmlnkn Sep 27 '17 at 02:10
3

I checked with php version 5.4.16


cd php-5.4.16

make clean
make clean all

find / -name php

rm -fr /usr/local/php /usr/local/lib/php /usr/local/bin/php /usr/local/include/php

whereis {php-config,phpize,php-cgi}
rm /usr/local/bin/php-config /usr/local/bin/phpize /usr/local/bin/php-cgi

whereis {pear,peardev}
rm /usr/local/bin/pear

rm /usr/local/bin/peardev


why I select phpize and php-config
because after ./configure I got this output

config.status: creating php5.spec
config.status: creating main/build-defs.h
config.status: creating scripts/phpize
config.status: creating scripts/man1/phpize.1
config.status: creating scripts/php-config
config.status: creating scripts/man1/php-config.1
config.status: creating sapi/cli/php.1
config.status: creating main/php_config.h

0

You could try to brute force it:

Do a find / > /tmp/all_files and save to a file all_files. (Exclude sysfs and procfs and other if you know the files are not there)

Do a rpm -qa | xargs rpm -al > /tmp/all_owned_files to get a list of all files "owned" by rpm. (Assuming this is a rpm based system, use other commands for non-rpm systems)

Do a diff between these two files, and comb through it.

Not Now
  • 2,572
-1

check the command in source directory

make clean

make clean all

Or you have to remove all the files as described by Aaron

  • 1
    make clean very rarely, in my experience, removes the installed binaries; it only cleans out compilation-related cruft from the build directory. – MadHatter Jun 19 '13 at 19:25
  • 1
    make clean in fact does not removed installed files. It simply removes things like object files (.o) so they can be re-compiled (say, if the configure or Makefile is changed). –  Jun 19 '13 at 19:38
  • I am just downloading the php source code to check what steps should be followed. –  Jun 19 '13 at 19:40