freebsd-src/release/picobsd/build/build
Luigi Rizzo f908e29f8d Cleanup the build scripts.
Approved-by: jordan
2000-02-08 08:25:00 +00:00

386 lines
9.5 KiB
Bash
Executable file
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/sh -
#
# $FreeBSD$
#
# 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
# support symbolically linked custom directory
BUILDDIR=`pwd`
export BUILDDIR
# assign default values to variables.
set_defaults() {
TYPE=${TYPE:-dial} # PicoBSD type (isp, router, net, custom, ...
# build image list
cat /dev/null > .image.list
for i in ../* ; do
if [ -d $i -a -f $i/PICOBSD ] ; then
a=`awk '/^#PicoBSD/ {print $2, $3, $4, $5, $6}' < $i/PICOBSD`
if [ "$a" != "" ]; then
echo "`basename $i` $a" >>.image.list
fi
fi
done
while read name sz init mfs_in floppy_in ; do
if [ "$name" != "#" -a $name != "" ] ; then
eval ${name}_DFLT_SIZE=$sz
eval ${name}_INIT=$init
eval ${name}_MFS_INODES=$mfs_in
eval ${name}_FLOPPY_INODES=$floppy_in
fi
done < .image.list
}
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: ${MFS_SIZE} kB\n\t3. Language: ${LANGUAGE}\n\
\t4. Site-info: ${SITE}\n"
}
# Main build procedure. It calls another scripts (stage1)
main() {
if [ "X${TYPE}" = "X" ] ; then
echo "^G^G^G-> wrong floppy type"
exit 10
fi
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 MFS_SIZE LANGUAGE TYPE SRC NO_DEVFS INIT
export SITE MFS_INODES FLOPPY_INODES FLOPPY_SIZE
./stage1
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
#
# Note that specifying an alternate directory is broken due to relative
# path assumptions during the kernel compilation phase of the build.
# For now just dialog-ify.
check_for_old_custom() {
KEEP_CUSTOM=no
if [ ! -d ../custom ] ; then
return
fi
CUSTOMLINK=`ls -l ../custom | awk -F\> '{ print $2 }' | awk '{ print $1 }'`
if dialog --title "Custom directory setup" --yesno "A custom configuration\n ${CUSTOMLINK}\nalready exists. Would you like to use it?" 7 50 ; then
KEEP_CUSTOM=yes
CUST_DIR=${CUSTOMLINK}
else
KEEP_CUSTOM=no
fi
# If custom is just a simple directory, assume the user wants it
}
# 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 MFS_SIZE=$"${TYPE}_DFLT_SIZE"
eval INIT=$"${TYPE}_INIT"
eval MFS_INODES=$"${TYPE}_MFS_INODES"
eval FLOPPY_INODES=$"${TYPE}_FLOPPY_INODES"
suffix="-${TYPE}"
if [ "${MFS_SIZE}" = "" ] ; then
echo "TYPE $TYPE not found!"
sleep 2
TYPE=""
fi
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=${MFS_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}, ${MFS_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: ${MFS_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 \
`awk '{ print $1, $1 }' < .image.list` \
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
MFS_SIZE=`cat ${RISU}`
if [ "${MFS_SIZE}" = "" ] ; then
eval MFS_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\
`cat .build.reply` \
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 \"picobsd.bin\",\n\
* name of other file to install.\n\
" 20 80 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
SITE=$2
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