Tuesday, March 25, 2008

Package Dependency Management

Installing linux software is infamous for the recursive dependency spiral that often occurs. There really isn't a universally appropriate package manager for LFS although a few techniques are detailed in hints.

The LFS and BLFS books specify the dependencies so that one can manually drill down to install the dependencies in turn as one makes the trip back from the bottom of the spiral. This is inelegant and cumbersome, but it is better than nothing. More cumbersome yet, is the need to check the list of files installed by the dependency to see if that dependency has already been installed. A handy command for this is whereis.

Currently, I am putting all BLFS packages.tar to be installed in /sources2. I am leaving the original /sources directory from the LFS install alone for now.

I am trying a script named ilog which seeks to record the output of "make install" and then record a list of files that changed recently. To use this script, the "make install" command line must be done separately so that the script can be called to do the "make install" command line as: "ilog make install". The detection of files that changed presumes that the system is quiet except for the "make install". The log files in /var/log/MAKE_INSTALL give a quick indication of whether a needed dependency is installed. Since each of those log files should contain a list of files that were changed during the "make install", it can be useful information if and when there is a desire to uninstall a package.
The order of package installation can be seen with:
ls -tr1 /var/log/MAKE_INSTALL

I attempt to reproduce the script here, though it may be line-wrap damaged by the editor:
#!/bin/bash
# Record all output of command -- usually "make install"
# Log filename will be composed of ilog-$MYPKG.log
# where $MYPKG is the basename of the current working directory.
MYPKG=$(basename $(pwd))
MYLOGDIR=/var/log/MAKE_INSTALL/
MYOUTPUTSDIR=/var/log/MAKE_INSTALL_OUTPUTS/
MYREGEX1=^${MYLOGDIR:0:${#MYLOGDIR}-1}$
MYREGEX2=^${MYOUTPUTSDIR:0:${#MYOUTPUTSDIR}-1}$
unset MYREGEXES
MYREGEXES[${#MYREGEXES[*]}]=$MYREGEX1
MYREGEXES[${#MYREGEXES[*]}]=$MYREGEX2
MYREGEXES[${#MYREGEXES[*]}]=^/sources2
MYREGEXES[${#MYREGEXES[*]}]=^/home
MYREGEXES[${#MYREGEXES[*]}]=^/root
LP='\('
RP='\)'
O_R='\|'
MYREGEX=
for M_R_X in ${MYREGEXES[*]}
do
if [ -n "$MYREGEX" ]; then
MYREGEX=${MYREGEX}${O_R}
fi
MYREGEX=${MYREGEX}${LP}${M_R_X}${RP}
done
if [ -z "$1" ]; then
echo "Usage: $(basename $0) command_string"
exit
fi
[ -n "$MYLOGDIR" -a ! -d "$MYLOGDIR" ] && mkdir "$MYLOGDIR"
[ -n "$MYLOGDIR" -a ! -d "$MYLOGDIR" ] && exit
[ -n "$MYOUTPUTSDIR" -a ! -d "$MYOUTPUTSDIR" ] && mkdir "$MYOUTPUTSDIR"
[ -n "$MYOUTPUTSDIR" -a ! -d "$MYOUTPUTSDIR" ] && exit
MYILOG=${MYLOGDIR}ilog-$MYPKG.log
MYOLOG=${MYOUTPUTSDIR}ilog-$MYPKG.log
START=$(date +%s)
date +"%F %H:%M:%S %a" 2>&1 | tee $MYILOG
echo "$MYPKG $*" 2>&1 | tee -a $MYILOG
date +"%F %H:%M:%S %a" 2>&1 | tee $MYOLOG
echo "$MYPKG $*" 2>&1 | tee -a $MYOLOG
# Run the commands
$* 2>&1 | tee -a $MYOLOG
# Commands are done!
# What got changed?
NOW=$(date +%s)
date +"%F %H:%M:%S %a" 2>&1 | tee -a $MYILOG
MINS=$(echo "scale=2;m=($NOW-$START)/60;(m+((m%100)>0))" | bc | sed -e "s/\..*$//")
echo "CHANGED FILES LIST" >> $MYILOG
find / -xdev -regex $MYREGEX -prune -o ! -type d -a -mmin -$(($MINS+1)) -print >> $MYILOG

Currently, my preferred method of uninstalling something is "make uninstall". That does depend upon the Makefile having uninstall, which can be seen in the Makefile if it has it. Also, it depends on the Makefile being in the same state it was in at the time of "make install".

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

Click blog title for the latest post