3 # Create a working chroot for snapshot building
8 set ncpu = `sysctl -n hw.ncpu`
12 echo "`$xdate` - SNAPSHOTS DOCLEAN BEGIN"
26 echo "Unknown option $arg"
27 echo "`$xdate` - SNAPSHOTS DOCLEAN END"
34 if ( "$build" == "" ) then
35 echo "build variable not set"
36 echo "`$xdate` - SNAPSHOTS DOCLEAN END"
40 if ( -e $build/root/dev/null ) then
41 echo "`$xdate` - Unmount devfs from $build/root/dev"
42 umount $build/root/dev
44 echo "`$xdate` - Unable to umount $build/root/dev"
45 echo "`$xdate` - SNAPSHOTS DOCLEAN END"
50 # remount the nullfs mount read-only just in case the umount fails.
52 umount $build/root/usr/pkgsrc/distfiles >& /dev/null
53 mount -u -o ro $build/root/usr/pkgsrc/distfiles >& /dev/null
55 if ( $?quick == 0 ) then
56 echo "`$xdate` - Destroying root environment at $build/root"
58 rm -rf $build/root >& /dev/null
59 if ( -d $build/root ) then
60 chflags -R noschg $build/root
64 mkdir -p $build/distfiles
66 mkdir -p $build/root/usr
68 echo "`$xdate` - Log files are in $build/*.out"
70 # Ignore quick/realquick options if there is no prior
73 if ( ! -e $build/root/etc/networks ) then
76 if ( ! -d $build/root/usr/src ) then
80 if ( ! -d $build/root/usr/pkgsrc ) then
85 # Clone the repos, create trakcing branches as necessary, checkout,
86 # and update (using fetch)
91 if ( $?quick == 0 ) then
92 echo "`$xdate` - Cloning $dflygit"
94 git clone -n $dflygit src
97 pushd $build/root/usr/src
98 if ( "`git branch | fgrep $dfly_branch`" == "" ) then
99 echo "`$xdate` - Branching-src $dfly_branch"
100 git branch $dfly_branch origin/$dfly_branch
102 echo "`$xdate` - Updating src"
103 git checkout $dfly_branch
109 pushd $build/root/usr
110 if ( $?quick == 0 ) then
111 echo "`$xdate` - Cloning $pkgsrcgit"
113 git clone -n $pkgsrcgit pkgsrc
116 pushd $build/root/usr/pkgsrc
117 if ( "`git branch | fgrep $pkgsrc_branch`" == "" ) then
118 echo "`$xdate` - Branching-pkgsrc $pkgsrc_branch"
119 git branch $pkgsrc_branch origin/$pkgsrc_branch
121 echo "`$xdate` - Updating pkgsrc"
122 git checkout $pkgsrc_branch
126 # Install/upgrade environment
128 pushd $build/root/usr/src
130 if ( $?realquick ) then
131 echo "`$xdate` - Not running build/quickworld - realquick mode"
134 echo "`$xdate` - Starting quickworld, tail -f $build/build.out"
135 make -j $ncpu quickworld >& $build/build.out
137 echo "`$xdate` - primary environment quickworld failed"
138 echo "`$xdate` - SNAPSHOTS DOCLEAN END"
142 echo "`$xdate` - Starting buildworld, tail -f $build/build.out"
143 make -j $ncpu buildworld >& $build/build.out
145 echo "`$xdate` - primary environment buildworld failed"
146 echo "`$xdate` - SNAPSHOTS DOCLEAN END"
152 if ( $?realquick == 0 ) then
153 echo "`$xdate` - Installing the world, tail -f $build/install.out"
154 make installworld DESTDIR=$build/root >& $build/install.out
156 make distribution DESTDIR=$build/root >& $build/install.out
158 echo "`$xdate` - Upgrading the world, tail -f $build/upgrade.out"
159 make upgrade DESTDIR=$build/root >& $build/upgrade.out
164 # Setup the chroot environment, including packages nrelease needs to
167 echo "`$xdate` - Setting up chroot environment in $build/root"
168 echo "`$xdate` - Mounting devfs"
169 if ( ! -e $build/root/dev/null ) then
170 mount_devfs dummy $build/root/dev
172 echo "`$xdate` - Mounting distfiles"
173 mount_null $build/distfiles $build/root/usr/pkgsrc/distfiles
175 #mkdir -m 1777 $build/root/tmp
176 #mkdir -m 1777 $build/root/var/tmp
178 if ( $?realquick == 0 ) then
179 echo "`$xdate` - Setting up ldd"
180 chroot $build/root /etc/rc.d/ldconfig start
182 cp /etc/resolv.conf $build/root/etc/
184 if ( ! -e $build/root/usr/pkg/bin/bmake ) then
185 echo "`$xdate` - Bootstrapping pkgsrc, tail -f $build/bootstrap.out"
186 chroot $build/root csh -c "cd /usr/pkgsrc/bootstrap; rm -rf /usr/obj/bootstrap; ./bootstrap --workdir=/usr/obj/bootstrap" >& $build/bootstrap.out
188 echo "`$xdate` - pkgsrc bootstrap had problems"
189 echo "`$xdate` - SNAPSHOTS DOCLEAN END"
194 if ( ! -e $build/root/usr/pkg/bin/mkisofs ) then
195 echo "`$xdate` - Setting up cdrecord and friends, tail -f $build/nrelease1.out"
196 setenv PKGSRC_PATH /usr/pkgsrc
197 chroot $build/root csh -c "cd /usr/src/nrelease; make fetch pkgsrc_cdrecord" >& $build/nrelease1.out
199 echo "`$xdate` - nrelease had problems"
200 echo "`$xdate` - SNAPSHOTS DOCLEAN END"
205 # The nrelease build needs scmgit as well. Try to get the binary package
206 # first and then build whatever else is needed from source. These packages
207 # are not part of the nrelease snapshot build, they are used by nrelease
210 if ( ! -e $build/root/usr/pkg/bin/git ) then
211 echo "`$xdate` - Setting up scmgit from pkgsrc, tail -f $build/nrelease2.out"
212 chroot $build/root csh -c "pkg_radd scmgit"
213 if ( ! -e $build/root/usr/pkg/bin/git ) then
214 echo "`$xdate` - Binary package not found, building from source"
215 chroot $build/root csh -c "cd /usr/pkgsrc/devel/scmgit; bmake update"
219 echo "`$xdate` - SNAPSHOTS DOCLEAN END"