2001-02-20 17:09:40 +00:00
|
|
|
|
#!/bin/sh -
|
|
|
|
|
#
|
|
|
|
|
# $FreeBSD$
|
|
|
|
|
#
|
|
|
|
|
# The new PicoBSD build script. Invoked as
|
|
|
|
|
#
|
|
|
|
|
# picobsd [options] floppy_type site_name
|
|
|
|
|
#
|
|
|
|
|
# Where floppy_type is a directory where the picobsd config info
|
|
|
|
|
# is held, and ${floppy_type}/floppy.tree.${site_name} contains
|
|
|
|
|
# optional site-specific configuration.
|
|
|
|
|
#
|
|
|
|
|
# For Options, see the bottom of the file where the processing is
|
2001-06-20 14:16:48 +00:00
|
|
|
|
# done. The picobsd(8) manpage might be of some help, but code and docs
|
|
|
|
|
# tend to lose sync over time...
|
2001-02-20 17:09:40 +00:00
|
|
|
|
#
|
|
|
|
|
# This script depends on the following files:
|
|
|
|
|
#
|
|
|
|
|
# in ${PICO_TREE} :
|
|
|
|
|
# Makefile.conf Makefile used to build the kernel
|
|
|
|
|
# config shell variables, sourced here.
|
|
|
|
|
# mfs.mtree mtree config file
|
|
|
|
|
#
|
|
|
|
|
# floppy.tree/ files which go on the floppy
|
|
|
|
|
# mfs_tree/ files which go onto the mfs
|
|
|
|
|
#
|
|
|
|
|
# in ${MY_TREE} :
|
|
|
|
|
# PICOBSD kernel config file
|
|
|
|
|
# config shell variables, sourced here.
|
|
|
|
|
# crunch.conf crunchgen configuration
|
|
|
|
|
# floppy.tree.exclude files from floppy.tree/ which we do not need here.
|
|
|
|
|
# floppy.tree/ local additions to the floppy.tree
|
|
|
|
|
# floppy.tree.${site}/ same as above, site specific.
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
#--- The main entry point is at the end.
|
|
|
|
|
#
|
|
|
|
|
|
2001-10-02 17:06:51 +00:00
|
|
|
|
# There are two set of initialization. The first one (set_defaults)
|
|
|
|
|
# is done on entry to the script, and is used to set default values
|
|
|
|
|
# for all variables which do not depend on floppy type and source tree.
|
|
|
|
|
#
|
|
|
|
|
# The second set is done after command line parsing, e.g.
|
|
|
|
|
# to resolve dependencies on the source tree.
|
|
|
|
|
#
|
|
|
|
|
# Naming:
|
|
|
|
|
# + variables that control operation (e.g. verbosity) and are generally
|
|
|
|
|
# set from the command line have o_ ("option") as a name prefix
|
|
|
|
|
#
|
|
|
|
|
# + variables which contain pathnames and values that should not change
|
|
|
|
|
# have c_ ("constant") as a name prefix
|
|
|
|
|
#
|
|
|
|
|
# + variables exported to Makefiles and subshells are CAPITAL
|
|
|
|
|
#
|
|
|
|
|
# + variables local to the script are lowercase, possibly with
|
|
|
|
|
# an l_ ("local") prefix
|
2001-02-20 17:09:40 +00:00
|
|
|
|
|
2001-10-02 17:06:51 +00:00
|
|
|
|
# SRC points to your FreeBSD source tree.
|
|
|
|
|
# l_usrtree points to the /usr subdir for the source tree.
|
|
|
|
|
# Normally /usr or ${SRC}/../usr
|
|
|
|
|
# l_objtree points to the obj tree. Normally ${l_usrtree}/obj-pico
|
|
|
|
|
# PICO_TREE is where standard picobsd stuff resides.
|
|
|
|
|
# Normally ${SRC}/release/picobsd
|
|
|
|
|
# You can set SRC with --src <directory>
|
|
|
|
|
# It is not recommended to override the other variables.
|
2001-09-20 13:09:01 +00:00
|
|
|
|
|
2001-10-02 17:06:51 +00:00
|
|
|
|
# MY_TREE (set later) is where this floppy type resides.
|
|
|
|
|
# BUILDDIR is the build directory
|
|
|
|
|
|
|
|
|
|
# set some default values for variables.
|
|
|
|
|
# needs to be done as the first thing in the script.
|
|
|
|
|
|
|
|
|
|
# log something on stdout if verbose.
|
|
|
|
|
o_verbose=0 # this needs to be here!
|
|
|
|
|
log() {
|
|
|
|
|
if [ ${o_verbose} -gt 0 ] ; then
|
|
|
|
|
printf "\n*** %s\n" "$*"
|
|
|
|
|
if [ ${o_verbose} -gt 1 ] ; then
|
|
|
|
|
read -p "=== Press enter to continue" foo
|
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
}
|
2001-02-20 17:09:40 +00:00
|
|
|
|
|
2002-03-08 02:24:21 +00:00
|
|
|
|
logverbose() {
|
|
|
|
|
printf "\n*** %s\n" "$*"
|
|
|
|
|
read -p "=== Press enter to continue" foo
|
|
|
|
|
}
|
|
|
|
|
|
2001-10-02 17:06:51 +00:00
|
|
|
|
set_defaults() {
|
|
|
|
|
# no way to use logging in this function, variable not set yet.
|
2001-02-20 17:09:40 +00:00
|
|
|
|
|
|
|
|
|
# EDITOR is the editor you use
|
2001-10-02 17:06:51 +00:00
|
|
|
|
# fd_size floppy size in KB (default to 1440). You can use 1480,
|
2001-02-20 17:09:40 +00:00
|
|
|
|
# 1720, 2880, etc. but beware that only 1440 and 1480 will boot
|
|
|
|
|
# from 1.44M floppy drives (1480 will not work on vmware).
|
|
|
|
|
EDITOR=${EDITOR:-vi}
|
2001-10-02 17:06:51 +00:00
|
|
|
|
fd_size=${fd_size:-1440}
|
|
|
|
|
|
|
|
|
|
o_all_in_mfs="yes" # put all files in mfs so you can boot and run
|
|
|
|
|
# the image via diskless boot.
|
|
|
|
|
o_clean="" # do not clean
|
|
|
|
|
o_interactive="" # default is interactive
|
|
|
|
|
o_verbose=0 # verbose level, 0 is silent
|
|
|
|
|
o_tarv="" # tar verbose flag, "" or "v"
|
|
|
|
|
o_init_src="" # non "" if we need to init libs and includes.
|
|
|
|
|
o_makeopts=${MAKEOPTS:--s} # make options, be silent by default
|
|
|
|
|
o_no_devfs=yes # we do not want devfs
|
2001-11-01 16:17:37 +00:00
|
|
|
|
o_do_modules="" # do not build modules
|
2001-10-02 17:06:51 +00:00
|
|
|
|
|
|
|
|
|
SRC="/usr/src" # default location for sources
|
|
|
|
|
c_startdir=`pwd` # directory where we start
|
|
|
|
|
# used to lookup config and create BUILDDIR
|
|
|
|
|
|
|
|
|
|
c_boot1=/boot/boot1 # boot blocks (in case you want custom ones)
|
|
|
|
|
c_boot2=/boot/boot2
|
|
|
|
|
|
|
|
|
|
c_reply=${c_reply:-`mktemp "/tmp/reply.XXXXXXXXXX"`}
|
|
|
|
|
# file where User replies will be put
|
|
|
|
|
c_mnt=`mktemp -d "/tmp/picobsd.XXXXXXXXXX"`
|
|
|
|
|
# mountpoint used to build memory filesystems
|
|
|
|
|
c_fs=fs.PICOBSD # filename used for the memory filesystem
|
|
|
|
|
c_img=picobsd.bin # filename used for the picobsd image
|
2001-02-20 17:09:40 +00:00
|
|
|
|
|
2001-10-02 17:06:51 +00:00
|
|
|
|
# select the right memory disk name
|
|
|
|
|
case `uname -r` in
|
|
|
|
|
5.*)
|
|
|
|
|
l_vn="md"
|
|
|
|
|
l_makedev="${SRC}/etc/MAKEDEV"
|
|
|
|
|
;;
|
|
|
|
|
*)
|
|
|
|
|
l_vn="vn"
|
|
|
|
|
l_makedev="/dev/MAKEDEV"
|
|
|
|
|
esac
|
2001-02-20 17:09:40 +00:00
|
|
|
|
# Find a suitable vnode
|
2001-10-02 17:06:51 +00:00
|
|
|
|
l_vnum=`mount | awk "/${l_vn}/ { num++ } END { printf \"%d\", num }"`
|
|
|
|
|
l_vndev=${l_vn}${l_vnum}
|
2001-02-20 17:09:40 +00:00
|
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
2001-10-02 17:06:51 +00:00
|
|
|
|
trap fail 2
|
|
|
|
|
#trap fail 3
|
|
|
|
|
#trap fail 6
|
|
|
|
|
trap fail 15
|
|
|
|
|
free_vnode # cleanup old vnodes
|
2001-02-20 17:09:40 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-07-14 09:07:13 +00:00
|
|
|
|
create_includes_and_libraries2() {
|
|
|
|
|
log "create_includes_and_libraries2() for ${SRC}"
|
|
|
|
|
MAKEOBJDIRPREFIX=${l_objtree}
|
|
|
|
|
export MAKEOBJDIRPREFIX
|
|
|
|
|
( cd ${SRC};
|
|
|
|
|
make -DNOCLEAN -DNOPROFILE -DNOGAMES -DNOLIBC_R -DPICOBSD buildworld
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
2001-10-02 17:06:51 +00:00
|
|
|
|
create_includes_and_libraries() {
|
|
|
|
|
log "create_includes_and_libraries() for ${SRC}"
|
|
|
|
|
# Optionally creates include directory and libraries.
|
|
|
|
|
mkdir -p ${l_usrtree}/include # the include directory...
|
|
|
|
|
mkdir -p ${l_usrtree}/share/misc # a few things go here
|
|
|
|
|
mkdir -p ${l_usrtree}/lib # libraries
|
|
|
|
|
mkdir -p ${l_usrtree}/sbin # some binaries
|
2002-03-22 18:36:41 +00:00
|
|
|
|
(cd ${SRC}; INCOWN=`id -un` BINOWN=`id -un` DESTDIR=${l_usrtree}/.. \
|
2001-11-24 20:22:20 +00:00
|
|
|
|
make -m ${SRC}/share/mk includes ) || fail $? includes
|
2002-03-22 18:36:41 +00:00
|
|
|
|
# Pick up the correct headers for libraries.
|
|
|
|
|
CFLAGS="-nostdinc -I${l_usrtree}/include" ; export CFLAGS
|
2001-10-02 17:06:51 +00:00
|
|
|
|
|
|
|
|
|
(cd ${SRC}
|
|
|
|
|
# $e is the invocation of make with correct environment
|
|
|
|
|
e="MAKEOBJDIRPREFIX=${l_objtree}/picobsd/libraries \
|
2002-03-22 18:36:41 +00:00
|
|
|
|
INCOWN=`id -un` BINOWN=`id -un` DESTDIR=${l_usrtree}/.. \
|
2001-11-24 20:22:20 +00:00
|
|
|
|
make -m ${SRC}/share/mk \
|
|
|
|
|
-DNOHTML -DNOINFO -DNOMAN -DNOSHARE -DNOFSCHG "
|
2002-03-11 05:54:22 +00:00
|
|
|
|
log "do a 'make obj' in a few places."
|
|
|
|
|
# This is very version-specific... The following works for 5.0
|
2001-10-02 17:06:51 +00:00
|
|
|
|
for i in lib secure/lib gnu/lib usr.sbin/pcvt/keycap \
|
|
|
|
|
gnu/usr.bin/perl usr.bin/lex usr.sbin/config ; do
|
|
|
|
|
(cd ${i}; eval $e obj)
|
|
|
|
|
done
|
2002-03-11 05:54:22 +00:00
|
|
|
|
log "now make the static libraries"
|
2001-10-02 17:06:51 +00:00
|
|
|
|
eval $e -DNOPROFILE -DNOPIC libraries
|
|
|
|
|
(cd ${SRC}/usr.sbin/config
|
|
|
|
|
eval $e # build binary
|
|
|
|
|
eval $e install # install it
|
|
|
|
|
)
|
|
|
|
|
) || fail $? "libraries"
|
|
|
|
|
log "Libraries done"
|
2001-02-20 17:09:40 +00:00
|
|
|
|
}
|
|
|
|
|
|
2001-10-02 17:06:51 +00:00
|
|
|
|
# set_type <type> looks in user or system directories for the floppy type
|
|
|
|
|
# specified as first argument, and sets variables according to the config.
|
|
|
|
|
# file. Also sets MY_TREE and BUILDDIR and SITE
|
2001-02-20 17:09:40 +00:00
|
|
|
|
|
2001-10-02 17:06:51 +00:00
|
|
|
|
set_type() {
|
|
|
|
|
local a
|
|
|
|
|
|
|
|
|
|
log "set_type()"
|
|
|
|
|
THETYPE=$1
|
|
|
|
|
SITE=$2
|
2001-02-20 17:09:40 +00:00
|
|
|
|
a=$1
|
2001-10-02 17:06:51 +00:00
|
|
|
|
for i in ${c_startdir}/${a} ${PICO_TREE}/${a} ; do
|
2001-06-20 14:16:48 +00:00
|
|
|
|
log "set_type: checking $i"
|
2001-02-20 17:09:40 +00:00
|
|
|
|
if [ -d $i -a -f $i/PICOBSD -a -f $i/crunch.conf ] ; then
|
|
|
|
|
set -- `cat $i/PICOBSD | \
|
|
|
|
|
awk '/^#PicoBSD/ {print $2, $3, $4, $5, $6}'`
|
|
|
|
|
if [ "$1" != "" ]; then
|
2001-10-02 17:06:51 +00:00
|
|
|
|
MFS_SIZE=$1 ; init_name=$2
|
|
|
|
|
mfs_inodes=$3 ; fd_inodes=$4
|
2001-02-20 17:09:40 +00:00
|
|
|
|
name=`(cd $i ; pwd) `
|
|
|
|
|
name=`basename $name`
|
|
|
|
|
MY_TREE=$i
|
2001-10-02 17:06:51 +00:00
|
|
|
|
BUILDDIR=${c_startdir}/build_dir-${name}
|
|
|
|
|
log "Matching file $name in $i"
|
2001-02-20 17:09:40 +00:00
|
|
|
|
return ;
|
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
done
|
|
|
|
|
echo "Type $a NOT FOUND"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
clean_tree() {
|
2001-10-02 17:06:51 +00:00
|
|
|
|
log "clean_tree()"
|
2001-02-20 17:09:40 +00:00
|
|
|
|
if [ "${name}" = "" ] ; then
|
2001-10-02 17:06:51 +00:00
|
|
|
|
echo "---> Wrong floppy type"
|
2001-02-20 17:09:40 +00:00
|
|
|
|
exit 3
|
|
|
|
|
fi
|
|
|
|
|
rm -rf ${BUILDDIR}
|
|
|
|
|
}
|
|
|
|
|
|
2001-09-20 02:52:02 +00:00
|
|
|
|
# free as much as possible from the vnode
|
|
|
|
|
free_vnode() {
|
2001-10-02 17:06:51 +00:00
|
|
|
|
log "free_vnode() ${l_vndev} "
|
|
|
|
|
umount ${c_mnt} 2> /dev/null || true
|
|
|
|
|
umount /dev/${l_vndev} 2> /dev/null || true
|
|
|
|
|
if [ "${l_vn}" = "vn" ] ; then
|
|
|
|
|
vnconfig -u ${l_vndev} 2> /dev/null || true
|
2001-09-20 02:52:02 +00:00
|
|
|
|
else
|
2001-10-02 17:06:51 +00:00
|
|
|
|
mdconfig -d -u ${l_vnum} 2> /dev/null || true
|
2001-09-20 02:52:02 +00:00
|
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
|
|
2001-02-20 17:09:40 +00:00
|
|
|
|
# prepare a message to be printed in the dialog menus.
|
|
|
|
|
set_msgs() { # OK
|
2001-10-02 17:06:51 +00:00
|
|
|
|
log "set_msgs()"
|
|
|
|
|
|
2001-02-20 17:09:40 +00:00
|
|
|
|
MSG1="Type: ${THETYPE} name $name"
|
|
|
|
|
|
|
|
|
|
MSG="PicoBSD build -- Current parameters:\n\n\t1. ${MSG1}\n\
|
|
|
|
|
\t2. MFS size: ${MFS_SIZE} kB\n\
|
|
|
|
|
\t3. Site-info: ${SITE}\n\t4. Full-path: ${MY_TREE}\n"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Main build procedure.
|
|
|
|
|
build_image() {
|
2001-10-02 17:06:51 +00:00
|
|
|
|
log "build_image() <${name}>"
|
|
|
|
|
[ "${name}" != "" ] || fail $? bad_type
|
2001-02-20 17:09:40 +00:00
|
|
|
|
clear
|
|
|
|
|
set_msgs
|
2001-10-02 17:06:51 +00:00
|
|
|
|
printf "${MSG}---> We'll use the sources living in ${SRC}\n\n"
|
|
|
|
|
|
|
|
|
|
# read config variables from a global and then a type-specific file
|
|
|
|
|
# basically STAND_LINKS and MY_DEVS, but can also override other
|
|
|
|
|
# variables.
|
|
|
|
|
#
|
|
|
|
|
. ${PICO_TREE}/build/config
|
|
|
|
|
if [ -f ${MY_TREE}/config ] ; then
|
|
|
|
|
. ${MY_TREE}/config
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# location of the object directory
|
|
|
|
|
PICO_OBJ=${l_objtree}/picobsd/${THETYPE}
|
|
|
|
|
log "PICO_OBJ is ${PICO_OBJ}"
|
|
|
|
|
|
2002-07-14 09:07:13 +00:00
|
|
|
|
if [ ${OSVERSION} -ge 500035 ] ; then
|
|
|
|
|
MAKEOBJDIRPREFIX=${l_objtree}
|
|
|
|
|
export MAKEOBJDIRPREFIX
|
|
|
|
|
log `cd ${SRC}; make -f Makefile.inc1 -V WMAKEENV`
|
|
|
|
|
eval export `cd ${SRC}; make -f Makefile.inc1 -V WMAKEENV`
|
|
|
|
|
fi
|
2001-10-02 17:06:51 +00:00
|
|
|
|
# create build directory and subtree
|
|
|
|
|
mkdir -p ${BUILDDIR}/crunch
|
|
|
|
|
# remove any old stuff
|
|
|
|
|
rm -f ${BUILDDIR}/kernel.gz ${BUILDDIR}/${c_fs}
|
|
|
|
|
# invoke commands to build a kernel
|
2001-02-20 17:09:40 +00:00
|
|
|
|
do_kernel
|
2001-10-02 17:06:51 +00:00
|
|
|
|
# fill a subdirectory with things that go into the floppy
|
|
|
|
|
# (mostly /etc and similar stuff)
|
|
|
|
|
populate_floppy_fs
|
|
|
|
|
# populate it and produce a file with the MFS image
|
|
|
|
|
populate_mfs_tree # things which go into mfs
|
|
|
|
|
# create, mount and fill a filesystem with floppy image
|
2001-02-20 17:09:40 +00:00
|
|
|
|
fill_floppy_image # copies everything into the floppy
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
build_package() {
|
2001-10-02 17:06:51 +00:00
|
|
|
|
local z msg
|
|
|
|
|
|
|
|
|
|
log "build_package()"
|
2001-02-20 17:09:40 +00:00
|
|
|
|
touch build.status
|
|
|
|
|
echo "##############################################" >>build.status
|
|
|
|
|
echo "## `date` ">>build.status
|
|
|
|
|
echo "##############################################" >>build.status
|
2001-05-08 20:44:37 +00:00
|
|
|
|
for z in bridge dial router net isp ; do
|
2001-02-20 17:09:40 +00:00
|
|
|
|
set_type ${z}
|
|
|
|
|
echo "---------------------------------------------">>build.status
|
|
|
|
|
echo "Building TYPE=${z}, SIZE=${MFS_SIZE}" >>build.status
|
2001-10-02 17:06:51 +00:00
|
|
|
|
msg="(ok)" # error message
|
|
|
|
|
build_image || msg="** FAILED! **"
|
|
|
|
|
echo " ${msg}">>build.status
|
|
|
|
|
# where do i put things ?
|
|
|
|
|
# clean_tree
|
2001-02-20 17:09:40 +00:00
|
|
|
|
done
|
|
|
|
|
exit 0
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Set build parameters interactively
|
|
|
|
|
|
|
|
|
|
main_dialog() {
|
2001-10-02 17:06:51 +00:00
|
|
|
|
local ans i l
|
|
|
|
|
|
|
|
|
|
log "main_dialog()"
|
2001-02-20 17:09:40 +00:00
|
|
|
|
while [ true ] ; do
|
|
|
|
|
set_msgs
|
2001-10-02 17:06:51 +00:00
|
|
|
|
rm ${c_reply}
|
|
|
|
|
dialog --menu "PicoBSD build menu -- (29 sep 2001)" 19 70 12 \
|
2001-02-20 17:09:40 +00:00
|
|
|
|
N "--> READY, build it <---" \
|
|
|
|
|
T "${MSG1}" \
|
|
|
|
|
K "edit Kernel config file" \
|
|
|
|
|
E "Edit crunch.conf file" \
|
|
|
|
|
S "MFS Size: ${MFS_SIZE}kB" \
|
2001-10-02 17:06:51 +00:00
|
|
|
|
I "Init type: ${init_name}" \
|
|
|
|
|
F "Floppy size: ${fd_size}kB" \
|
|
|
|
|
M "MFS bytes per inode: ${mfs_inodes}" \
|
|
|
|
|
U "UFS bytes per inode: ${fd_inodes}" \
|
2001-02-20 17:09:40 +00:00
|
|
|
|
$ "Site-info: ${SITE}" \
|
|
|
|
|
Q "Quit" \
|
2001-10-02 17:06:51 +00:00
|
|
|
|
2> ${c_reply}
|
|
|
|
|
ans=`cat ${c_reply}`
|
|
|
|
|
rm ${c_reply}
|
2001-02-20 17:09:40 +00:00
|
|
|
|
case ${ans} in
|
|
|
|
|
T)
|
|
|
|
|
l=""
|
2001-10-02 17:06:51 +00:00
|
|
|
|
for i in ${c_startdir} ${c_startdir}/* ${PICO_TREE}/* ; do
|
2001-02-20 17:09:40 +00:00
|
|
|
|
if [ -d $i -a -f $i/PICOBSD -a -f $i/crunch.conf ]; then
|
|
|
|
|
l="$l `basename $i` `basename $i`"
|
|
|
|
|
fi
|
|
|
|
|
done
|
|
|
|
|
log $l
|
2002-02-14 19:21:50 +00:00
|
|
|
|
{ dialog --menu "Setup the type of configuration" 12 70 5 $l \
|
|
|
|
|
2> ${c_reply} && set_type "`cat ${c_reply}`" ${SITE} ; } || true
|
2001-02-20 17:09:40 +00:00
|
|
|
|
;;
|
|
|
|
|
I)
|
2002-02-14 19:21:50 +00:00
|
|
|
|
{ dialog --menu "Choose your init(8) program" \
|
2001-02-20 17:09:40 +00:00
|
|
|
|
10 70 2 init "Standard init (requires getty)" \
|
2001-10-02 17:06:51 +00:00
|
|
|
|
oinit "small init from TinyWare" 2> ${c_reply} \
|
2002-02-14 19:21:50 +00:00
|
|
|
|
&& init_name=`cat ${c_reply}` ; } || true
|
2001-02-20 17:09:40 +00:00
|
|
|
|
;;
|
|
|
|
|
|
|
|
|
|
K) ${EDITOR} ${MY_TREE}/PICOBSD ;;
|
|
|
|
|
|
|
|
|
|
E) ${EDITOR} ${MY_TREE}/crunch.conf ;;
|
|
|
|
|
|
|
|
|
|
S)
|
2002-02-14 19:21:50 +00:00
|
|
|
|
{ dialog --title "MFS Size setup" --inputbox \
|
2001-02-20 17:09:40 +00:00
|
|
|
|
"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 \
|
2001-10-02 17:06:51 +00:00
|
|
|
|
this as small as possible. " 10 70 2> ${c_reply} \
|
2002-02-14 19:21:50 +00:00
|
|
|
|
&& MFS_SIZE=`cat ${c_reply}` ; } || true
|
2001-02-20 17:09:40 +00:00
|
|
|
|
;;
|
|
|
|
|
|
|
|
|
|
\$)
|
2002-02-14 19:21:50 +00:00
|
|
|
|
{ dialog --title "Site info setup" --inputbox \
|
2001-02-20 17:09:40 +00:00
|
|
|
|
"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/ . " \
|
2002-02-14 19:21:50 +00:00
|
|
|
|
10 70 2> ${c_reply} && SITE=`cat ${c_reply}` ; } || true
|
2001-02-20 17:09:40 +00:00
|
|
|
|
;;
|
|
|
|
|
|
|
|
|
|
F)
|
2002-03-08 02:24:21 +00:00
|
|
|
|
{ dialog --menu "Set floppy size" 15 70 4 \
|
2001-10-02 17:06:51 +00:00
|
|
|
|
1440 "1.44MB" 1720 "1.72MB" 2880 "2.88MB" 4096 "4MB" \
|
2002-03-08 02:24:21 +00:00
|
|
|
|
2> ${c_reply} && fd_size=`cat ${c_reply}` ; } || true
|
2001-02-20 17:09:40 +00:00
|
|
|
|
;;
|
|
|
|
|
|
|
|
|
|
M)
|
2002-03-08 02:24:21 +00:00
|
|
|
|
{ dialog --title "MFS bytes per inode:" --inputbox \
|
2001-02-20 17:09:40 +00:00
|
|
|
|
"Enter MFS bytes per inode (typically 4096..65536). \
|
|
|
|
|
A larger value means fewer inodes but more space on MFS" \
|
2002-03-11 05:54:22 +00:00
|
|
|
|
10 70 2> ${c_reply} && mfs_inodes=`cat ${c_reply}` ; } || true
|
2001-02-20 17:09:40 +00:00
|
|
|
|
;;
|
|
|
|
|
|
|
|
|
|
U)
|
2002-03-08 02:24:21 +00:00
|
|
|
|
{ dialog --title "Floppy bytes per inode:" --inputbox \
|
2001-02-20 17:09:40 +00:00
|
|
|
|
"Enter floppy bytes per inode (typically 3072..65536). \
|
|
|
|
|
A larger value means fewer inodes but more space on the floppy." \
|
2002-03-08 02:24:21 +00:00
|
|
|
|
10 70 2> ${c_reply} && fd_inodes=`cat ${c_reply}` ; } || true
|
2001-02-20 17:09:40 +00:00
|
|
|
|
;;
|
|
|
|
|
|
|
|
|
|
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() {
|
2001-10-02 17:06:51 +00:00
|
|
|
|
log "do_install()"
|
|
|
|
|
|
2001-11-01 16:17:37 +00:00
|
|
|
|
if [ "${o_interactive}" = "NO" ] ; then
|
|
|
|
|
echo "+++ Build completed +++"
|
|
|
|
|
cat .build.reply
|
|
|
|
|
return
|
|
|
|
|
fi
|
2001-09-01 18:27:39 +00:00
|
|
|
|
dialog --title "Build ${THETYPE} completed" --inputbox \
|
2001-02-20 17:09:40 +00:00
|
|
|
|
"\nThe build process was completed successfuly.\n\
|
|
|
|
|
`cat .build.reply` \n\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\
|
2001-10-02 17:06:51 +00:00
|
|
|
|
* Enter to install ${c_img},\n\
|
|
|
|
|
" 20 80 2> ${c_reply}
|
2001-02-20 17:09:40 +00:00
|
|
|
|
if [ "$?" = "0" ]; then
|
2001-10-02 17:06:51 +00:00
|
|
|
|
echo "Writing ${c_img}..."
|
|
|
|
|
dd if=${BUILDDIR}/${c_img} of=/dev/fd0.${fd_size}
|
2001-02-20 17:09:40 +00:00
|
|
|
|
else
|
2001-10-02 17:06:51 +00:00
|
|
|
|
echo "Ok, the image is in ${c_img}"
|
2001-02-20 17:09:40 +00:00
|
|
|
|
fi
|
|
|
|
|
echo "Done."
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------
|
|
|
|
|
|
2001-10-02 17:06:51 +00:00
|
|
|
|
# invoke the Makefile to compile the kernel.
|
2001-02-20 17:09:40 +00:00
|
|
|
|
do_kernel() { # OK
|
2001-10-02 17:06:51 +00:00
|
|
|
|
log "do_kernel() Preparing kernel \"$name\" in $MY_TREE"
|
2002-07-14 09:07:13 +00:00
|
|
|
|
(cd $MY_TREE; export name SRC BUILDDIR # used in this makefile ;
|
|
|
|
|
# export CONFIG
|
2001-11-01 16:17:37 +00:00
|
|
|
|
if [ "${o_do_modules}" = "yes" ] ; then
|
|
|
|
|
MODULES=""
|
|
|
|
|
export MODULES
|
|
|
|
|
fi
|
2001-11-24 20:22:20 +00:00
|
|
|
|
make -m ${SRC}/share/mk -v -f ${PICO_TREE}/build/Makefile.conf ) || \
|
2001-02-20 17:09:40 +00:00
|
|
|
|
fail $? missing_kernel
|
|
|
|
|
}
|
|
|
|
|
|
2001-10-02 17:06:51 +00:00
|
|
|
|
# Populate the variable part of the floppy filesystem. Must be done before
|
|
|
|
|
# the MFS because its content might need to be copied there as well.
|
2001-02-20 17:09:40 +00:00
|
|
|
|
#
|
2001-10-02 17:06:51 +00:00
|
|
|
|
# This involves fetching files from three subtrees, in this order:
|
2001-02-20 17:09:40 +00:00
|
|
|
|
#
|
2001-10-02 17:06:51 +00:00
|
|
|
|
# 1. a standard one, from which type-specific files are excluded;
|
2001-02-20 17:09:40 +00:00
|
|
|
|
# 2. a type-specific one;
|
|
|
|
|
# 3. a site-specific one.
|
|
|
|
|
#
|
|
|
|
|
# Files are first copied to a local tree and then compressed.
|
|
|
|
|
|
|
|
|
|
populate_floppy_fs() { # OK
|
2001-09-20 02:52:02 +00:00
|
|
|
|
local dst excl srcdir
|
2001-02-20 17:09:40 +00:00
|
|
|
|
|
2001-10-02 17:06:51 +00:00
|
|
|
|
log "populate_floppy_fs()"
|
2001-02-20 17:09:40 +00:00
|
|
|
|
dst=${BUILDDIR}/floppy.tree
|
2001-10-02 17:06:51 +00:00
|
|
|
|
log "pwd=`pwd` Populating floppy filesystem..."
|
2001-02-20 17:09:40 +00:00
|
|
|
|
|
2001-09-20 02:52:02 +00:00
|
|
|
|
# clean relics from old compilations.
|
|
|
|
|
rm -rf ${dst} || true
|
|
|
|
|
mkdir ${dst}
|
2001-02-20 17:09:40 +00:00
|
|
|
|
|
|
|
|
|
excl=${MY_TREE}/floppy.tree.exclude
|
|
|
|
|
if [ -f ${excl} ] ; then
|
|
|
|
|
excl="--exclude-from ${excl}"
|
2001-10-02 17:06:51 +00:00
|
|
|
|
log "Files excluded from generic tree: `echo;cat ${excl}`"
|
2001-02-20 17:09:40 +00:00
|
|
|
|
else
|
|
|
|
|
excl=""
|
|
|
|
|
fi
|
|
|
|
|
(cd ${PICO_TREE}/floppy.tree ; tar -cf - --exclude CVS ${excl} . ) | \
|
2001-10-02 17:06:51 +00:00
|
|
|
|
(cd ${dst} ; tar x${o_tarv}f - )
|
|
|
|
|
log "Copied from generic floppy-tree `echo; ls -laR ${dst}`"
|
2001-02-20 17:09:40 +00:00
|
|
|
|
|
|
|
|
|
srcdir=${MY_TREE}/floppy.tree
|
|
|
|
|
if [ -d ${srcdir} ] ; then
|
2001-10-02 17:06:51 +00:00
|
|
|
|
log "update with type-specific files:"
|
2001-02-20 17:09:40 +00:00
|
|
|
|
(cd ${srcdir} ; tar -cf - --exclude CVS . ) | \
|
2001-10-02 17:06:51 +00:00
|
|
|
|
(cd ${dst} ; tar x${o_tarv}f - )
|
|
|
|
|
log "Copied from type floppy-tree `echo; ls -laR ${dst}`"
|
2001-02-20 17:09:40 +00:00
|
|
|
|
else
|
2001-10-02 17:06:51 +00:00
|
|
|
|
log "No type-specific floppy-tree"
|
2001-02-20 17:09:40 +00:00
|
|
|
|
fi
|
|
|
|
|
if [ -d ${srcdir}.${SITE} ] ; then
|
2001-10-02 17:06:51 +00:00
|
|
|
|
log "Update with site-specific (${SITE}) files:"
|
2001-02-20 17:09:40 +00:00
|
|
|
|
(cd ${srcdir}.${SITE} ; tar -cf - --exclude CVS . ) | \
|
2001-10-02 17:06:51 +00:00
|
|
|
|
(cd ${dst} ; tar x${o_tarv}f - )
|
|
|
|
|
log "Copied from site floppy-tree `echo; ls -laR ${dst}`"
|
2001-02-20 17:09:40 +00:00
|
|
|
|
else
|
2001-10-02 17:06:51 +00:00
|
|
|
|
log "No site-specific floppy-tree"
|
2001-02-20 17:09:40 +00:00
|
|
|
|
fi
|
2002-03-11 05:54:22 +00:00
|
|
|
|
|
2001-02-20 17:09:40 +00:00
|
|
|
|
# gzip returns an error if it fails to compress some file
|
2001-10-02 17:06:51 +00:00
|
|
|
|
(cd $dst ; gzip -9 etc/*
|
|
|
|
|
log "Compressed files in etc/ `echo; ls -l etc`"
|
2001-02-20 17:09:40 +00:00
|
|
|
|
) || true
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
create_mfs() { # OK
|
2001-10-02 17:06:51 +00:00
|
|
|
|
log "create_mfs() Preparing MFS filesystem..."
|
2001-02-20 17:09:40 +00:00
|
|
|
|
|
|
|
|
|
free_vnode
|
|
|
|
|
|
|
|
|
|
# zero-fill the MFS image
|
2001-10-02 17:06:51 +00:00
|
|
|
|
init_fs_image ${BUILDDIR}/${c_fs} ${MFS_SIZE}
|
2001-02-20 17:09:40 +00:00
|
|
|
|
|
2001-10-02 17:06:51 +00:00
|
|
|
|
log "Labeling MFS image"
|
2001-02-20 17:09:40 +00:00
|
|
|
|
# Disklabel "auto" behaves strangely for sizes < 1024K. Basically
|
|
|
|
|
# it fails to install a label on the system. On the other hand,
|
|
|
|
|
# if you provide a specific disk type, the boot code is not
|
|
|
|
|
# installed so you have more space on the disk...
|
|
|
|
|
# For small image sizes, use std disktypes
|
|
|
|
|
if [ ${MFS_SIZE} -lt 1024 ] ; then
|
2001-10-02 17:06:51 +00:00
|
|
|
|
disklabel -rw ${l_vndev} fd${MFS_SIZE} || fail $? mfs_disklabel
|
2001-02-20 17:09:40 +00:00
|
|
|
|
else
|
2001-10-02 17:06:51 +00:00
|
|
|
|
disklabel -rw ${l_vndev} auto || fail $? mfs_disklabel
|
2001-02-20 17:09:40 +00:00
|
|
|
|
fi
|
2002-03-08 02:24:21 +00:00
|
|
|
|
newfs -i ${mfs_inodes} -m 0 -p 0 -o space -f 512 -b 4096 \
|
|
|
|
|
/dev/${l_vndev}c > /dev/null
|
2001-10-02 17:06:51 +00:00
|
|
|
|
mount /dev/${l_vndev}c ${c_mnt} || fail $? no_mount
|
|
|
|
|
log "`df /dev/${l_vndev}c`"
|
2001-02-20 17:09:40 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Populate the memory filesystem with binaries and non-variable
|
|
|
|
|
# configuration files.
|
|
|
|
|
# First do an mtree pass, then create directory links and device entries,
|
|
|
|
|
# then run crunchgen etc. to build the binary and create links.
|
|
|
|
|
# Then copy the specific/generic mfs_tree.
|
|
|
|
|
# Finally, if required, make a copy of the floppy.tree onto /fd
|
|
|
|
|
|
2001-10-02 17:06:51 +00:00
|
|
|
|
populate_mfs_tree() {
|
|
|
|
|
local a dst
|
2001-02-20 17:09:40 +00:00
|
|
|
|
|
2001-10-02 17:06:51 +00:00
|
|
|
|
log "populate_mfs_tree()"
|
|
|
|
|
early_mfs_mount=0
|
|
|
|
|
if [ "${early_mfs_mount}" = "1" ] ; then
|
|
|
|
|
create_mfs
|
|
|
|
|
dst=${c_mnt}
|
2001-02-20 17:09:40 +00:00
|
|
|
|
else
|
2001-10-02 17:06:51 +00:00
|
|
|
|
dst=${BUILDDIR}/mfs.tree
|
|
|
|
|
# clean relics from old compilations.
|
|
|
|
|
rm -rf ${dst} || true
|
|
|
|
|
mkdir ${dst}
|
2001-02-20 17:09:40 +00:00
|
|
|
|
fi
|
2001-10-02 17:06:51 +00:00
|
|
|
|
|
|
|
|
|
log "pwd=`pwd`, Populating MFS tree..."
|
|
|
|
|
|
|
|
|
|
# use type-specific mfs.mtree, default to generic one.
|
|
|
|
|
a=${MY_TREE}/mfs.mtree
|
|
|
|
|
[ -f ${a} ] || a=${PICO_TREE}/build/mfs.mtree
|
|
|
|
|
log "Running mtree using $a..."
|
|
|
|
|
mtree -deU -f $a -p ${dst} > /dev/null || fail $? mtree
|
2001-02-20 17:09:40 +00:00
|
|
|
|
|
|
|
|
|
# XXX create links
|
|
|
|
|
for i in ${STAND_LINKS}; do
|
2001-10-02 17:06:51 +00:00
|
|
|
|
ln -s /stand ${dst}/$i
|
2001-02-20 17:09:40 +00:00
|
|
|
|
done
|
2001-10-02 17:06:51 +00:00
|
|
|
|
ln -s /dev/null ${dst}/var/run/log
|
|
|
|
|
ln -s /etc/termcap ${dst}/usr/share/misc/termcap
|
2001-02-20 17:09:40 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(
|
|
|
|
|
cd ${BUILDDIR}/crunch
|
2001-10-02 17:06:51 +00:00
|
|
|
|
log "Making and installing crunch1 from `pwd` src ${SRC}..."
|
2001-02-20 17:09:40 +00:00
|
|
|
|
a=${BUILDDIR}/crunch1.conf
|
2001-06-21 08:49:46 +00:00
|
|
|
|
( export BUILDDIR SRC MY_TREE PICO_OBJ ;
|
2001-11-24 20:22:20 +00:00
|
|
|
|
make -m ${SRC}/share/mk \
|
|
|
|
|
-v -f ${PICO_TREE}/build/Makefile.conf ${BUILDDIR}/crunch.mk )
|
2001-10-02 17:06:51 +00:00
|
|
|
|
log "Libs are ${LIBS} "
|
2002-07-14 09:07:13 +00:00
|
|
|
|
export SRC # used by crunch.mk
|
|
|
|
|
# export LIBS CFLAGS
|
2001-02-20 17:09:40 +00:00
|
|
|
|
log "Now make -f crunch.mk"
|
2001-11-24 20:22:20 +00:00
|
|
|
|
make -m ${SRC}/share/mk ${o_makeopts} -f ${BUILDDIR}/crunch.mk
|
2001-02-20 17:09:40 +00:00
|
|
|
|
strip --remove-section=.note --remove-section=.comment crunch1
|
2001-10-02 17:06:51 +00:00
|
|
|
|
mv crunch1 ${dst}/stand/crunch
|
|
|
|
|
chmod 555 ${dst}/stand/crunch
|
|
|
|
|
log "Making links for binaries..."
|
2001-02-20 17:09:40 +00:00
|
|
|
|
for i in `crunchgen -l $a` ; do
|
2001-10-02 17:06:51 +00:00
|
|
|
|
ln ${dst}/stand/crunch ${dst}/stand/${i};
|
2001-02-20 17:09:40 +00:00
|
|
|
|
done
|
2001-06-21 08:49:46 +00:00
|
|
|
|
# rm $a # do not remove!
|
2001-02-20 17:09:40 +00:00
|
|
|
|
) || fail $? crunch
|
|
|
|
|
|
2001-10-02 17:06:51 +00:00
|
|
|
|
if [ -f ${dst}/stand/sshd ] ; then
|
2002-03-11 05:54:22 +00:00
|
|
|
|
log "Setting up host key for sshd:"
|
|
|
|
|
if [ -f ${BUILDDIR}/floppy.tree/etc/ssh_host_key.gz ] ; then
|
2001-10-07 17:22:46 +00:00
|
|
|
|
log "Using existing host key"
|
|
|
|
|
else
|
2002-03-11 05:54:22 +00:00
|
|
|
|
log "Generating new host key"
|
|
|
|
|
ssh-keygen -f ${BUILDDIR}/floppy.tree/etc/ssh_host_key \
|
|
|
|
|
-N "" -C "root@picobsd"
|
|
|
|
|
gzip -9 ${BUILDDIR}/floppy.tree/etc/ssh_host_key* || true
|
2001-10-07 17:22:46 +00:00
|
|
|
|
fi
|
2001-02-20 17:09:40 +00:00
|
|
|
|
fi
|
|
|
|
|
|
2002-03-08 02:24:21 +00:00
|
|
|
|
log "Copy generic and site-specific MFS tree..."
|
|
|
|
|
for MFS_TREE in ${PICO_TREE}/mfs_tree ${MY_TREE}/mfs_tree ; do
|
|
|
|
|
if [ -d ${MFS_TREE} ] ; then
|
|
|
|
|
log "Copy ${MFS_TREE} ..."
|
|
|
|
|
(cd ${MFS_TREE} ; tar -cf - --exclude CVS . ) | \
|
2002-03-11 05:54:22 +00:00
|
|
|
|
(cd ${dst} ; tar x${o_tarv}f - )
|
2002-03-08 02:24:21 +00:00
|
|
|
|
fi
|
|
|
|
|
done
|
2001-10-02 17:06:51 +00:00
|
|
|
|
|
|
|
|
|
if [ "${o_all_in_mfs}" = "yes" ]; then
|
|
|
|
|
log "Copy generic floppy_tree into MFS..."
|
|
|
|
|
cp -Rp ${BUILDDIR}/floppy.tree/* ${dst}/fd
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
[ "`id -u`" = "0" ] || cat <<__EOF
|
|
|
|
|
|
|
|
|
|
### -------------------------------------------------------------------
|
|
|
|
|
###
|
|
|
|
|
### WARNING: You are not running with root permissions, so the next
|
|
|
|
|
### stages are likely to fail because they call commands such as
|
|
|
|
|
### chown, {vn|md}config, mount/umount which need adequate rights.
|
|
|
|
|
###
|
|
|
|
|
### The results of the compilation so far is in directory
|
|
|
|
|
### ${BUILDDIR}
|
|
|
|
|
### which has the following content:
|
|
|
|
|
|
|
|
|
|
`ls -l ${BUILDDIR}`
|
|
|
|
|
|
|
|
|
|
###
|
|
|
|
|
### -------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
__EOF
|
|
|
|
|
|
|
|
|
|
if [ "${o_no_devfs}" != "" ] ; then
|
|
|
|
|
# create device entries using MAKEDEV
|
|
|
|
|
(cd ${dst}/dev
|
|
|
|
|
ln -s ${l_makedev} ; chmod 555 MAKEDEV
|
|
|
|
|
./MAKEDEV ${MY_DEVS}
|
|
|
|
|
rm MAKEDEV
|
|
|
|
|
)
|
|
|
|
|
fi
|
|
|
|
|
log "Fixing permissions"
|
|
|
|
|
(cd ${dst}; chown -R root . )
|
2001-02-20 17:09:40 +00:00
|
|
|
|
|
2002-03-21 03:15:06 +00:00
|
|
|
|
if [ -n "${import_files}" ] ; then
|
|
|
|
|
log "importing ${import_files} into mfs"
|
|
|
|
|
# We do it in a chroot environment on the target so
|
|
|
|
|
# symlinks are followed correctly.
|
|
|
|
|
cp `which tar` ${dst}/my_copy_of_tar
|
|
|
|
|
(cd ${l_usrtree}/.. ; tar cf - ${import_files} ) | \
|
|
|
|
|
(chroot ${dst} /my_copy_of_tar xf - )
|
|
|
|
|
rm ${dst}/my_copy_of_tar
|
|
|
|
|
fi
|
|
|
|
|
|
2001-10-02 17:06:51 +00:00
|
|
|
|
if [ "${early_mfs_mount}" != "1" ] ; then
|
|
|
|
|
create_mfs
|
|
|
|
|
log "Copy mfs tree into file"
|
|
|
|
|
(cd ${dst} ; tar cf - . ) | ( cd ${c_mnt} ; tar xf - )
|
2001-02-20 17:09:40 +00:00
|
|
|
|
fi
|
2001-10-02 17:06:51 +00:00
|
|
|
|
# now umount and fsck the filesystem.
|
|
|
|
|
log "Status of mfs image"
|
|
|
|
|
df -ik ${c_mnt}
|
|
|
|
|
umount ${c_mnt}
|
|
|
|
|
fsck -p /dev/${l_vndev}c
|
2001-09-20 02:52:02 +00:00
|
|
|
|
free_vnode
|
2001-02-20 17:09:40 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
final_cleanup() {
|
2001-10-02 17:06:51 +00:00
|
|
|
|
log "final_cleanup()"
|
2001-02-20 17:09:40 +00:00
|
|
|
|
free_vnode
|
2001-10-02 17:06:51 +00:00
|
|
|
|
rm -rf ${c_mnt} ${c_reply} 2> /dev/null || true
|
|
|
|
|
rm -f ${c_reply}
|
2001-02-20 17:09:40 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# fail errno errcode
|
|
|
|
|
# This function is used to trap errors and print msgs
|
|
|
|
|
#
|
|
|
|
|
fail() {
|
2001-10-02 17:06:51 +00:00
|
|
|
|
local errno errocode where
|
|
|
|
|
|
2001-02-20 17:09:40 +00:00
|
|
|
|
errno=$1
|
|
|
|
|
errcode=$2
|
2001-10-02 17:06:51 +00:00
|
|
|
|
where=$3
|
|
|
|
|
echo "---> fail: Error <${errno}> error code <${errcode}> in <${where}>"
|
|
|
|
|
case ${errcode} in
|
2001-02-20 17:09:40 +00:00
|
|
|
|
no_vnconfig)
|
2001-10-02 17:06:51 +00:00
|
|
|
|
echo "Error in vnconfig on /dev/${l_vndev}..."
|
|
|
|
|
echo "Either you are not running as root or your running kernel"
|
|
|
|
|
echo "does not have the ${l_vn}(4) device."
|
2001-02-20 17:09:40 +00:00
|
|
|
|
;;
|
|
|
|
|
mfs_disklabel)
|
2001-10-02 17:06:51 +00:00
|
|
|
|
echo "Error while labeling ${c_fs} size ${MFS_SIZE}"
|
2001-02-20 17:09:40 +00:00
|
|
|
|
;;
|
|
|
|
|
no_mount)
|
2001-10-02 17:06:51 +00:00
|
|
|
|
echo "Error while mounting ${c_fs} (/dev/${l_vndev}c) on ${c_mnt}"
|
2001-02-20 17:09:40 +00:00
|
|
|
|
;;
|
|
|
|
|
mtree)
|
2001-10-02 17:06:51 +00:00
|
|
|
|
echo "Error while making hierarchy in ${c_mnt}"
|
2001-02-20 17:09:40 +00:00
|
|
|
|
;;
|
|
|
|
|
crunch)
|
|
|
|
|
echo "Error while building ${name}."
|
|
|
|
|
;;
|
|
|
|
|
floppy_disklabel)
|
2001-10-02 17:06:51 +00:00
|
|
|
|
echo "Error while doing disklabel on of floppy.img size $fd_size"
|
2001-02-20 17:09:40 +00:00
|
|
|
|
;;
|
|
|
|
|
missing_kernel)
|
2001-04-23 19:52:13 +00:00
|
|
|
|
echo "Error: you must build PICOBSD${suffix} kernel first"
|
2001-02-20 17:09:40 +00:00
|
|
|
|
;;
|
2001-09-04 02:01:52 +00:00
|
|
|
|
includes)
|
|
|
|
|
echo "Error: failed while making includes"
|
|
|
|
|
;;
|
|
|
|
|
libraries)
|
|
|
|
|
echo "Error: failed while making libraries"
|
|
|
|
|
;;
|
2001-10-02 17:06:51 +00:00
|
|
|
|
bad_type)
|
|
|
|
|
echo "Error: unknown floppy type ${name}"
|
|
|
|
|
;;
|
|
|
|
|
no_space)
|
|
|
|
|
echo "Error: no space left on device (${where})"
|
|
|
|
|
;;
|
2002-03-21 03:15:06 +00:00
|
|
|
|
no_mfs)
|
|
|
|
|
echo "Error: while writing MFS into the kernel."
|
|
|
|
|
;;
|
2001-02-20 17:09:40 +00:00
|
|
|
|
"")
|
|
|
|
|
echo "User break"
|
2001-10-02 17:06:51 +00:00
|
|
|
|
errcode="userbreak"
|
2001-02-20 17:09:40 +00:00
|
|
|
|
;;
|
|
|
|
|
*)
|
|
|
|
|
echo "unknown error, maybe user break: $errno $errcode"
|
|
|
|
|
;;
|
|
|
|
|
esac
|
|
|
|
|
echo "---> Aborting $0"
|
|
|
|
|
# try to cleanup the vnode.
|
|
|
|
|
final_cleanup
|
|
|
|
|
exit 2
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
# Create a zero-filled disk image with a boot sector, and vnconfig it.
|
|
|
|
|
#
|
|
|
|
|
|
|
|
|
|
init_fs_image() { # filename size_in_kbytes
|
2001-10-02 17:06:51 +00:00
|
|
|
|
local imgname imgsize
|
|
|
|
|
|
|
|
|
|
log "init_fs_image() $1 $2"
|
2001-02-20 17:09:40 +00:00
|
|
|
|
imgname=$1 ; imgsize=$2
|
|
|
|
|
dd if=/dev/zero of=${imgname} count=${imgsize} bs=1k 2> /dev/null
|
2001-10-02 17:06:51 +00:00
|
|
|
|
dd if=${c_boot1} of=${imgname} conv=notrunc 2> /dev/null
|
2001-02-20 17:09:40 +00:00
|
|
|
|
|
2001-10-02 17:06:51 +00:00
|
|
|
|
if [ "${l_vn}" = "vn" ] ; then
|
|
|
|
|
vnconfig -c -s labels ${l_vndev} ${imgname} || fail $? no_vnconfig
|
2001-09-20 02:52:02 +00:00
|
|
|
|
else
|
2001-10-02 17:06:51 +00:00
|
|
|
|
mdconfig -a -t vnode -u ${l_vnum} -f ${imgname} || fail $? no_vnconfig
|
2001-09-20 02:52:02 +00:00
|
|
|
|
fi
|
2001-02-20 17:09:40 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fill_floppy_image() {
|
2001-10-02 17:06:51 +00:00
|
|
|
|
local blocks sectors dst
|
|
|
|
|
|
|
|
|
|
log "fill_floppy_image()"
|
|
|
|
|
dst=${c_mnt} # where to create the image
|
|
|
|
|
|
|
|
|
|
log "Preparing ${fd_size}kB floppy filesystem..."
|
2001-02-20 17:09:40 +00:00
|
|
|
|
|
|
|
|
|
# correct block and number of sectors according to size.
|
2001-10-02 17:06:51 +00:00
|
|
|
|
blocks=${fd_size}; sectors=18
|
2001-02-20 17:09:40 +00:00
|
|
|
|
if [ "${blocks}" = "1720" ]; then
|
|
|
|
|
blocks=1722 ; sectors=21
|
|
|
|
|
elif [ "${blocks}" = "1480" ]; then
|
|
|
|
|
blocks=1476 ;
|
|
|
|
|
fi
|
|
|
|
|
|
2001-10-02 17:06:51 +00:00
|
|
|
|
init_fs_image ${BUILDDIR}/${c_img} ${blocks}
|
2001-02-20 17:09:40 +00:00
|
|
|
|
|
2001-10-02 17:06:51 +00:00
|
|
|
|
log "Labeling floppy image"
|
2001-05-11 07:39:40 +00:00
|
|
|
|
b2=${BUILDDIR}/boot2 # modified boot2
|
2001-10-02 17:06:51 +00:00
|
|
|
|
perl -pne 's/\/boot\/loader/\/kernel\0\0\0\0\0/' ${c_boot2} > ${b2}
|
2002-03-08 02:24:21 +00:00
|
|
|
|
|
|
|
|
|
# create a disklabel ...
|
|
|
|
|
disklabel -Brw -b ${c_boot1} -s ${b2} ${l_vndev} auto || \
|
2001-02-20 17:09:40 +00:00
|
|
|
|
fail $? floppy_disklabel
|
|
|
|
|
|
2002-03-08 02:24:21 +00:00
|
|
|
|
# and copy partition c: into partition a: using some sed magic
|
|
|
|
|
disklabel ${l_vndev} | sed -e '/ c:/{p;s/c:/a:/;}' | \
|
|
|
|
|
disklabel -R ${l_vndev} /dev/stdin
|
|
|
|
|
|
2001-10-02 17:06:51 +00:00
|
|
|
|
log "Newfs floppy image"
|
2002-03-08 02:24:21 +00:00
|
|
|
|
newfs -i ${fd_inodes} -m 0 -p 0 -o space -f 512 -b 4096 \
|
2002-03-11 05:54:22 +00:00
|
|
|
|
/dev/${l_vndev}a > /dev/null
|
2001-02-20 17:09:40 +00:00
|
|
|
|
|
2001-10-02 17:06:51 +00:00
|
|
|
|
log "Mounting floppy image"
|
2002-03-08 02:24:21 +00:00
|
|
|
|
mount /dev/${l_vndev}a ${dst}
|
2001-02-20 17:09:40 +00:00
|
|
|
|
|
|
|
|
|
(
|
|
|
|
|
cd ${BUILDDIR}
|
2002-07-14 09:07:13 +00:00
|
|
|
|
# $1 takes the offset of the MFS filesystem
|
|
|
|
|
set `strings -at d kernel | grep "MFS Filesystem goes here"`
|
|
|
|
|
mfs_ofs=$(($1 + 8192))
|
|
|
|
|
log "Preload kernel with file ${c_fs} at ${mfs_ofs}"
|
|
|
|
|
dd if=${c_fs} ibs=8192 iseek=1 of=kernel obs=${mfs_ofs} \
|
|
|
|
|
oseek=1 conv=notrunc
|
2001-10-02 17:06:51 +00:00
|
|
|
|
log "Compress with kgzip and copy to floppy image"
|
2001-02-20 17:09:40 +00:00
|
|
|
|
kgzip -o kernel.gz kernel
|
2001-10-02 17:06:51 +00:00
|
|
|
|
cp -p kernel.gz ${dst}/kernel || fail $? no_space "copying kernel"
|
2001-02-20 17:09:40 +00:00
|
|
|
|
|
2001-10-02 17:06:51 +00:00
|
|
|
|
log "now transfer floppy tree if needed"
|
2001-02-20 17:09:40 +00:00
|
|
|
|
# now transfer the floppy tree. If it is already in mfs, dont bother.
|
2001-10-02 17:06:51 +00:00
|
|
|
|
if [ "${o_all_in_mfs}" != "yes" ] ; then
|
|
|
|
|
cp -Rp floppy.tree/* ${dst} || \
|
|
|
|
|
fail $? no_space "copying floppy tree"
|
2001-02-20 17:09:40 +00:00
|
|
|
|
fi
|
|
|
|
|
)
|
2001-10-02 17:06:51 +00:00
|
|
|
|
(log "Fixing permissions"; cd ${dst}; chown -R root *)
|
2002-03-11 05:54:22 +00:00
|
|
|
|
# rm -rf ${BUILDDIR}/floppy.tree || true # cleanup
|
2001-02-20 17:09:40 +00:00
|
|
|
|
|
2001-10-02 17:06:51 +00:00
|
|
|
|
df -ik ${dst} | colrm 70 > .build.reply
|
2001-02-20 17:09:40 +00:00
|
|
|
|
free_vnode
|
2001-10-02 17:06:51 +00:00
|
|
|
|
rm -rf ${dst}
|
|
|
|
|
rm ${BUILDDIR}/kernel.gz ${BUILDDIR}/${c_fs}
|
2001-02-20 17:09:40 +00:00
|
|
|
|
}
|
|
|
|
|
|
2001-10-02 17:06:51 +00:00
|
|
|
|
# This function creates variables which depend on the source tree in use:
|
2002-07-14 09:07:13 +00:00
|
|
|
|
# SRC, l_usrtree, l_objtree
|
2001-10-02 17:06:51 +00:00
|
|
|
|
# Optionally creates libraries, includes and the like (for cross compiles,
|
|
|
|
|
# needs to be done once).
|
|
|
|
|
|
|
|
|
|
set_build_parameters() {
|
|
|
|
|
log "set_build_parameters() SRC is ${SRC}"
|
|
|
|
|
if [ "${SRC}" = "/usr/src" ] ; then
|
|
|
|
|
l_usrtree=${USR:-/usr}
|
|
|
|
|
else
|
|
|
|
|
l_usrtree=${USR:-${SRC}/../usr}
|
2001-09-28 21:02:15 +00:00
|
|
|
|
fi
|
2001-10-02 17:06:51 +00:00
|
|
|
|
l_objtree=${l_usrtree}/obj-pico
|
|
|
|
|
PICO_TREE=${PICO_TREE:-${SRC}/release/picobsd}
|
2002-07-14 09:07:13 +00:00
|
|
|
|
set `grep "#define[\t ]__FreeBSD_version" ${SRC}/sys/sys/param.h`
|
|
|
|
|
OSVERSION=$3
|
2002-07-14 12:07:06 +00:00
|
|
|
|
log "OSVERSION is ${OSVERSION}"
|
2001-10-02 17:06:51 +00:00
|
|
|
|
if [ "${o_init_src}" != "" ] ; then
|
2002-07-14 09:07:13 +00:00
|
|
|
|
if [ ${OSVERSION} -lt 500035 ] ; then
|
|
|
|
|
create_includes_and_libraries
|
|
|
|
|
else
|
|
|
|
|
create_includes_and_libraries2
|
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
if [ ${OSVERSION} -lt 500035 ] ; then
|
|
|
|
|
# Create the right LIBS and CFLAGS for further builds.
|
|
|
|
|
# and build the config program
|
|
|
|
|
LIBS="-L${l_usrtree}/lib"
|
|
|
|
|
CFLAGS="-nostdinc -I${l_usrtree}/include"
|
|
|
|
|
export LIBS CFLAGS
|
|
|
|
|
CONFIG=${l_usrtree}/sbin/config
|
|
|
|
|
export CONFIG
|
2001-09-28 21:02:15 +00:00
|
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------
|
2001-10-02 17:06:51 +00:00
|
|
|
|
# Main entry of the script. Initialize variables, parse command line
|
|
|
|
|
# arguments.
|
|
|
|
|
|
|
|
|
|
set_defaults
|
2001-02-20 17:09:40 +00:00
|
|
|
|
while [ true ]; do
|
|
|
|
|
case $1 in
|
2001-06-20 14:16:48 +00:00
|
|
|
|
--src) # set the source path instead of /usr/src
|
2001-10-07 17:22:46 +00:00
|
|
|
|
SRC=`(cd $2; pwd)`
|
2001-09-28 21:02:15 +00:00
|
|
|
|
shift
|
2001-10-02 17:06:51 +00:00
|
|
|
|
;;
|
|
|
|
|
--init)
|
|
|
|
|
o_init_src="YES"
|
2001-06-20 14:16:48 +00:00
|
|
|
|
;;
|
2001-09-04 02:01:52 +00:00
|
|
|
|
|
2001-02-20 17:09:40 +00:00
|
|
|
|
--floppy_size)
|
2001-10-02 17:06:51 +00:00
|
|
|
|
fd_size=$2
|
2001-02-20 17:09:40 +00:00
|
|
|
|
shift
|
|
|
|
|
;;
|
2001-10-02 17:06:51 +00:00
|
|
|
|
|
|
|
|
|
--all_in_mfs)
|
|
|
|
|
o_all_in_mfs="yes"
|
|
|
|
|
;;
|
|
|
|
|
|
|
|
|
|
--no_all_in_mfs)
|
|
|
|
|
o_all_in_mfs=""
|
|
|
|
|
;;
|
|
|
|
|
|
2001-11-01 16:17:37 +00:00
|
|
|
|
--modules) # also build kernel modules
|
|
|
|
|
o_do_modules="yes"
|
|
|
|
|
;;
|
2001-02-20 17:09:40 +00:00
|
|
|
|
-n)
|
2001-10-02 17:06:51 +00:00
|
|
|
|
o_interactive="NO"
|
2001-02-20 17:09:40 +00:00
|
|
|
|
;;
|
2001-10-02 17:06:51 +00:00
|
|
|
|
|
|
|
|
|
-clear|-clean|-c) # clean
|
|
|
|
|
o_clean="YES"
|
|
|
|
|
o_interactive="NO"
|
2001-02-20 17:09:40 +00:00
|
|
|
|
;;
|
2001-10-02 17:06:51 +00:00
|
|
|
|
|
|
|
|
|
-v) # need -v -v to wait for user input
|
|
|
|
|
o_verbose=$((${o_verbose}+1)) # verbose level
|
|
|
|
|
o_tarv="v" # tar verbose flag
|
|
|
|
|
o_makeopts="-d l" # be verbose
|
2001-02-20 17:09:40 +00:00
|
|
|
|
;;
|
|
|
|
|
*)
|
|
|
|
|
break ;
|
|
|
|
|
;;
|
|
|
|
|
|
|
|
|
|
esac
|
|
|
|
|
shift
|
|
|
|
|
done
|
2001-10-02 17:06:51 +00:00
|
|
|
|
set_build_parameters # things that depend on ${SRC}
|
|
|
|
|
set_type $1 $2 # type and site, respectively
|
2001-02-20 17:09:40 +00:00
|
|
|
|
|
|
|
|
|
# If $1="package", it creates a neat set of floppies
|
|
|
|
|
|
|
|
|
|
if [ "$1" = "package" ] ; then
|
|
|
|
|
build_package
|
|
|
|
|
fi
|
2001-10-02 17:06:51 +00:00
|
|
|
|
if [ "${o_interactive}" != "NO" ] ; then
|
2001-02-20 17:09:40 +00:00
|
|
|
|
main_dialog
|
|
|
|
|
fi
|
2001-10-02 17:06:51 +00:00
|
|
|
|
if [ "${o_clean}" = "YES" ] ; then
|
2001-02-20 17:09:40 +00:00
|
|
|
|
clean_tree
|
|
|
|
|
else
|
|
|
|
|
build_image
|
|
|
|
|
do_install
|
|
|
|
|
fi
|
|
|
|
|
final_cleanup
|
|
|
|
|
exit 0
|