#! /bin/bash export PYTHONPATH=/usr/lib/anaconda export PATH=$PATH:/usr/lib/anaconda-runtime VERSION=3.7 BUILDDIR=/home/centos/7build DISTDIR=/home/centos/u7build BUILDTIME=`date +%Y%m%d%H%M` LOGFILE=/home/centos/u7build/build.$BUILDTIME.log echo "Starting Build ... - logging to $LOGFILE" echo "Starting Build" > $LOGFILE #run as root ... ## Clean out build area rm -f $BUILDDIR/SRPMS/* rm -f $BUILDDIR/RPMS/i386/* rm -f $BUILDDIR/RPMS/noarch/* rm -f $BUILDDIR/RPMS/athlon/* rm -f $BUILDDIR/RPMS/i686/* rm -f $BUILDDIR/RPMS/i486/* rm -f $BUILDDIR/RPMS/i586/* rm -rf $BUILDDIR/BUILD/* ## Build comps echo "Building Comps" echo "Building Comps" >> $LOGFILE rpmbuild -ba $BUILDDIR/SPECS/comps-centos-first.spec >> $LOGFILE 2>&1 cp $BUILDDIR/SRPMS/comps* $DISTDIR/SRPMS.centos/ >> $LOGFILE 2>&1 rm -f $DISTDIR/i386/RedHat/RPMS/comps-3* >> $LOGFILE 2>&1 cp $BUILDDIR/RPMS/i386/comps* $DISTDIR/i386/RedHat/RPMS/ >> $LOGFILE 2>&1 cp -f $BUILDDIR/RPMS/i386/comps* $DISTDIR/i386/RedHat/base/comps.rpm >> $LOGFILE 2>&1 ## Build centos-yumcache echo "Building Yumcache" echo "Building Yumcache" >> $LOGFILE rpmbuild -ba $BUILDDIR/SPECS/centos-yumcache-3.1.spec >> $LOGFILE 2>&1 cp $BUILDDIR/SRPMS/centos-yumcache* $DISTDIR/SRPMS.centos/ >> $LOGFILE 2>&1 rm -f $DISTDIR/i386/RedHat/RPMS/centos-yumcache* >> $LOGFILE 2>&1 cp $BUILDDIR/RPMS/noarch/centos-yumcache* $DISTDIR/i386/RedHat/RPMS/ >> $LOGFILE 2>&1 ## Build rpmdb echo "Building Rpmdb" echo "Building Rpmdb" >> $LOGFILE #remove if installed rpm -e rpmdb-redhat rpmbuild -ba $BUILDDIR/SPECS/rpmdb-redhat-rhel.spec >> $LOGFILE 2>&1 cp $BUILDDIR/SRPMS/rpmdb-redhat* $DISTDIR/SRPMS.centos/ >> $LOGFILE 2>&1 rm -f $DISTDIR/i386/RedHat/RPMS/rpmdb-redhat* >> $LOGFILE 2>&1 cp $BUILDDIR/RPMS/i386/rpmdb-redhat* $DISTDIR/i386/RedHat/RPMS/ >> $LOGFILE 2>&1 rpm --resign $DISTDIR/i386/RedHat/RPMS/comps* $DISTDIR/SRPMS.centos/comps* $DISTDIR/i386/RedHat/RPMS/centos-yumcache* $DISTDIR/SRPMS.centos/centos-yumcache* $DISTDIR/i386/RedHat/RPMS/rpmdb-redhat* $DISTDIR/SRPMS.centos/rpmdb-redhat* $DISTDIR/i386/RedHat/base/comps.rpm cd $DISTDIR ## Run genhd first time echo "Running genhdlist" echo "Running genhdlist" >> $LOGFILE /usr/lib/anaconda-runtime/genhdlist \ --withnumbers $DISTDIR/i386 >> $LOGFILE 2>&1 ## then pkgorder echo "Getting pkgorder" echo "Getting pkgorder" >> $LOGFILE /usr/lib/anaconda-runtime/pkgorder \ $DISTDIR/i386 i386 RedHat | tee $DISTDIR/i386/pkgorder-i386.txt ## then genhd again echo "Running genhdlist again" echo "Running genhdlist again" >> $LOGFILE /usr/lib/anaconda-runtime/genhdlist \ --withnumbers --fileorder=$DISTDIR/i386/pkgorder-i386.txt \ $DISTDIR/i386 >> $LOGFILE 2>&1 ## then build installer echo "Building Installer" echo "Building Installer" >> $LOGFILE /usr/lib/anaconda-runtime/buildinstall --comp dist-3.0 \ --pkgorder $DISTDIR/i386/pkgorder-i386.txt \ --release final \ --product CentOS-3 \ --version 3.0 $DISTDIR/i386/ >> $LOGFILE 2>&1 cp -au $DISTDIR/splash.lss $DISTDIR/i386/isolinux # echo "Making srpm repo" echo "Making srpm repo" >> $LOGFILE # $DISTDIR/scripts/mksrpms >> $LOGFILE 2>&1 echo "Splitting Tree" echo "Splitting Tree" >> $LOGFILE /usr/lib/anaconda-runtime/splittree.py --arch=i386 --total-discs=6 \ --bin-discs=3 --src-discs=3 \ --release-string=CentOS-3 \ --pkgorderfile=$DISTDIR/i386/pkgorder-i386.txt \ --distdir=$DISTDIR/i386/ \ --srcdir=$DISTDIR/i386/SRPMS/ >> $LOGFILE 2>&1 rm -rf $DISTDIR/i386-disc* >> $LOGFILE 2>&1 mv $DISTDIR/i386/-disc1/ $DISTDIR/i386-disc1 >> $LOGFILE 2>&1 mv $DISTDIR/i386/-disc2/ $DISTDIR/i386-disc2 >> $LOGFILE 2>&1 mv $DISTDIR/i386/-disc3/ $DISTDIR/i386-disc3 >> $LOGFILE 2>&1 mv $DISTDIR/i386/-disc4/ $DISTDIR/i386-disc4 >> $LOGFILE 2>&1 mv $DISTDIR/i386/-disc5/ $DISTDIR/i386-disc5 >> $LOGFILE 2>&1 mv $DISTDIR/i386/-disc6/ $DISTDIR/i386-disc6 >> $LOGFILE 2>&1 ## run genhd on isos echo "Running genhdlist on isos" echo "Running genhdlist on isos" >> $LOGFILE rm $DISTDIR/i386-disc1/RedHat/base/hdlist* >> $LOGFILE 2>&1 /usr/lib/anaconda-runtime/genhdlist \ --withnumbers --fileorder $DISTDIR/i386/pkgorder-i386.txt \ $DISTDIR/i386-disc[123] >> $LOGFILE 2>&1 echo "Building final comps" echo "Building final comps" >> $LOGFILE ## build final comps rm -f $BUILDDIR/RPMS/i386/comps* >> $LOGFILE 2>&1 rpmbuild -ba $BUILDDIR/SPECS/comps-centos.spec >> $LOGFILE 2>&1 rpm --resign $BUILDDIR/SRPMS/comps* $BUILDDIR/RPMS/i386/comps* cp $BUILDDIR/SRPMS/comps* $DISTDIR/SRPMS.centos/ >> $LOGFILE 2>&1 rm -f $DISTDIR/i386-disc1/RedHat/RPMS/comps-3* >> $LOGFILE 2>&1 cp $BUILDDIR/RPMS/i386/comps* $DISTDIR/i386-disc1/RedHat/RPMS/ >> $LOGFILE 2>&1 rm -f $DISTDIR/i386-disc3/RedHat/RPMS/comps-3* >> $LOGFILE 2>&1 cp $BUILDDIR/RPMS/i386/comps* $DISTDIR/i386-disc3/RedHat/RPMS/ >> $LOGFILE 2>&1 rm -f $DISTDIR/i386-disc1/RedHat/base/comps.rpm >> $LOGFILE 2>&1 cp -f $BUILDDIR/RPMS/i386/comps* $DISTDIR/i386-disc1/RedHat/base/comps.rpm >> $LOGFILE 2>&1 rm -f $DISTDIR/i386/RedHat/RPMS/comps-3* >> $LOGFILE 2>&1 cp $BUILDDIR/RPMS/i386/comps* $DISTDIR/i386/RedHat/RPMS/ >> $LOGFILE 2>&1 cp -f $BUILDDIR/RPMS/i386/comps* $DISTDIR/i386/RedHat/base/comps.rpm >> $LOGFILE 2>&1 cp -al $DISTDIR/docs $DISTDIR/i386-disc4 cp -al $DISTDIR/addons $DISTDIR/i386-disc3 rm -rf $DISTDIR/buildinstall* echo "Writing isos" echo "Writing isos" >> $LOGFILE ## write the isos publisher='CentOS Project' bootimg='isolinux/isolinux.bin' bootcat='isolinux/boot.cat' distname='CentOS' distvers='3.7' #mkisopts='-r -N -L -d -D -J' mkisopts='-r -J' today="$(date '+%d %b %Y')" mkisofs $mkisopts \ -V "CentOS-3.7 Disk 1" \ -A "CentOS-3.7 created on $today" \ -P "$publisher" \ -p "$publisher" \ -b "$bootimg" \ -c "$bootcat" \ -no-emul-boot -boot-load-size 4 -boot-info-table \ -x lost+found \ -o "$distname"-1.iso \ i386-disc1 >> $LOGFILE 2>&1 /usr/lib/anaconda-runtime/implantisomd5 "$distname"-1.iso >> $LOGFILE 2>&1 for i in 2 3 4 5 6 ; do cp -au $DISTDIR/i386/RPM-GPG-KEY-CentOS-3 $DISTDIR/i386-disc${i} mkisofs $mkisopts \ -V "CentOS-3.7 Disk $i" \ -A "CentOS-3.7 created $today" \ -P "$publisher" \ -p "$publisher" \ -x lost+found \ -o "$distname"-${i}.iso \ i386-disc${i} >> $LOGFILE 2>&1 /usr/lib/anaconda-runtime/implantisomd5 "$distname"-${i}.iso >> $LOGFILE 2>&1 done echo "Finished - log is $LOGFILE" echo "Finished" >> $LOGFILE