1b412cc49SMatthew Dillon#!/bin/csh 2b412cc49SMatthew Dillon# 3b412cc49SMatthew Dillon# Create a working chroot for snapshot building 4b412cc49SMatthew Dillon# 5b412cc49SMatthew Dillon 6b412cc49SMatthew Dillonsource config 7b412cc49SMatthew Dillon 8b412cc49SMatthew Dillonset ncpu = `sysctl -n hw.ncpu` 9b412cc49SMatthew Dillonset pushdsilent 10b412cc49SMatthew Dillonset xdate = "date" 11b412cc49SMatthew Dillon 123dae329dSSascha Wildner# needed for ports 'ex' script execution 133dae329dSSascha Wildner# 143dae329dSSascha Wildnersetenv TERM xterm 153dae329dSSascha Wildner 16b412cc49SMatthew Dillonecho "`$xdate` - SNAPSHOTS DOBUILD BEGIN" 17b412cc49SMatthew Dillon 18b412cc49SMatthew Dillon# Options 19b412cc49SMatthew Dillon# 20b412cc49SMatthew Dillonset nrelease_args = "release" 21b412cc49SMatthew Dillon 22b412cc49SMatthew Dillonforeach arg ( $argv ) 23b412cc49SMatthew Dillon switch ( $arg ) 24b412cc49SMatthew Dillon case "realquick": 25b412cc49SMatthew Dillon set quick = 1 26b412cc49SMatthew Dillon set realquick = 1 27b412cc49SMatthew Dillon set nrelease_args = "realquick" 28b412cc49SMatthew Dillon breaksw 29b412cc49SMatthew Dillon case "quick": 30b412cc49SMatthew Dillon set quick = 1 31b412cc49SMatthew Dillon set nrelease_args = "quick" 32b412cc49SMatthew Dillon breaksw 33b412cc49SMatthew Dillon default: 34b412cc49SMatthew Dillon echo "`$xdate` - Unknown option $arg" 35b412cc49SMatthew Dillon echo "`$xdate` - SNAPSHOTS DOBUILD END" 36b412cc49SMatthew Dillon exit 1 37b412cc49SMatthew Dillon endsw 38b412cc49SMatthew Dillonend 39b412cc49SMatthew Dillon 40b412cc49SMatthew Dillonecho "`$xdate` - Setting up chroot environment" 41b412cc49SMatthew Dillonif ( ! -e $build/root/dev/null ) then 42b412cc49SMatthew Dillon mount_devfs dummy $build/root/dev 43b412cc49SMatthew Dillonendif 44b412cc49SMatthew Dillon 453dae329dSSascha Wildnersync; sleep 1 463dae329dSSascha Wildnerumount $build/root/usr/distfiles >& /dev/null 473dae329dSSascha Wildnerumount $build/root/usr/src >& /dev/null 483dae329dSSascha Wildnerumount $build/root/usr/dports >& /dev/null 493dae329dSSascha Wildnersync; sleep 1 503dae329dSSascha Wildnermount_null $build/distfiles $build/root/usr/distfiles 513dae329dSSascha Wildnermount_null $build/src $build/root/usr/src 523dae329dSSascha Wildnermount_null $build/dports $build/root/usr/dports 53b412cc49SMatthew Dillon 54b412cc49SMatthew Dillonecho "`$xdate` - Build is running nrelease, tail -f $build/nrelease-build.out" 553dae329dSSascha Wildnerchroot $build/root csh -c "cd /usr/src/nrelease; make -DNOPROFILE -DWITHOUT_SRCS MAKE_JOBS=1 img $nrelease_args" >& $build/nrelease-build.out 56b412cc49SMatthew Dillon 57b412cc49SMatthew Dillonif ( $? > 0 ) then 58b412cc49SMatthew Dillon echo "`$xdate` - NRelease build had a problem, see $build/nrelease-build.out" 59b412cc49SMatthew Dillon echo "`$xdate` - SNAPSHOTS DOBUILD END" 60b412cc49SMatthew Dillon exit 1 61b412cc49SMatthew Dillonendif 62b412cc49SMatthew Dillon 63b412cc49SMatthew Dillon# Figure out the filename 64b412cc49SMatthew Dillon# 65b412cc49SMatthew Dillonset arch = `uname -p` 66b412cc49SMatthew Dillonif ( "$arch" == "i386" ) then 67b412cc49SMatthew Dillonset kobjs = $build/root/usr/obj/usr/src/sys/GENERIC 68b412cc49SMatthew Dillonelse 69b412cc49SMatthew Dillonset kobjs = $build/root/usr/obj/usr/src/sys/X86_64_GENERIC 70b412cc49SMatthew Dillonendif 71b412cc49SMatthew Dillon 72b412cc49SMatthew Dillonif ( ! -f $kobjs/vers.txt ) then 73b412cc49SMatthew Dillon echo "`$xdate` - nrelease build did not generate $kobjs/vers.txt" 74b412cc49SMatthew Dillon echo "`$xdate` - SNAPSHOTS DOBUILD END" 75b412cc49SMatthew Dillon exit 1 76b412cc49SMatthew Dillonendif 77b412cc49SMatthew Dillon 78b412cc49SMatthew Dillon# Store the snapshots. Make sure the files are inaccessible until 79b412cc49SMatthew Dillon# completely written out. 80b412cc49SMatthew Dillon# 81b412cc49SMatthew Dillonset basename = `cat $kobjs/vers.txt` 82b412cc49SMatthew Dillonmkdir -p $snapshots/$arch/images 83b412cc49SMatthew Dillonmkdir -p $snapshots/$arch/kernels 84b412cc49SMatthew Dillonset filepath = $snapshots/$arch 85b412cc49SMatthew Dillonumask 077 86*a291abfbSMatthew Dillonbzip2 < $build/root/usr/obj/release/dfly.iso > $filepath/images/$basename.iso.bz2 87*a291abfbSMatthew Dillonbzip2 < $build/root/usr/obj/release/dfly.img > $filepath/images/$basename.img.bz2 88*a291abfbSMatthew Dillon(cd $build/root/usr/obj/release/root; tar cf - boot | bzip2 > $filepath/kernels/$basename.boot.tar.bz2) 89b412cc49SMatthew Dillonchmod 644 $filepath/images/$basename.iso.bz2 90b412cc49SMatthew Dillonchmod 644 $filepath/images/$basename.img.bz2 91b412cc49SMatthew Dillonchmod 644 $filepath/kernels/$basename.boot.tar.bz2 92b412cc49SMatthew Dillonsync 933dae329dSSascha Wildnerumask 022 94b412cc49SMatthew Dillonpushd $filepath/images 95b412cc49SMatthew Dillonmd5 $basename.iso.bz2 >> CHECKSUM.MD5 96b412cc49SMatthew Dillonmd5 $basename.img.bz2 >> CHECKSUM.MD5 973dae329dSSascha Wildnerchmod 644 CHECKSUM.MD5 98b412cc49SMatthew Dillonpopd 99b412cc49SMatthew Dillon 100b412cc49SMatthew Dillonpushd $filepath/kernels 101b412cc49SMatthew Dillonmd5 $basename.boot.tar.bz2 >> CHECKSUM.MD5 1023dae329dSSascha Wildnerchmod 644 CHECKSUM.MD5 103b412cc49SMatthew Dillonpopd 104b412cc49SMatthew Dillon 105b412cc49SMatthew Dillon# Only adjust the 'latest' softlink shortcuts for 106b412cc49SMatthew Dillon# development snapshots. Release shortcuts have 107b412cc49SMatthew Dillon# to be done manually. 108b412cc49SMatthew Dillon# 109b412cc49SMatthew Dillonif ( "$relsname" == "DEV" ) then 110b412cc49SMatthew Dillon pushd $filepath 111b412cc49SMatthew Dillon rm -f DragonFly-${arch}-LATEST-ISO.iso.bz2.new 112b412cc49SMatthew Dillon rm -f DragonFly-${arch}-LATEST-IMG.img.bz2.new 113b412cc49SMatthew Dillon rm -f DragonFly-${arch}-LATEST-BOOT.tar.bz2.new 114b412cc49SMatthew Dillon ln -s images/$basename.iso.bz2 DragonFly-${arch}-LATEST-ISO.iso.bz2.new 115b412cc49SMatthew Dillon ln -s images/$basename.img.bz2 DragonFly-${arch}-LATEST-IMG.img.bz2.new 116b412cc49SMatthew Dillon ln -s kernels/$basename.boot.tar.bz2 DragonFly-${arch}-LATEST-BOOT.tar.bz2.new 117b412cc49SMatthew Dillon mv -f DragonFly-${arch}-LATEST-ISO.iso.bz2.new \ 118b412cc49SMatthew Dillon DragonFly-${arch}-LATEST-ISO.iso.bz2 119b412cc49SMatthew Dillon mv -f DragonFly-${arch}-LATEST-IMG.img.bz2.new \ 120b412cc49SMatthew Dillon DragonFly-${arch}-LATEST-IMG.img.bz2 121b412cc49SMatthew Dillon mv -f DragonFly-${arch}-LATEST-BOOT.tar.bz2.new \ 122b412cc49SMatthew Dillon DragonFly-${arch}-LATEST-BOOT.tar.bz2 123b412cc49SMatthew Dillon popd 124b412cc49SMatthew Dillonendif 125b412cc49SMatthew Dillon 1263dae329dSSascha Wildnersync; sleep 1 1273dae329dSSascha Wildnerumount $build/root/usr/distfiles >& /dev/null 1283dae329dSSascha Wildnerumount $build/root/usr/src >& /dev/null 1293dae329dSSascha Wildnerumount $build/root/usr/dports >& /dev/null 1303dae329dSSascha Wildnerumount $build/root/dev >& /dev/null 131b412cc49SMatthew Dillon 132b412cc49SMatthew Dillonecho "`$xdate` - SNAPSHOTS DOBUILD END" 133