I'd like to share my modified package management scripts with everyone. They worked quite well to build up and strip down my LFS system. I first created a full LFS system for development use, then from that I created a stripped-down minimal LFS system for production (fits on a flash drive). I used "lpm -e package" to remove packages. I also followed much of the advice in the small-lfs.txt hint to get rid of unnecessary files and directories. I was able to get the system down to just 85MB in size.
=== lpm ==================================================== lpm is a script that acts as a wrapper for the install-log installation logger (see install-log.txt hint). It provides a simple form of package management. I took the lpm script as provided by the lpm.txt hint and added a few more features, making it more rpm-like in the process. See the usage in the script below. SAMPLE OUTPUT # lpm -q sed sed-4.1.4 # lpm -ql sed /bin/sed /usr/share/doc/sed-4.1.4/sed.html /usr/share/info/sed.info /usr/share/man/man1/sed.1 # lpm -qf /bin/sed sed-4.1.4 SCRIPT /usr/bin/lpm #!/bin/sh # # LPM - Linux from scratch Package Manager - v1.3 (1.3.3) # Date: 24-04-2004 (Edited: 20-01-2006) # # # CC-GPL 2004 Daniel Zilli <[EMAIL PROTECTED]> # # This program is free software; you can redistribute it and/or modify it under # the terms of the GNU General Public License as published by the Free Software # Foundation; either version 2 of the License, or (at your option) any later # version. # # This program is distributed in the hope that it will be useful, but WITHOUT # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more # details. # # http://creativecommons.org/licenses/GPL/2.0/legalcode.pt # # Changes by Jason Aeschilman <[EMAIL PROTECTED]> # > changed some options to be more rpm-like # > added -f option # > added -q option # > added -qa option # > added -qf option # > added -ql option # Alias to make the command shorter logpath="/var/log/install-log" option=$1 arg=$2 # Shows the options and version of LPM. usage() { echo "LPM: Linux from scratch Package Manager - v1.3.3" echo " -l log the install" echo " -f log the install (force update)" echo " -e erase a package" echo " -q display package name and version" echo " -qa list all packages" echo " -qf list all packages owning FILE" echo " -ql list files in a package" } checkarg() { if [ -z "$arg" ]; then echo "LPM: missing argument to '$option'" usage exit fi } # Check for force argument F="" if [ "$option" = "-f" ]; then F="-f" fi # Log installation if [ "$option" = "-l" -o "$option" = "-f" ]; then # If you didn't pass a second argument, LPM will use # your pwd as name of the logfile if [ -n "$arg" ]; then /usr/bin/install-log $F $arg else /usr/bin/install-log $F $(basename $(pwd)) fi exit fi # Erase all the files installed by the package. if [ "$option" = "-e" ]; then checkarg echo -n "Are you sure you want to uninstall package '$arg' [y/n]? " read response if [ "$response" = "y" -o "$response" = "Y" ]; then xargs rm < $logpath/$arg && rm $logpath/$arg echo "LPM: package '$arg' successfully removed" else echo "LPM: erase aborted by user - no files modified" fi exit fi # Display package name and version if [ "$option" = "-q" ]; then checkarg ls -1 $logpath/$arg* | sed -e "[EMAIL PROTECTED]/@@" exit fi # List all packages if [ "$option" = "-qa" ]; then ls -1 $logpath exit fi # List all packages owning FILE if [ "$option" = "-qf" ]; then checkarg FILENAME="$arg" if [ ${arg:0:1} != "/" ]; then PWD=`pwd` BASENAME=`basename $arg` FILENAME="$PWD/$BASENAME" fi egrep "^$FILENAME$" $logpath/* | sed -e "[EMAIL PROTECTED]/@@" -e "s@:.*@@" exit fi # List files in a package if [ "$option" = "-ql" ]; then checkarg cat $logpath/$arg-* exit fi # If no option match, display usage usage === listnew ==================================================== listnew is a script that will show you all files modified since a given time. It is based off the install-log.sh script written by Gerard Beekmans. It uses the .timestamp file used by install-log (for which lpm is a wrapper). This made it easy to check changes before and after installation of packages. It helped prevent me from making mistakes during installation logging and allowed me to easily reset the timestamp whenever it made sense to do so. Keep in mind that although this script behaves similar to the install-log binary program, the results may differ. This script has just an exclusion list while install-log has both an inclusion and exclusion list. Also, I added the file type letter to the beginning of each filename to see what is a symlink [l] and what is a regular file [f]. SAMPLE OUTPUT # listnew [l] /usr/bin/vi [f] /usr/bin/vim # listnew -r CAUTION: You will lose the ability to see what files have changed since last reset! Do you really want to reset the timestamp file [y/n]? y [timestamp file reset] SCRIPT /usr/bin/listnew [EMAIL PROTECTED] ~]# cat /usr/bin/listnew #!/bin/bash # # Based on log-install script by Gerard Beekmans <[EMAIL PROTECTED]> # # DEPENDENCIES: This script depends on log-install's use of .timestamp file PROG=`basename $0` # Timestamp file TSFILE="/var/log/install-log/.timestamp" usage() { echo "Usage: $PROG [OPTION]" echo "Display all new or changed files since '.timestamp'" echo " -t, --timestamp show timestamp file information" echo " -r, --reset reset timestamp to current date and time" echo " -h, --help this help message" } if [ "$1" = "-t" -o "$1" = "--timestamp" ]; then echo "Current timestamp file:" ls -l $TSFILE exit fi if [ "$1" = "-r" -o "$1" = "--reset" ]; then echo "CAUTION: You will lose the ability to see what files have changed since last reset!" echo -n "Do you really want to reset the timestamp file [y/n]? " read response if [ "$response" = "y" -o "$response" = 'Y' ]; then CMD="touch $TSFILE" $CMD echo "[timestamp file reset]" else echo "[reset aborted by user]" fi exit fi if [ "$1" = "-h" -o "$1" = "--help" ]; then usage exit fi if [ -n "$1" ]; then echo "$PROG: unrecognized option: '$1'" usage exit fi PRUNEPATH="/proc /usr/src /usr/local/src /tmp /usr/tmp /root /home /mnt /dev /sys /usr/var /usr/misc /etc/cups/certs /usr/share/info/dir /var/log/install-log /sources /tools" PRUNEREGEX=`echo $PRUNEPATH | \ sed -e 's,^,\\\(^,' -e 's, ,$\\\)\\\|\\\(^,g' -e 's,$,$\\\),'` find / -regex "$PRUNEREGEX" -prune -o -cnewer $TSFILE ! -type d -printf "[%y] %p\n" -- http://linuxfromscratch.org/mailman/listinfo/blfs-support FAQ: http://www.linuxfromscratch.org/blfs/faq.html Unsubscribe: See the above information page
