1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
|
#!/bin/sh -
#
# $Id: build,v 1.12.2.1 1999/02/22 21:25:15 abial Exp $
#
# You can set the SRC variable which points to your source tree. It's
# /usr/src by default (most people shouldn't change it).
SRC=/usr/src
# Default MFS sizes for different types of the floppy. Again, most people
# shouldn't change them unless they know what they are doing.
DIAL_DFLT_SIZE=1600
ROUTER_DFLT_SIZE=820
NET_DFLT_SIZE=1700
ISP_DFLT_SIZE=1700
# DEVFS is currently broken. Always set this.
#
NO_DEVFS=yes
# Path to srcdirs of special program for init(8) (standard if empty)
INIT=
# --------- YOU SHOULD NOT NEED TO CHANGE ANYTHING BELOW -----------
# The "build" script will ask you for parameters. Just run it... :-)
# --------- YOU SHOULD NOT NEED TO CHANGE ANYTHING BELOW -----------
set -e
# Build kernel with previously set parameters.
build_kernel() {
echo ""
echo "-> Checking if we have to build the PICOBSD kernel..."
(cd ../${TYPE}/conf; make)
echo ""
}
# Main build procedure. It calls other scripts (stage1-3 and populate)
main() {
if [ "${TYPE}" = "dial" ]
then
suffix="-D"
fi
if [ "${TYPE}" = "net" ]
then
suffix="-N"
fi
if [ "${TYPE}" = "isp" ]
then
suffix="-I"
fi
if [ "${TYPE}" = "router" ]
then
suffix="-R"
fi
if [ "${TYPE}" = "custom" ]
then
suffix="-C"
fi
export suffix
clear
echo "-> Building with following parameters:"
echo -n " Type: ${TYPE}"
if [ "X${INIT}" != "X" ]
then
echo " (using ${INIT} as init(8))"
else
echo ""
fi
echo " MFS size: ${SIZE} kB"
echo " Language: ${LANGUAGE}"
echo ""
echo "-> We'll use the sources living in ${SRC}"
echo ""
echo "-> I hope you have checked the ../${TYPE}/conf/PICOBSD config file..."
echo ""
echo ""
sleep 2
# Build the kernel, if necessary
build_kernel
export SIZE LANGUAGE TYPE SRC NO_DEVFS INIT
for i in stage1 populate stage2 stage3
do
echo "====================== ${i} started ====================="
./${i}
if [ "X$?" != "X0" ]
then
echo ""
echo "-> ERROR in \"${i}\" script. Aborting the build process."
echo -n "-> Cleaning temporary files... "
umount -f /mnt
vnconfig -u /dev/rvn0
./clean ${TYPE}
echo "Done."
exit 10
else
echo "==================== ${i} completed ====================="
fi
done
}
# check for existing custom config directory and ask user if they want to use it
check_for_old_custom() {
KEEP_CUSTOM=no
if [ ! -d ../custom ]
then
return
fi
clear
echo " Custom directory setup"
echo ""
echo "There is an existing custom configuration linked to"
ls -l ../custom | awk -F\> '{ print $2 }' | awk '{ print $1 }'
echo ""
read -p "Do you wish to use the existing custom directory? (yes/no): " KEEP_CUSTOM
}
# Ask for, and set the custom config directory
set_custom() {
clear
echo " Custom directory setup"
echo ""
echo "Please enter the full path to the directory containing your"
echo "custom setup."
echo "This directory tree must be laid out exactly like the standard"
echo "ones. (E.g. you can type in /home/abial/work/custom, which"
echo "should contain conf/, crunch1/, floppy.tree/, lang/, mfs.tree/)."
echo ""
read -p "Enter the custom directory: " CUST_DIR
if [ "X${CUST_DIR}" = "X" ]
then
echo "-> Error. Custom directory cannot be null!"
exit 1
fi
}
# Set the LANGUAGE variable
set_lang() {
clear
echo " Language setup"
echo ""
echo "Language can be either 'en' (English - default) or 'pl' (Polish)"
echo ""
read -p "Enter the LANGUAGE (en, pl): " LANGUAGE
if [ "X${LANGUAGE}" = "X" ]
then
LANGUAGE=en
fi
}
# Set the INIT variable
set_init() {
clear
echo " Choose your init(8) program"
echo ""
echo "You can choose either standard init(8) (which requires getty), or"
echo "you can choose 'oinit' from TinyWare collection."
echo ""
read -p "Enter the INIT (init, oinit): " INIT
if [ "X${INIT}" = "Xinit" ]
then
unset INIT
fi
}
# Set the default MFS size depending on the type of setup
set_dflt_size() {
echo ""
if [ "X${TYPE}" = "X" ]
then
TYPE=dial
fi
echo "Setting default MFS size for \"${TYPE}\" type floppy."
if [ "X${TYPE}" = "Xdial" ]
then
SIZE=$DIAL_DFLT_SIZE
elif [ "X${TYPE}" = "Xnet" ]
then
SIZE=$NET_DFLT_SIZE
elif [ "X${TYPE}" = "Xrouter" ]
then
SIZE=$ROUTER_DFLT_SIZE
elif [ "X${TYPE}" = "Xisp" ]
then
SIZE=$ISP_DFLT_SIZE
elif [ "X${TYPE}" = "Xcustom" ]
then
SIZE=$DIAL_DFLT_SIZE
else
echo "Unknown type of setup: \"${TYPE}\". Aborting..."
exit 10
fi
}
# Set MFS size interactively
set_size() {
clear
echo " Memory Filesystem (MFS) Size setup"
echo ""
echo " Size can be anything decent (usually 1700 or 2500) in kB."
echo " NOTE1: you can also use other numbers (e.g. 1500, 1456, 1789 ...)"
echo " even much bigger (like 4567), but keep in mind that this memory is"
echo " totally lost to other programs. Usually you want to keep this as small as"
echo " possible."
echo ""
echo " NOTE2: for pre-canned setups there are specific requirements:"
echo " dial - requires at least SIZE=$DIAL_DFLT_SIZE"
echo " router - requires at least SIZE=$ROUTER_DFLT_SIZE (500kB less without SNMP)"
echo " net - requires at least SIZE=$NET_DFLT_SIZE (500kB less without SNMP)"
echo " isp - requires at least SIZE=$ISP_DFLT_SIZE (500kB less without SNMP)"
echo ""
echo " The last two configurations are not likely to run reliably on machines"
echo " with less than 10MB of RAM, while the 'dial' is tested and proved to run"
echo " as many as ~30 processes on 10 consoles with only 8MB RAM. YMMV."
echo ""
read -p "Enter the SIZE in kB: " SIZE
if [ "X${SIZE}" = "X" ]
then
set_dflt_size
fi
}
# Set type of floppy interactively
set_type() {
clear
echo " Setup the type of configuration"
echo ""
echo " Type can be either 'dial', 'router', 'net' or 'isp'. There are four"
echo " sets of configuration files in subdirs ../dial, ../router, ../net"
echo " and ../isp respectively - the contents of the floppy is constructed"
echo " basing on the Makefiles and scripts in them."
echo ""
echo " You can also type in 'custom', and you'll be asked to enter the"
echo " full path to directory tree, where you stored your custom"
echo " configuration, laid out exactly like the standard ones. (E.g."
echo " you can type in /home/abial/work/custom, which should contain"
echo " conf/, crunch1/, floppy.tree/, lang/, mfs.tree/)."
echo ""
echo " If you define TYPE=dial, you'll end up having a floppy which is"
echo " suitable for dialup access and not much else. If you define TYPE=net,"
echo " you'll have a small router-fixit-like floppy, which lacks most"
echo " interactive tools. TYPE=isp gives you a dialin server floppy."
echo ""
read -p "Enter the TYPE of the floppy (dial, net, router, isp): " TYPE
if [ "X${TYPE}" = "X" ]
then
TYPE=dial
fi
if [ "X${TYPE}" = "Xrouter" ]
then
INIT=oinit
fi
if [ "X${TYPE}" = "Xcustom" ]
then
check_for_old_custom
if [ "X${KEEP_CUSTOM}" != "Xyes" ]
then
[ -r ../custom ] && rm -f ../custom
set_custom
(cd ..; ln -sf ${CUST_DIR} custom)
fi
fi
if [ "X${TYPE}" = "Xdial" -a "X${INIT}" = "X" ]
then
set_init
fi
set_dflt_size
}
put_title() {
clear
echo " Building the PicoBSD v. 0.4 floppy"
echo "============================================================================"
echo ""
}
#-------------------------------------------------------------------
# Main entry of the script
# If $1="package", it creates a neat set of floppies
if [ X"$1" = X"package" ]
then
touch build.status
echo "##############################################" >>build.status
echo "## `date` ">>build.status
echo "##############################################" >>build.status
./clean dial
for y in en pl
do
for z in dial router net isp
do
TYPE=${z}
LANGUAGE=${y}
set_dflt_size
echo "---------------------------------------------">>build.status
echo "Building TYPE=${z}, LANGUAGE=${y}, SIZE=${SIZE}" >>build.status
export TYPE SIZE LANGUAGE SRC NO_DEVFS INIT
main
if [ "X$?" != "X0" ]
then
echo " ** FAILED! **">>build.status
else
echo " (ok)">>build.status
fi
mv picobsd.bin pb_${y}${suffix}.bin
echo "Calling ./clean for ${TYPE}, ${LANGUAGE}, ${SIZE}">>build.status
./clean ${TYPE}
done
done
exit 0
fi
# Set build parameters interactively
TYPE=dial
LANGUAGE=en
set_dflt_size
while [ "X${ans}" != "Xn" ]
do
put_title
echo "Current build parameters are as follows:"
echo ""
echo " 1. Type: ${TYPE}"
if [ "X${INIT}" != "X" ]
then
echo " a. (using ${INIT} as init(8))"
else
echo " a. (using stock init as init(8))"
fi
echo ""
echo " 2. MFS size: ${SIZE} kB"
echo " 3. Language: ${LANGUAGE}"
echo ""
echo "Which parameter would you like to change?"
read -p "(1, a, 2, 3; n -no change, build it ; q -quit): " ans
case ${ans} in
1) set_type
clear
;;
a) set_init
clear
;;
2) set_size
clear
;;
3) set_lang
clear
;;
q) echo ""
echo "Hey! Don't give up so quickly. Quitting for now..."
echo ""
exit 0
;;
n) ;;
*) echo "Unknown option \"${ans}\". Try again."
sleep 2
clear
;;
esac
done
# Export the parameters
export LANGUAGE SIZE TYPE SRC NO_DEVFS INIT
# Call the build procedure
main
# Install if it's ok.
echo ""
if [ "X$?" = "X0" ]
then
echo "The build process was completed successfuly."
echo ""
echo "Now we are going to install the image on the floppy."
./install
fi
exit 0
|