#!/bin/bash
if [ -z "$1" -o ! -d "$1" ]; then
echo "$0: updates instimage from a Red Hat RPMS directory"
echo "usage: $0
"
exit 1
fi
pythondeps() {
DIR=$1
cp /usr/bin/strace $DIR
(cd $DIR; \
chroot . strace -o straceout.$$ \
usr/bin/anaconda -m dir://mnt/source --test --text --traceonly
)
((cat $DIR/straceout.$$ |
grep ^open | grep '= [0-9]' | sed 's/[^"]*"//' | sed 's/".*//' |
sort -u | grep /usr/lib/python
) ; \
(cd $DIR;
find usr/lib/python* -type f | sed 's,^,/,' \
)) | sort | uniq -u |
\
sed s,^,./, | while read fn; do
[ ! -d $DIR/$fn ] && rm $DIR/$fn
done
rm -f $DIR/strace $DIR/straceout.$$
}
SRC=$1/RedHat/RPMS
cd ../trees/hdimage
DEST=$PWD
cd -
cd ../../../RedHat/instimage
DESTGR=$PWD
cd -
echo "DEST is $DEST"
echo "DESTGR is $DESTGR"
PACKAGES="glibc-2 ldconfig setup e2fsprogs-1 XFree86-libs XFree86-SVGA
XFree86-S3 XFree86-S3V XFree86-FBDev XFree86-75dpi-fonts
XFree86-3. xpm-3 glib- gtk+- gnome-libs slang python-1 newt
imlib-1 libpng libtiff libjpeg- libtermcap-2 zlib rpm
rpm-devel ash- bash- pygtk- pygnome- util-linux procps
esound-0 audiofile-0 strace"
KEEPFILE=/tmp/keepfile.$$
cat > $KEEPFILE <> $KEEPFILEGR < /dev/null; then
RPMS="$RPMS $J"
fi
else
RPMS="$RPMS $J"
fi
done
done
rm -rf $DEST; mkdir -p $DEST/usr/sbin
rm -rf $DESTGR; mkdir -p $DESTGR/usr/sbin
for n in $RPMS; do
echo "expanding $n"
rpm2cpio $n | (cd $DEST; cpio -E $KEEPFILE --quiet -iumd)
rpm2cpio $n | (cd $DESTGR; cpio -E $KEEPFILEGR --quiet -iumd)
done
rm -f $KEEPFILE $KEEPFILEGR
for p in $DEST $DESTGR; do
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; tar cSpf - .) | (cd $p/usr/bin; tar xSpf -)
(cd $p/sbin; tar cSpf - .) | (cd $p/usr/sbin; tar xSpf -)
rm -rf $p/bin
rm -rf $p/sbin
rm -rf $p/boot $p/home $p/root $p/tmp
cp /sbin/ldconfig $p
(cd $p; chroot $p ./ldconfig \
$([ -d $p/usr/X11R6/lib ] && echo /usr/X11R6/lib) )
rm -f $p/ldconfig
find $p -name "*.so" | xargs strip
find $p -name "*.py" | while read fn; do
if [ -f ${fn}c ]; then
rm -f $fn
fi
done
done
# Xserver needs a place to put the compiled xkb maps.
rm -rf $DESTGR/usr/X11R6/lib/X11/xkb/compiled
ln -s /tmp $DESTGR/usr/X11R6/lib/X11/xkb/compiled
make install DESTDIR=$DEST > /dev/null
make install DESTDIR=$DESTGR > /dev/null
pythondeps $DEST
# this is only for the minimal second stage
cd $DEST/usr/lib
find python1.5 | cpio --quiet -H crc -o | gzip -9 > python1.5.cgz
rm -rf python1.5
ls libnewt* libslang* | cpio --quiet -H crc -o |
gzip -9 > slang-newt.cgz
rm -f libnewt* libslang*
cd -
cd $DEST/usr/bin
echo python1.5 | cpio --quiet -H crc -o | gzip -9 > python1.5.cgz
rm -f python python1.5
ln -s python1.5 python
mv anaconda anaconda.real
cd -
cp -a anaconda-stub $DEST/usr/bin/anaconda