#!/bin/bash #Copyright 2003 William Stearns #Version 0.0.2 Banner () { echo "======== $* ========" } Debug () { echo "$*" >&2 } GetFile () { if [ -n "$1" ]; then for OneSource in $Sources ; do case $OneSource in /*) #Local path if [ -n "`ls -A1rt $OneSource/$1 2>/dev/null`" ]; then Debug $1 found in $OneSource if [ "$OneSource" = "$Cache" ]; then Debug $1 already in cache break else Debug Copying $1 from $OneSource cp -p $OneSource/$1 $Cache >/dev/null && break #Exit if successful fi fi ;; *::*) #Rsync if rsync "$OneSource/$1" >/dev/null 2>&1 ; then #Return code 0=file exists, 23, not there. Works with wildcards. Debug Rsyncing $1 down from $OneSource rsync -a "$OneSource/$1" "$Cache" >/dev/null && break #Exits from innermost for/while/until loop. else Debug Rsync $OneSource doesn\'t have $1 fi ;; http*|ftp*) Debug http/ftp unimplemented. # cd "$WorkDir/sources/" # wget "$1" # cd - ;; esac done else Debug Nothing requested in GetFile fi echo `ls -A1rt $Cache/$1 2>/dev/null | tail -1` #Most recent cached rpm } build="yes" for OneRequest in $* ; do case $OneRequest in --nobuild) build='no' ;; fileutils|chgrp|chmod|chown|cp|dd|df|ln|ls|mkdir|mknod|mv|rm|rmdir|sync|touch|dir|dircolors|du|install|mkfifo|shred|vdir) fileutils='yes' ;; nc) nc='yes' ;; textutils|cat|cut|sort|cksum|comm|csplit|cut|expand|fmt|fold|head|join|md5sum|nl|od|paste|pr|ptx|sha1sum|split|sum|tac|tail|tr|tsort|unexpand|uniq|wc) textutils='yes' ;; procps|ps|sysctl|free|oldps|pgrep|pkill|skill|snice|tload|top|uptime|vmstat|w|watch) procps='yes' ;; *) Debug Unknown request $OneRequest, what rpm has that? ;; esac done if [ -z "$fileutils$nc$textutils$procps" ]; then #If no requests made, build everything fileutils="yes" nc="yes" textutils="yes" procps='yes' fi #Preferred first, space separated rsync or /path/ dirs (future ftp/http) Sources="/usr/src/staticiso-sources/ zaphod.stearns.org::redhatmirror/pub/redhat/linux/updates/7.3/en/os/SRPMS/ zaphod.stearns.org::redhatmirror/pub/redhat/linux/7.3/en/os/i386/SRPMS/" Cache=/usr/src/staticiso-sources/ if [ -z "$WorkDir" ]; then WorkDir="$HOME/staticiso-build/" fi mkdir --parents "$Cache" if [ -d "$WorkDir" ]; then echo "$WorkDir exists, exiting." exit 1 fi mkdir --parents "$WorkDir" mkdir --parents "$WorkDir/unpack/" if ! cd "$WorkDir" 2>/dev/null ; then echo "Unable to change to $WorkDir, exiting." exit 1 fi export CFLAGS="$CFLAGS -static" if [ "$fileutils" = "yes" ]; then Banner fileutils if [ "$build" = 'yes' ]; then MyRpm=`GetFile fileutils-*.src.rpm` rpm --rebuild "$MyRpm" fi cd "$WorkDir/unpack/" rpm2cpio /home/wstearns/rpm/RPMS/i386/fileutils-*.i386.rpm | cpio -i -d -m fi if [ "$nc" = "yes" ]; then #FIXME - makefile clobbers -static Banner nc if [ "$build" = 'yes' ]; then MyRpm=`GetFile nc-*.src.rpm` Debug Source RPM is $MyRpm fi rpm --rebuild "$MyRpm" cd "$WorkDir/unpack/" rpm2cpio /home/wstearns/rpm/RPMS/i386/nc-*.i386.rpm | cpio -i -d -m fi if [ "$textutils" = "yes" ]; then Banner textutils if [ "$build" = 'yes' ]; then MyRpm=`GetFile textutils-*.src.rpm` rpm --rebuild "$MyRpm" fi cd "$WorkDir/unpack/" rpm2cpio /home/wstearns/rpm/RPMS/i386/textutils-*.i386.rpm | cpio -i -d -m fi if [ "$procps" = "yes" ]; then #FIXME - not -static Banner procps MyRpm=`GetFile procps-*.src.rpm` if [ "$build" = 'yes' ]; then rpm --rebuild "$MyRpm" cd "$WorkDir/unpack/" fi rpm2cpio /home/wstearns/rpm/RPMS/i386/procps-*.i386.rpm | cpio -i -d -m fi #Template #if [ "$ZZ" = "yes" ]; then # Banner ZZ # MyRpm=`GetFile ZZ-*.src.rpm` # if [ "$build" = 'yes' ]; then # rpm --rebuild "$MyRpm" # cd "$WorkDir/unpack/" # fi # rpm2cpio /home/wstearns/rpm/RPMS/i386/ZZ-*.i386.rpm | cpio -i -d -m #fi cd "$WorkDir" mkisofs -gid 0 -uid 0 -pad -r -T -o "$WorkDir/static.`date +%y%m%d`.iso" unpack/ bzip2 -9 -k "$WorkDir/static.`date +%y%m%d`.iso"