From f310eff703165e10933c61cbedbb8877dbae78d0 Mon Sep 17 00:00:00 2001 From: Jeremy Katz Date: Mon, 23 Jul 2007 19:16:15 +0000 Subject: 2007-07-23 Jeremy Katz * scripts/upd-instroot: Switch the way we build second stage images. Move to using yum to populate with a set of packages and then do pruning of the installed root. Prune with our file list + doing dso dep checking. This will be slower, but should help to avoid us having to maintain the list as much and avoiding the problems when things grow new library deps. --- scripts/upd-instroot | 151 ++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 119 insertions(+), 32 deletions(-) (limited to 'scripts') diff --git a/scripts/upd-instroot b/scripts/upd-instroot index 847865384..d761dc774 100755 --- a/scripts/upd-instroot +++ b/scripts/upd-instroot @@ -60,30 +60,116 @@ prunePackageList() { -qp $PACKAGEFILES | egrep "$PATTERN" | sed 's/.* //' } +# pulled right out of mkinitrd.... +DSO_DEPS="" +get_dso_deps() { + bin="$1" ; shift + DSO_DEPS="" + + declare -a FILES + declare -a NAMES + + # this is a hack, but the only better way requires binutils or elfutils + # be installed. i.e., we need readelf to find the interpretter. + for ldso in /lib*/ld*.so* ; do + [ -x $ldso ] || continue + $ldso --verify $bin >/dev/null 2>&1 || continue + + # I still hate shell. + declare -i n=0 + while read NAME I0 FILE ADDR I1 ; do + [ "$FILE" == "not" ] && FILE="$FILE $ADDR" + NAMES[$n]="$NAME" + FILES[$n]="$FILE" + let n++ + done << EOF + $(LD_TRACE_PRELINKING=1 LD_WARN= LD_TRACE_LOADED_OBJECTS=1 \ + $ldso $bin 2>/dev/null) +EOF + done + + [ ${#FILES[*]} -eq 0 ] && return 1 + + # we don't want the name of the binary in the list + if [ "${FILES[0]}" == "$bin" ]; then + FILES[0]="" + NAMES[0]="" + [ ${#FILES[*]} -eq 1 ] && return 1 + fi + + declare -i n=0 + while [ $n -lt ${#FILES[*]} ]; do + FILE="${FILES[$n]}" + if [ "$FILE" == "not found" ]; then + cat 1>&2 </dev/null + cat $KEEPFILES | while read spec ; do + for filespec in `find . -path "./$spec"` ; do + if [ ! -e $filespec ]; then + continue + elif [ ! -d $filespec ]; then + instFile $filespec $PKGDEST + else + for i in `find $filespec -type f` ; do instFile $i $PKGDEST ; done + fi + done done - pushd $PKGDEST/$LIBDIR >/dev/null 2>&1 - if [ -d obsolete/linuxthreads/ ]; then - for x in obsolete/linuxthreads/*-* ; do - lib_base=$(basename $x | cut -d- -f1) - rm -f ./$lib_base[.-]* - mv -f obsolete/linuxthreads/$lib_base[.-]* . - done - rmdir obsolete/linuxthreads obsolete - fi - popd >/dev/null 2>&1 + popd >/dev/null + + rm -fr $PKGDEST/yumdir } die () { @@ -936,9 +1022,9 @@ EOF fi echo "Assembling package list..." -RPMS=$(prunePackageList $PACKAGEDIR "$PACKAGES") +RPMS="$PACKAGES" [ -n "$DEBUG" ] && echo "RPMS are $RPMS" -RPMSGR=$(prunePackageList $PACKAGEDIR "$PACKAGESGR $PACKAGESRESCUE") +RPMSGR="$PACKAGES $PACKAGESGR $PACKAGESRESCUE" [ -n "$DEBUG" ] && echo "RPMSGR are $RPMSGR" rm -rf $DEST; mkdir -p $DEST/usr/sbin @@ -949,6 +1035,7 @@ ln -s /tmp $DESTGR/var/lib/xkb # concat KEEPFILEGR and KEEPFILERESCUE lists # cat $KEEPFILERESCUE >> $KEEPFILEGR +cat $KEEPFILE >> $KEEPFILEGR # # filter paths in keepfile lists for use by cpio @@ -961,18 +1048,18 @@ done echo "Expanding text packages..." expandPackageSet "$RPMS" $DEST $KEEPFILE -(cd $DEST; tar cSpf - .) | (cd $DESTGR; tar xSpf -) +#(cd $DEST; tar cSpf - .) | (cd $DESTGR; tar xSpf -) echo "Expanding graphical packages..." expandPackageSet "$RPMSGR" $DESTGR $KEEPFILEGR -echo "retrieving timezones" -TZDIR=${TMPDIR:-/tmp}/glibc-timezone-$$ -mkdir -p $TZDIR/usr/share/zoneinfo -rpm2cpio $TZDATA | (cd $TZDIR; cpio --quiet -iumd usr/share/zoneinfo ./usr/share/zoneinfo ./usr/share/zoneinfo/* usr/share/zoneinfo/*) -[ $? = 0 ] || die "ERROR: Unable to expand timezone data ($TZDATA)" -(cd $TZDIR; tar cSpf - $TIMEZONES) | (cd $DEST; tar xSpf -) -(cd $TZDIR; tar cSpf - $TIMEZONES) | (cd $DESTGR; tar xSpf -) +# echo "retrieving timezones" +# TZDIR=${TMPDIR:-/tmp}/glibc-timezone-$$ +# mkdir -p $TZDIR/usr/share/zoneinfo +# rpm2cpio $TZDATA | (cd $TZDIR; cpio --quiet -iumd usr/share/zoneinfo ./usr/share/zoneinfo ./usr/share/zoneinfo/* usr/share/zoneinfo/*) +# [ $? = 0 ] || die "ERROR: Unable to expand timezone data ($TZDATA)" +# (cd $TZDIR; tar cSpf - $TIMEZONES) | (cd $DEST; tar xSpf -) +# (cd $TZDIR; tar cSpf - $TIMEZONES) | (cd $DESTGR; tar xSpf -) chown -R root:root $DEST $DESTGR chmod -R a+rX-w $DEST $DESTGR @@ -996,11 +1083,11 @@ for p in $DEST $DESTGR; do $p/usr/lib/anaconda-runtime/fixmtime.py $DEBUG $p done -for p in $DEST $DESTGR; do - if [ -f $p/usr/lib/locale/locale-archive.tmpl ]; then - mv $p/usr/lib/locale/locale-archive.tmpl $p/usr/lib/locale/locale-archive - fi -done +# for p in $DEST $DESTGR; do +# if [ -f $p/usr/lib/locale/locale-archive.tmpl ]; then +# mv $p/usr/lib/locale/locale-archive.tmpl $p/usr/lib/locale/locale-archive +# fi +# done # Remove locales unused during the install cat $DESTGR/usr/lib/anaconda/lang-table* | awk ' -- cgit