gpt(8): Add HAMMER and HAMMER2 support
[dragonfly.git] / tools / snapshots / doclean
blob78e3dab4af5e396349a2eec96079ba08f2a366a8
1 #!/bin/csh
3 # Create a working chroot for snapshot building
6 source config
8 # slow and steady wins the race, don't interfere
9 # with other stuff
10 set ncpu = 1
11 #set ncpu = `sysctl -n hw.ncpu`
12 set pushdsilent
13 set xdate = "date"
15 # needed for ports 'ex' script execution
17 setenv TERM xterm
19 echo "`$xdate` - SNAPSHOTS DOCLEAN BEGIN"
21 # Options
23 foreach arg ( $argv )
24 switch ( $arg )
25 case "realquick":
26 set quick = 1
27 set realquick = 1
28 breaksw
29 case "quick":
30 set quick = 1
31 breaksw
32 default:
33 echo "Unknown option $arg"
34 echo "`$xdate` - SNAPSHOTS DOCLEAN END"
35 exit 1
36 endsw
37 end
39 # Remove environment
41 if ( "$build" == "" ) then
42 echo "build variable not set"
43 echo "`$xdate` - SNAPSHOTS DOCLEAN END"
44 exit 1
45 endif
47 if ( -e $build/root/usr/src/nrelease && -e $build/root/dev/null ) then
48 echo "`$xdate` - Cleanup previous nrelease"
49 chroot $build/root csh -c "cd /usr/src/nrelease; make -DNOPROFILE -DWITHOUT_SRCS clean"
50 endif
52 if ( -e $build/root/dev/null ) then
53 sync; sleep 1
54 echo "`$xdate` - Unmount devfs from $build/root/dev"
55 umount $build/root/dev
56 if ( $? > 0 ) then
57 echo "`$xdate` - Unable to umount $build/root/dev"
58 echo "`$xdate` - SNAPSHOTS DOCLEAN END"
59 exit 1
60 endif
61 endif
63 sync; sleep 1
64 umount $build/root/usr/distfiles >& /dev/null
65 umount $build/root/usr/src >& /dev/null
66 umount $build/root/usr/dports >& /dev/null
68 if ( $?quick == 0 ) then
69 echo "`$xdate` - Destroying root environment at $build/root"
70 sleep 5
71 rm -rf $build/root >& /dev/null
72 if ( -d $build/root ) then
73 chflags -R noschg $build/root
74 endif
75 rm -rf $build/root
76 endif
77 mkdir -p $build/distfiles
78 mkdir -p $build/root
79 mkdir -p $build/root/usr
81 echo "`$xdate` - Log files are in $build/*.out"
83 # Ignore quick/realquick options if there is no prior
84 # installation
86 if ( ! -e $build/root/etc/networks ) then
87 unset realquick
88 endif
89 if ( ! -d $build/src ) then
90 unset quick
91 unset realquick
92 endif
93 if ( ! -d $build/dports ) then
94 unset quick
95 unset realquick
96 endif
98 # Clone the repos, create trakcing branches as necessary, checkout,
99 # and update (using fetch)
101 # DragonFly sources
103 pushd $build
105 if ( ! -d src ) then
106 echo "`$xdate` - Cloning $dflygit"
107 git clone -n $dflygit src
108 endif
109 pushd $build/src
110 if ( "`git branch | fgrep $dfly_branch`" == "" ) then
111 echo "`$xdate` - Branching-src $dfly_branch"
112 git branch $dfly_branch origin/$dfly_branch
113 endif
114 echo "`$xdate` - Updating src"
115 git checkout $dfly_branch
116 git pull
117 popd
119 # Package sources
121 if ( ! -d dports ) then
122 echo "`$xdate` - Cloning $dportsgit"
123 git clone -n $dportsgit dports
124 endif
125 pushd $build/dports
126 if ( "`git branch | fgrep $dports_branch`" == "" ) then
127 echo "`$xdate` - Branching-dports $dports_branch"
128 git branch $dports_branch origin/$dports_branch
129 endif
130 echo "`$xdate` - Updating dports"
131 git checkout $dports_branch
132 git pull
133 popd
135 # null mounts
137 mkdir -p $build/root/usr/src
138 mkdir -p $build/root/usr/dports
139 mkdir -p $build/root/usr/distfiles
141 echo "`$xdate` - Mounting src, dports, distfiles"
142 mount_null $build/src $build/root/usr/src
143 mount_null $build/dports $build/root/usr/dports
144 mount_null $build/distfiles $build/root/usr/distfiles
146 popd
147 # popped build
149 # Install/upgrade environment
151 pushd $build/root/usr/src
153 if ( $?realquick ) then
154 echo "`$xdate` - Not running build/quickworld - realquick mode"
155 else
156 if ( $?quick ) then
157 echo "`$xdate` - Starting quickworld, tail -f $build/build.out"
158 make -j $ncpu quickworld >& $build/build.out
159 if ( $? ) then
160 echo "`$xdate` - primary environment quickworld failed"
161 echo "`$xdate` - SNAPSHOTS DOCLEAN END"
162 exit 1
163 endif
164 else
165 echo "`$xdate` - Starting buildworld, tail -f $build/build.out"
166 make -j $ncpu buildworld >& $build/build.out
167 if ( $? ) then
168 echo "`$xdate` - primary environment buildworld failed"
169 echo "`$xdate` - SNAPSHOTS DOCLEAN END"
170 exit 1
171 endif
172 endif
173 endif
175 if ( $?realquick == 0 ) then
176 echo "`$xdate` - Installing the world, tail -f $build/install.out"
177 make installworld DESTDIR=$build/root >& $build/install.out
178 pushd etc
179 make distribution DESTDIR=$build/root >& $build/install.out
180 popd
181 echo "`$xdate` - Upgrading the world, tail -f $build/upgrade.out"
182 make upgrade DESTDIR=$build/root >& $build/upgrade.out
183 endif
185 # Setup the chroot environment, including packages nrelease needs to
186 # build.
188 echo "`$xdate` - Setting up chroot environment in $build/root"
189 echo "`$xdate` - Mounting devfs"
190 if ( ! -e $build/root/dev/null ) then
191 mount_devfs dummy $build/root/dev
192 endif
194 #mkdir -m 1777 $build/root/tmp
195 #mkdir -m 1777 $build/root/var/tmp
197 if ( $?realquick == 0 ) then
198 echo "`$xdate` - Setting up ldd"
199 chroot $build/root /etc/rc.d/ldconfig start
200 endif
201 cp /etc/resolv.conf $build/root/etc/
202 rm -rf $build/root/usr/obj/dports
203 mkdir -p $build/root/usr/obj/dports
205 cat > $build/root/etc/make.conf << EOF
207 # set by doclean
209 git_UNSET=CONTRIB PERL DIALOG
213 if ( ! -e $build/root/usr/local/bin/bmake ) then
214 echo "`$xdate` - Bootstrapping dports, tail -f $build/bootstrap.out"
215 chroot $build/root csh -c "cd /usr/dports/devel/bmake; make all install" >& $build/bootstrap.out
216 if ( $? > 0 ) then
217 echo "`$xdate` - dports bootstrap had problems"
218 echo "`$xdate` - SNAPSHOTS DOCLEAN END"
219 exit 1
220 endif
221 endif
223 # The nrelease build needs cdrecord and git. Try to get the binary package
224 # first and then build whatever else is needed from source. These packages
225 # are not part of the nrelease snapshot build, they are used by nrelease
226 # to do the build.
228 if ( ! -e $build/root/usr/local/bin/mkisofs ) then
229 echo "`$xdate` - Setting up cdrecord and friends, tail -f $build/nrelease1.out"
230 #chroot $build/root csh -c "pkg_radd cdrecord"
231 if ( ! -e $build/root/usr/local/bin/mkisofs ) then
232 echo "`$xdate` - Binary package not found, building from source"
233 chroot $build/root csh -c "cd /usr/dports/sysutils/cdrtools; make -DBATCH all install"
234 endif
235 endif
237 if ( ! -e $build/root/usr/local/bin/git ) then
238 echo "`$xdate` - Setting up git from dports, tail -f $build/nrelease2.out"
239 #chroot $build/root csh -c "pkg_radd git"
240 if ( ! -e $build/root/usr/local/bin/git ) then
241 echo "`$xdate` - Binary package not found, building from source"
242 chroot $build/root csh -c "cd /usr/dports/devel/git; make -DBATCH all install"
243 endif
244 endif
246 echo "`$xdate` - SNAPSHOTS DOCLEAN END"