#!/bin/sh ###################################################################### myname=$0 url="ftp://plamo.linet.gr.jp/pub/Srcs/grub-0.97.tar.gz" pkgbase=grub vers=0.97 arch=i386 build=P4 src="$pkgbase-$vers" OPT_CONFIG=" " DOCS="AUTHORS BUGS COPYING ChangeLog INSTALL MAINTENANCE NEWS README THANKS TODO" pkgs="$pkgbase-$vers" pkgl="$pkgbase-$vers-$arch-$build" file1=grubconfig file2=egrubconfig file3=setup.bootloader file4=esetup.bootloader ###################################################################### # Patches from FC6 grub-0.97-13.src.rpm patch0=grub-0.93-configfile.patch patch1=grub-0.90-symlinkmenulst.patch # patches 20-39 are for grub-install bits patch20=grub-0.97-install.in.patch patch21=grub-0.94-installcopyonly.patch patch22=grub-0.94-addsyncs.patch # patches 40-59 are for miscellaneous build related patches # link against curses statically patch40=grub-0.95-staticcurses.patch # patches submitted upstream and pending approval # change the message so that how to accept changes is clearer (#53846) patch81=grub-0.93-endedit.patch # patches 100-199 are for features proposed but not accepted upstream # add support for appending kernel arguments patch100=grub-0.90-append.patch # add support for lilo -R-esque select a new os to boot into patch101=grub-0.97-once.patch # patches 200-299 are for graphics mode related patches patch200=grub-0.95-graphics.patch patch201=grub-0.91-splashimagehelp.patch patch202=grub-0.93-graphics-bootterm.patch patch203=grub-0.95-hiddenmenu-tweak.patch # patches 500+ are for miscellaneous little things # support for non-std devs (eg cciss, etc) patch500=grub-0.93-special-device-names.patch # i2o device support patch501=grub-0.94-i2o.patch # detect cciss/ida/i2o patch502=grub-0.95-moreraid.patch # for some reason, using the initrd max part of the setup.S structure # causes problems on x86_64 and with 4G/4G patch505=grub-0.94-initrdmax.patch # we need to use O_DIRECT to avoid hitting oddities with caching patch800=grub-0.95-odirect.patch # the 2.6 kernel no longer does geometry fixups. so now I get to do it # instead in userspace everywhere. patch1000=grub-0.95-geometry-26kernel.patch # Support for booting from a RAID1 device patch1100=grub-0.95-md.patch patch1101=grub-0.95-md-rework.patch # Ignore everything before the XPM header in the bootsplash patch1102=grub-0.95-xpmjunk.patch # Don't go to "graphics" mode unless we find the bootsplash and it's an xpm, # and don't print any errors about the missing file while current_term is # "graphics". patch1103=grub-0.95-splash-error-term.patch # Mark the simulation stack executable patch1104=grub-0.97-nxstack.patch patch1105=grub-0.97-nx-multiinstall.patch # always use a full path for mdadm. patch1110=grub-0.97-mdadm-path.patch # always install into the mbr if we're on a raid1 /boot. patch1111=grub-0.95-md-mbr.patch # gcc4 fixes. patch1115=grub-0.97-gcc4.patch # Make non-MBR installs work again on non-raid1. patch1120=grub-0.95-nonmbr.patch # Make "grub-install --recheck" look like the menace it is. patch1130=grub-0.95-recheck-bad.patch # Fix missing prototypes, since grub nicely sets -Wmissing-prototypes and # then tries to build conftests without them. patch1135=grub-0.97-prototypes.patch # put /usr/lib/grub back in /usr/share/grub like it was before, so other # scripts don't screw up. patch1140=grub-0.97-datadir.patch # install correctly on dmraid devices patch1145=grub-0.97-dmraid.patch patch1146=grub-0.97-dmraid-recheck-bad.patch patch1147=grub-0.97-dmraid-partition-names.patch # fix mactel keyboard bugs patch1148=grub-0.97-mactel-kbd.patch # fix error reporting patch1149=grub-0.97-stderr.patch # fix grub-install to notice mpath partitions patch1150=grub-0.97-mpath.patch fscheck() { PANGRAM="The quick brown fox jumps over the lazy dog." echo -n "Checking for the filesystem ... " mkdir pangram ; ( cd pangram ; touch $PANGRAM ) mv pangram pangram~ ; mkdir pangram ; touch -r pangram~ pangram tar cpf pangram.tar pangram ; rmdir pangram ; mv pangram~ pangram for i in $PANGRAM ; do tar rpf pangram.tar pangram/$i ; done touch -t `date '+%m%d0900'` pangram.tar ; gzip pangram.tar touch pangram.tar.gz ; mv pangram.tar.gz pangram1.tgz tar cpf pangram.tar pangram touch -t `date '+%m%d0900'` pangram.tar ; gzip pangram.tar touch pangram.tar.gz ; mv pangram.tar.gz pangram2.tgz if cmp -s pangram1.tgz pangram2.tgz ; then echo "OK" rm -rf pangram pangram1.tgz pangram2.tgz else echo "NG" cat <<- "EOF" Hmm, packaging may not be done properly on this filesystem. Would you please try again on a default filesystem, thanks! Happy packaging!! Quitting... EOF exit fi } install2() { install -d ${2%/*} ; install -m 644 $1 $2 } strip_bindir() { echo "compressing in $1" if [ -d $1 ] ; then ( shopt -s nullglob cd $1 for i in * ; do echo "$i" if [ -h $i ] ; then continue ; fi chk=`file $i | grep "not stripped"` if [ "x$chk" != "x" ] ; then echo "stripping -p $i" strip -p $i fi done ) fi } strip_libdir() { echo "compressing in $1" if [ -d $1 ] ; then ( shopt -s nullglob cd $1 for i in *.so *.so.* *.a ; do echo "$i" if [ -h $i ] ; then continue ; fi chk=`nm -a $i | grep " a "` if [ "x$chk" != "x" ] ; then if [ "x$i" != "x${i%.a}" ] ; then echo -n "ranlib and " touch -r $i $i.mt ; ranlib $i ; touch -r $i.mt $i ; rm $i.mt fi echo "stripping -gp $i" strip -gp $i fi done ) fi } gzip_dir() { echo "compressing in $1" if [ -d $1 ] ; then ( cd $1 files=`ls -f --indicator-style=none | tail -n +3` for i in $files ; do echo "$i" if [ ! -f $i -a ! -h $i -o "x$i" != "x${i%.gz}" ] ; then continue ; fi lnks=`ls -l $i | awk '{print $2}'` if [ $lnks -gt 1 ] ; then inum=`ls -i $i | awk '{print $1}'` for j in `find . -maxdepth 1 -inum $inum` ; do if [ ${j#./} == $i ] ; then gzip -f $i else rm -f ${j#./} ; ln $i.gz ${j#./}.gz fi done elif [ -h $i ] ; then ln_target=`ls -l $i | awk '{print $11}'` rm -f $i ; ln -s $ln_target.gz $i.gz else gzip $i fi done for i in $files ; do mv ${i%.gz}.gz $C ; done for i in $files ; do mv $C/${i%.gz}.gz . ; done ) fi } gzip_one() { gzip $1 ; mv $1.gz $C ; mv $C/${1##*/}.gz ${1%/*} } compress() { for i in {$P/usr,$P}/{bin,sbin} ; do strip_bindir $i ; done for i in {$P/usr,$P}/lib ; do strip_libdir $i ; done if [ -f $infodir/dir ] ; then rm -f $infodir/dir ; fi gzip_dir $infodir for i in `seq 9` n ; do gzip_dir $mandir/man$i ; done } #fscheck W=`pwd` for i in `seq 0 $((${#src[@]} - 1))` ; do S[$i]=$W/${src[$i]} ; B[$i]=$W/build`test ${#src[@]} -eq 1 || echo $i` done P=$W/work ; C=$W/pivot infodir=$P/usr/share/info mandir=$P/usr/share/man docdir=$P/usr/share/doc if [ $# -eq 0 ] ; then opt_download=1 opt_config=1 opt_build=1 opt_package=1 else for i in "$@" ; do case $i in download) opt_download=1 ;; config) opt_config=1 ;; build) opt_build=1 ;; package) opt_package=1 ;; esac done fi if [ "$opt_download" == "1" ] ; then for i in $url ; do if [ ! -f ${##*.} -a ! -f ${i##*/} ] ; then wget $i ; fi done for i in $url ; do case ${i##*.} in tar) tar xvpf ${i##*/} ;; gz) tar xvpzf ${i##*/} ;; bz2) tar xvpjf ${i##*/} ;; esac done fi if [ "$opt_config" == "1" ] ; then for i in `seq 0 $((${#B[@]} - 1))` ; do if [ -d ${B[$i]} ] ; then rm -rf ${B[$i]} ; fi ; cp -a ${S[$i]} ${B[$i]} done ###################################################################### # * ./configure を行う前に適用したい設定やパッチなどがある場合はここに # 記述します。 ###################################################################### for i in `seq 0 $((${#B[@]} - 1))` ; do cd ${B[$i]} patch -Np1 -i $W/$patch0 patch -Np1 -i $W/$patch1 patch -Np1 -i $W/$patch20 patch -Np1 -i $W/$patch21 patch -Np1 -i $W/$patch22 patch -Np1 -i $W/$patch40 patch -Np0 -i $W/$patch81 patch -Np1 -i $W/$patch100 patch -Np1 -i $W/$patch101 patch -Np1 -i $W/$patch200 patch -Np1 -i $W/$patch201 patch -Np1 -i $W/$patch202 patch -Np1 -i $W/$patch203 patch -Np1 -i $W/$patch500 patch -Np1 -i $W/$patch501 patch -Np1 -i $W/$patch502 # This patch fixes #116311 patch -Np1 -i $W/$patch505 patch -Np1 -i $W/$patch800 patch -Np1 -i $W/$patch1000 patch -Np1 -i $W/$patch1100 patch -Np1 -i $W/$patch1101 patch -Np1 -i $W/$patch1102 patch -Np1 -i $W/$patch1103 patch -Np1 -i $W/$patch1104 patch -Np1 -i $W/$patch1105 patch -Np1 -i $W/$patch1110 patch -Np1 -i $W/$patch1111 patch -Np1 -i $W/$patch1115 patch -Np1 -i $W/$patch1120 patch -Np1 -i $W/$patch1130 patch -Np1 -i $W/$patch1135 patch -Np1 -i $W/$patch1140 patch -Np1 -i $W/$patch1145 patch -Np1 -i $W/$patch1146 patch -Np1 -i $W/$patch1147 patch -Np1 -i $W/$patch1148 patch -Np1 -i $W/$patch1149 patch -Np1 -i $W/$patch1150 if [ -f Makefile ] ; then make clean fi if [ -f config.log ] ; then rm -rf config.cache config.log fi echo "doing autoreconf" autoreconf sleep 3 if [ -x configure ] ; then ./configure --prefix=/usr --infodir='${prefix}'/share/info \ --mandir='${prefix}'/share/man ${OPT_CONFIG[$i]} fi patch -Np1 -i $W/grub-0.97-staticlink.patch patch -Np1 -i $W/grub-0.97-staticlink2.patch done fi if [ "$opt_build" == "1" ] ; then for i in `seq 0 $((${#B[@]} - 1))` ; do cd ${B[$i]} if [ -f Makefile ] ; then make fi done fi if [ "$opt_package" == "1" ] ; then if [ `id -u` -ne 0 ] ; then read -p "Do you want to package as root? [y/N] " ans if [ "x$ans" == "xY" -o "x$ans" == "xy" ] ; then cd $W ; /bin/su -c "$0 package" ; exit fi fi if [ -d $P ] ; then rm -rf $P ; fi ; mkdir -p $P if [ -d $C ] ; then rm -rf $C ; fi ; mkdir -p $C touch $W/i.st ; sleep 1 for i in `seq 0 $((${#B[@]} - 1))` ; do cd ${B[$i]} if [ -f Makefile ] ; then make install DESTDIR=$P fi done ###################################################################### # * make install でコピーされないファイルがある場合はここに記述します。 ###################################################################### mkdir -p $P/sbin install -m 544 -o root -g root $W/$file1 $P/sbin install -m 544 -o root -g root $W/$file2 $P/sbin mkdir -p $P/var/log/setup install -m 544 -o root -g root $W/$file3 $P/var/log/setup install -m 544 -o root -g root $W/$file4 $P/var/log/setup mkdir -p $P/boot/grub cp $P/usr/share/grub/i386-pc/stage{1,2} $P/boot/grub # cp $P/usr/lib/grub/i386-pc/stage2 $P/boot/grub touch $W/i.et cd $W find $P -newer i.st ! -newer i.et -exec touch -t `date '+%m%d0900'` {} \; compress ###################################################################### # * compress 対象以外で圧縮したいディレクトリやファイルがある場合はここ # に記述します(strip_{bin,lib}dir や gzip_{dir,one} を使います)。 # * 他のアーカイブから追加したいファイルがある場合はここに記述します。 ###################################################################### for i in `seq 0 $((${#DOCS[@]} - 1))` ; do for j in ${DOCS[$i]} ; do for k in ${S[$i]}/$j ; do install2 $k $docdir/${src[$i]}/${k#${S[$i]}/} touch -r $k $docdir/${src[$i]}/${k#${S[$i]}/} gzip_one $docdir/${src[$i]}/${k#${S[$i]}/} done done if [ $i -eq 0 ] ; then install $myname $docdir/$src touch -t `date '+%m%d0900'` $docdir/$src/$myname gzip_one $docdir/$src/$myname else ln $docdir/$src/$myname.gz $docdir/${src[$i]} fi ( cd $docdir ; find ${src[$i]} -type d -exec touch -r $W/{} {} \; ) done ###################################################################### # * 完成した作業ディレクトリから tar イメージを作成する手順を以降に記述 # します(こだわりを求めないなら単に makepkg でも良いです)。 ###################################################################### # tar cvpf $pkgl.tar -C $P usr/bin/hoge # tar rvpf $pkgl.tar -C $P usr/share/man/man1/hoge.1.gz # tar rvpf $pkgl.tar -C $P usr/share/doc/$src # touch -t `date '+%m%d0900'` $pkgl.tar ; gzip $pkgl.tar ; touch $pkgl.tar.gz # mv $pkgl.tar.gz $pkgl.tgz ( cd $P ; /sbin/makepkg ../$pkgl.tgz ) # rm -rf i.et i.st work pivot fi