1 | #!/bin/sh
|
---|
2 | #
|
---|
3 | # mkdist 3.6 - Make a Minix distribution Author: Kees J. Bot
|
---|
4 | # 20 Dec 1994
|
---|
5 |
|
---|
6 | system=`uname`
|
---|
7 |
|
---|
8 | usage()
|
---|
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.
|
---|
19 | while getopts '' opt; do usage; done
|
---|
20 | shift `expr $OPTIND - 1`
|
---|
21 |
|
---|
22 | case $system:$# in
|
---|
23 | Minix: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 | ;;
|
---|
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
|
---|
42 |
|
---|
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/mkswap
|
---|
72 | bin/mv
|
---|
73 | bin/od
|
---|
74 | bin/part
|
---|
75 | bin/partition
|
---|
76 | bin/readall
|
---|
77 | bin/repartition
|
---|
78 | bin/rm
|
---|
79 | bin/rmdir
|
---|
80 | bin/sed
|
---|
81 | bin/setup
|
---|
82 | bin/shutdown
|
---|
83 | bin/sleep
|
---|
84 | bin/sort
|
---|
85 | bin/stty
|
---|
86 | bin/sysenv
|
---|
87 | bin/tar
|
---|
88 | bin/uname
|
---|
89 | bin/uncompress
|
---|
90 | bin/update
|
---|
91 | bin/vol
|
---|
92 | bin/zcat
|
---|
93 | etc
|
---|
94 | etc/rc
|
---|
95 | lib
|
---|
96 | lib/keymaps
|
---|
97 | `cd $base/usr && echo lib/keymaps/*`
|
---|
98 | lib/pwdauth
|
---|
99 | mdec
|
---|
100 | mdec/boot
|
---|
101 | mdec/bootblock
|
---|
102 | mdec/jumpboot
|
---|
103 | mdec/masterboot
|
---|
104 | tmp
|
---|
105 | "
|
---|
106 |
|
---|
107 | if [ "$std" ]
|
---|
108 | then
|
---|
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 "
|
---|
122 | The installation root and /usr can be put on either one diskette of at least
|
---|
123 | 1.2 Mb, or on two diskettes of at least 720 kb.
|
---|
124 |
|
---|
125 | Do 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
|
---|
153 | else
|
---|
154 | rootdir=$base
|
---|
155 | v1='-t 1'
|
---|
156 | fi
|
---|
157 |
|
---|
158 | umount $rootdev 2>/dev/null
|
---|
159 | if [ "$std" ]
|
---|
160 | then
|
---|
161 | umount ${rootdev}p1 2>/dev/null
|
---|
162 | umount ${rootdev}p2 2>/dev/null
|
---|
163 | else
|
---|
164 | umount $rootdir/minix 2>/dev/null
|
---|
165 | umount $rootdir/etc 2>/dev/null
|
---|
166 | fi
|
---|
167 | mkfs $v1 -i 272 $rootdev 480 || exit
|
---|
168 | mount $rootdev /mnt || exit
|
---|
169 | if [ "$std" ]
|
---|
170 | then
|
---|
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)
|
---|
177 | else
|
---|
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
|
---|
182 | fi
|
---|
183 | cpdir -vx $rootdir /mnt || exit
|
---|
184 | install -d -o 0 -g 0 -m 755 /mnt || exit
|
---|
185 | install -d -o 0 -g 0 -m 555 /mnt/root || exit
|
---|
186 | install -d -o 0 -g 0 -m 555 /mnt/mnt || exit
|
---|
187 | install -d -o 0 -g 0 -m 555 /mnt/usr || exit
|
---|
188 | if [ "$std" ]
|
---|
189 | then
|
---|
190 | umount ${rootdev}p2 2>/dev/null # Unhide /etc
|
---|
191 | umount ${rootdev}p1 || exit # Unhide /minix
|
---|
192 | else
|
---|
193 | umount $rootdir/etc || exit # Unhide /etc
|
---|
194 | umount $rootdir/minix || exit # Unhide /minix
|
---|
195 | fi
|
---|
196 | install -d -o 2 -g 0 -m 755 /mnt/minix || exit
|
---|
197 | install -d -o 2 -g 0 -m 755 /mnt/etc || exit
|
---|
198 | set `ls -t $rootdir/minix` # Install the latest kernel
|
---|
199 | install -c $rootdir/minix/$1 /mnt/minix/`echo $1 | sed 's/r[0-9]*$//` || exit
|
---|
200 | cpdir -v $base/usr/src/etc /mnt/etc || exit # Install a fresh /etc
|
---|
201 | chown -R 0:0 /mnt/etc # Patch up owner and mode
|
---|
202 | chmod 600 /mnt/etc/shadow
|
---|
203 |
|
---|
204 | # Change /etc/fstab.
|
---|
205 | echo >/mnt/etc/fstab "\
|
---|
206 | # Poor man's File System Table.
|
---|
207 |
|
---|
208 | root=unknown
|
---|
209 | usr=unknown"
|
---|
210 |
|
---|
211 | # How to install?
|
---|
212 | echo >/mnt/etc/issue "\
|
---|
213 |
|
---|
214 | Login as root and run 'setup' to install Minix."
|
---|
215 |
|
---|
216 | umount $rootdev || exit
|
---|
217 | test "$std" && umount $root 2>/dev/null
|
---|
218 | installboot -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.)
|
---|
222 | partition -mf $rootdev 0 81:960 0:0 81:1440 81:480 >/dev/null || exit
|
---|
223 |
|
---|
224 | if [ "$std" ]
|
---|
225 | then
|
---|
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
|
---|
235 | fi
|
---|
236 |
|
---|
237 | mkfs $v1 -i 96 $usrdev 720 || exit
|
---|
238 | mount $usrdev /mnt || exit
|
---|
239 | install -d -o 0 -g 0 -m 755 /mnt || exit
|
---|
240 | (cd $base/usr && exec tar cfD - $usrlist) | (cd /mnt && exec tar xvfp -) || exit
|
---|
241 | umount $usrdev || exit
|
---|
242 |
|
---|
243 | # Put a "boot the other drive" bootblock on the /usr floppy.
|
---|
244 | installboot -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.
|
---|
247 | test "$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.
|
---|
251 | set -$- `df | grep "^$usr"`
|
---|
252 | size=`expr \\( $4 \\* 6 / 10 + 999 \\) / 1000`
|
---|
253 |
|
---|
254 | echo -n "
|
---|
255 | You now need enough diskettes to hold /usr in compressed form, close to
|
---|
256 | $size Mb total. "
|
---|
257 |
|
---|
258 | size=
|
---|
259 | while [ -z "$size" ]
|
---|
260 | do
|
---|
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
|
---|
273 | done
|
---|
274 |
|
---|
275 | drive=
|
---|
276 | while [ -z "$drive" ]
|
---|
277 | do
|
---|
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
|
---|
288 | done
|
---|
289 |
|
---|
290 | echo "
|
---|
291 | Enter the floppies in drive $drive when asked to. Mark them with the volume
|
---|
292 | numbers!
|
---|
293 | "
|
---|
294 | sleep 2
|
---|
295 |
|
---|
296 | if [ `arch` = i86 ]; then bits=13; else bits=16; fi
|
---|
297 |
|
---|
298 | >/tmp/DONE
|
---|
299 | cd /usr && tar cvf - . /tmp/DONE \
|
---|
300 | | compress -b$bits | vol -w $size /dev/fd$drive &&
|
---|
301 | echo Done.
|
---|