remove traces of benchmarks from test/.
[minix.git] / commands / scripts / mkdist.sh
blob8e0664bf58d3031a5235b284f84214622be29a2c
1 #!/bin/sh
3 # mkdist 3.6 - Make a Minix distribution Author: Kees J. Bot
4 # 20 Dec 1994
6 system=`uname`
8 usage()
10 case $system in
11 Minix) echo "Usage: $0" >&2
13 Minix-vmd) echo "Usage: $0 base-path root-device usr-device" >&2
14 esac
15 exit 1
18 # No options.
19 while getopts '' opt; do usage; done
20 shift `expr $OPTIND - 1`
22 case $system:$# in
23 Minix:0)
24 # Interactive.
25 case "$0" in
26 /tmp/*)
27 rm -f "$0"
29 *) # Move out of /usr.
30 cp -p "$0" /tmp/mkdist
31 exec /tmp/mkdist
32 esac
33 std=t
34 base=/
35 export PATH=/bin:/usr/bin
37 Minix-vmd:3)
38 # Called by an external script from Minix-vmd to help make a distribution.
39 std=
40 base="$1" rootdev="$2" usrdev="$3"
41 esac
43 usrlist="
44 bin
45 bin/MAKEDEV
46 bin/arch
47 bin/badblocks
48 bin/chmod
49 bin/clone
50 bin/compress
51 bin/cp
52 bin/cpdir
53 bin/df
54 `test -f $base/usr/bin/mtools || echo bin/dosdir bin/dosread bin/doswrite`
55 `test -f $base/usr/bin/mtools && echo bin/mtools`
56 bin/edparams
57 bin/getty
58 bin/grep
59 bin/installboot
60 bin/isodir
61 bin/isoinfo
62 bin/isoread
63 bin/kill
64 bin/ln
65 bin/login
66 bin/ls
67 bin/mined
68 bin/mkdir
69 bin/mkfs
70 bin/mknod
71 bin/mv
72 bin/od
73 bin/part
74 bin/partition
75 bin/readall
76 bin/repartition
77 bin/rm
78 bin/rmdir
79 bin/sed
80 bin/setup
81 bin/shutdown
82 bin/sleep
83 bin/sort
84 bin/stty
85 bin/sysenv
86 bin/tar
87 bin/uname
88 bin/uncompress
89 bin/update
90 bin/vol
91 bin/zcat
92 etc
93 etc/rc
94 lib
95 lib/keymaps
96 `cd $base/usr && echo lib/keymaps/*`
97 lib/pwdauth
98 mdec
99 mdec/boot
100 mdec/bootblock
101 mdec/jumpboot
102 mdec/masterboot
106 if [ "$std" ]
107 then
108 # Find the root device, and the real root device.
109 . /etc/fstab
110 realroot=`printroot -r`
111 if [ $realroot = $root ]
112 then
113 rootdir=/
114 else
115 umount $root >/dev/null 2>&1
116 mount $root /root || exit
117 rootdir=/root
120 echo -n "
121 The installation root and /usr can be put on either one diskette of at least
122 1.2 Mb, or on two diskettes of at least 720 kb.
124 Do you want to use a single diskette of at least 1.2 Mb? [y] "; read single
126 case $single in
127 ''|[yY]*|sure)
128 single=t
130 *) single=
131 esac
133 echo -n "Which drive to use? [0] "; read drive
135 case $drive in
136 '') drive=0
138 [01]) ;;
139 *) echo "Please type '0' or '1'" >&2; exit 1
140 esac
142 if [ "$single" ]
143 then
144 echo -n "Insert the root+usr diskette in drive $drive and hit RETURN"
145 else
146 echo -n "Insert the root diskette in drive $drive and hit RETURN"
148 read ret
150 rootdev=/dev/fd$drive
151 v1=-1
152 else
153 rootdir=$base
154 v1='-t 1'
157 umount $rootdev 2>/dev/null
158 if [ "$std" ]
159 then
160 umount ${rootdev}p1 2>/dev/null
161 umount ${rootdev}p2 2>/dev/null
162 else
163 umount $rootdir/minix 2>/dev/null
164 umount $rootdir/etc 2>/dev/null
166 mkfs $v1 -i 272 $rootdev 480 || exit
167 mount $rootdev /mnt || exit
168 if [ "$std" ]
169 then
170 partition -mf $rootdev 0 81:960 81:240 81:240 >/dev/null || exit
171 repartition $rootdev >/dev/null || exit
172 mkfs $v1 ${rootdev}p1 || exit
173 mkfs $v1 ${rootdev}p2 || exit
174 mount ${rootdev}p1 $rootdir/minix || exit # Hide /minix and /etc
175 mount ${rootdev}p2 $rootdir/etc 2>/dev/null # (complains about /etc/mtab)
176 else
177 install -d /tmp/.minix || exit
178 install -d /tmp/.etc || exit # Hide /minix and /etc
179 mount -t lo /tmp/.minix $rootdir/minix || exit
180 mount -t lo /tmp/.etc $rootdir/etc || exit
182 cpdir -vx $rootdir /mnt || exit
183 install -d -o 0 -g 0 -m 755 /mnt || exit
184 install -d -o 0 -g 0 -m 555 /mnt/root || exit
185 install -d -o 0 -g 0 -m 555 /mnt/mnt || exit
186 install -d -o 0 -g 0 -m 555 /mnt/usr || exit
187 if [ "$std" ]
188 then
189 umount ${rootdev}p2 2>/dev/null # Unhide /etc
190 umount ${rootdev}p1 || exit # Unhide /minix
191 else
192 umount $rootdir/etc || exit # Unhide /etc
193 umount $rootdir/minix || exit # Unhide /minix
195 install -d -o 2 -g 0 -m 755 /mnt/minix || exit
196 install -d -o 2 -g 0 -m 755 /mnt/etc || exit
197 set `ls -t $rootdir/minix` # Install the latest kernel
198 install -c $rootdir/minix/$1 /mnt/minix/`echo $1 | sed 's/r[0-9]*$//` || exit
199 cpdir -v $base/usr/src/etc /mnt/etc || exit # Install a fresh /etc
200 chown -R 0:0 /mnt/etc # Patch up owner and mode
201 chmod 600 /mnt/etc/shadow
203 # Change /etc/fstab.
204 echo >/mnt/etc/fstab "\
205 # Poor man's File System Table.
207 root=unknown
208 usr=unknown"
210 # How to install?
211 echo >/mnt/etc/issue "\
213 Login as root and run 'setup' to install Minix."
215 umount $rootdev || exit
216 test "$std" && umount $root 2>/dev/null
217 installboot -d $rootdev $base/usr/mdec/bootblock boot >/dev/null
219 # Partition the root floppy whether necessary or not. (Two images can be
220 # concatenated, or a combined image can be split later.)
221 partition -mf $rootdev 0 81:960 0:0 81:1440 81:480 >/dev/null || exit
223 if [ "$std" ]
224 then
225 if [ "$single" ]
226 then
227 repartition $rootdev >/dev/null
228 usrdev=${rootdev}p2
229 else
230 echo -n "Insert the usr diskette in drive $drive and hit RETURN"
231 read ret
232 usrdev=$rootdev
236 mkfs $v1 -i 96 $usrdev 720 || exit
237 mount $usrdev /mnt || exit
238 install -d -o 0 -g 0 -m 755 /mnt || exit
239 (cd $base/usr && exec tar cfD - $usrlist) | (cd /mnt && exec tar xvfp -) || exit
240 umount $usrdev || exit
242 # Put a "boot the other drive" bootblock on the /usr floppy.
243 installboot -m $usrdev /usr/mdec/masterboot >/dev/null
245 # We're done for Minix-vmd here, it has its own ideas on how to package /usr.
246 test "$std" || exit 0
248 # Guess the size of /usr in compressed form. Assume compression down to 60%
249 # of the original size. Use "disk megabytes" of 1000*1024 for a safe guess.
250 set -$- `df | grep "^$usr"`
251 size=`expr \\( $4 \\* 6 / 10 + 999 \\) / 1000`
253 echo -n "
254 You now need enough diskettes to hold /usr in compressed form, close to
255 $size Mb total. "
257 size=
258 while [ -z "$size" ]
260 if [ "$single" ]; then defsize=1440; else defsize=720; fi
262 echo -n "What is the size of the diskettes? [$defsize] "; read size
264 case $size in
265 '') size=$defsize
267 360|720|1200|1440)
269 *) echo "Sorry, I don't believe \"$size\", try again." >&2
270 size=
271 esac
272 done
274 drive=
275 while [ -z "$drive" ]
277 echo -n "What floppy drive to use? [0] "; read drive
279 case $drive in
280 '') drive=0
282 [01])
284 *) echo "It must be 0 or 1, not \"$drive\"."
285 drive=
286 esac
287 done
289 echo "
290 Enter the floppies in drive $drive when asked to. Mark them with the volume
291 numbers!
293 sleep 2
295 if [ `arch` = i86 ]; then bits=13; else bits=16; fi
297 >/tmp/DONE
298 cd /usr && tar cvf - . /tmp/DONE \
299 | compress -b$bits | vol -w $size /dev/fd$drive &&
300 echo Done.