source: trunk/minix/tools/release.sh@ 20

Last change on this file since 20 was 9, checked in by Mattia Monga, 14 years ago

Minix 3.1.2a

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