#!/bin/csh # # Create a working chroot for snapshot building # source config # slow and steady wins the race, don't interfere # with other stuff set ncpu = 1 #set ncpu = `sysctl -n hw.ncpu` set pushdsilent set xdate = "date" # needed for ports 'ex' script execution # setenv TERM xterm echo "`$xdate` - SNAPSHOTS DOCLEAN BEGIN" # Options # foreach arg ( $argv ) switch ( $arg ) case "realquick": set quick = 1 set realquick = 1 breaksw case "quick": set quick = 1 breaksw default: echo "Unknown option $arg" echo "`$xdate` - SNAPSHOTS DOCLEAN END" exit 1 endsw end # Remove environment # if ( "$build" == "" ) then echo "build variable not set" echo "`$xdate` - SNAPSHOTS DOCLEAN END" exit 1 endif if ( -e $build/root/usr/src/nrelease && -e $build/root/dev/null ) then echo "`$xdate` - Cleanup previous nrelease" chroot $build/root csh -c "cd /usr/src/nrelease; make -DNOPROFILE -DWITHOUT_SRCS clean" endif if ( -e $build/root/dev/null ) then sync; sleep 1 echo "`$xdate` - Unmount devfs from $build/root/dev" umount $build/root/dev if ( $? > 0 ) then echo "`$xdate` - Unable to umount $build/root/dev" echo "`$xdate` - SNAPSHOTS DOCLEAN END" exit 1 endif endif sync; sleep 1 umount $build/root/usr/distfiles >& /dev/null umount $build/root/usr/src >& /dev/null umount $build/root/usr/dports >& /dev/null if ( $?quick == 0 ) then echo "`$xdate` - Destroying root environment at $build/root" sleep 5 rm -rf $build/root >& /dev/null if ( -d $build/root ) then chflags -R noschg $build/root endif rm -rf $build/root endif mkdir -p $build/distfiles mkdir -p $build/root mkdir -p $build/root/usr echo "`$xdate` - Log files are in $build/*.out" # Ignore quick/realquick options if there is no prior # installation # if ( ! -e $build/root/etc/networks ) then unset realquick endif if ( ! -d $build/src ) then unset quick unset realquick endif if ( ! -d $build/dports ) then unset quick unset realquick endif # Clone the repos, create trakcing branches as necessary, checkout, # and update (using fetch) # # DragonFly sources # pushd $build if ( ! -d src ) then echo "`$xdate` - Cloning $dflygit" git clone -n $dflygit src endif pushd $build/src if ( "`git branch | fgrep $dfly_branch`" == "" ) then echo "`$xdate` - Branching-src $dfly_branch" git branch $dfly_branch origin/$dfly_branch endif echo "`$xdate` - Updating src" git checkout $dfly_branch git pull popd # Package sources # if ( ! -d dports ) then echo "`$xdate` - Cloning $dportsgit" git clone -n $dportsgit dports endif pushd $build/dports if ( "`git branch | fgrep $dports_branch`" == "" ) then echo "`$xdate` - Branching-dports $dports_branch" git branch $dports_branch origin/$dports_branch endif echo "`$xdate` - Updating dports" git checkout $dports_branch git pull popd # null mounts # mkdir -p $build/root/usr/src mkdir -p $build/root/usr/dports mkdir -p $build/root/usr/distfiles echo "`$xdate` - Mounting src, dports, distfiles" mount_null $build/src $build/root/usr/src mount_null $build/dports $build/root/usr/dports mount_null $build/distfiles $build/root/usr/distfiles popd # popped build # Install/upgrade environment # pushd $build/root/usr/src if ( $?realquick ) then echo "`$xdate` - Not running build/quickworld - realquick mode" else if ( $?quick ) then echo "`$xdate` - Starting quickworld, tail -f $build/build.out" make -j $ncpu quickworld >& $build/build.out if ( $? ) then echo "`$xdate` - primary environment quickworld failed" echo "`$xdate` - SNAPSHOTS DOCLEAN END" exit 1 endif else echo "`$xdate` - Starting buildworld, tail -f $build/build.out" make -j $ncpu buildworld >& $build/build.out if ( $? ) then echo "`$xdate` - primary environment buildworld failed" echo "`$xdate` - SNAPSHOTS DOCLEAN END" exit 1 endif endif endif if ( $?realquick == 0 ) then echo "`$xdate` - Installing the world, tail -f $build/install.out" make installworld DESTDIR=$build/root >& $build/install.out pushd etc make distribution DESTDIR=$build/root >& $build/install.out popd echo "`$xdate` - Upgrading the world, tail -f $build/upgrade.out" make upgrade DESTDIR=$build/root >& $build/upgrade.out endif # Setup the chroot environment, including packages nrelease needs to # build. # echo "`$xdate` - Setting up chroot environment in $build/root" echo "`$xdate` - Mounting devfs" if ( ! -e $build/root/dev/null ) then mount_devfs dummy $build/root/dev endif #mkdir -m 1777 $build/root/tmp #mkdir -m 1777 $build/root/var/tmp if ( $?realquick == 0 ) then echo "`$xdate` - Setting up ldd" chroot $build/root /etc/rc.d/ldconfig start endif cp /etc/resolv.conf $build/root/etc/ rm -rf $build/root/usr/obj/dports mkdir -p $build/root/usr/obj/dports cat > $build/root/etc/make.conf << EOF # set by doclean # git_UNSET=CONTRIB PERL DIALOG EOF if ( ! -e $build/root/usr/local/bin/bmake ) then echo "`$xdate` - Bootstrapping dports, tail -f $build/bootstrap.out" chroot $build/root csh -c "cd /usr/dports/devel/bmake; make all install" >& $build/bootstrap.out if ( $? > 0 ) then echo "`$xdate` - dports bootstrap had problems" echo "`$xdate` - SNAPSHOTS DOCLEAN END" exit 1 endif endif # The nrelease build needs cdrecord and git. Try to get the binary package # first and then build whatever else is needed from source. These packages # are not part of the nrelease snapshot build, they are used by nrelease # to do the build. # if ( ! -e $build/root/usr/local/bin/mkisofs ) then echo "`$xdate` - Setting up cdrecord and friends, tail -f $build/nrelease1.out" #chroot $build/root csh -c "pkg_radd cdrecord" if ( ! -e $build/root/usr/local/bin/mkisofs ) then echo "`$xdate` - Binary package not found, building from source" chroot $build/root csh -c "cd /usr/dports/sysutils/cdrtools; make -DBATCH all install" endif endif if ( ! -e $build/root/usr/local/bin/git ) then echo "`$xdate` - Setting up git from dports, tail -f $build/nrelease2.out" #chroot $build/root csh -c "pkg_radd git" if ( ! -e $build/root/usr/local/bin/git ) then echo "`$xdate` - Binary package not found, building from source" chroot $build/root csh -c "cd /usr/dports/devel/git; make -DBATCH all install" endif endif echo "`$xdate` - SNAPSHOTS DOCLEAN END"