MF4S: Sync with the developments that Luigi's been doing in -stable.

This commit is contained in:
Josef Karthauser 2001-04-23 19:55:03 +00:00
parent 7bba070f1c
commit 18668d0278
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=75881
7 changed files with 8 additions and 1070 deletions

View file

@ -1,250 +0,0 @@
# PicoBSD Makefile
#
# $FreeBSD$
#
# Building a PicoBSD kernel involves four basic operations:
#
# 1. Build a kernel. This is done by the 'kernel' target.
# 2. Build a PicoBSD file system. This file system is loaded into an
# MFS at boot time. This is done by the 'fs' target.
# 3. Build a single executable file for all the programs, and install it in
# the mfs image. This is done by the 'crunch' target.
# 4. Build a floppy image containing the MFS image and some helper code
# to boot it. This is done by the 'image' target.
# 5. Copy the image to the floppy. Done by the 'copy' target.
# 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
EDITOR = vi
# LANGUAGE language to be used (en or pl)
LANGUAGE = en
# FLOPPY_SIZE floppy size in KB (default to 1440)
FLOPPY_SIZE = 1440
# BUILDDIR is this directory
BUILDDIR = ${.CURDIR}
# These programs are built with non-standard parameters. To be sure of
# getting them right, we need to rebuild every time; otherwise we might
# trip over the 'make world' objects.
# To do this right, we need to build the objects in a different directory.
# FIXME.
SPECIAL_PROGS = ../../../usr.bin/login ../../../usr.bin/passwd
# Get default parameters for MFS
.include "mfsinfo"
# MFS information
MFS_NAME = fs.PICOBSD
MFS_MOUNTPOINT = mmnt
MFS_VNODE = /dev/vn0
# /etc/rc for the mfs image. This reads the real stuff off the floppy
MFS_RC = floppy.tree/etc/mfs.rc
FLOPPY_NAME = picobsd.bin
FLOPPY_VNODE = /dev/vn1
FLOPPY_MOUNTPOINT = fmnt
# Variables for building kernel
CONF ?= $(SRC)/sys/i386/conf
CONFFILE = PICOBSD${suffix}
COMPILE = $(SRC)/sys/compile/$(CONFFILE)
KERNFILE = $(COMPILE)/kernel
FDEV ?= /dev/fd0
# DEVFS is currently broken. Always set this.
#
NO_DEVFS = yes
# Should we keep this?
VER = 0.445
all: kernel.gz ${MFS_NAME} crunch ${FLOPPY_NAME} copy crunch-2
kernel.gz: ${COMPILE}/kernel
@echo "--> Compressing kernel"
cp -p ${COMPILE}/kernel kernel
strip kernel
strip --remove-section=.note --remove-section=.comment kernel
gzip -f -9 -v -n kernel
@ls -l kernel.gz
# Create the MFS image file
${MFS_NAME}: ${MFS_VNODE} ${MFS_MOUNTPOINT}
@echo "--> Building and mounting MFS image vnode"
-umount -f ${MFS_MOUNTPOINT}
-umount -f ${MFS_VNODE}
rm -f .mfs_mounted
-vnconfig -u ${MFS_VNODE}
rm -f ${MFS_NAME}
dd of=${MFS_NAME} if=/dev/zero count=${MFS_SIZE} bs=1k
awk 'BEGIN {printf "%c%c", 85, 170}' | \
dd of=${MFS_NAME} obs=1 seek=510 conv=notrunc 2> /dev/null
vnconfig -s labels -c ${MFS_VNODE} ${MFS_NAME}
dd if=/boot/boot1 of=${MFS_NAME} conv=notrunc
disklabel -rw vn0 auto
newfs -i ${MFS_INODES} -m 0 -p 0 -o space ${MFS_VNODE}c
make .mfs_mounted
make -f Makefile.mfs DESTDIR=${MFS_MOUNTPOINT} LANGUAGE=${LANGUAGE}
make -f Makefile.mfs devnodes DESTDIR=${MFS_MOUNTPOINT} LANGUAGE=${LANGUAGE}
MFS_MOUNTPOINT=${MFS_MOUNTPOINT} INIT=${INIT} VER=${VER} BUILDDIR=${BUILDDIR} LANGUAGE=${LANGUAGE}
# Populate the MFS image.
crunch: ${MFS_MOUNTPOINT}
@echo "--> Populating MFS image"
-vnconfig -c ${MFS_VNODE} ${MFS_NAME}
make .mfs_mounted
# We need to make login with other options
for i in ${SPECIAL_PROGS}; do (cd $$i; make clean); done
cd crunch1; make SRC=${SRC} INIT=${INIT}; make install MFS_MOUNTPOINT=../${MFS_MOUNTPOINT}
# who can tell me how these damned help files get in here?
rm -rf ${MFS_MOUNTPOINT}/sbin/help
# Other files for the mfs file system
(cd mfs; tar cXf ../floppy.tree.exclude - . | (cd ../${MFS_MOUNTPOINT}; tar xf -))
cd ${MFS_MOUNTPOINT}; chown -R root *
df -ik ${MFS_MOUNTPOINT}
umount ${MFS_MOUNTPOINT}
rm .mfs_mounted
fsck -p ${MFS_VNODE}
# Create and mount the floppy image
${FLOPPY_NAME}: ${FLOPPY_VNODE} ${FLOPPY_MOUNTPOINT} ${MFS_NAME} .mfs_mounted
@echo "--> Preparing ${FLOPPY_SIZE}kB floppy filesystem"
-umount ${FLOPPY_VNODE}
rm -f .floppy_mounted
-vnconfig -u ${FLOPPY_VNODE}
dd of=${FLOPPY_NAME} if=/dev/zero count=${FLOPPY_SIZE} bs=1k
awk 'BEGIN {printf "%c%c", 85, 170}' | \
dd of=${FLOPPY_NAME} obs=1 seek=510 conv=notrunc
-vnconfig -s labels -c ${FLOPPY_VNODE} ${FLOPPY_NAME}
dd if=/boot/boot1 of=${FLOPPY_NAME} conv=notrunc
disklabel -Brw -b /boot/boot1 -s /boot/boot2 ${FLOPPY_VNODE}c fd${FLOPPY_SIZE}
newfs -i ${FLOPPY_INODES} -m 0 -p 0 -o space ${FLOPPY_VNODE}c
make .floppy_mounted
copy: ../floppy.tree/boot .floppy_mounted
@echo "--> Populating floppy filesystem from ../floppy.tree"
@echo -- Make a loader
kgzip -o floppy.tree/boot/loader /boot/loader
@echo -- copy base floppy tree
(wd=`pwd`; cd ../floppy.tree ; tar cXhf $${wd}/floppy.tree.exclude - . ) | \
(cd ${FLOPPY_MOUNTPOINT} ; tar xvf - )
@echo -- Now update from our private floppy tree if it exists
@echo -- Local files in `pwd`/floppy.tree
if [ -d floppy.tree ] ; then \
(cd floppy.tree; tar cXhf ../floppy.tree.exclude - .) | \
(cd ${FLOPPY_MOUNTPOINT} ; tar xvf - ); \
fi
# We get stuff here that we can't use. When the transition
# to Makefile-based build is complete, we can delete this.
# XXX
rm -rf ${FLOPPY_MOUNTPOINT}/etc
(cd floppy.etc; tar czvXf ../floppy.tree.exclude ../${FLOPPY_MOUNTPOINT}/etc.tar.gz .)
df -ik ${FLOPPY_MOUNTPOINT}
@echo -- Generate password file if we don't have one on the floppy.
@echo -- The variable PASSWD is defined in mfsinfo
if [ ${PASSWD} = NO ] ; then \
cp -p ${FLOPPY_MOUNTPOINT}/etc/master.passwd .; \
pwd_mkdb -d . master.passwd; \
mv spwd.db ${FLOPPY_MOUNTPOINT}/etc/; \
rm pwd.db master.passwd; \
fi
cp kernel.gz ${FLOPPY_MOUNTPOINT}/kernel.gz
if [ -f .mfs_mounted ]; then \
umount ${MFS_VNODE}; \
rm .mfs_mounted; \
fi
@echo -- Insert the MFS image
gzip -9cv ${MFS_NAME} > ${FLOPPY_MOUNTPOINT}/${MFS_NAME}.gz
(echo "-> Fixing permissions"; cd ${FLOPPY_MOUNTPOINT}; chown -R root *)
df -ik ${FLOPPY_MOUNTPOINT}
umount ${FLOPPY_MOUNTPOINT}
rm .floppy_mounted
floppy:
@if [ -f .floppy_mounted ]; then \
umount ${FLOPPY_MOUNTPOINT}; \
rm .floppy_mounted; \
fi
@echo Copying ${FLOPPY_NAME} to ${FDEV}c. This will take about 50 seconds.
@dd if=${FLOPPY_NAME} of=${FDEV}c bs=36b >/dev/null
@echo Safe to remove disk from ${FDEV}
floppy2:
@if [ -d crunch2 ]; then \
if [ ! -d crunch2/floppy2 ]; then \
(cd crunch2; make); \
fi; \
echo copying crunch2/floppy to ${FDEV}c. This will take about 50 seconds.; \
cd crunch2/floppy2; tar czvf - . | dd of=/dev/rfd0 conv=sync; \
echo Safe to remove disk from ${FDEV}; \
else \
echo No second floppy; \
fi
# crunch-2: Build second floppy
crunch-2:
if [ -d crunch2 ]; then cd crunch2; make; fi
# Secondary targets
${COMPILE}/kernel: ${CONFFILE}
@echo "--> Building kernel"
grep -q MD_ROOT ${CONFFILE}; if [ $$? -ne 0 ]; then \
echo -- '***** Config file must include MD_ROOT'; \
exit 1; \
fi
cp ${CONFFILE} ${CONF}; \
cd ${CONF}; \
config ${CONFFILE}; \
cd ${COMPILE}; \
make depend all
# Device nodes for the vnode devices
${FLOPPY_VNODE} ${MFS_VNODE}:
(cd /dev; ./MAKEDEV `basename $@`)
# Directories to make
${MFS_MOUNTPOINT} ${FLOPPY_MOUNTPOINT} ../floppy.tree/boot:
mkdir -p $@
tidy: umount vnunconfig
rm -f ${MFS_NAME} ${MFS_NAME}.gz ${FLOPPY_NAME} *~ Make.log kernel.gz
clean: tidy
if [ -d floppy.tree ]; then \
cd floppy.tree; rm -f boot/loader; \
fi
rm -rf ${MFS_MOUNTPOINT} ${FLOPPY_MOUNTPOINT} crunch1.conf
cd crunch1; make clean
if [ -d crunch2 ]; then cd crunch2; make clean; fi
if [ -d ${COMPILE} ] ; then cd ${COMPILE}; make clean; fi
# XXX Just for testing
vnconfig: vnunconfig
vnconfig -c ${MFS_VNODE} ${MFS_NAME}
vnconfig -c ${FLOPPY_VNODE} ${FLOPPY_NAME}
vnunconfig:
-vnconfig -u ${MFS_VNODE}
-vnconfig -u ${FLOPPY_VNODE}
mount: .floppy_mounted .mfs_mounted
umount:
-umount ${MFS_VNODE} ${MFS_MOUNTPOINT} ${FLOPPY_VNODE} ${FLOPPY_MOUNTPOINT}
rm -f .floppy_mounted .mfs_mounted
.floppy_mounted:
mount ${FLOPPY_VNODE} ${FLOPPY_MOUNTPOINT}
touch $@
.mfs_mounted:
mount ${MFS_VNODE} ${MFS_MOUNTPOINT}
touch $@

View file

@ -5,22 +5,20 @@
SRC?=/usr/src
CONF?=$(SRC)/sys/i386/conf
CONFFILE=PICOBSD${suffix}
CONFFILE=PICOBSD-${name}
COMPILE=$(SRC)/sys/compile/$(CONFFILE)
KERNFILE=$(COMPILE)/kernel
all: $(KERNFILE)
$(KERNFILE): ${COMPILE} do_a_make_in_the_kernel_directory_anyways
${CONF}/${CONFFILE}: PICOBSD
cp PICOBSD ${CONF}/${CONFFILE}
cp PICOBSD.hints ${CONF}/${CONFFILE}.hints
do_a_make_in_the_kernel_directory_anyways:
(cd ${COMPILE}; make KERNEL=kernel -DNO_MODULES)
${COMPILE}: ${CONF}/${CONFFILE}
(cd ${CONF}; config ${CONFFILE}; cd ${COMPILE}; \
make KERNEL=kernel -DNO_MODULES depend )
(cd ${CONF}; config $(CONFFILE); \
cd ${COMPILE}; make KERNEL=kernel -DNO_MODULES depend )
$(KERNFILE): ${COMPILE}
(cd ${COMPILE}; \
make KERNEL=kernel -DNO_MODULES)
$(CONF)/${CONFFILE}: PICOBSD
cp PICOBSD $(CONF)/${CONFFILE}

View file

@ -1,38 +0,0 @@
#
# $FreeBSD$
#
SRC?=/usr/src
all: crunch
crunch:
@cat crunch.conf|sed -e "s@/usr/src@${SRC}@" >crunch1.conf
-@( if [ -f crunch.inc ] ; then \
crunchgen -p ${PICO_OBJ} -o -h ./crunch.inc ./crunch1.conf ; \
else \
crunchgen -p ${PICO_OBJ} -o ./crunch1.conf ; \
fi )
@${MAKE} -f crunch1.mk
strip --remove-section=.note --remove-section=.comment crunch1
clean:
if [ -f crunch1.mk ]; then \
make -f crunch1.mk realclean ; \
fi ;
rm -f crunch1*
install:
cp crunch1 ${MFS_MOUNTPOINT}/stand/crunch
chmod 555 ${MFS_MOUNTPOINT}/stand/crunch
for i in `crunchgen -l crunch1.conf` ; \
do \
ln ${MFS_MOUNTPOINT}/stand/crunch ${MFS_MOUNTPOINT}/stand/$${i}; \
done
rm ${MFS_MOUNTPOINT}/stand/crunch
# Install the MIB files
#mkdir -p ${MFS_MOUNTPOINT}/usr/local/share/snmp/mibs
#cp ../../net/crunch1/mibs/*.txt ${MFS_MOUNTPOINT}/usr/local/share/snmp/mibs/
.include <bsd.prog.mk>

View file

@ -1,48 +0,0 @@
#
# $FreeBSD$
#
DESTDIR?=${MFS_MOUNTPOINT}
STAND_LINKS?= bin sbin usr/local/bin
USR_LINKS?= bin sbin libexec
#PL_LOCALE_LINKS?= pl polish
MY_DEVS?= std tun2 cuaa0 cuaa1 cuaa2 vty10 fd0 ad0 pty0 ttyd0 cuaa0 wd1 wd2 wd3 bpf0 bpf1 sa0 sa1
all: tree links
tree:
@echo "--- making tree"
@( if [ -f mfs.mtree ] ; then \
mtree -deU -f mfs.mtree -p ${DESTDIR}; \
else \
mtree -deU -f ../build/mfs.mtree -p ${DESTDIR} ; \
fi )
links: tree
@echo "--- making links"
(cd ${DESTDIR}; \
for i in ${STAND_LINKS}; \
do \
ln -s /stand $${i}; \
done; \
cd var/run; \
ln -s /dev/null log; \
cd ../../usr; \
for i in ${USR_LINKS}; \
do \
ln -s /stand $${i}; \
done; \
cd share/misc;\
ln -s /etc/termcap termcap; )
# We don't do it under 'all' because it's needed only on non-DEVFS systems
devnodes: tree
@echo "--- making device nodes"
(cd ${DESTDIR}/dev; \
ln -s /dev/MAKEDEV; \
./MAKEDEV ${MY_DEVS}; \
rm MAKEDEV)
clean:

View file

@ -1,387 +0,0 @@
#!/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
OBJ=/usr/obj-pico
# --------- 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 # 1440 1480 1720 (the latter will not boot!)
# 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 script (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 OBJ 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 ${MFS_MOUNTPOINT}
rm -rf ${MFS_MOUNTPOINT}
vnconfig -u /dev/rvn${VNUM}
./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` \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\
* 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.${FLOPPY_SIZE}
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

View file

@ -1,47 +0,0 @@
#! /bin/sh -
#
# $FreeBSD$
#
set -e
# Get a list of targets.
TARGETS=""
for i in ../* ; do
if [ -d $i -a -f $i/PICOBSD ] ; then
TARGETS="$TARGETS `basename $i`"
fi
done
if [ $# -lt 1 ]; then
echo "What to clean?"
echo "Possible targets are:${TARGETS} or 'all'"
exit 1
fi
if [ "$1" = "all" ]; then
list=${TARGETS}
old="old"
else
list=$1
old=$1
fi
if [ -f picobsd.bin ]; then
mv -f picobsd.bin picobsd.bin.${old}
fi
rm -fr kernel kernel.gz fs.PICOBSD *.o *core *.db \
.build.reply stage1.out build.status .image.list \
floppy.tree loader
cd ..
rm -rf help/tmp_hlp
echo "===================== $0 tools started ===================="
for j in $list ; do
echo "===================== $0 $j started ======================"
(cd ${j}/crunch1; \
if [ -f crunch1.mk ]; then \
make -f crunch1.mk realclean || true ; \
fi ; \
make -f ../../build/Makefile.crunch clean)
echo "=============== $0 $j completed successfuly =============="
done

View file

@ -1,290 +0,0 @@
#! /bin/sh -
# $FreeBSD$
#
# stage1 -- this script prepares the actual picobsd image
. ../Version
set -e # abort in case of untested errors
# By default, /tmp should exist.
#
MFS_NAME=fs.PICOBSD
MFS_MOUNTPOINT=`mktemp -d "/tmp/picobsd.XXXXXXXXXX"`
export MFS_MOUNTPOINT
PICO_OBJ=${OBJ}/picobsd/${TYPE}
export PICO_OBJ
# Location of the boot blocks (in case you want them custom-built)
boot1=/boot/boot1
boot2=/boot/boot2
rm -f kernel.gz ${MFS_NAME} # cleanup...
# find a suitable vnode
VNUM=`mount | awk "/vn/ { num++ } END { printf \"%d\", num }"`
export VNUM
echo "-> Using vn${VNUM}..."
trap fail 2 # catch user interrupt
# free as much as possible from the vnode
free_vnode() {
umount ${MFS_MOUNTPOINT} 2> /dev/null || true
umount /dev/vn${VNUM} 2> /dev/null || true
vnconfig -u /dev/rvn${VNUM} 2> /dev/null || true
}
# fail errno errcode
# This function is used to trap errors and print msgs
#
fail() {
errno=$1
errcode=$2
echo "--> Error $errno code $errcode"
case $errcode in
no_vnconfig)
echo "Error while doing vnconfig of ${MFS_NAME} on /dev/rvn${VNUM}..."
echo " Most probably your running kernel doesn't have the vn(4) device."
;;
disklabel)
echo "Error while labeling ${MFS_NAME} size ${MFS_SIZE}"
;;
no_mount)
echo "Error while mounting ${MFS_NAME} (/dev/vn${VNUM}c) on ${MFS_MOUNTPOINT}"
;;
mtree)
echo "Error while making hierarchy in ${MFS_MOUNTPOINT}"
;;
makedevs)
echo "Error while making devices in ${MFS_MOUNTPOINT}"
;;
crunch)
echo "Error while building ../${TYPE}/crunch1..."
;;
vnconfig2)
echo "Error while doing vnconfig of floppy.img on /dev/rvn${VNUM}..."
;;
disklabel)
echo "Error while doing disklabel on of floppy.img size $FLOPPY_SIZE"
;;
kernel_compress)
echo "Error while copying compressed kernel to disk"
;;
mfs_compress)
echo "Error while copying compressed mfs image to disk"
;;
missing_kernel)
echo "-> ERROR: you must build PICOBSD${suffix} kernel first"
;;
*)
echo "unknown error, maybe user break: $errno $errcode"
;;
esac
echo "-> Aborting $0"
# try to cleanup the vnode.
free_vnode
rm -rf ${MFS_MOUNTPOINT} 2> /dev/null || true
exit 10
}
create_mfs() {
echo "-> Preparing MFS filesystem..."
free_vnode
# zero-fill the MFS image
dd of=${MFS_NAME} if=/dev/zero count=${MFS_SIZE} bs=1k 2> /dev/null
vnconfig -s labels -c /dev/rvn${VNUM} ${MFS_NAME} 2>/dev/null || \
fail $? no_vnconfig
dd if=/boot/boot1 of=${MFS_NAME} conv=notrunc 2> /dev/null
# This command does weird things on 2.2.x systems.
# For small image sizes, use std disktypes
if [ ${MFS_SIZE} -lt 1024 ] ; then
disklabel -rw /dev/rvn${VNUM} fd${MFS_SIZE} || fail $? disklabel
else
disklabel -rw vn${VNUM} auto || fail $? disklabel
fi
newfs -i ${MFS_INODES} -m 0 -p 0 -o space /dev/rvn${VNUM}c
mount /dev/vn${VNUM}c ${MFS_MOUNTPOINT} || fail $? no_mount
pwd=`pwd`
}
populate_mfs() {
echo "-> Populating MFS tree..."
cd ../${TYPE}
make -f Makefile.mfs DESTDIR=${MFS_MOUNTPOINT} > /dev/null || \
fail $? mtree
if [ X"${NO_DEVFS}" != X"" ] ; then
make -f Makefile.mfs DESTDIR=${MFS_MOUNTPOINT} devnodes \
> /dev/null || fail $? makedevs
fi
MFS_RC=mfs_tree/etc/rc
if [ ! -f ${MFS_RC} ] ; then # no private version. use generic mfs.rc
MFS_RC=${BUILDDIR}/../${MFS_RC}
fi
if [ "${INIT}" = "oinit" ] ; then
cat ${MFS_RC} | sed -e "s/@VER@/${VER}/g" > ${MFS_MOUNTPOINT}/etc/oinit.rc
else
cat ${MFS_RC} | sed -e "s/@VER@/${VER}/g" > ${MFS_MOUNTPOINT}/etc/rc
fname=mfs_tree/etc/login.conf
if [ ! -f ${fname} ] ; then
fname=${BUILDDIR}/../${fname}
fi
cp ${fname} ${MFS_MOUNTPOINT}/etc/login.conf
fi
if [ "${TYPE}" = "dial" ] ; then
for i in login dialup; do
cp lang/${i}.${LANGUAGE} ${MFS_MOUNTPOINT}/stand/${i}
done
ln -s /stand/reboot ${MFS_MOUNTPOINT}/stand/shutdown
(cd ../help;\
rm -rf tmp_hlp;\
mkdir tmp_hlp;\
for i in `ls *.hlp.${LANGUAGE}`; do \
cp $i tmp_hlp/`basename $i .hlp.${LANGUAGE}`;\
done;\
cd tmp_hlp;\
ar -cru help.a *;\
cp help.a ${MFS_MOUNTPOINT}/help.a)
fi
echo "-> Making and installing crunch1..."
cd crunch1
make -f ../../build/Makefile.crunch "SRC=${SRC}" && \
make -f ../../build/Makefile.crunch install 2>&1 >/dev/null || \
fail $? crunch
cd ${pwd}
if [ -f ${MFS_MOUNTPOINT}/stand/sshd ] ; then
echo "creating host key for sshd"
ssh-keygen -f ${MFS_MOUNTPOINT}/etc/ssh_host_key -N "" -C "root@picobsd"
fi
cp -Rp ../mfs_tree/stand/update ${MFS_MOUNTPOINT}/stand/update
(echo "-> Fixing permissions"; cd ${MFS_MOUNTPOINT}; chown -R root *)
df -ik ${MFS_MOUNTPOINT}
umount ${MFS_MOUNTPOINT}
fsck -p /dev/rvn${VNUM}c
vnconfig -u /dev/rvn${VNUM}
}
do_kernel() {
echo "-> Preparing kernel..."
(cd ../${TYPE}; make -v -f ${BUILDDIR}/Makefile.conf )
cp -p ${SRC}/sys/compile/PICOBSD${suffix}/kernel kernel || \
fail $? missing_kernel
strip kernel
strip --remove-section=.note --remove-section=.comment kernel
}
do_floppy() {
# On entry we are in /usr/src/release/build.
echo "==> Preparing ${FLOPPY_SIZE}kB floppy filesystem..."
# correct block and number of sectors according to size.
blocks=${FLOPPY_SIZE}
sectors=18
if [ "${blocks}" = "1720" ]; then
blocks=1722
sectors=21
elif [ "${blocks}" = "1480" ]; then
blocks=1476
fi
echo "${sectors} sectors per track"
# create image
dd of=picobsd.bin if=/dev/zero count=${blocks} bs=1k
# put in boot sector so vnconfig and disklabel will not complain
dd if=${boot1} of=picobsd.bin conv=notrunc 2> /dev/null
vnconfig -c /dev/rvn${VNUM} picobsd.bin || fail $? vnconfig2
disklabel -Brw -b ${boot1} -s ${boot2} /dev/vn${VNUM}c \
fd${FLOPPY_SIZE} || \
fail $? disklabel
newfs -i ${FLOPPY_INODES} -m 0 -p 0 -o space /dev/rvn${VNUM}c
mount /dev/vn${VNUM}c ${MFS_MOUNTPOINT}
# preload kernel, compress with kgzip and copy to floppy image
cc -o ./wmk /usr/src/release/write_mfs_in_kernel.c
./wmk kernel ${MFS_NAME}
rm wmk
kgzip -o kernel.gz kernel
cp -p kernel.gz ${MFS_MOUNTPOINT}/kernel
echo "==> Populating floppy filesystem..."
# Configuration files are first copied to a local tree, then
# compressed, then transferred back to the floppy.
rm -rf floppy.tree || true
mkdir floppy.tree
excl=${BUILDDIR}/../${TYPE}/floppy.tree.exclude
if [ -f ${excl} ] ; then
excl="--exclude-from ${excl}"
echo "Exclude following files from ${excl}:\n==="
cat ${excl}
echo "==="
else
excl=""
fi
(cd ${BUILDDIR}/../floppy.tree ; tar -cf - --exclude CVS ${excl} . ) | \
(cd floppy.tree ; tar xvf - )
srcdir=${BUILDDIR}/../${TYPE}/floppy.tree
if [ -d ${srcdir} ] ; then
echo "-> update with private files:"
(cd ${srcdir} ; tar cf - --exclude CVS . ) | \
(cd floppy.tree ; tar xvf - )
fi
if [ -d ${srcdir}.${SITE} ] ; then
echo "-> update with site-specific (${SITE}) files:"
(cd ${srcdir}.${SITE} ; tar cf - --exclude CVS . ) | \
(cd floppy.tree ; tar xvf - )
fi
files="motd"
echo "-> Copying language dependent files: ${files} -> ${MFS_MOUNTPOINT}/etc ..."
for i in ${files} ; do
if [ -f ${BUILDDIR}/../${TYPE}/lang/${i}.${LANGUAGE} ] ; then
cat ${BUILDDIR}/../${TYPE}/lang/${i}.${LANGUAGE} | \
sed -e "s/@VER@/${VER}/g" > floppy.tree/etc/${i}
fi
done
# XXX check this! i am unsure how it is necessary.
if [ "${TYPE}" = "dial" ] ; then
cp -p floppy.tree/etc/master.passwd .
pwd_mkdb -d . master.passwd
mv spwd.db floppy.tree/etc/
rm pwd.db master.passwd
fi
# gzip returns an error if it fails to compress some file
gzip -9 floppy.tree/etc/* || true
# now transfer the floppy tree
cp -Rp floppy.tree/* ${MFS_MOUNTPOINT}
rm -rf floppy.tree || true # cleanup
(echo "-> Fixing permissions"; cd ${MFS_MOUNTPOINT} ; chown -R root *)
df -ik ${MFS_MOUNTPOINT} | colrm 70 > .build.reply
umount ${MFS_MOUNTPOINT}
rm -rf ${MFS_MOUNTPOINT}
vnconfig -u /dev/rvn${VNUM}
rm kernel.gz ${MFS_NAME}
}
do_kernel
create_mfs
populate_mfs
do_floppy