#!/bin/bash ORIGDIR=`pwd` if [ -z "$1" ]; then echo "upd-instroot: updates instimage from a Red Hat RPMS directory" echo "usage: $0 []" exit 1 fi if [ ! -d $1 ]; then LATEST="latest --arch $ARCH" fi PACKAGEDIR=$1 ARCH=`rpm -qp --qf "%{ARCH}" $PACKAGEDIR/anaconda-runtime*.rpm` NEEDGR=yes if [ $ARCH = ia64 ]; then NEEDGR="" fi prunePackageList() { PACKAGEPATH=$1 PACKAGES="$2" if [ -n "$LATEST" ]; then $LATEST $PACKAGEPATH $PACKAGES return fi PATTERN="" PACKAGEFILES="" for PKG in $PACKAGES; do PATTERN="${PATTERN:+${PATTERN}|}(^$PKG )" PACKAGEFILES="$PACKAGEFILES $(ls $PACKAGEPATH/${PKG}*)" done # gtk+, enough said PATTERN=$(echo $PATTERN | sed 's,[\+\*],\\&,g') PACKAGEFILES=$(ls $PACKAGEFILES | sort -u) rpm --qf "%{NAME} $PACKAGEPATH/%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}.rpm\n" \ -qp $PACKAGEFILES | egrep "$PATTERN" | sed 's/.* //' } expandPackageSet() { RPMS=$1 PKGDEST=$2 KEEPFILE=$3 for n in $RPMS; do echo -ne "\rExpanding packages..." $(basename $n) if [ $(rpm -qp --qf '%{NAME}' $n) = "glibc" ] ; then GLIBC=$n fi rpm2cpio $n | (cd $PKGDEST; cpio -E $KEEPFILE --quiet -iumd) echo -ne "\rExpanding packages..." "$(basename $n | sed 's/./ /g')" done } if [ -z "$2" ]; then DEST=/tmp/upd-instroot else DEST=$2 fi if [ -z "$3" ]; then DESTGR=/tmp/upd-instroot else DESTGR=$3 fi rm -rf $DEST $DESTGR mkdir -p $DEST mkdir -p $DESTGR PACKAGES="glibc setup python newt libtermcap zlib ash e2fsprogs util-linux raidtools locale-ja popt mount procps rpm XFree86 Xconfigurator anaconda anaconda-runtime kudzu-devel kudzu db1 db2 db3 rpm-python bzip2" if [ $ARCH = i386 ]; then PACKAGES="$PACKAGES kernel-pcmcia-cs syslinux" fi # xpm is missing # Some packages are listed twice, but that's okay PACKAGESGR="anaconda XFree86-libs imlib libpng libtiff libjpeg XFree86-S3 XFree86-75dpi-fonts XFree86-ISO8859-2-75dpi-fonts glib gtk+ XFree86-ISO8859-9-75dpi-fonts esound audiofile gnome-libs XFree86-100dpi-fonts XFree86-ISO8859-2 XFree86-ISO8859-9 XFree86-xfs e2fsprogs fileutils glibc rsh less ftp readline gzip popt specspo util-linux rpm rpm-devel open grep net-tools traceroute tar procps textutils sed ncurses bash cpio mt-st iputils sh-utils XFree86-cyrillic-fonts XFree86 Xconfigurator pygnome pygtk pygtk-libglade pygnome-libglade pygnome-applet pygnome-capplet gdk-pixbuf" if [ $ARCH != ia64 ]; then PACKAGESGR="$PACKAGESGR mtools pine modutils" fi if [ $ARCH = sparc ]; then PACKAGESGR="$PACKAGESGR XFree86-Sun tilo silo" fi if [ $ARCH = i386 ]; then PACKAGESGR="$PACKAGESGR XFree86-I128" fi KEEPFILE=/tmp/keepfile.$$ cat > $KEEPFILE <> $KEEPFILEGR <> $KEEPFILEGR <<-EOF usr/X11R6/lib/X11/fonts/100dpi/cour* usr/X11R6/lib/X11/fonts/100dpi/helv* usr/X11R6/lib/X11/fonts/100dpi/tim* usr/X11R6/lib/X11/fonts/100dpi/fonts* usr/share/fonts/ISO8859-2/100dpi/cour* usr/share/fonts/ISO8859-2/100dpi/helv* usr/share/fonts/ISO8859-2/100dpi/tim* usr/share/fonts/ISO8859-2/100dpi/fonts* EOF fi echo "Assembling package list..." RPMS=$(prunePackageList $PACKAGEDIR "$PACKAGES") RPMSGR=$(prunePackageList $PACKAGEDIR "$PACKAGESGR") rm -rf $DEST; mkdir -p $DEST/usr/sbin rm -rf $DESTGR; mkdir -p $DESTGR/usr/sbin $DESTGR/var/state ln -s /tmp $DESTGR/var/state/xkb echo -n "Expanding packages..." expandPackageSet "$RPMS" $DEST $KEEPFILE (cd $DEST; tar cSpf - .) | (cd $DESTGR; tar xSpf -) expandPackageSet "$RPMSGR" $DESTGR $KEEPFILEGR echo -e "\rExpanding packages..." echo "retrieving timezones" TZDIR=/tmp/glibc-timezone-$$ mkdir -p $TZDIR/usr/share/zoneinfo rpm2cpio $GLIBC | (cd $TZDIR; cpio --quiet -iumd usr/share/zoneinfo usr/share/zoneinfo/*) (cd $TZDIR; tar cSpf - $TIMEZONES) | (cd $DEST; tar xSpf -) (cd $TZDIR; tar cSpf - $TIMEZONES) | (cd $DESTGR; tar xSpf -) rm -rf $TZDIR # XXX kludge, fix me #rm -f $DEST/usr/lib/python1.5/site-packages/rpmmodule.so #rm -f $DESTGR/usr/lib/python1.5/site-packages/rpmmodule.so rm -f $DEST/usr/lib/anaconda/rpmmodule.so rm -f $DESTGR/usr/lib/anaconda/rpmmodule.so if [ $ARCH = sparc ]; then rm -f $DESTGR/usr/X11R6/bin/XF86_VGA16 fi echo "Running mkfontdir..." if [ -n "$NEEDGR" ]; then for I in $DESTGR/usr/X11R6/lib/X11/fonts/* $DESTGR/usr/share/fonts/ISO8859-2/* $DESTGR/usr/share/fonts/ISO8859-9/*; do /usr/X11R6/bin/mkfontdir $I done fi rm -f $KEEPFILE $KEEPFILEGR echo -n "Scrubbing trees..." for p in $DEST $DESTGR; do echo -n -e "\rScrubbing trees..." "$p" ln -s ../lib/anaconda/raidstart-stub $p/usr/bin/raidstart ln -s ../lib/anaconda/raidstop-stub $p/usr/bin/raidstop mv $p/usr/sbin/anaconda $p/usr/bin/anaconda mv $p/usr/lib/anaconda-runtime/lib* $p/usr/lib mv $p/usr/lib/anaconda-runtime/collage $p/usr/bin find $p -type d | xargs chmod 755 if [ -f $p/bin/bash ]; then rm -f $p/bin/ash ln -s bash $p/bin/sh else ln -s ash $p/bin/sh fi (cd $p/bin; find) | (cd $p/bin; /bin/cpio --quiet -pdmu $p/usr/bin) (cd $p/sbin; find) | (cd $p/sbin; /bin/cpio --quiet -pdmu $p/usr/sbin) rm -rf $p/bin rm -rf $p/sbin rm -rf $p/boot $p/home $p/root $p/tmp find $p -name "*.a" | grep -v "usr/X11R6/lib/modules" | xargs rm -rf (cd /usr/share/zoneinfo; find . -type f -or -type l | grep '^./[A-Z]' | sort | sed 's/^..//' | gzip -9) > $p/usr/lib/timezones.gz if [ -x /usr/bin/runroot ]; then REALPATH=`(cd $p; /bin/pwd)` runroot dist-7.0 --arch $ARCH "cd $REALPATH\; usr/lib/anaconda-runtime/scrubtree $REALPATH" else $p/usr/lib/anaconda-runtime/scrubtree $p fi echo -n -e "\rScrubbing trees..." "$(echo $p | sed 's/./ /g')" done echo -e "\nCompressing .mo files in stage2 images..." if [ -d $DEST/usr/share/locale ]; then for i in `find $DEST/usr/share/locale -name anaconda.mo`; do gzip -9 $i mv -f $i.gz $i done fi echo "Patching python library..." # always use passive mode for ftp installs cd $DEST/usr/lib/python1.5 patch -p0 > /dev/null < python1.5.cgz rm -rf python1.5 find anaconda | cpio --quiet -H crc -o | gzip -9 > anaconda.cgz rm -rf anaconda ls libnewt* libslang* | cpio --quiet -H crc -o | gzip -9 > slang-newt.cgz rm -f libnewt* libslang* cd $DEST/usr/bin echo python1.5 | cpio --quiet -H crc -o | gzip -9 > python1.5.cgz /bin/rm -f python python1.5 /bin/ln -s python1.5 python mv anaconda anaconda.real mv $DEST/usr/lib/anaconda-runtime/anaconda-stub anaconda cd $DEST/lib ls libcom* libcrypt* libdl* libe2p* libext2* libm* libnss* libnsl* \ libpthread* libss* libtermcap* libuuid* \ | cpio --quiet -H crc -o | gzip -9 > libs.cgz rm -f libcom* libcrypt* libdl* libe2p* libext2* libm* libnss* libnsl* \ libpthread* libss* libtermcap* libuuid* cd $DEST/usr find X11R6 | cpio --quiet -H crc -o | gzip -9 > X11R6.cgz rm -rf X11R6 cd $DEST/usr/sbin ls [a-r]* | cpio --quiet -H crc -o | gzip -9 > sbin.cgz rm -f [a-r]* rm -rf $DEST/usr/lib/anaconda-runtime if [ -n "$NEEDGR" ]; then cd $ORIGDIR $DESTGR/usr/lib/anaconda-runtime/checkcards.py $DESTGR/usr/share/kudzu/pcitable $DESTGR/usr/X11R6/lib/X11/Cards fi