Unix Programming - autotools with python: how to implement make uninstall

This is Interesting: Free IT Magazines  
Home > Archive > Unix Programming > January 2005 > autotools with python: how to implement make uninstall





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author autotools with python: how to implement make uninstall
Uwe Mayer

2005-01-23, 7:47 am

Hi,

Perhaps you could comment on the following solution I picked in combining
Automake and Python to perform a program installation /uninstallation:

I've written a Python application which uses autoconf and automake for
configuring and building the application. However, automake does a poor job
in installing the application to the correct paths, so I added a line to
the install-data-local hook, to call the Python install routine:

install-data-local:
python setup.py install --root=${DESTDIR} --prefix=${prefix}
--record installed_files.log


The --root= is a general prefix, much like "make DESTDIR=tmp install". The
--prefix= is the same as the ./configure --prefix= option

In order to provide an uninstall mechanisme (in which Pyhon does a poor job)
the --record switch logs all installed files (while removing leading "/"!!)

The uninstall-hook looks like this:

-- snip --
DESTDIR=/

uninstall-local:
perl -n -e '$$ENV{DESTDIR} = "/" unless (exists $$ENV{DESTDIR});
print "$$ENV{DESTDIR}$$_"' <installed_files.log| xargs rm
xargs -n 1 dirname <installed_files.log |uniq | PERL -n -e
'$$ENV{DESTDIR} = "/" unless (exists $$ENV{DESTDIR}); print
"$$ENV{DESTDIR}$$_"' | sort -r |xargs rmdir --ignore-fail-on-non-empty
-- snip --

The first line removes all installed files.
The second line recursively tries to remove the directories if they are
empty.
The DESTDIR above is not available as environment variable (to perl) by
default. Only if "make DESTDIR=<path> install"-type is used.
The inline PERL script prepends the value of DESTDIR (or /) to each line in
the installed_files.log file. I don't quite like this solution yet.

Having this: the following works:
$ ./configure
$ make DESTDIR=tmp install
$ make DESTDIR=tmp uninstall

and:
$ ./configure --prefix=/home/foo
$ make install
$ make uninstall

and combinded:
$ ./configure --prefix=/home/foo
$ make DESTDIR=tmp install
$ make DESTDIR=tmp uninstall

Please comment on the portability, stability, or whatever of this solution
and perhaps provide some suggestions how to improve this.

Thanks
Uwe
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com