#!/bin/bash usage() { echo "Usage: buildinstall [--comp ] [--pkgorder ] [--version ] [--release ] " >&2 exit 1 } COMPNAME=dist-7.0 while [ $# -gt 0 ]; do case $1 in --pkgorder) PKGORDER=$2 shift; shift ;; --comp) COMPNAME=$2 shift; shift ;; --version) VERSION=$2 shift; shift ;; --release) RELEASESTR=$2 shift; shift ;; *) if [ -n "$DIR" -o ! -d $1/RedHat/RPMS ]; then usage fi DIR=$1 shift ;; esac done if [ -z "$VERSION" ]; then VERSION=7.1 fi if [ -z "$DIR" ]; then usage fi if [ -z "$RELEASESTR" ]; then usage fi p=`cd $DIR; /bin/pwd | sed 's,/md1/,/,g'` BUILDINSTDIR=$p/buildinstall.tree.$$ rm -rf $BUILDINSTDIR mkdir -p $BUILDINSTDIR UPD_INSTROOT=./upd-instroot MK_IMAGES=./mk-images BUILDARCH=`rpm -qp --qf "%{ARCH}" $p/RedHat/RPMS/anaconda-runtime-[0-9]*` if [ ! -f $UPD_INSTROOT ]; then cd $BUILDINSTDIR rpm2cpio $p/RedHat/RPMS/anaconda-runtime-[0-9]* | cpio --quiet -iumd ./usr/lib/anaconda-runtime/upd-instroot usr/lib/anaconda-runtime/upd-instroot mv usr/lib/anaconda-runtime/upd-instroot . rm -rf usr else cp -a $UPD_INSTROOT $BUILDINSTDIR/upd-instroot fi UPD_INSTROOT=$BUILDINSTDIR/upd-instroot if [ ! -f $MK_IMAGES ]; then cd $BUILDINSTDIR rpm2cpio $p/RedHat/RPMS/anaconda-runtime-[0-9]* | cpio --quiet -iumd ./usr/lib/anaconda-runtime/mk-images* usr/lib/anaconda-runtime/mk-images* mv usr/lib/anaconda-runtime/mk-images* . rm -rf usr else cp $MK_IMAGES* $BUILDINSTDIR/ fi MK_IMAGES=$BUILDINSTDIR/mk-images echo "Building images..." $UPD_INSTROOT --comp $COMPNAME $p/RedHat/RPMS $p/image-template $p/RedHat/instimage # XXX hack - msw if [ $BUILDARCH = "sparc" ]; then BUILDARCH=sparc64 fi if [ -n "$PKGORDER" -a -x $p/RedHat/instimage/usr/lib/anaconda-runtime/pkgorder ]; then echo "Getting package order..." if [ -x /usr/bin/runroot ]; then runroot --quiet $COMPNAME --onlyone --arch $BUILDARCH \ "PYTHONPATH=$p/RedHat/instimage/usr/lib/anaconda $p/RedHat/instimage/usr/lib/anaconda-runtime/pkgorder $p $BUILDARCH" > $PKGORDER else PYTHONPATH=$p/RedHat/instimage/usr/lib/anaconda $p/RedHat/instimage/usr/lib/anaconda-runtime/pkgorder $p $BUILDARCH > $PKGORDER fi fi if [ -x /usr/bin/runroot ]; then runroot $COMPNAME --onlyone --arch $BUILDARCH "cd $BUILDINSTDIR\; ./mk-images $p/RedHat/RPMS $p $p/image-template $BUILDARCH $VERSION" else $MK_IMAGES $p/RedHat/RPMS $p $p/image-template $BUILDARCH $VERSION fi MK_STAMP=./makestamp.py echo "Writing .discinfo file" if [ ! -f $MK_STAMP ]; then cd $BUILDINSTDIR rpm2cpio $p/RedHat/RPMS/anaconda-runtime-[0-9]* | cpio --quiet -iumd ./usr/lib/anaconda-runtime/makestamp* usr/lib/anaconda-runtime/makestamp* mv usr/lib/anaconda-runtime/makestamp* . rm -rf usr else cp $MK_STAMP* $BUILDINSTDIR/ fi MK_STAMP=$BUILDINSTDIR/makestamp.py $MK_STAMP --releasestr="$RELEASESTR" --arch=$BUILDARCH --discNum="1,2,3" --baseDir=RedHat/base --packagesDir=RedHat/RPMS --pixmapsDir=RedHat/pixmaps --outfile=$p/.discinfo rm -rf $BUILDINSTDIR rm -rf $p/image-template $p/RedHat/instimage