removed some verbose messages
[minix3.git] / tools / release.sh
blob0f455a354f315995364f125745234df2da6ec792
1 #!/bin/sh
3 set -e
5 XBIN=usr/xbin
7 PACKAGEDIR=/usr/bigports/Packages
8 PACKAGESOURCEDIR=/usr/bigports/Sources
9 secs=`expr 32 '*' 64`
10 export SHELL=/bin/sh
12 make_hdimage()
14 dd if=$TMPDISK of=usrimage bs=$BS count=$USRBLOCKS
16 rootsize=`stat -size rootimage`
17 usrsize=`stat -size usrimage`
19 rootsects=`expr $rootsize / 512`
20 usrsects=`expr $usrsize / 512`
22 # installboot -m needs at least 1KB
23 dd < /dev/zero >tmpimage count=2
24 partition -fm tmpimage 2 81:$rootsects* 0:0 81:$usrsects
25 installboot -m tmpimage /usr/mdec/masterboot
26 dd < tmpimage > subpart count=1
28 primsects=`expr 1 + $rootsects + $usrsects`
29 cyl=`expr '(' $primsects ')' / $secs + 1`
30 padsects=`expr $cyl \* $secs - 1 - $primsects`
32 { dd < /dev/zero count=1
33 cat subpart
34 cat rootimage
35 cat usrimage
36 dd < /dev/zero count=$padsects
37 } > hdimage
38 partition -m hdimage 81:`expr $primsects + $padsects`*
39 installboot -m hdimage /usr/mdec/masterboot
42 hdemu_root_changes()
44 $RELEASEDIR/usr/bin/installboot -d $TMPDISK3 \
45 $RELEASEDIR/usr/mdec/bootblock boot/boot
46 echo \
47 'bootcd=2
48 disable=inet
49 bios_wini=yes
50 bios_remap_first=1
51 ramimagedev=c0d7p0s0
52 bootbig(1, Regular MINIX 3) { image=/boot/image_big; boot }
53 bootsmall(2, Small MINIX 3 (<16MB)) {image=/boot/image_small; boot }
54 main() { trap 10000 boot ; menu; }
55 save' | $RELEASEDIR/usr/bin/edparams $TMPDISK3
57 echo \
58 'root=/dev/c0d7p0s0
59 usr=/dev/c0d7p0s2
60 usr_roflag="-r"' > $RELEASEDIR/etc/fstab
63 usb_root_changes()
65 $RELEASEDIR/usr/bin/installboot -d $TMPDISK3 \
66 $RELEASEDIR/usr/mdec/bootblock boot/boot
67 echo \
68 'bios_wini=yes
69 bios_remap_first=1
70 rootdev=c0d7p0s0
71 save' | $RELEASEDIR/usr/bin/edparams $TMPDISK3
73 echo \
74 'root=/dev/c0d7p0s0
75 usr=/dev/c0d7p0s2
76 ' > $RELEASEDIR/etc/fstab
79 RELEASEDIR=/usr/r
80 RELEASEPACKAGE=${RELEASEDIR}/usr/install/packages
81 RELEASEPACKAGESOURCES=${RELEASEDIR}/usr/install/package-sources
82 IMAGE=cdfdimage
83 ROOTIMAGE=rootimage
84 CDFILES=/usr/tmp/cdreleasefiles
85 sh tell_config OS_RELEASE . OS_VERSION >/tmp/rel.$$
86 version_pretty=`sed 's/[" ]//g;/^$/d' </tmp/rel.$$`
87 version=`sed 's/[" ]//g;/^$/d' </tmp/rel.$$ | tr . _`
88 subfn="subreleaseno.$version"
89 if [ -f "$subfn" ]
90 then sub="`cat $subfn`"
91 else sub=0
93 echo "`expr $sub + 1`" >$subfn
94 IMG_BASE=minix${version}_ide_build$sub
95 BS=4096
97 HDEMU=0
98 COPY=0
99 SVNREV=""
100 PACKAGES=1
102 while getopts "pchu?r:" c
104 case "$c" in
106 echo "Usage: $0 [-p] [-c] [-h] [-r <tag>] [-u]" >&2
107 exit 1
110 echo " * Making HD image"
111 IMG_BASE=minix${version}_bios_build$sub
112 HDEMU=1
115 echo " * Copying, not SVN"
116 COPY=1
119 PACKAGES=0
122 SVNREV=-r$OPTARG
125 echo " * Making live USB-stick image"
126 IMG_BASE=minix${version}_usb_build$sub
127 HDEMU=1
128 USB=1
130 esac
131 done
133 if [ "$USB" -ne 0 ]; then
134 IMG=${IMG_BASE}.img
135 else
136 IMG=${IMG_BASE}.iso
138 IMGBZ=${IMG}.bz2
139 echo "Making $IMGBZ"
141 USRMB=400
143 USRBLOCKS="`expr $USRMB \* 1024 \* 1024 / $BS`"
144 USRSECTS="`expr $USRMB \* 1024 \* 2`"
145 ROOTKB=4096
146 ROOTSECTS="`expr $ROOTKB \* 2`"
147 ROOTBLOCKS="`expr $ROOTKB \* 1024 / $BS`"
149 if [ "$COPY" -ne 1 ]
150 then
151 echo "Note: this script wants to do svn operations."
154 TD1=.td1
155 TD2=.td2
156 TD3=.td3
159 if [ -f $TD1 ]
160 then TMPDISK="`cat $TD1`"
161 echo " * Warning: I'm going to overwrite $TMPDISK!"
162 else
163 echo "Temporary (sub)partition to use to make the /usr FS image? "
164 echo "I need $USRMB MB. It will be mkfsed!"
165 echo -n "Device: /dev/"
166 read dev || exit 1
167 TMPDISK=/dev/$dev
170 if [ -b $TMPDISK ]
171 then :
172 else echo "$TMPDISK is not a block device.."
173 exit 1
176 echo $TMPDISK >$TD1
178 if [ -f $TD2 ]
179 then TMPDISK2="`cat $TD2`"
180 echo " * Warning: I'm going to overwrite $TMPDISK2!"
181 else
182 echo "Temporary (sub)partition to use for /tmp? "
183 echo "It will be mkfsed!"
184 echo -n "Device: /dev/"
185 read dev || exit 1
186 TMPDISK2=/dev/$dev
189 if [ -b $TMPDISK2 ]
190 then :
191 else echo "$TMPDISK2 is not a block device.."
192 exit 1
195 echo $TMPDISK2 >$TD2
197 if [ -f $TD3 ]
198 then TMPDISK3="`cat $TD3`"
199 echo " * Warning: I'm going to overwrite $TMPDISK3!"
200 else
201 echo "It has to be at least $ROOTKB KB."
202 echo ""
203 echo "Temporary (sub)partition to use to make the root FS image? "
204 echo "It will be mkfsed!"
205 echo -n "Device: /dev/"
206 read dev || exit 1
207 TMPDISK3=/dev/$dev
210 if [ -b $TMPDISK3 ]
211 then :
212 else echo "$TMPDISK3 is not a block device.."
213 exit 1
216 echo $TMPDISK3 >$TD3
218 umount $TMPDISK || true
219 umount $TMPDISK2 || true
220 umount $TMPDISK3 || true
222 if [ $TMPDISK = $TMPDISK2 -o $TMPDISK = $TMPDISK3 -o $TMPDISK2 = $TMPDISK3 ]
223 then
224 echo "Temporary devices can't be equal."
225 exit
228 echo " * Cleanup old files"
229 rm -rf $RELEASEDIR $IMG $IMAGE $ROOTIMAGE $IMGBZ $CDFILES image*
230 mkdir -p $CDFILES || exit
231 mkdir -p $RELEASEDIR
232 mkfs -B $BS -b $ROOTBLOCKS $TMPDISK3 || exit
233 mkfs $TMPDISK2 || exit
234 echo " * mounting $TMPDISK3 as $RELEASEDIR"
235 mount $TMPDISK3 $RELEASEDIR || exit
236 mkdir -m 755 $RELEASEDIR/usr
237 mkdir -m 1777 $RELEASEDIR/tmp
238 mount $TMPDISK2 $RELEASEDIR/tmp
240 mkfs -B $BS -b $USRBLOCKS $TMPDISK || exit
241 echo " * Mounting $TMPDISK as $RELEASEDIR/usr"
242 mount $TMPDISK $RELEASEDIR/usr || exit
243 mkdir -p $RELEASEDIR/tmp
244 mkdir -p $RELEASEDIR/usr/tmp
245 mkdir -p $RELEASEDIR/$XBIN
246 mkdir -p $RELEASEDIR/usr/bin
247 mkdir -p $RELEASEDIR/bin
248 mkdir -p $RELEASEPACKAGE
249 mkdir -p $RELEASEPACKAGESOURCES
251 echo " * Transfering bootstrap dirs to $RELEASEDIR"
252 cp -p /bin/* /usr/bin/* $RELEASEDIR/$XBIN
253 cp -rp /usr/lib $RELEASEDIR/usr
254 cp -rp /bin/bigsh /bin/sh $RELEASEDIR/bin
255 cp -rp /usr/bin/make /usr/bin/install /usr/bin/yacc /usr/bin/flex $RELEASEDIR/usr/bin
257 if [ -d $PACKAGEDIR -a -d $PACKAGESOURCEDIR -a $PACKAGES -ne 0 ]
258 then echo " * Indexing packages"
259 bintotal=0
260 ( cd $PACKAGEDIR
261 for p in *.tar.bz2
262 do echo $p >&2
263 p="`echo $p | sed 's/.tar.bz2//'`"
264 descr="../$p/.descr"
265 if [ -f "$descr" ]
266 then echo "$p|`cat $descr`"
268 done >List
270 for d in $PACKAGEDIR $PACKAGESOURCEDIR
271 do echo Counting size of $d
272 f=$d/SizeMB
273 if [ ! -f $f ]
274 then
275 b="`bzip2 -dc $d/*.bz2 | wc -c`"
276 echo "`expr 1 + $b / 1024 / 1024`" >$f
278 echo "`cat $f` MB."
279 done
280 echo " * Transfering $PACKAGEDIR to $RELEASEPACKAGE"
281 cp $PACKAGEDIR/* $RELEASEPACKAGE/
282 echo " * Transfering $PACKAGESOURCEDIR to $RELEASEPACKAGESOURCES"
283 cp $PACKAGESOURCEDIR/* $RELEASEPACKAGESOURCES/ || true
287 # Make sure compilers and libraries are bin-owned
288 chown -R bin $RELEASEDIR/usr/lib
289 chmod -R u+w $RELEASEDIR/usr/lib
291 if [ "$COPY" -ne 1 ]
292 then
293 echo " * Doing new svn export"
294 ( cd $RELEASEDIR/usr && svn export $SVNREV https://gforge.cs.vu.nl/svn/minix/trunk/src )
295 else
296 ( cd .. && make depend && make clean )
297 srcdir=/usr/src
298 ( cd $srcdir && tar cf - . ) | ( cd $RELEASEDIR/usr && mkdir src && cd src && tar xf - )
301 echo " * Fixups for owners and modes of dirs and files"
302 chown -R bin $RELEASEDIR/usr/src
303 chmod -R u+w $RELEASEDIR/usr/src
304 find $RELEASEDIR/usr/src -type d | xargs chmod 755
305 find $RELEASEDIR/usr/src -type f | xargs chmod 644
306 find $RELEASEDIR/usr/src -name configure | xargs chmod 755
307 find $RELEASEDIR/usr/src/commands -name build | xargs chmod 755
308 # Bug tracking system not for on cd
309 rm -rf $RELEASEDIR/usr/src/doc/bugs
311 # Make sure the CD knows it's a CD, unless it's not
312 if [ "$USB" -eq 0 ]
313 then date >$RELEASEDIR/CD
315 echo " * Chroot build"
316 chroot $RELEASEDIR "PATH=/$XBIN sh -x /usr/src/tools/chrootmake.sh" || exit 1
317 echo " * Chroot build done"
318 echo " * Removing bootstrap files"
319 rm -rf $RELEASEDIR/$XBIN
320 # The build process leaves some file in src as root.
321 chown -R bin $RELEASEDIR/usr/src*
322 cp issue.install $RELEASEDIR/etc/issue
324 if [ "$USB" -ne 0 ]
325 then
326 usb_root_changes
327 elif [ "$HDEMU" -ne 0 ]
328 then
329 hdemu_root_changes
332 echo $version_pretty >$RELEASEDIR/etc/version
333 echo " * Counting files"
334 extrakb=`du -s $RELEASEDIR/usr/install | awk '{ print $1 }'`
335 expr `df $TMPDISK | tail -1 | awk '{ print $4 }'` - $extrakb >$RELEASEDIR/.usrkb
336 find $RELEASEDIR/usr | fgrep -v /install/ | wc -l >$RELEASEDIR/.usrfiles
337 find $RELEASEDIR -xdev | wc -l >$RELEASEDIR/.rootfiles
338 echo " * Zeroing remainder of temporary areas"
339 df $TMPDISK
340 df $TMPDISK3
341 cp /dev/zero $RELEASEDIR/usr/.x 2>/dev/null || true
342 rm $RELEASEDIR/usr/.x
343 cp /dev/zero $RELEASEDIR/.x 2>/dev/null || true
344 rm $RELEASEDIR/.x
346 umount $TMPDISK || exit
347 umount $TMPDISK2 || exit
348 umount $TMPDISK3 || exit
349 (cd ../boot && make)
350 (cd .. && make depend)
351 make clean
352 make image || exit 1
353 mv image image_big
354 make clean
355 make image_small || exit 1
356 dd if=$TMPDISK3 of=$ROOTIMAGE bs=$BS count=$ROOTBLOCKS
357 # Prepare image and image_small for cdfdboot
358 mv image_big image
359 sh mkboot cdfdboot $TMPDISK3
360 cp $IMAGE $CDFILES/bootflop.img
361 cp release/cd/* $CDFILES || true
362 echo "This is Minix version $version_pretty prepared `date`." >$CDFILES/VERSION.TXT
364 h_opt=
365 bootimage=$IMAGE
366 if [ "$HDEMU" -ne 0 ]; then
367 make_hdimage
368 h_opt='-h'
369 bootimage=hdimage
372 if [ "$USB" -ne 0 ]; then
373 mv $bootimage $IMG
374 else
375 writeisofs -l MINIX -b $bootimage $h_opt $CDFILES $IMG || exit 1
377 if [ "$HDEMU" -eq 0 ]
378 then
379 echo "Appending Minix root and usr filesystem"
380 # Pad ISO out to cylinder boundary
381 isobytes=`stat -size $IMG`
382 isosects=`expr $isobytes / 512`
383 isopad=`expr $secs - '(' $isosects % $secs ')'`
384 dd if=/dev/zero count=$isopad >>$IMG
385 # number of sectors
386 isosects=`expr $isosects + $isopad`
387 ( cat $IMG $ROOTIMAGE ;
388 dd if=$TMPDISK bs=$BS count=$USRBLOCKS ) >m
389 mv m $IMG
390 # Make CD partition table
391 installboot -m $IMG /usr/mdec/masterboot
392 # Make sure there is no hole..! Otherwise the ISO format is
393 # unreadable.
394 partition -m $IMG 0 81:$isosects 81:$ROOTSECTS 81:$USRSECTS