source: trunk/minix/commands/scripts/mkdist.sh@ 9

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

Minix 3.1.2a

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