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
|
#!/bin/sh -
#
# $Id: build,v 1.15 1999/08/23 08:33:07 luigi 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
# --------- 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 -----------
# EDITOR is the editor you use
EDITOR=${EDITOR:-vi}
# LANGUAGE language to be used (en or pl)
LANGUAGE=en
# SITE site-specific files
SITE=
# FLOPPY_SIZE floppy size in KB (default to 1440)
FLOPPY_SIZE=1440
# DEVFS is currently broken. Always set this.
#
NO_DEVFS=yes
# RISU is where dialog replies go.
RISU=.build.reply
# abort in case of error...
set -e
. ../Version
# assign default values to variables.
set_defaults() {
TYPE=${TYPE:-dial} # PicoBSD type (isp, router, net, custom, ...
while read name suff sz init mfs_in floppy_in ; do
if [ "$name" != "#" -a $name != "" ] ; then
eval ${name}_suffix=$suff
eval ${name}_DFLT_SIZE=$sz
eval ${name}_INIT=$init
eval ${name}_MFS_INODES=$mfs_in
eval ${name}_FLOPPY_INODES=$floppy_in
fi
done <<__eof__
# build MFS - Byte/inode -
# name suffix DFLT_SZ init MFS FLOPPY
dial -D 1600 init 4096 32768
router -R 820 oinit 3072 32768
net -N 2200 init 4096 32768
isp -I 2400 init 4096 32768
custom -C 2400 init 8192 32768
__eof__
}
set_msgs() {
MSG1="Type: ${TYPE}"
if [ "X${TYPE}" = "Xcustom" ] ; then
MSG1="${MSG1} (from ${CUST_DIR})"
fi
MSG="PicoBSD build -- Current parameters:\n\n\t1. ${MSG1}\n\
\t2. MFS size: ${SIZE} kB\n\t3. Language: ${LANGUAGE}\n\
\t4. Site-info: ${SITE}\n"
}
# Main build procedure. It calls another scripts (stage1)
main() {
export suffix
clear
set_msgs
printf "${MSG}"
echo "-> We'll use the sources living in ${SRC}"
echo ""
echo "-> I hope you have checked the ../${TYPE}/PICOBSD config file..."
echo ""
echo ""
sleep 2
export SIZE LANGUAGE TYPE SRC NO_DEVFS INIT
export SITE MFS_INODES FLOPPY_INODES FLOPPY_SIZE
# Build the kernel, if necessary
echo ""
echo "-> Checking if we have to build the PICOBSD kernel..."
(cd ../${TYPE}; make -f ../build/Makefile.conf )
echo ""
./stage1 2>&1 | tee stage1.out
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
fi
echo "==================== ${i} completed ====================="
}
# 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() {
dialog --title "Custom directory setup" --inputbox \
"Please enter the full path to the directory containing your \
custom setup. \
This directory tree must be laid out exactly like the standard \
ones. (E.g. you can type in /home/abial/work/custom, which \
should contain crunch1/, floppy.tree/, lang/ )." \
10 70 2> ${RISU}
CUST_DIR=`cat ${RISU}`
}
# Set type of floppy interactively. Also set the various defaults
# associated to each type. We can override them manually afterwards.
set_type() {
eval SIZE=$"${TYPE}_DFLT_SIZE"
eval INIT=$"${TYPE}_INIT"
eval MFS_INODES=$"${TYPE}_MFS_INODES"
eval FLOPPY_INODES=$"${TYPE}_FLOPPY_INODES"
eval suffix=$"${TYPE}_suffix"
case ${TYPE} in
custom)
check_for_old_custom
if [ "X${KEEP_CUSTOM}" != "Xyes" ] ; then
[ -r ../custom ] && rm -f ../custom
set_custom
(cd ..; ln -sf ${CUST_DIR} custom)
fi
;;
esac
}
build_package() {
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_type
echo "---------------------------------------------">>build.status
echo "Building TYPE=${z}, LANGUAGE=${y}, SIZE=${SIZE}" >>build.status
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
}
# Set build parameters interactively
main_dialog() {
while [ true ] ; do
set_msgs
dialog --menu "PicoBSD build menu -- ver ${VER} (22aug1999)" 19 70 12 \
N "No change, build it" \
T "${MSG1}" \
K "edit Kernel config file for ${TYPE}" \
E "Edit crunch.conf file for ${TYPE}" \
S "MFS Size: ${SIZE}kB" \
L "Language: ${LANGUAGE}" \
I "Init type: ${INIT}" \
F "Floppy size: ${FLOPPY_SIZE}kB" \
M "MFS bytes per inode: ${MFS_INODES}" \
U "UFS bytes per inode: ${FLOPPY_INODES}" \
$ "Site-info: ${SITE}" \
Q "Quit" \
2> ${RISU}
ans=`cat ${RISU}`
rm ${RISU}
case ${ans} in
T)
dialog --menu "Setup the type of configuration" 12 70 5 \
dial "dialin (ppp etc.)" \
router "router/bridge/mrouter" \
net "net admin tool" \
isp "isp (ppp and terminal server)" \
custom "custom config (need pathname)" 2> ${RISU} || rm ${RISU}
if [ -f ${RISU} ] ; then
TYPE=`cat ${RISU}`
set_type
fi
;;
I)
dialog --menu "Choose your init(8) program" \
10 70 2 init "Standard init (requires getty)" \
oinit "small init from TinyWare" 2> ${RISU} || rm ${RISU}
if [ -f ${RISU} ] ; then
INIT=`cat ${RISU}`
fi
;;
K) ${EDITOR} ../${TYPE}/PICOBSD ;;
E) ${EDITOR} ../${TYPE}/crunch1/crunch.conf ;;
S)
dialog --title "MFS Size setup" --inputbox \
"MFS size depends on what you need to put on the MFS image. Typically \
ranges between 820kB (for very small bridge/router images) to \
as much as 2500kB kB for a densely packed image. \
Keep in mind that this memory is \
totally lost to other programs. Usually you want to keep \
this as small as possible. " 10 70 2> ${RISU} || rm ${RISU}
if [ -f ${RISU} ] ; then
SIZE=`cat ${RISU}`
if [ "${SIZE}" = "" ] ; then
eval SIZE=$"${TYPE}_DFLT_SIZE"
fi
fi
;;
L)
dialog --menu "Please choose language" \
10 40 2 en English pl Polish 2> ${RISU} || rm ${RISU}
if [ -f ${RISU} ] ; then
LANGUAGE=`cat ${RISU}`
fi
;;
\$)
dialog --title "Site info setup" --inputbox \
"Please enter the full path to the directory \
containing site-specific setup. \
This directory tree must contain files that replace \
standard ones in floppy.tree/ and mfs.tree/ . " \
10 70 2> ${RISU} || rm ${RISU}
if [ -f ${RISU} ] ; then
SITE=`cat ${RISU}`
fi
;;
F)
dialog --menu "Set floppy size" 15 70 4 \
1440 "1.44MB" 1720 "1.72MB" \
2880 "2.88MB" 4096 "4MB" 2> ${RISU} || rm ${RISU}
if [ -f ${RISU} ] ; then
FLOPPY_SIZE=`cat ${RISU}`
fi
;;
M)
dialog --title "MFS bytes per inode:" --inputbox \
"Enter MFS bytes per inode (typically 4096..65536). \
A larger value means fewer inodes but more space on MFS" \
10 70 2> ${RISU} || rm ${RISU}
if [ -f ${RISU} ] ; then
MFS_INODES=`cat ${RISU}`
if [ "${MFS_INODES}" = "" ] ; then
eval MFS_INODES=$"${TYPE}_DFLT_MFS_INODES"
fi
fi
;;
U)
dialog --title "Floppy bytes per inode:" --inputbox \
"Enter floppy bytes per inode (typically 3072..65536). \
A larger value means fewer inodes but more space on the floppy." \
10 70 2> ${RISU} || rm ${RISU}
if [ -f ${RISU} ] ; then
FLOPPY_INODES=`cat ${RISU}`
if [ "${FLOPPY_INODES}" = "" ] ; then
eval FLOPPY_INODES=$"${TYPE}_DFLT_FLOPPY_INODES"
fi
fi
;;
N) break 2
;;
Q) exit 0 ;;
*) echo "Unknown option \"${ans}\". Try again."
sleep 2
clear
;;
esac
done
}
# Call the build procedure
# Install image
do_install() {
dialog --title "Build ${TYPE} completed" --inputbox \
"\nThe build process was completed successfuly.\n\
Now we are going to install the image on the floppy.\n\
Please insert a blank floppy in /dev/fd0.\\n
WARNING: the contents of the floppy will be permanently erased!\n\
\n\
Your options:\n\
* ^C or [Cancel] to abort,\n\
* Enter to install \"${FILENAME}\",\n\
* name of other file to install.\n\
" 20 70 2> ${RISU}
if [ "$?" = "0" ]; then
FILENAME=`cat ${RISU}`
if [ "${FILENAME}" = "" ] ; then
FILENAME=picobsd.bin
fi
echo "Writing ${FILENAME}..."
dd if=${FILENAME} of=/dev/rfd0
else
echo "Ok, the image is in picobsd.bin"
fi
echo "Done."
}
#-------------------------------------------------------------------
# Main entry of the script
interactive="YES"
if [ "$1" = "-n" ] ; then
interactive="NO"
shift
fi
TYPE=$1
set_defaults
set_type
# If $1="package", it creates a neat set of floppies
if [ "$1" = "package" ] ; then
build_package
fi
if [ "$interactive" = "YES" ] ; then
main_dialog
fi
main # build ${TYPE}
do_install
exit 0
|