#!/bin/bash ORIGDIR=`pwd` COMPONENT="" if [ "$1" == "--comp" ]; then COMPONENT=$2 shift; shift fi if [ -z "$1" ]; then echo "upd-instroot: updates instimage from a Red Hat RPMS directory" echo "usage: $0 --comp [templatedir] [instroot]" exit 1 fi if [ ! -d $1 ]; then if [ -z "$ARCH" ]; then echo "ARCH must be set" >&2 exit 1 fi LATEST="latest --arch $ARCH" fi PACKAGEDIR=$1 if [ -z "$ARCH" ]; then ARCH=`rpm -qp --qf "%{ARCH}" $PACKAGEDIR/anaconda-runtime*.rpm` fi if [ $ARCH = x86_64 ]; then LIBDIR=lib64 else LIBDIR=lib fi NEEDGR=yes prunePackageList() { PACKAGEPATH=$1 PACKAGES="$2" if [ -n "$LATEST" ]; then $LATEST $PACKAGEPATH $PACKAGES if [ $? != 0 ]; then $LATEST $PACKAGEPATH $PACKAGES >&2 kill -9 $$ fi return fi PATTERN="" PACKAGEFILES="" for PKG in $PACKAGES; do PATTERN="${PATTERN:+${PATTERN}|}(^$PKG )" PACKAGEFILES="$PACKAGEFILES $(ls $PACKAGEPATH/${PKG}*{${ARCH},noarch}.rpm 2>/dev/null)" 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 KEEPFILES=$3 for n in $RPMS; do echo -ne "\rExpanding packages..." $(basename $n) if [ $(rpm -qp --qf '%{NAME}' $n) = "glibc-common" ] ; then GLIBC=$n fi rpm2cpio $n | (cd $PKGDEST; cpio -E $KEEPFILES --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 glibc-common setup openssl python python2 newt slang libtermcap zlib ash e2fsprogs util-linux raidtools popt procps rpm XFree86 Xconfigurator anaconda anaconda-runtime kudzu hwdata bzip2 bzip2-libs dosfstools pciutils reiserfs-utils parted sed busybox-anaconda rpm-python booty hdparm lvm rhpl pyxf86config libxml2 libxml2-python glib2 elfutils-libelf bogl-bterm bogl krb5-libs convertdb1" if [ $ARCH = i386 -o $ARCH = x86_64 ]; then PACKAGES="$PACKAGES kernel-pcmcia-cs kernel-utils" fi if [ $ARCH = ia64 ]; then PACKAGES="$PACKAGES elilo" fi if [ $ARCH = s390 -o $ARCH = s390x ]; then PACKAGES="$PACKAGES s390utils oco binutils s390installer pdksh wget net-tools inetd openssh openssh-server coreutils modutils initscripts gawk xauth portmap telnet-server login ssh_keys" fi # xpm is missing # Some packages are listed twice, but that's okay # # The packages in this list are needed for the graphical installer to run # # Extra stuff we want for rescue mode should go in PACKAGESRESCUE # PACKAGESGR="anaconda XFree86-libs libpng XFree86-75dpi-fonts XFree86-ISO8859-2-75dpi-fonts gtk2 XFree86-ISO8859-9-75dpi-fonts esound audiofile libgnome XFree86-100dpi-fonts fonts-ISO8859-2 fonts-ISO8859-9 XFree86-xfs e2fsprogs coreutils glibc glibc-common readline popt specspo util-linux rpm procps ncurses bash cpio XFree86 Xconfigurator gnome-python2 pygtk2 gdk-pixbuf XFree86-KOI8-R XFree86-KOI8-R-75dpi-fonts pam reiserfs-utils atk pango freetype gnome-python2-canvas libgnomecanvas libart_lgpl expat anaconda-images anaconda-help XFree86-base-fonts ttfonts-ko taipeifonts XFree86-ISO8859-15-75dpi-fonts rhpl redhat-config-keyboard Xft fontconfig redhat-artwork ttfonts-ja ttfonts-zh_TW bitmap-fonts-cjk urw-fonts comps-extras XFree86-libs-data convertdb1" # # stuff ONLY included for rescue mode # # these packages are combined with the PACKAGES and PACKAGESGR for big stage 2 # PACKAGESRESCUE="bzip2 bzip2-libs dump findutils ftp gzip iputils joe krb5-libs less man mdadm modutils mtools mt-st mtr net-tools open openssh openssh-clients pciutils rsh traceroute tar" # turn off options we dont want, ie. set package list to something harmless if [ -z "$NEEDGR" ]; then PACKAGESGR="bash" PACKAGESRESCUE="bash" fi # # add bootloader for particular arch # if [ $ARCH = sparc ]; then PACKAGESGR="$PACKAGESGR tilo silo" fi if [ $ARCH = i386 -o $ARCH = x86_64 ]; then PACKAGESGR="$PACKAGESGR syslinux" fi if [ $ARCH = alpha ]; then PACKAGESGR="$PACKAGESGR aboot" fi if [ $ARCH = ia64 ]; then PACKAGESGR="$PACKAGESGR elilo" fi # # special packages for particular arches # if [ $ARCH = s390 -o $ARCH = s390x ]; then PACKAGESGR="$PACKAGESGR s390utils oco binutils s390installer pdksh net-tools inetd openssh openssh-server coreutils login wget initscripts xauth modutils portmap openssl telnet-server strace ssh_keys" fi if [ $ARCH = ppc ]; then PACKAGESGR="$PACKAGESGR fbset" fi # # KEEPFILE is all files to keep from the packages in PACKAGES # # This is what is present in http, ftp, and hard drive installs, and is # supposed to be a small image because these methods keep it in RAM. # # It also is the base on which the other install images build on top of, # so if something is needed by all images it should go here # KEEPFILE=/tmp/keepfile.$$ cat > $KEEPFILE <> $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 # # KEEPFILERESCUE is all files to keep from the packages in PACKAGESRESCUE # # This defines the files in addition to KEEPFILE and KEEPFILEGR that make up # the install images for NFS and CD/DVD based rescue mode installs. This # image is not loaded into memory so it can be considerably larger. # # NOTE: hd, ftp, and http rescue mode use and image based on KEEPFILE since # it has to be much smaller due to memory usage. # KEEPFILERESCUE=/tmp/keepfilerescue.$$ cat > $KEEPFILERESCUE <> $KEEPFILEGR # # filter paths in keepfile lists for use by cpio # for file in $KEEPFILE $KEEPFILEGR; do cat $file | awk '{print $1 "\n./" $1}' > $file- mv -f $file- $file done 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 ./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 chown -R root:root $DEST $DESTGR chmod -R a+rX-w $DEST $DESTGR if [ $ARCH = s390 -o $ARCH = s390x ]; then for i in $DEST $DESTGR; do (cd $i/etc/ssh; chmod og-r ssh_host*key primes sshd_config) mv $i/bin/sed $i/bin/sed_save mv $i/bin/sort $i/bin/sort_save mv $i/bin/mknod $i/bin/mknod_save done fi # Remove locales unused during the install cat $DESTGR/usr/lib/anaconda/lang-table* | awk ' { gsub("-", "", $5); print $5; print gensub(/\..*$/,"","",$5); print gensub(/_.*$/,"","",$5); if (split ($5, a, "\.") > 1) { print gensub(/\..*$/,tolower("." a[2]),"",$5); }; gsub("-", "", $8); print $8; print gensub(/\..*$/,"","",$8); print gensub(/_.*$/,"","",$8); if (split ($8, a, "\.") > 1) { print gensub(/\..*$/,tolower("." a[2]),"",$8); }; } ' | LC_ALL=C sort -u > $DESTGR/locales for p in lib share; do ( cd $DESTGR/usr/$p/locale && { ls | grep -v locale.alias | LC_ALL=C sort > $DESTGR/locales.list LC_ALL=C comm -13 $DESTGR/locales $DESTGR/locales.list | xargs rm -rf } ); done rm -f $DESTGR/locales $DESTGR/locales.list # Remove unneeded XFree86 modules rm -rf $DESTGR/usr/X11R6/$LIBDIR/modules/dri rm -f $DESTGR/usr/X11R6/$LIBDIR/modules/libscanpci.a rm -f $DESTGR/usr/X11R6/$LIBDIR/modules/libxf1bpp.a rm -f $DESTGR/usr/X11R6/$LIBDIR/modules/fonts/libspeedo.a rm -f $DESTGR/usr/X11R6/$LIBDIR/modules/drivers/linux/v4l_drv.o rm -f $DESTGR/usr/X11R6/$LIBDIR/modules/extensions/libdri.a rm -f $DESTGR/usr/X11R6/$LIBDIR/modules/extensions/libxtrap.a rm -f $DESTGR/usr/X11R6/$LIBDIR/modules/extensions/librecord.a rm -f $DESTGR/usr/X11R6/$LIBDIR/modules/extensions/lib{GLcore,glx,pex5}* # fixup joe links ln -fs jpicorc $DESTGR/etc/joe/picorc ln -fs jmacsrc $DESTGR/etc/joe/emacsrc ln -fs jmacs $DESTGR/usr/bin/emacs ln -fs jpico $DESTGR/usr/bin/pico echo "Creating nsswitch.conf" cat > $DEST/etc/nsswitch.conf < $DESTGR/etc/man.config rm -f $DESTGR/etc/man.config-old fi echo "Running mkfontdir..." if [ -n "$NEEDGR" ]; then /usr/X11R6/bin/mkfontdir -p /usr/X11R6/lib/X11/fonts/encodings/ -e $DESTGR/usr/X11R6/lib/X11/fonts/encodings $DESTGR/usr/X11R6/lib/X11/fonts/* $DESTGR/usr/share/fonts/ISO8859-9/* rm -f $DESTGR/usr/X11R6/bin/mkfontdir fi echo "Getting pango modules" if [ -n "$NEEDGR" ]; then if [ -x /usr/bin/runroot -a -n "$COMPONENT" ]; then REALPATH=`(cd $DESTGR; /bin/pwd | sed 's,/md1/,/,g')` runroot $COMPONENT --onlyone --arch $ARCH "LD_LIBRARY_PATH=/usr/X11R6/$LIBDIR:$LD_LIBRARY_PATH /usr/sbin/chroot $REALPATH /usr/bin/pango-querymodules 2> $REALPATH/etc/pango/pango.modules" else LD_LIBRARY_PATH=/usr/X11R6/$LIBDIR:$LD_LIBRARY_PATH /usr/sbin/chroot $DESTGR /usr/bin/pango-querymodules > $DESTGR/etc/pango/pango.modules fi rm -f $DESTGR/usr/bin/pango-querymodules fi echo "Munging gtkrc to not use Bluecurve icon theme" if [ -n "$NEEDGR" ]; then mv $DESTGR/usr/share/themes/Bluecurve/gtk-2.0/gtkrc $DESTGR/usr/share/themes/Bluecurve/gtk-2.0/gtkrc-old cat $DESTGR/usr/share/themes/Bluecurve/gtk-2.0/gtkrc-old | grep -v "iconrc" > $DESTGR/usr/share/themes/Bluecurve/gtk-2.0/gtkrc rm -f $DESTGR/usr/share/themes/Bluecurve/gtk-2.0/gtkrc-old fi echo "Getting gtk2 input method modules" if [ -n "$NEEDGR" ]; then if [ -x /usr/bin/runroot -a -n "$COMPONENT" ]; then REALPATH=`(cd $DESTGR; /bin/pwd | sed 's,/md1/,/,g')` runroot $COMPONENT --onlyone --arch $ARCH "LD_LIBRARY_PATH=/usr/X11R6/$LIBDIR:$LD_LIBRARY_PATH /usr/sbin/chroot $REALPATH /usr/bin/gtk-query-immodules-2.0 2> $REALPATH/etc/gtk-2.0/gtk.immodules" else LD_LIBRARY_PATH=/usr/X11R6/$LIBDIR:$LD_LIBRARY_PATH /usr/sbin/chroot $DESTGR /usr/bin/gtk-query-immodules-2.0 > $DESTGR/etc/gtk-2.0/gtk.immodules fi rm -f $DESTGR/usr/bin/gtk-query-immodules-2.0 fi echo "Getting gtk2 gdk-pixbuf loaders" if [ -n "$NEEDGR" ]; then if [ -x /usr/bin/runroot -a -n "$COMPONENT" ]; then runroot $COMPONENT --onlyone --arch $ARCH "LD_LIBRARY_PATH=/usr/X11R6/$LIBDIR:$LD_LIBRARY_PATH /usr/sbin/chroot $REALPATH /usr/bin/gdk-pixbuf-query-loaders 2> $REALPATH/etc/gtk-2.0/gdk-pixbuf.loaders" else LD_LIBRARY_PATH=/usr/X11R6/$LIBDIR:$LD_LIBRARY_PATH /usr/sbin/chroot $DESTGR /usr/bin/gdk-pixbuf-query-loaders > $DESTGR/etc/gtk-2.0/gdk-pixbuf.loaders fi rm -f $DESTGR/usr/bin/gdk-pixbuf-query-loaders fi # make the changes we want to fonts.conf for anaconda (#65913) if [ -n "$NEEDGR" ]; then echo -n "Munging fonts.conf" sed s/AR\ PL\ SungtiL\ GB/Fangsong\ ti/g $DESTGR/etc/fonts/fonts.conf > $DESTGR/etc/fonts/fonts.conf.foo mv $DESTGR/etc/fonts/fonts.conf.foo $DESTGR/etc/fonts/fonts.conf fi rm -f $KEEPFILE $KEEPFILEGR $KEEPFILERESCUE echo -n "Scrubbing trees..." for p in $DEST $DESTGR; do echo -n -e "\rScrubbing trees..." "$p" cp $p/usr/lib/anaconda/raidstart-stub $p/usr/bin/raidstart cp $p/usr/lib/anaconda/raidstop-stub $p/usr/bin/raidstop cp $p/usr/lib/anaconda/losetup-stub $p/usr/bin/losetup cp $p/usr/lib/anaconda/pump-stub $p/usr/bin/pump cp $p/usr/lib/anaconda/list-harddrives-stub $p/usr/bin/list-harddrives cp $p/usr/lib/anaconda/kudzu-probe-stub $p/usr/bin/kudzu-probe cp $p/usr/lib/anaconda/loadkeys-stub $p/usr/bin/loadkeys cp $p/usr/lib/anaconda/mknod-stub $p/usr/bin/mknod cp $p/usr/lib/anaconda/rescue-startx-stub $p/usr/bin/rescue-startx mv $p/usr/sbin/anaconda $p/usr/bin/anaconda mv $p/usr/lib/anaconda-runtime/lib* $p/usr/$LIBDIR # we only want the libunicode-lite stuff on the minimal image if [ $p = $DESTGR ]; then rm -f $p/usr/$LIBDIR/libunicode-lite* fi 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 # copy bootloader files for sparc if [ $ARCH = sparc -a $p = $DESTGR ]; then mkdir -p $p/usr/lib/anaconda-runtime/boot (cd $p/boot; find -name "*.b") | (cd $p/boot; /bin/cpio --quiet -pdmu $p/usr/lib/anaconda-runtime/boot) fi # copy bootloader file for alpha if [ $ARCH = alpha -a $p = $DESTGR ]; then mkdir -p $p/usr/lib/anaconda-runtime/boot cp -af $p/boot/bootlx $p/usr/lib/anaconda-runtime/boot fi # copy bootloader files for ia64 if [ $ARCH = ia64 -a $p = $DESTGR ]; then mkdir -p $p/usr/lib/anaconda-runtime/boot cp -af $p/boot/efi/EFI/redhat//* $p/usr/lib/anaconda-runtime/boot fi rm -rf $p/boot $p/home $p/root $p/tmp find $p -name "*.a" | grep -v "usr/X11R6/$LIBDIR/modules" | xargs rm -rf find $p -name "lib*.la" |grep -v "usr/$LIBDIR/gtk-2.0" | xargs rm -rf for f in newt popt rpm rpmio; do rm -f $p/usr/$LIBDIR/lib$f.so done if [ "$ARCH" != "s390" -a "$ARCH" != "s390x" ]; then (cd $p/lib; rm -f libnss_files.so.1 libnss_dns.so.1) fi (cd /usr/share/zoneinfo; find . -type f -or -type l | grep '^./[A-Z]' | sort | sed 's/^..//' | gzip -9) > $p/usr/$LIBDIR/timezones.gz if [ -x /usr/bin/runroot -a -n "$COMPONENT" ]; then REALPATH=`(cd $p; /bin/pwd | sed 's,/md1/,/,g')` runroot $COMPONENT --onlyone --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 "Creating fontconfig cache" if [ -n "$NEEDGR" ]; then if [ -x /usr/bin/runroot -a -n "$COMPONENT" ]; then REALPATH=`(cd $DESTGR; /bin/pwd | sed 's,/md1/,/,g')` runroot $COMPONENT --onlyone --arch $ARCH "LD_LIBRARY_PATH=/usr/X11R6/$LIBDIR:$LD_LIBRARY_PATH /usr/sbin/chroot $REALPATH /usr/bin/fc-cache -v" else LD_LIBRARY_PATH=/usr/X11R6/$LIBDIR:$LD_LIBRARY_PATH /usr/sbin/chroot $DESTGR /usr/bin/fc-cache -v fi rm -f $DESTGR/usr/bin/fc-cache fi if [ $ARCH = "alpha" ]; then rm -rf $DEST/usr/share/locale rm -rf $DEST/usr/$LIBDIR/locale fi echo "Patching python library..." # always use passive mode for ftp installs cd $DEST/usr/$LIBDIR/python2.2 patch -p0 > /dev/null <