3.1.3b tag.
[minix3.git] / tools / release.sh
blobd7de3ee86ccd6f398a37c34d761b4cf0e816dc4b
1 #!/bin/sh
3 set -e
5 XBIN=usr/xbin
6 SRC=src
8 PACKAGEDIR=/usr/bigports/Packages
9 PACKAGESOURCEDIR=/usr/bigports/Sources
10 secs=`expr 32 '*' 64`
11 export SHELL=/bin/sh
13 make_hdimage()
15 dd if=$TMPDISK of=usrimage bs=$BS count=$USRBLOCKS
17 rootsize=`stat -size rootimage`
18 usrsize=`stat -size usrimage`
20 rootsects=`expr $rootsize / 512`
21 usrsects=`expr $usrsize / 512`
23 # installboot -m needs at least 1KB
24 dd < /dev/zero >tmpimage count=2
25 partition -fm tmpimage 2 81:$rootsects* 0:0 81:$usrsects
26 installboot -m tmpimage /usr/mdec/masterboot
27 dd < tmpimage > subpart count=1
29 primsects=`expr 1 + $rootsects + $usrsects`
30 cyl=`expr '(' $primsects ')' / $secs + 1`
31 padsects=`expr $cyl \* $secs - 1 - $primsects`
33 { dd < /dev/zero count=1
34 cat subpart
35 cat rootimage
36 cat usrimage
37 dd < /dev/zero count=$padsects
38 } > hdimage
39 partition -m hdimage 81:`expr $primsects + $padsects`*
40 installboot -m hdimage /usr/mdec/masterboot
43 hdemu_root_changes()
45 $RELEASEDIR/usr/bin/installboot -d $TMPDISK3 \
46 $RELEASEDIR/usr/mdec/bootblock boot/boot
47 echo \
48 'bootcd=2
49 disable=inet
50 bios_wini=yes
51 bios_remap_first=1
52 ramimagedev=c0d7p0s0
53 bootbig(1, MINIX 3) { image=/boot/image_big; 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 IMG_BASE=minix${version}_ide
89 BS=4096
91 HDEMU=0
92 COPY=0
93 SVNREV=""
94 REVTAG=""
95 PACKAGES=1
97 FILENAMEOUT=""
99 while getopts "s:pchu?r:f:" c
101 case "$c" in
103 echo "Usage: $0 [-p] [-c] [-h] [-r <tag>] [-u] [-f <filename>] [-s <username>]" >&2
104 exit 1
107 echo " * Making HD image"
108 IMG_BASE=minix${version}_bios
109 HDEMU=1
112 echo " * Copying, not SVN"
113 COPY=1
116 PACKAGES=0
119 SVNREV=-r$OPTARG
122 echo " * Making live USB-stick image"
123 IMG_BASE=minix${version}_usb
124 HDEMU=1
125 USB=1
128 FILENAMEOUT="$OPTARG"
130 s) USERNAME="--username=$OPTARG"
132 esac
133 done
135 USRMB=580
137 USRBLOCKS="`expr $USRMB \* 1024 \* 1024 / $BS`"
138 USRSECTS="`expr $USRMB \* 1024 \* 2`"
139 ROOTKB=4096
140 ROOTSECTS="`expr $ROOTKB \* 2`"
141 ROOTBLOCKS="`expr $ROOTKB \* 1024 / $BS`"
143 if [ "$COPY" -ne 1 ]
144 then
145 echo "Note: this script wants to do svn operations."
148 TD1=.td1
149 TD2=.td2
150 TD3=.td3
153 if [ -f $TD1 ]
154 then TMPDISK="`cat $TD1`"
155 echo " * Warning: I'm going to overwrite $TMPDISK!"
156 else
157 echo "Temporary (sub)partition to use to make the /usr FS image? "
158 echo "I need $USRMB MB. It will be mkfsed!"
159 echo -n "Device: /dev/"
160 read dev || exit 1
161 TMPDISK=/dev/$dev
164 if [ -b $TMPDISK ]
165 then :
166 else echo "$TMPDISK is not a block device.."
167 exit 1
170 echo $TMPDISK >$TD1
172 if [ -f $TD2 ]
173 then TMPDISK2="`cat $TD2`"
174 echo " * Warning: I'm going to overwrite $TMPDISK2!"
175 else
176 echo "Temporary (sub)partition to use for /tmp? "
177 echo "It will be mkfsed!"
178 echo -n "Device: /dev/"
179 read dev || exit 1
180 TMPDISK2=/dev/$dev
183 if [ -b $TMPDISK2 ]
184 then :
185 else echo "$TMPDISK2 is not a block device.."
186 exit 1
189 echo $TMPDISK2 >$TD2
191 if [ -f $TD3 ]
192 then TMPDISK3="`cat $TD3`"
193 echo " * Warning: I'm going to overwrite $TMPDISK3!"
194 else
195 echo "It has to be at least $ROOTKB KB."
196 echo ""
197 echo "Temporary (sub)partition to use to make the root FS image? "
198 echo "It will be mkfsed!"
199 echo -n "Device: /dev/"
200 read dev || exit 1
201 TMPDISK3=/dev/$dev
204 if [ -b $TMPDISK3 ]
205 then :
206 else echo "$TMPDISK3 is not a block device.."
207 exit 1
210 echo $TMPDISK3 >$TD3
212 umount $TMPDISK || true
213 umount $TMPDISK2 || true
214 umount $TMPDISK3 || true
216 if [ $TMPDISK = $TMPDISK2 -o $TMPDISK = $TMPDISK3 -o $TMPDISK2 = $TMPDISK3 ]
217 then
218 echo "Temporary devices can't be equal."
219 exit
222 echo " * Cleanup old files"
223 rm -rf $RELEASEDIR $IMG $IMAGE $ROOTIMAGE $CDFILES image*
224 mkdir -p $CDFILES || exit
225 mkdir -p $RELEASEDIR
226 mkfs -B $BS -b $ROOTBLOCKS $TMPDISK3 || exit
227 mkfs $TMPDISK2 || exit
228 echo " * mounting $TMPDISK3 as $RELEASEDIR"
229 mount $TMPDISK3 $RELEASEDIR || exit
230 mkdir -m 755 $RELEASEDIR/usr
231 mkdir -m 1777 $RELEASEDIR/tmp
232 mount $TMPDISK2 $RELEASEDIR/tmp
234 echo making /usr
235 mkfs -B $BS -b $USRBLOCKS $TMPDISK || exit
236 echo " * Mounting $TMPDISK as $RELEASEDIR/usr"
237 mount $TMPDISK $RELEASEDIR/usr || exit
238 mkdir -p $RELEASEDIR/tmp
239 mkdir -p $RELEASEDIR/usr/tmp
240 mkdir -p $RELEASEDIR/$XBIN
241 mkdir -p $RELEASEDIR/usr/bin
242 mkdir -p $RELEASEDIR/bin
243 mkdir -p $RELEASEPACKAGE
244 mkdir -p $RELEASEPACKAGESOURCES
246 echo " * Transfering bootstrap dirs to $RELEASEDIR"
247 cp -p /bin/* /usr/bin/* $RELEASEDIR/$XBIN
248 cp -rp /usr/lib $RELEASEDIR/usr
249 cp -rp /bin/bigsh /bin/sh /bin/echo $RELEASEDIR/bin
250 cp -rp /usr/bin/make /usr/bin/install /usr/bin/yacc /usr/bin/flex $RELEASEDIR/usr/bin
252 if [ -d $PACKAGEDIR -a -d $PACKAGESOURCEDIR -a $PACKAGES -ne 0 ]
253 then echo " * Indexing packages"
254 bintotal=0
255 ( cd $PACKAGEDIR
256 for p in *.tar.bz2
257 do echo $p >&2
258 p="`echo $p | sed 's/.tar.bz2//'`"
259 descr="../$p/.descr"
260 if [ -f "$descr" ]
261 then echo "$p|`cat $descr`"
263 done >List
265 for d in $PACKAGEDIR $PACKAGESOURCEDIR
266 do echo Counting size of $d
267 f=$d/SizeMB
268 if [ ! -f $f ]
269 then
270 b="`bzip2 -dc $d/*.bz2 | wc -c`"
271 echo "`expr 1 + $b / 1024 / 1024`" >$f
273 echo "`cat $f` MB."
274 done
275 echo " * Transfering $PACKAGEDIR to $RELEASEPACKAGE"
276 cp $PACKAGEDIR/* $RELEASEPACKAGE/
277 echo " * Transfering $PACKAGESOURCEDIR to $RELEASEPACKAGESOURCES"
278 cp $PACKAGESOURCEDIR/* $RELEASEPACKAGESOURCES/ || true
282 # Make sure compilers and libraries are bin-owned
283 chown -R bin $RELEASEDIR/usr/lib
284 chmod -R u+w $RELEASEDIR/usr/lib
286 if [ "$COPY" -ne 1 ]
287 then
288 echo " * Doing new svn export"
289 BRANCH=r3.1.3
290 REPO=https://gforge.cs.vu.nl/svn/minix/branches/$BRANCH
291 REVISION="`svn info $USERNAME $SVNREV $REPO | grep '^Revision: ' | awk '{ print $2 }'`"
292 echo "Doing export of revision $REVISION from $REPO."
293 ( cd $RELEASEDIR/usr && svn $USERNAME export -r$REVISION $REPO && mv $BRANCH $SRC )
294 REVTAG=r$REVISION
295 echo "
297 /* Added by release script */
298 #ifndef _SVN_REVISION
299 #define _SVN_REVISION \"$REVISION\"
300 #endif" >>$RELEASEDIR/usr/src/include/minix/sys_config.h
302 else
303 ( cd .. && make depend && make clean )
304 srcdir=/usr/$SRC
305 ( cd $srcdir && tar cf - . ) | ( cd $RELEASEDIR/usr && mkdir $SRC && cd $SRC && tar xf - )
306 REVTAG=copy
309 if [ "$USB" -ne 0 ]; then
310 IMG=${IMG_BASE}_${REVTAG}.img
311 else
312 IMG=${IMG_BASE}_${REVTAG}.iso
315 echo " * Fixups for owners and modes of dirs and files"
316 chown -R bin $RELEASEDIR/usr/$SRC
317 chmod -R u+w $RELEASEDIR/usr/$SRC
318 find $RELEASEDIR/usr/$SRC -type d | xargs chmod 755
319 find $RELEASEDIR/usr/$SRC -type f | xargs chmod 644
320 find $RELEASEDIR/usr/$SRC -name configure | xargs chmod 755
321 find $RELEASEDIR/usr/$SRC/commands -name build | xargs chmod 755
322 # Bug tracking system not for on cd
323 rm -rf $RELEASEDIR/usr/$SRC/doc/bugs
325 # Make sure the CD knows it's a CD, unless it's not
326 if [ "$USB" -eq 0 ]
327 then date >$RELEASEDIR/CD
329 echo " * Chroot build"
330 cp chrootmake.sh $RELEASEDIR/usr/$SRC/tools/chrootmake.sh
331 chroot $RELEASEDIR "PATH=/$XBIN sh -x /usr/$SRC/tools/chrootmake.sh" || exit 1
332 # Copy built images for cd booting
333 cp $RELEASEDIR/boot/image_big image
334 echo " * Chroot build done"
335 echo " * Removing bootstrap files"
336 rm -rf $RELEASEDIR/$XBIN
337 # The build process leaves some file in $SRC as root.
338 chown -R bin $RELEASEDIR/usr/src*
339 cp issue.install $RELEASEDIR/etc/issue
341 if [ "$USB" -ne 0 ]
342 then
343 usb_root_changes
344 elif [ "$HDEMU" -ne 0 ]
345 then
346 hdemu_root_changes
349 echo $version_pretty, SVN revision $SVNREV, generated `date` >$RELEASEDIR/etc/version
350 echo " * Counting files"
351 extrakb=`du -s $RELEASEDIR/usr/install | awk '{ print $1 }'`
352 expr `df $TMPDISK | tail -1 | awk '{ print $4 }'` - $extrakb >$RELEASEDIR/.usrkb
353 find $RELEASEDIR/usr | fgrep -v /install/ | wc -l >$RELEASEDIR/.usrfiles
354 find $RELEASEDIR -xdev | wc -l >$RELEASEDIR/.rootfiles
355 echo " * Zeroing remainder of temporary areas"
356 df $TMPDISK
357 df $TMPDISK3
358 cp /dev/zero $RELEASEDIR/usr/.x 2>/dev/null || true
359 rm $RELEASEDIR/usr/.x
360 cp /dev/zero $RELEASEDIR/.x 2>/dev/null || true
361 rm $RELEASEDIR/.x
363 umount $TMPDISK || exit
364 umount $TMPDISK2 || exit
365 umount $TMPDISK3 || exit
367 (cd ../boot && make)
368 dd if=$TMPDISK3 of=$ROOTIMAGE bs=$BS count=$ROOTBLOCKS
369 sh mkboot cdfdboot $TMPDISK3
370 cp $IMAGE $CDFILES/bootflop.img
371 cp release/cd/* $CDFILES || true
372 echo "This is Minix version $version_pretty prepared `date`." >$CDFILES/VERSION.TXT
374 h_opt=
375 bootimage=$IMAGE
376 if [ "$HDEMU" -ne 0 ]; then
377 make_hdimage
378 h_opt='-h'
379 bootimage=hdimage
382 if [ "$USB" -ne 0 ]; then
383 mv $bootimage $IMG
384 else
385 writeisofs -l MINIX -b $bootimage $h_opt $CDFILES $IMG || exit 1
387 if [ "$HDEMU" -eq 0 ]
388 then
389 echo "Appending Minix root and usr filesystem"
390 # Pad ISO out to cylinder boundary
391 isobytes=`stat -size $IMG`
392 isosects=`expr $isobytes / 512`
393 isopad=`expr $secs - '(' $isosects % $secs ')'`
394 dd if=/dev/zero count=$isopad >>$IMG
395 # number of sectors
396 isosects=`expr $isosects + $isopad`
397 ( cat $IMG $ROOTIMAGE ;
398 dd if=$TMPDISK bs=$BS count=$USRBLOCKS ) >m
399 mv m $IMG
400 # Make CD partition table
401 installboot -m $IMG /usr/mdec/masterboot
402 # Make sure there is no hole..! Otherwise the ISO format is
403 # unreadable.
404 partition -m $IMG 0 81:$isosects 81:$ROOTSECTS 81:$USRSECTS
408 if [ "$FILENAMEOUT" ]
409 then echo "$IMG" >$FILENAMEOUT