Put picobsd build scripts in sync with the ones in -STABLE.

With these scripts i was able to build a _working_ image of a
bridge-like floppy image with a reasonable set of utilities
in it, despite the code size increase we have in 5.0

The scripts are slightly different from the previous ones especially
on the place where the kernel and binaries are built. Hopefully
this will not cause too much trouble to people (is there any???)
using the old scripts.
This commit is contained in:
Luigi Rizzo 2001-01-29 22:47:46 +00:00
parent f47892a9f7
commit a0ab7f4419
3 changed files with 80 additions and 75 deletions

View File

@ -6,7 +6,7 @@ SRC?=/usr/src
CONF?=$(SRC)/sys/i386/conf
CONFFILE=PICOBSD${suffix}
COMPILE=$(OBJ)/usr/src/sys/$(CONFFILE)
COMPILE=$(SRC)/sys/compile/$(CONFFILE)
KERNFILE=$(COMPILE)/kernel
all: $(KERNFILE)
@ -17,8 +17,10 @@ ${CONF}/${CONFFILE}: PICOBSD
cp PICOBSD.hints ${CONF}/${CONFFILE}.hints
${COMPILE}: ${CONF}/${CONFFILE}
(cd ${CONF}; config ${CONFFILE}; cd ${COMPILE}; \
make KERNEL=kernel -DNO_MODULES depend )
$(KERNFILE): ${COMPILE}
(cd ${SRC}; \
make buildkernel KERNEL=${CONFFILE} -DNO_MODULES)
(cd ${COMPILE}; \
make KERNEL=kernel -DNO_MODULES)

View File

@ -6,7 +6,7 @@
# 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
OBJ=/usr/obj-pico
# --------- YOU SHOULD NOT NEED TO CHANGE ANYTHING BELOW -----------
# The "build" script will ask you for parameters. Just run it... :-)
@ -20,7 +20,7 @@ LANGUAGE=en
SITE=
# FLOPPY_SIZE floppy size in KB (default to 1440)
FLOPPY_SIZE=1440
FLOPPY_SIZE=1440 # 1440 1480 1720 (the latter will not boot!)
# DEVFS is currently broken. Always set this.
#
@ -338,7 +338,7 @@ this as small as possible. " 10 70 2> ${RISU} || rm ${RISU}
do_install() {
dialog --title "Build ${TYPE} completed" --inputbox \
"\nThe build process was completed successfuly.\n\
`cat .build.reply` \
`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\
@ -354,7 +354,7 @@ Your options:\n\
FILENAME=picobsd.bin
fi
echo "Writing ${FILENAME}..."
dd if=${FILENAME} of=/dev/rfd0
dd if=${FILENAME} of=/dev/rfd0.${FLOPPY_SIZE}
else
echo "Ok, the image is in picobsd.bin"
fi

View File

@ -2,7 +2,7 @@
# $FreeBSD$
#
# stage1 -- this script fills the mfs for the picobsd kernel
# stage1 -- this script prepares the actual picobsd image
. ../Version
@ -17,6 +17,26 @@ 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
#
@ -59,30 +79,25 @@ fail() {
missing_kernel)
echo "-> ERROR: you must build PICOBSD${suffix} kernel first"
;;
*)
echo "unknown error, maybe user break: $errno $errcode"
;;
esac
echo "-> Aborting $0"
umount ${MFS_MOUNTPOINT} 2> /dev/null || true
# try to cleanup the vnode.
free_vnode
rm -rf ${MFS_MOUNTPOINT} 2> /dev/null || true
exit 10
}
rm -f kernel.gz ${MFS_NAME} # cleanup...
create_mfs() {
echo "-> Preparing MFS filesystem..."
VNUM=`mount | awk "/vn/ { num++ } END { printf \"%d\", num }"`
export VNUM
echo "-> Using vn${VNUM}..."
umount /dev/vn${VNUM} 2> /dev/null || true
umount ${MFS_MOUNTPOINT} 2> /dev/null || true
vnconfig -u /dev/rvn${VNUM} 2> /dev/null || true
free_vnode
# zero-fill the MFS image
dd of=${MFS_NAME} if=/dev/zero count=${MFS_SIZE} bs=1k 2> /dev/null
awk 'BEGIN {printf "%c%c", 85, 170}' | \
dd of=${MFS_NAME} obs=1 seek=510 conv=notrunc 2> /dev/null
vnconfig -s labels -c /dev/rvn${VNUM} ${MFS_NAME} 2>/dev/null || \
fail $? no_vnconfig
@ -112,7 +127,7 @@ populate_mfs() {
> /dev/null || fail $? makedevs
fi
MFS_RC=floppy.tree/etc/mfs.rc
MFS_RC=mfs_tree/etc/rc
if [ ! -f ${MFS_RC} ] ; then # no private version. use generic mfs.rc
MFS_RC=${BUILDDIR}/../${MFS_RC}
fi
@ -120,12 +135,11 @@ populate_mfs() {
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
if [ -f floppy.tree/etc/mfs.login.conf ] ; then
cp floppy.tree/etc/mfs.login.conf ${MFS_MOUNTPOINT}/etc/login.conf
else
cp ${BUILDDIR}/../floppy.tree/etc/mfs.login.conf \
${MFS_MOUNTPOINT}/etc/login.conf
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
@ -153,8 +167,9 @@ populate_mfs() {
cd ${pwd}
if [ -f ${MFS_MOUNTPOINT}/stand/sshd ] ; then
echo "creating host key for sshd"
ssh-keygen1 -f ${MFS_MOUNTPOINT}/etc/ssh_host_key -N "" -C "root@picobsd"
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}
@ -163,16 +178,13 @@ populate_mfs() {
vnconfig -u /dev/rvn${VNUM}
}
# stage2
do_kernel() {
echo "-> Preparing kernel..."
(cd ../${TYPE}; make -v -f ${BUILDDIR}/Makefile.conf )
cp -p ${OBJ}/${SRC}/sys/PICOBSD${suffix}/kernel kernel || \
cp -p ${SRC}/sys/compile/PICOBSD${suffix}/kernel kernel || \
fail $? missing_kernel
strip kernel
strip --remove-section=.note --remove-section=.comment kernel
gzip -9 -v -n kernel
}
do_floppy() {
@ -180,23 +192,37 @@ do_floppy() {
echo "==> Preparing ${FLOPPY_SIZE}kB floppy filesystem..."
dd of=picobsd.bin if=/dev/zero count=${FLOPPY_SIZE} bs=1k
awk 'BEGIN {printf "%c%c", 85, 170}' | \
dd of=picobsd.bin obs=1 seek=510 conv=notrunc 2> /dev/null
# 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
dd if=/boot/boot1 of=picobsd.bin conv=notrunc 2> /dev/null
# XXX todo: use a type matching floppy size.
disklabel -Brw -b /boot/boot1 -s /boot/boot2 /dev/vn${VNUM}c fd1440 || \
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
@ -213,25 +239,27 @@ do_floppy() {
else
excl=""
fi
(cd ${BUILDDIR}/../floppy.tree ; tar -cf - ${excl} . ) | \
(cd ${BUILDDIR}/../floppy.tree ; tar -cf - --exclude CVS ${excl} . ) | \
(cd floppy.tree ; tar xvf - )
if [ -d ${BUILDDIR}/../${TYPE}/floppy.tree ] ; then
srcdir=${BUILDDIR}/../${TYPE}/floppy.tree
if [ -d ${srcdir} ] ; then
echo "-> update with private files:"
(cd ${BUILDDIR}/../${TYPE}/floppy.tree ; tar cf - . ) | \
(cd ${srcdir} ; tar cf - --exclude CVS . ) | \
(cd floppy.tree ; tar xvf - )
fi
if [ -d ${BUILDDIR}/../${TYPE}/floppy.tree.${SITE} ] ; then
if [ -d ${srcdir}.${SITE} ] ; then
echo "-> update with site-specific (${SITE}) files:"
(cd ${BUILDDIR}/../${TYPE}/floppy.tree.${SITE} ; tar cf - . ) | \
(cd ${srcdir}.${SITE} ; tar cf - --exclude CVS . ) | \
(cd floppy.tree ; tar xvf - )
fi
rm -f floppy.tree/etc/mfs\.* # mfs.rc, mfs.login.conf
files="motd"
echo "-> Copying language dependent files: ${files} -> ${MFS_MOUNTPOINT}/etc ..."
for i in ${files} ; do
cat ${BUILDDIR}/../${TYPE}/lang/${i}.${LANGUAGE} | \
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.
@ -244,41 +272,16 @@ do_floppy() {
# gzip returns an error if it fails to compress some file
gzip -9 floppy.tree/etc/* || true
# Now, first copy large files, then small ones.
cp -p kernel.gz ${MFS_MOUNTPOINT}/kernel.gz || fail $? kernel_compress
gzip -9cv ${MFS_NAME} > ${MFS_MOUNTPOINT}/${MFS_NAME}.gz || \
fail $? mfs_compress
if [ ! -d ${MFS_MOUNTPOINT}/boot ] ; then
mkdir -p ${MFS_MOUNTPOINT}/boot
fi
#
# make small loader
#(cd /usr/src/sys/boot/i386/loader ; make clean ;
# cd /usr/src/sys/boot/i386 ; make -DNOFORTH )
if [ -f /usr/src/sys/boot/i386/loader/loader ]; then
theloader=/usr/src/sys/boot/i386/loader/loader
else
theloader=/boot/loader
fi
kgzip -o loader $theloader
cp -p loader ${MFS_MOUNTPOINT}/boot/loader
#
# now transfer the floppy tree
cp -Rp floppy.tree/* ${MFS_MOUNTPOINT}
cat <<__EOF > ${MFS_MOUNTPOINT}/boot/loader.rc
load /kernel
load -t mfs_root /${MFS_NAME}
__EOF
rm -rf floppy.tree || true # cleanup
(echo "-> Fixing permissions"; cd ${MFS_MOUNTPOINT} ; chown -R root *)
df -ik ${MFS_MOUNTPOINT} > .build.reply
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}
rm kernel.gz ${MFS_NAME}
}
do_kernel