First I should start by saying I don't use LFS but I do have a tendency to occasionally install stuff outside of whatever is the local package manager of the distro I am working on at the time (even those with big repositories are always missing something). There are some nice tools to help you keep track of stuff you install this way (e.g.
paco) but to be honest I usually just knock up a short shell script that runs a couple of find commands and diffs the difference to create a log of newly installed files, like so:
Code:
#!/bin/sh
BEFORE=$(mktemp -t before.XXXXXX)
AFTER=$(mktemp -t after.XXXXXX)
INSTALL_LOG=$(basename $(pwd))_install.log
find /bin /etc /lib* /opt /sbin /usr ! -type d -print > $BEFORE
$@
find /bin /etc /lib* /opt /sbin /usr ! -type d -print > $AFTER
diff $BEFORE $AFTER | sed -n 's/^> //p' > $INSTALL_LOG
echo "Created: $INSTALL_LOG"
I save the above with an appropriate name (e.g. loginstall) somewhere in my $PATH and make it executable. Then I can just just preface it to any install command I wish to track, e.g.:
Code:
loginstall make install
or perhaps:
Code:
loginstall ./VirtualBox-4.1.18-78361-Linux_x86.run
When the install is done a suitably name log file will be created, listing all the files that were installed. After I install software move the log into /var/log/footprints, so that I can reference it later.
These logs can be used to remove files or create a backup of the software using tar or cpio. For example, to to create a backup of the installed files using cpio:
Code:
cat logfilename | cpio -ovHnewc | xz > packagename_backup.cpio.xz
Or with tar:
Code:
cat logfilename | tar cvJPf packagename_backup.tar.xz -T-
Note: It is also possible to recreate the logfile by doing a file listing on one of these backup packages.
To remove files I can switch to root and issue:
Code:
cat logfilename | xargs -d'\n' -n1 rm -v
You will note that I only log files that are created, not directories. This is trick I picked up from paco and is done for several reasons. It keeps the logs less bloated (smaller), it allows for simple "one liner" uninstall commands like the one above and finally most directories end up being shared among many packages, making it trickier to work out which to remove. For the most part empty directories have little effect on your system and are safe to ignore. If it ever bothers you you can always construct a find command using the "-empty" option to track down old empty directories that you might want to remove.
P.S. Here is a demo video of how this works
http://shelr.tv/records/500549a696608020cc0000ce