head	1.23;
access;
symbols
	RELENG_4_11_0_RELEASE:1.17.2.11
	RELENG_4_11:1.17.2.11.0.18
	RELENG_4_11_BP:1.17.2.11
	RELENG_4_10_0_RELEASE:1.17.2.11
	RELENG_4_10:1.17.2.11.0.16
	RELENG_4_10_BP:1.17.2.11
	RELENG_4_9_0_RELEASE:1.17.2.11
	RELENG_4_9:1.17.2.11.0.14
	RELENG_4_9_BP:1.17.2.11
	RELENG_4_8_0_RELEASE:1.17.2.11
	RELENG_4_8:1.17.2.11.0.12
	RELENG_4_8_BP:1.17.2.11
	RELENG_4_7_0_RELEASE:1.17.2.11
	RELENG_4_7:1.17.2.11.0.10
	RELENG_4_7_BP:1.17.2.11
	RELENG_4_6_2_RELEASE:1.17.2.11
	RELENG_4_6_1_RELEASE:1.17.2.11
	RELENG_4_6_0_RELEASE:1.17.2.11
	RELENG_4_6:1.17.2.11.0.8
	RELENG_4_6_BP:1.17.2.11
	RELENG_4_5_0_RELEASE:1.17.2.11
	RELENG_4_5:1.17.2.11.0.6
	RELENG_4_5_BP:1.17.2.11
	RELENG_4_4_0_RELEASE:1.17.2.11
	RELENG_4_4:1.17.2.11.0.4
	RELENG_4_4_BP:1.17.2.11
	RELENG_4_3_0_RELEASE:1.17.2.11
	RELENG_4_3:1.17.2.11.0.2
	RELENG_4_3_BP:1.17.2.11
	RELENG_4_2_0_RELEASE:1.17.2.3
	RELENG_4_1_1_RELEASE:1.17
	PRE_SMPNG:1.18
	RELENG_4_1_0_RELEASE:1.17
	RELENG_3_5_0_RELEASE:1.7.2.8
	RELENG_4_0_0_RELEASE:1.17
	RELENG_4:1.17.0.2
	RELENG_4_BP:1.17
	RELENG_3_4_0_RELEASE:1.7.2.6
	RELENG_3_3_0_RELEASE:1.7.2.5
	RELENG_3_2_PAO:1.7.2.1.0.2
	RELENG_3_2_PAO_BP:1.7.2.1
	RELENG_3_2_0_RELEASE:1.7.2.1
	RELENG_3_1_0_RELEASE:1.7
	RELENG_3:1.7.0.2
	RELENG_3_BP:1.7
	RELENG_3_0_0_RELEASE:1.4
	v0_4:1.1.1.1
	PICOBSD:1.1.1;
locks; strict;
comment	@# @;


1.23
date	2001.04.23.19.55.03;	author joe;	state dead;
branches;
next	1.22;

1.22
date	2001.01.29.22.47.46;	author luigi;	state Exp;
branches;
next	1.21;

1.21
date	2000.11.07.12.33.46;	author joe;	state Exp;
branches;
next	1.20;

1.20
date	2000.11.02.13.38.10;	author joe;	state Exp;
branches;
next	1.19;

1.19
date	2000.11.02.01.57.23;	author joe;	state Exp;
branches;
next	1.18;

1.18
date	2000.04.25.18.59.51;	author dwhite;	state Exp;
branches;
next	1.17;

1.17
date	2000.02.08.08.25.00;	author luigi;	state Exp;
branches
	1.17.2.1;
next	1.16;

1.16
date	99.10.17.22.42.57;	author dwhite;	state Exp;
branches;
next	1.15;

1.15
date	99.10.11.20.52.50;	author dwhite;	state Exp;
branches;
next	1.14;

1.14
date	99.10.11.05.13.52;	author dwhite;	state Exp;
branches;
next	1.13;

1.13
date	99.10.08.03.59.59;	author dwhite;	state Exp;
branches;
next	1.12;

1.12
date	99.08.28.01.33.13;	author peter;	state Exp;
branches;
next	1.11;

1.11
date	99.08.25.01.12.55;	author dwhite;	state Exp;
branches;
next	1.10;

1.10
date	99.08.23.08.33.08;	author luigi;	state Exp;
branches;
next	1.9;

1.9
date	99.08.22.21.42.32;	author dwhite;	state Exp;
branches;
next	1.8;

1.8
date	99.03.09.21.15.08;	author abial;	state Exp;
branches;
next	1.7;

1.7
date	99.01.19.23.02.05;	author abial;	state Exp;
branches
	1.7.2.1;
next	1.6;

1.6
date	99.01.14.23.14.46;	author abial;	state Exp;
branches;
next	1.5;

1.5
date	98.10.25.15.15.55;	author abial;	state Exp;
branches;
next	1.4;

1.4
date	98.09.20.00.46.07;	author abial;	state Exp;
branches;
next	1.3;

1.3
date	98.09.11.13.14.25;	author abial;	state Exp;
branches;
next	1.2;

1.2
date	98.09.07.06.46.25;	author abial;	state Exp;
branches;
next	1.1;

1.1
date	98.08.27.17.38.42;	author abial;	state Exp;
branches
	1.1.1.1;
next	;

1.1.1.1
date	98.08.27.17.38.42;	author abial;	state Exp;
branches;
next	;

1.7.2.1
date	99.03.09.21.19.11;	author abial;	state Exp;
branches;
next	1.7.2.2;

1.7.2.2
date	99.08.22.23.07.43;	author dwhite;	state Exp;
branches;
next	1.7.2.3;

1.7.2.3
date	99.08.23.11.36.19;	author luigi;	state Exp;
branches;
next	1.7.2.4;

1.7.2.4
date	99.08.25.01.13.31;	author dwhite;	state Exp;
branches;
next	1.7.2.5;

1.7.2.5
date	99.08.29.15.52.26;	author peter;	state Exp;
branches;
next	1.7.2.6;

1.7.2.6
date	99.10.17.23.05.12;	author dwhite;	state Exp;
branches;
next	1.7.2.7;

1.7.2.7
date	2000.02.12.19.04.03;	author luigi;	state Exp;
branches;
next	1.7.2.8;

1.7.2.8
date	2000.05.31.12.49.10;	author luigi;	state Exp;
branches;
next	;

1.17.2.1
date	2000.11.08.01.24.18;	author joe;	state Exp;
branches;
next	1.17.2.2;

1.17.2.2
date	2000.11.08.02.11.54;	author joe;	state Exp;
branches;
next	1.17.2.3;

1.17.2.3
date	2000.11.16.10.54.05;	author joe;	state Exp;
branches;
next	1.17.2.4;

1.17.2.4
date	2000.12.06.20.38.18;	author luigi;	state Exp;
branches;
next	1.17.2.5;

1.17.2.5
date	2000.12.22.02.17.06;	author luigi;	state Exp;
branches;
next	1.17.2.6;

1.17.2.6
date	2000.12.22.18.27.47;	author joe;	state Exp;
branches;
next	1.17.2.7;

1.17.2.7
date	2001.01.10.22.34.38;	author luigi;	state Exp;
branches;
next	1.17.2.8;

1.17.2.8
date	2001.01.26.20.56.19;	author luigi;	state Exp;
branches;
next	1.17.2.9;

1.17.2.9
date	2001.01.31.01.56.44;	author luigi;	state Exp;
branches;
next	1.17.2.10;

1.17.2.10
date	2001.02.14.23.29.58;	author luigi;	state Exp;
branches;
next	1.17.2.11;

1.17.2.11
date	2001.02.19.23.49.54;	author luigi;	state dead;
branches;
next	;


desc
@@


1.23
log
@MF4S: Sync with the developments that Luigi's been doing in -stable.
@
text
@#! /bin/sh -

# $FreeBSD: src/release/picobsd/build/stage1,v 1.22 2001/01/29 22:47:46 luigi Exp $
#
# 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
@


1.22
log
@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.
@
text
@d3 1
a3 1
# $FreeBSD: src/release/picobsd/build/stage1,v 1.21 2000/11/07 12:33:46 joe Exp $
@


1.21
log
@Load the kernel and root file systems from floppy:/.
@
text
@d3 1
a3 1
# $FreeBSD: src/release/picobsd/build/stage1,v 1.20 2000/11/02 13:38:10 joe Exp $
d5 1
a5 1
# stage1 -- this script fills the mfs for the picobsd kernel
d20 20
d82 3
d87 2
a88 1
    umount ${MFS_MOUNTPOINT} 2> /dev/null || true
a92 2
rm -f kernel.gz ${MFS_NAME}    # cleanup...

a94 3
    VNUM=`mount | awk "/vn/ { num++ } END { printf \"%d\", num }"`
    export VNUM
    echo "-> Using vn${VNUM}..."
d96 1
a96 3
    umount /dev/vn${VNUM} 2> /dev/null || true
    umount ${MFS_MOUNTPOINT} 2> /dev/null || true
    vnconfig -u /dev/rvn${VNUM} 2> /dev/null || true
d98 1
a100 3
    awk 'BEGIN {printf "%c%c", 85, 170}' | \
	dd of=${MFS_NAME} obs=1 seek=510 conv=notrunc  2> /dev/null

d130 1
a130 1
    MFS_RC=floppy.tree/etc/mfs.rc
d138 3
a140 5
	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
d142 1
d170 1
a170 1
	ssh-keygen1 -f ${MFS_MOUNTPOINT}/etc/ssh_host_key -N "" -C "root@@picobsd"
d172 1
a180 2
# stage2

d184 1
a184 1
    cp -p ${OBJ}/${SRC}/sys/PICOBSD${suffix}/kernel kernel || \
a187 1
    gzip -9 -v -n kernel
d195 14
a208 5
    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

d211 2
a212 4
    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 || \
d219 7
d242 1
a242 1
    (cd ${BUILDDIR}/../floppy.tree ; tar -cf - ${excl} . ) | \
d245 2
a246 1
    if [ -d ${BUILDDIR}/../${TYPE}/floppy.tree ] ; then
d248 1
a248 1
	(cd ${BUILDDIR}/../${TYPE}/floppy.tree ; tar cf - . ) | \
d251 1
a251 1
    if [ -d ${BUILDDIR}/../${TYPE}/floppy.tree.${SITE} ] ; then
d253 1
a253 1
	(cd ${BUILDDIR}/../${TYPE}/floppy.tree.${SITE} ; tar cf - . ) | \
a255 1
    rm -f floppy.tree/etc/mfs\.*  # mfs.rc, mfs.login.conf
d259 2
a260 1
	cat ${BUILDDIR}/../${TYPE}/lang/${i}.${LANGUAGE} | \
d262 1
a274 22
    # 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

    #
d277 1
a277 4
    cat <<__EOF > ${MFS_MOUNTPOINT}/boot/loader.rc
load /kernel
load -t mfs_root /${MFS_NAME}
__EOF
d280 1
a280 1
    df -ik ${MFS_MOUNTPOINT} > .build.reply
d284 1
a284 1
    # rm kernel.gz ${MFS_NAME}
@


1.20
log
@Build picobsd object files in /usr/obj/picobsd/${TYPE}.
@
text
@d3 1
a3 1
# $FreeBSD: src/release/picobsd/build/stage1,v 1.19 2000/11/02 01:57:23 joe Exp $
d272 2
a273 2
load kernel
load -t mfs_root ${MFS_NAME}
@


1.19
log
@Copy the built kernel from the right place.  (Forgotten in the last
commit.)
@
text
@d3 1
a3 1
# $FreeBSD: src/release/picobsd/build/stage1,v 1.18 2000/04/25 18:59:51 dwhite Exp $
d16 3
@


1.18
log
@Commit PicoBSD mega-patch:
. Bring PicoBSD up to date with -CURRENT reality.
. Make PicoBSD smart and not spam /dev/vn0 and /mnt.  Now it uses the first
  unused vn device and creates a temporary mountpoint in /tmp.
. Miscellaneous build cleanups and optimizations.

Unfortunately the bridge, isp, and router floppies are too big and need
the axe treatment.  The install floppy needs updating to -CURRENT. Dial and
net build and (appear to) run OK.  I will be adressing these in the
near future (unless someone beats me to it :-) ).

PR:		misc/17737
Submitted by:	Omachonu Ogali <oogali@@intranova.net>
@
text
@d3 1
a3 1
# $FreeBSD: src/release/picobsd/build/stage1,v 1.17 2000/02/08 08:25:00 luigi Exp $
d168 1
a168 1
    cp -p ${SRC}/sys/compile/PICOBSD${suffix}/kernel kernel || \
@


1.17
log
@Cleanup the build scripts.

Approved-by: jordan
@
text
@d3 1
a3 1
# $FreeBSD$
d11 2
d14 3
a16 1
MFS_MOUNTPOINT=/mnt
d26 1
a26 1
	echo "Error while doing vnconfig of ${MFS_NAME} on /dev/rvn0..."
d33 1
a33 1
	echo "Error while mounting ${MFS_NAME} (/dev/vn0c) on ${MFS_MOUNTPOINT}"
d45 1
a45 1
	echo "Error while doing vnconfig of floppy.img on /dev/rvn0..."
d61 2
d70 5
a74 1
    umount /dev/vn0 2> /dev/null || true
d76 1
a76 1
    vnconfig -u /dev/rvn0 2> /dev/null || true
d83 1
a83 1
    vnconfig -s labels -c /dev/rvn0 ${MFS_NAME} 2>/dev/null || \
d91 1
a91 1
	disklabel -rw /dev/rvn0 fd${MFS_SIZE} || fail $? disklabel
d93 1
a93 1
	disklabel -rw vn0 auto || fail $? disklabel
d96 2
a97 2
    newfs -i ${MFS_INODES} -m 0 -p 0 -o space /dev/rvn0c
    mount /dev/vn0c ${MFS_MOUNTPOINT} || fail $? no_mount
d159 2
a160 2
    fsck -p /dev/rvn0c
    vnconfig -u /dev/rvn0
d185 1
a185 1
    vnconfig -c /dev/rvn0 picobsd.bin || fail $? vnconfig2
d190 1
a190 1
    disklabel -Brw -b /boot/boot1 -s /boot/boot2 /dev/rvn0 fd1440 || \
d193 1
a193 1
    newfs -i ${FLOPPY_INODES} -m 0 -p 0 -o space /dev/rvn0c
d195 1
a195 1
    mount /dev/vn0c ${MFS_MOUNTPOINT}
d228 1
a228 1
    echo "-> Copying language dependent files: ${files} -> /mnt/etc ..."
d276 2
a277 1
    vnconfig -u /dev/rvn0
@


1.17.2.1
log
@MFS: Build the kernel in /usr/obj/usr/src/sys/ using 'make buildkernel'.
@
text
@d3 1
a3 1
# $FreeBSD: src/release/picobsd/build/stage1,v 1.17 2000/02/08 08:25:00 luigi Exp $
d158 1
a158 1
    cp -p ${OBJ}/${SRC}/sys/PICOBSD${suffix}/kernel kernel || \
@


1.17.2.2
log
@MFC: Make PicoBSD smart and not spam /dev/vn0 and /mnt.  Now it
     uses the first unused vn device and creates a temporary
     mountpoint in /tmp.

Approved by:	jkh
@
text
@d3 1
a3 1
# $FreeBSD: src/release/picobsd/build/stage1,v 1.17.2.1 2000/11/08 01:24:18 joe Exp $
a10 2
# By default, /tmp should exist.
#
d12 1
a12 3
MFS_MOUNTPOINT=`mktemp -d "/tmp/picobsd.XXXXXXXXXX"`
export MFS_MOUNTPOINT

d22 1
a22 1
	echo "Error while doing vnconfig of ${MFS_NAME} on /dev/rvn${VNUM}..."
d29 1
a29 1
	echo "Error while mounting ${MFS_NAME} (/dev/vn${VNUM}c) on ${MFS_MOUNTPOINT}"
d41 1
a41 1
	echo "Error while doing vnconfig of floppy.img on /dev/rvn${VNUM}..."
a56 2
    umount ${MFS_MOUNTPOINT} 2> /dev/null || true
    rm -rf ${MFS_MOUNTPOINT} 2> /dev/null || true
d64 1
a64 5
    VNUM=`mount | awk "/vn/ { num++ } END { printf \"%d\", num }"`
    export VNUM
    echo "-> Using vn${VNUM}..."

    umount /dev/vn${VNUM} 2> /dev/null || true
d66 1
a66 1
    vnconfig -u /dev/rvn${VNUM} 2> /dev/null || true
d73 1
a73 1
    vnconfig -s labels -c /dev/rvn${VNUM} ${MFS_NAME} 2>/dev/null || \
d81 1
a81 1
	disklabel -rw /dev/rvn${VNUM} fd${MFS_SIZE} || fail $? disklabel
d83 1
a83 1
	disklabel -rw vn${VNUM} auto || fail $? disklabel
d86 2
a87 2
    newfs -i ${MFS_INODES} -m 0 -p 0 -o space /dev/rvn${VNUM}c
    mount /dev/vn${VNUM}c ${MFS_MOUNTPOINT} || fail $? no_mount
d149 2
a150 2
    fsck -p /dev/rvn${VNUM}c
    vnconfig -u /dev/rvn${VNUM}
d175 1
a175 1
    vnconfig -c /dev/rvn${VNUM} picobsd.bin || fail $? vnconfig2
d180 1
a180 1
    disklabel -Brw -b /boot/boot1 -s /boot/boot2 /dev/vn${VNUM}c fd1440 || \
d183 1
a183 1
    newfs -i ${FLOPPY_INODES} -m 0 -p 0 -o space /dev/rvn${VNUM}c
d185 1
a185 1
    mount /dev/vn${VNUM}c ${MFS_MOUNTPOINT}
d218 1
a218 1
    echo "-> Copying language dependent files: ${files} -> ${MFS_MOUNTPOINT}/etc ..."
d266 1
a266 2
    rm -rf ${MFS_MOUNTPOINT}
    vnconfig -u /dev/rvn${VNUM}
@


1.17.2.3
log
@MFC: Build picobsd versions of things in /usr/obj/picobsd/TYPE.

Approved by:	jkh
@
text
@d3 1
a3 1
# $FreeBSD: src/release/picobsd/build/stage1,v 1.17.2.2 2000/11/08 02:11:54 joe Exp $
a15 3

PICO_OBJ=${OBJ}/picobsd/${TYPE}
export PICO_OBJ
@


1.17.2.4
log
@Misc. cleanup:
* deal with new location of kernel and objects;
* take mfs files from mfs_tree;
* build a small version of the loader without FORTH
@
text
@d3 1
a3 1
# $FreeBSD: src/release/picobsd/build/stage1,v 1.17.2.3 2000/11/16 10:54:05 joe Exp $
d17 2
a18 2
MAKEOBJDIRPREFIX=${OBJ}/picobsd/${TYPE}
export MAKEOBJDIRPREFIX
d115 1
a115 1
    MFS_RC=mfs_tree/etc/rc
d123 5
a127 3
	fname=mfs_tree/etc/login.conf
	if [ ! -f ${fname} ] ; then
	    fname=${BUILDDIR}/../${fname}
a128 1
	cp ${fname} ${MFS_MOUNTPOINT}/etc/login.conf
a157 1
    cp -Rp ../mfs_tree/stand/update ${MFS_MOUNTPOINT}/stand/update
d171 1
a171 1
    cp -p ${SRC}/sys/compile/PICOBSD${suffix}/kernel kernel || \
d216 1
a216 1
    (cd ${BUILDDIR}/../floppy.tree ; tar -cf - --exclude CVS ${excl} . ) | \
d219 1
a219 2
    srcdir=${BUILDDIR}/../${TYPE}/floppy.tree
    if [ -d ${srcdir} ] ; then
d221 1
a221 1
	(cd ${srcdir} ; tar cf - --exclude CVS . ) | \
d224 1
a224 1
    if [ -d ${srcdir}.${SITE} ] ; then
d226 1
a226 1
	(cd ${srcdir}.${SITE} ; tar cf - --exclude CVS . ) | \
d229 1
d233 1
a233 2
	if [ -f ${BUILDDIR}/../${TYPE}/lang/${i}.${LANGUAGE} ] ; then
	    cat ${BUILDDIR}/../${TYPE}/lang/${i}.${LANGUAGE} | \
a234 1
	fi
d258 5
a262 4
    (cd /usr/src/lib/libstand ; make obj ; make )
    (cd /usr/src/sys/boot/i386 ; make obj ; make -DNOFORTH )
    theloader=${MAKEOBJDIRPREFIX}/usr/src/sys/boot/i386/loader/loader
    if [ ! -f ${theloader} ]; then
@


1.17.2.5
log
@Several cleanups of this script, including, in order of importance:

+ support for different floppy sizes (1480, 1720, 2880)
+ remove the loader, revert back to the use of preloaded fs images.
  Space is too tight to waste 60-70KB on /boot/loader.
+ Remove some useless awk stuff to write magic numbers in the boot sector.
+ Try to trap ^C and cleanup the vn device.

Hopefully the removal of the loader will make room for some more
useful stuff on the disk.
@
text
@d3 1
a3 1
# $FreeBSD$
d5 1
a5 1
# stage1 -- this script prepares the actual picobsd image
a19 20
# 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
}

a61 3
    *)
	echo "unknown error, maybe user break: $errno $errcode"
	;;
d64 1
a64 2
    # try to cleanup the vnode.
    free_vnode
d69 2
d73 3
d77 3
a79 1
    free_vnode
a80 1
    # zero-fill the MFS image
d83 3
d166 2
d175 1
d183 5
a187 14
    # 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
d190 4
a193 2
    disklabel -Brw -b ${boot1} -s ${boot2} /dev/vn${VNUM}c \
	fd${FLOPPY_SIZE} || \
a199 7
    # 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

d249 21
d272 5
a276 1
    rm -rf floppy.tree || true # cleanup
d282 1
a282 1
    rm kernel.gz ${MFS_NAME}
@


1.17.2.6
log
@MFC: Support the -p flag to crunchgen to get the objects built in the
     right object directory.
@
text
@d3 1
a3 1
# $FreeBSD: src/release/picobsd/build/stage1,v 1.17.2.5 2000/12/22 02:17:06 luigi Exp $
d17 2
a18 2
PICO_OBJ=${OBJ}/picobsd/${TYPE}
export PICO_OBJ
@


1.17.2.7
log
@ssh-keygen1 is now ssh-keygen
@
text
@d3 1
a3 1
# $FreeBSD: src/release/picobsd/build/stage1,v 1.17.2.6 2000/12/22 18:27:47 joe Exp $
d170 1
a170 1
	ssh-keygen -f ${MFS_MOUNTPOINT}/etc/ssh_host_key -N "" -C "root@@picobsd"
@


1.17.2.8
log
@Better formatting of the final report.
@
text
@d3 1
a3 1
# $FreeBSD: src/release/picobsd/build/stage1,v 1.17.2.7 2001/01/10 22:34:38 luigi Exp $
d279 1
a279 1
    df -ik ${MFS_MOUNTPOINT} | colrm 70 > .build.reply
@


1.17.2.9
log
@Make sure files on the floppy have root as owner (or things
like sshd might not work, e.g. prevent you from logging in).
@
text
@d3 1
a3 1
# $FreeBSD: src/release/picobsd/build/stage1,v 1.17.2.8 2001/01/26 20:56:19 luigi Exp $
a277 1
    (echo "-> Fixing permissions"; cd ${MFS_MOUNTPOINT}; chown -R root *)
@


1.17.2.10
log
@Rearrange the script so that a copy of the floppy.tree can
also be stored into the mfsroot image at /fd , which is also
used as a mountpoint for the floppy. This way, the initial
/etc/rc script can try to mount a floppy, and even if it fails
you will find some useful stuff there.

This lets you boot a picobsd /kernel over NFS using etherboot
or perhaps pxeboot.

The copy is controlled by a variable at the beginning of the script,
depending on what you place there the space overhead is very
limited (and potentially you can save something).
@
text
@d3 1
a3 1
# $FreeBSD$
a10 4
# if you include the floppy tree in the mfs, you
# can boot from the image via diskless.
INCLUDE_FLOPPY_IN_MFS="yes"

d130 31
d172 1
d174 1
a174 14
    # copy mfs tree
    if [ -d ${BUILDDIR}/../${TYPE}/mfs_tree ]; then
	# we have a type-specific mfs tree
	MFS_TREE=${BUILDDIR}/../${TYPE}/mfs_tree
    else # normal case, use the default mfs tree
	MFS_TREE=${BUILDDIR}/../mfs_tree
    fi
    (cd ${MFS_TREE} ; tar -cf - --exclude CVS . ) | \
	    (cd ${MFS_MOUNTPOINT} ; tar xvf - )

    if [ "${INCLUDE_FLOPPY_IN_MFS}" = "yes" ]; then
	cp -Rp ${BUILDDIR}/floppy.tree/* ${MFS_MOUNTPOINT}/fd
    fi
    (echo "-> Fixing permissions"; cd ${MFS_MOUNTPOINT}; chown -R root . )
a225 13
    # now transfer the floppy tree
    cp -Rp floppy.tree/* ${MFS_MOUNTPOINT}
    (echo "-> Fixing permissions"; cd ${MFS_MOUNTPOINT}; chown -R root *)
    rm -rf floppy.tree || true # cleanup

    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}
}

populate_floppy_fs() {
d248 1
a248 1
	(cd ${srcdir} ; tar -cf - --exclude CVS . ) | \
d253 1
a253 1
	(cd ${srcdir}.${SITE} ; tar -cf - --exclude CVS . ) | \
d274 11
a286 1

d289 2
a290 3
populate_floppy_fs	# things which go into floppy
populate_mfs		# things which go into mfs
do_floppy # copies everything into the floppy
@


1.17.2.11
log
@Add the new picobsd build script, and remove the old ones.
This script should be a significant improvement over the old
ones for the following reasons (modulo bugs...):

 + it can be run from anywhere;
 + a single script does everything including cleanup;
 + removes the need for a number of makefiles used before;
 + it does not write anymore into /usr/src/release/picobsd/ ;
 + all the files produced by the compilation are put into a single
   directory (plus OBJDIR as specified by the various programs);
 + it has slightly better diagnosting and debugging modes;
 + it permits PicoBSD configurations to be placed anywhere;
 + configurations can now be as simple as two files -- PICOBSD
   and crunch.conf, thus removing the need for supporting
   language-specific versions. You just define a new floppy
   type and populate the tree.
@
text
@d3 1
a3 1
# $FreeBSD: src/release/picobsd/build/stage1,v 1.17.2.10 2001/02/14 23:29:58 luigi Exp $
@


1.16
log
@Reverse the sense of the /mnt/boot/defaults dir check.  This was causing
the bootloader to not load the loader.conf and thus the MFS image.  The result
was 'panic: no init'.
@
text
@d3 1
a3 1
# $FreeBSD: src/release/picobsd/build/stage1,v 1.15 1999/10/11 20:52:50 dwhite Exp $
d12 1
d26 1
a26 1
	echo "Error while labeling ${MFS_NAME} size $SIZE"
d29 1
a29 1
	echo "Error while mounting ${MFS_NAME} (/dev/vn0c) on /mnt"
d32 1
a32 1
	echo "Error while making hierarchy in /mnt"
d35 1
a35 1
	echo "Error while making devices in /mnt"
d60 1
a60 4
echo "-> Preparing MFS filesystem..."
umount /dev/vn0 2> /dev/null || true
umount /mnt 2> /dev/null || true
vnconfig -u /dev/rvn0 2> /dev/null || true
d62 5
a66 1
dd of=${MFS_NAME} if=/dev/zero count=${SIZE} bs=1k 2> /dev/null
d68 1
a68 2
awk 'BEGIN {printf "%c%c", 85, 170}' | \
    dd of=${MFS_NAME} obs=1 seek=510 conv=notrunc  2> /dev/null
d70 2
a71 1
vnconfig -s labels -c /dev/rvn0 ${MFS_NAME} 2>/dev/null || fail $? no_vnconfig
d73 2
a74 1
dd if=/boot/boot1 of=${MFS_NAME} conv=notrunc 2> /dev/null
d76 7
a82 5
# This command does weird things on 2.2.x systems.
# For small image sizes, use std disktypes
if [ ${SIZE} -lt 1024 ] ; then
	disklabel -rw /dev/rvn0 fd${SIZE} || fail $? disklabel
else
d84 4
a87 1
fi
d89 2
a90 2
newfs -i ${MFS_INODES} -m 0 -p 0 -o space /dev/rvn0c
mount /dev/vn0c /mnt || fail $? no_mount
d92 9
a100 1
pwd=`pwd`
d102 6
a107 17
echo "-> Populating MFS tree..."
cd ../${TYPE}
make -f Makefile.mfs || fail $? mtree
if [ X"${NO_DEVFS}" != X"" ] ; then
    make -f Makefile.mfs devnodes || fail $? makedevs
fi

MFS_RC=floppy.tree/etc/mfs.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" > /mnt/etc/oinit.rc
else
    cat ${MFS_RC} | sed -e "s/@@VER@@/${VER}/g" > /mnt/etc/rc
    if [ -f floppy.tree/etc/mfs.login.conf ] ; then
	cp floppy.tree/etc/mfs.login.conf /mnt/etc/login.conf
d109 7
a115 1
	cp ${BUILDDIR}/../floppy.tree/etc/mfs.login.conf /mnt/etc/login.conf
d117 10
a126 12
    cat lang/README.${LANGUAGE} | sed -e "s/@@VER@@/${VER}/g" > /mnt/README
fi
cp lang/update.${LANGUAGE} /mnt/stand/update
if [ "${TYPE}" = "dial" ] ; then
    for i in reboot login dialup; do
	cp lang/${i}.${LANGUAGE} /mnt/stand/${i}
    done
    ln -f /mnt/stand/reboot /mnt/stand/shutdown
    (cd ../help;\
    rm -rf tmp_hlp;\
    mkdir tmp_hlp;\
    for i in `ls *.hlp.${LANGUAGE}`; do \
d128 5
a132 9
    done;\
    cd tmp_hlp;\
    ar -cru help.a *;\
    cp help.a /mnt/help.a)
fi

echo "-> Making and installing crunch1..."
cd crunch1
make "SRC=${SRC}" && make install 2>&1 >/dev/null || fail $? crunch
d134 11
a144 1
cd ${pwd}
d146 6
a151 1
(echo "-> Fixing permissions"; cd /mnt; chown -R root *)
d155 4
a158 2
echo "-> Preparing kernel..."
cp -p ${SRC}/sys/compile/PICOBSD${suffix}/kernel kernel || \
d160 4
d165 2
a166 15
echo "-> Preparing kernel with MFS filesystem inside..."
df -ik /mnt
umount /mnt
fsck -p /dev/rvn0c
vnconfig -u /dev/rvn0

strip kernel
strip --remove-section=.note --remove-section=.comment kernel
gzip -9 -v -n kernel

#---- stage3

# stage3 -- prepare floppy filesystem and image.
# by default we are in /usr/src/release/build
#
d168 1
a168 4
echo "-> Preparing ${FLOPPY_SIZE}kB floppy filesystem..."
umount /dev/vn0 2> /dev/null || true
umount /mnt 2> /dev/null || true
vnconfig -u /dev/rvn0 2> /dev/null || true
d170 1
a170 1
dd of=picobsd.bin if=/dev/zero count=${FLOPPY_SIZE} bs=1k
d172 1
a172 1
awk 'BEGIN {printf "%c%c", 85, 170}' | \
d175 1
a175 2
#vnconfig -s labels -c /dev/rvn0 picobsd.bin 2>/dev/null
vnconfig -c /dev/rvn0 picobsd.bin || fail $? vnconfig2
d177 1
a177 1
dd if=/boot/boot1 of=picobsd.bin conv=notrunc 2> /dev/null
d179 2
a180 2
# XXX todo: right floppy size!
disklabel -Brw -b /boot/boot1 -s /boot/boot2 /dev/rvn0 fd1440 || \
d183 1
a183 1
newfs -i ${FLOPPY_INODES} -m 0 -p 0 -o space /dev/rvn0c
d185 1
a185 1
mount /dev/vn0c /mnt
d187 1
a187 1
echo "-> Populating floppy filesystem..."
d189 31
a219 20
### copy floppy tree excluding private files.
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 - ${excl} . ) | (cd /mnt ; tar xvf - )

if [ -d ${BUILDDIR}/../${TYPE}/floppy.tree ] ; then
    echo "-> update with private files:"
    (cd ${BUILDDIR}/../${TYPE}/floppy.tree ; tar cf - . ) | (cd /mnt ; tar xvf - )
fi

files="hosts motd"
echo "-> Copying language dependent files: ${files} -> /mnt/etc ..."
for i in ${files} ; do
d221 48
a268 2
		sed -e "s/@@VER@@/${VER}/g" > /mnt/etc/${i}
done
d270 4
a273 43
if [ "${TYPE}" = "dial" ] ; then
    cp -p /mnt/etc/master.passwd .
    pwd_mkdb -d . master.passwd
    mv spwd.db /mnt/etc/
    rm pwd.db master.passwd
fi

cp kernel.gz /mnt/kernel.gz || fail $? kernel_compress

gzip -9cv ${MFS_NAME} > /mnt/${MFS_NAME}.gz || fail $? mfs_compress

if [ ! -d /mnt/boot/defaults ] ; then
    mkdir -p /mnt/boot/defaults
fi
cp /boot/loader .
# Make sure we have the a.out stubs we need...
# This is deprecated for 3.X
if [ ! -f /usr/lib/aout/kzhead.o ] ; then
	(cd ${SRC}/sys/i386/boot/kzipboot && make all install clean)
fi
/usr/bin/kzip -v loader
mv loader.kz /mnt/boot/loader
rm -f loader loader.o
# XXX is next line ok ?
echo "/boot/loader" >/mnt/boot.config
cp ${SRC}/sys/boot/forth/loader.4th /mnt/boot/
cp ${SRC}/sys/boot/forth/support.4th /mnt/boot/
cp ${SRC}/sys/boot/forth/loader.conf /mnt/boot/defaults
echo "userconfig_script_load=\"YES\""	>/mnt/boot/loader.conf
echo "rootfs_load=\"YES\""		>>/mnt/boot/loader.conf
echo "rootfs_name=\"${MFS_NAME}\""	>>/mnt/boot/loader.conf
echo "rootfs_type=\"mfs_root\""		>>/mnt/boot/loader.conf
for i in frames screen ; do
	cp ${SRC}/share/examples/bootforth/${i}.4th /mnt/boot/
done
cp ../forth/loader.rc /mnt/boot/loader.rc
cp ../forth/menu.4th /mnt/boot/menu.4th
(echo "-> Fixing permissions"; cd /mnt; chown -R root *)

df -ik /mnt
umount /mnt
vnconfig -u /dev/rvn0
rm kernel.gz ${MFS_NAME}
@


1.15
log
@Fix handling of the 'custom' directory symlink.
Properly abstract the PicoBSD build directory instead of depending too much
on pwd's and relative paths.

Submitted by:	 John Baldwin <jobaldwi@@vt.edu>
@
text
@d3 1
a3 1
# $FreeBSD: src/release/picobsd/build/stage1,v 1.14 1999/10/11 05:13:52 dwhite Exp $
d215 1
a215 1
if [ -d /mnt/boot/defaults ] ; then
@


1.14
log
@Be explicit about kzip location to avoid accidentally calling KDE kzip.
@
text
@d3 1
a3 1
# $FreeBSD: src/release/picobsd/build/stage1,v 1.13 1999/10/08 03:59:59 dwhite Exp $
d95 1
a95 1
    MFS_RC=../${MFS_RC}
d104 1
a104 1
	cp ../floppy.tree/etc/mfs.login.conf /mnt/etc/login.conf
d181 1
a181 1
excl=../${TYPE}/floppy.tree.exclude
d190 1
a190 1
(cd ../floppy.tree ; tar -cf - ${excl} . ) | (cd /mnt ; tar xvf - )
d192 1
a192 1
if [ -d ../${TYPE}/floppy.tree ] ; then
d194 1
a194 1
    (cd ../${TYPE}/floppy.tree ; tar cf - . ) | (cd /mnt ; tar xvf - )
d200 1
a200 1
	cat ../${TYPE}/lang/${i}.${LANGUAGE} | \
@


1.13
log
@Add a new floppy type, install.  This type builds a disk that can
slice, partition, newfs, and install FreeBSD from a tarball on a remote server.
Handy for doing mass-installs for server farms.

Documentation following shortly.
@
text
@d3 1
a3 1
# $FreeBSD: src/release/picobsd/build/stage1,v 1.12 1999/08/28 01:33:13 peter Exp $
d224 1
a224 1
kzip -v loader
@


1.12
log
@$Id$ -> $FreeBSD$
@
text
@d3 1
a3 1
# $FreeBSD$
d215 3
a217 2
mkdir /mnt/boot
mkdir /mnt/boot/defaults
@


1.11
log
@Add missing quote.
@
text
@d3 1
a3 1
#	$Id: stage1,v 1.10 1999/08/23 08:33:08 luigi Exp $
@


1.10
log
@Additional cleanup of the picobsd scripts.
Also bump Version to 0.445
@
text
@d3 1
a3 1
#	$Id: stage1,v 1.9 1999/08/22 21:42:32 dwhite Exp $
d186 1
a186 1
    echo "===
@


1.9
log
@Major PicoBSD update by luigi with some debugging help from myself.

. Now builds on -STABLE (-CURRENT is broken due to bugs)
. etc directory contents centralized instead of in each
  type directory (can exclude & override as desired)
. Removed extraneous language files (lang files for rc really necessary?)
. dialog-based build tool with support for custom floppy builds
. MFS image loads as a mfs_root module instead of compiled into kernel

THIS IS BROKEN ON CURRENT.  I'll MFC to -STABLE immediately following.
luigi tells me I have an OK from jkh on the MFC.

Submitted by:	luigi
@
text
@d3 1
a3 1
#	$Id$
d11 1
d13 1
a13 1
# is the function used to trap errors and print msgs
d21 1
a21 1
	echo "Error while doing vnconfig of fs.PICOBSD on /dev/rvn0..."
d25 1
a25 1
	echo "Error while labeling fs.PICOBSD size $SIZE"
d28 1
a28 1
	echo "Error while mounting fs.PICOBSD (/dev/vn0c) on /mnt"
d45 9
a58 1

d64 1
a64 1
dd of=fs.PICOBSD if=/dev/zero count=${SIZE} bs=1k 2> /dev/null
d67 1
a67 1
    dd of=fs.PICOBSD obs=1 seek=510 conv=notrunc  2> /dev/null
d69 1
a69 1
vnconfig -s labels -c /dev/rvn0 fs.PICOBSD 2>/dev/null || fail $? no_vnconfig
d71 1
a71 1
dd if=/boot/boot1 of=fs.PICOBSD conv=notrunc 2> /dev/null
d81 1
a81 1
newfs -i ${MFS_INODES} -m 0 -p 0 -o space /dev/rvn0c 2>&1 >/dev/null
d90 1
a90 1
	make -f Makefile.mfs devnodes || fail $? makedevs
d93 3
a95 6
# MY_ETC contains files which override the global config in DEFAULT_ETC

if [ -f floppy.tree/etc/mfs.rc ] ; then
    MFS_RC=floppy.tree/etc/mfs.rc
else
    MFS_RC=../floppy.tree/etc/mfs.rc
a134 9
#if [ ! -f ${SRC}/sys/compile/PICOBSD${suffix}.${SIZE}/kernel ]; then
#    echo "-> ERROR: you must build PICOBSD${suffix}.${SIZE} first"
#    exit 1
#fi
if [ ! -f ${SRC}/sys/compile/PICOBSD${suffix}/kernel ]; then
    echo "-> ERROR: you must build PICOBSD${suffix} first"
    exit 1
fi

d136 2
a137 5
cp -p ${SRC}/sys/compile/PICOBSD${suffix}/kernel kernel
if [ ! -f kernel ]; then
	echo "-> ERROR: you must build PICOBSD${suffix} kernel first"
	exit 1
fi
d141 1
a141 1
umount /mnt 2>&1 >/dev/null
d143 1
a143 5
vnconfig -u /dev/rvn0 2>&1 >/dev/null

#if [ ! -f ../tools/write_mfs_in_kernel/wmik ]; then
#	(cd ../tools/write_mfs_in_kernel; make)
#fi
a144 1
#../tools/write_mfs_in_kernel/wmik kernel fs.PICOBSD
d147 1
a147 2
gzip -9 -n kernel
#rm fs.PICOBSD
a154 5
if [ ! -f kernel.gz ]; then
	echo "-> ERROR: you must build kernel.gz first"
	exit 1
fi

d160 1
a160 1
dd of=picobsd.bin if=/dev/zero count=${FLOPPY_SIZE} bs=1k 2> /dev/null
d166 1
a166 1
vnconfig -c /dev/rvn0 picobsd.bin 2>/dev/null || fail $? vnconfig2
d171 2
a172 1
disklabel -Brw -b /boot/boot1 -s /boot/boot2 /dev/rvn0 fd1440 2>&1 >/dev/null || fail $?  disklabel
d174 1
a174 1
newfs -i ${FLOPPY_INODES} -m 0 -p 0 -o space /dev/rvn0c 2>&1 >/dev/null
d178 1
a178 1
echo "-> `pwd`: Populating floppy filesystem..."
d180 11
a190 4
# copy floppy tree excluding private files.
(cd ../floppy.tree ; \
    tar -cvf - --exclude-from ../${TYPE}/floppy.tree.exclude . ) | \
    (cd /mnt ; tar xvf - )
a191 1
# update with private files
d193 2
a194 1
    (cd ../${TYPE}/floppy.tree ; tar cvf - . ) | (cd /mnt ; tar xvf - )
d197 3
a199 2
echo "-> `pwd`: Copying language dependent files..."
for i in hosts motd ; do
d205 4
a208 4
	cp -p /mnt/etc/master.passwd .
	pwd_mkdb -d . master.passwd
	mv spwd.db /mnt/etc/
	rm pwd.db master.passwd
d211 1
a211 5
if [ "X$?" != "X0" ] ; then
	echo "-> ERROR while transferring ../${TYPE}/floppy.tree to /mnt..."
	echo "-> Aborting $0"
	exit 10
fi
d213 1
a213 13
cp kernel.gz /mnt/kernel.gz
if [ "X$?" != "X0" ] ; then
	echo "-> ERROR while transferring kernel.gz to /mnt..."
	echo "-> Aborting $0"
	exit 10
fi

gzip -9cv fs.PICOBSD > /mnt/fs.PICOBSD.gz
if [ "X$?" != "X0" ] ; then
	echo "\-> ERROR transferring MFS to /mnt"
	echo "-> Aborting $0"
	exit 10
fi
d231 5
a235 6
echo "userconfig_script_load=\"YES\"">/mnt/boot/loader.conf
echo "rootfs_load=\"YES\"" >>/mnt/boot/loader.conf
echo "rootfs_name=\"fs.PICOBSD\"" >>/mnt/boot/loader.conf
echo "rootfs_type=\"mfs_root\"" >>/mnt/boot/loader.conf
for i in frames screen
do
a240 1
rm kernel.gz
a242 1

d245 1
@


1.8
log
@Take boot1/boot2 from their new place, i.e. /boot/, not from
(currently nonexistent) /usr/mdec/.

Submitted by:	luigi
@
text
@d3 1
d5 8
a12 1
#	$Id: stage1,v 1.7 1999/01/19 23:02:05 abial Exp $
d14 108
d123 14
a136 1
set -e
d138 4
a141 2
if [ ! -f ${SRC}/sys/compile/PICOBSD${suffix}.${SIZE}/kernel ]; then
	echo "-> ERROR: you must build PICOBSD${suffix}.${SIZE} first"
d145 8
a152 9
echo "-> Preparing kernel..."
cp -p ${SRC}/sys/compile/PICOBSD${suffix}.${SIZE}/kernel kernel
#if [ "${TYPE}" != "dial" ]
#then
#	echo "-> Preparing kvm database..."
#	mv /var/db/kvm_kernel.db /var/db/old.db
#	kvm_mkdb kernel
#	cp /var/db/kvm_kernel.db kvm_kernel.db
#	mv /var/db/old.db /var/db/kvm_kernel.db
d155 18
a172 1
echo "-> Preparing MFS filesystem..."
d177 1
a177 1
dd of=fs.PICOBSD if=/dev/zero count=${SIZE} bs=1k 2> /dev/null
d180 25
a204 1
                dd of=fs.PICOBSD obs=1 seek=510 conv=notrunc  2> /dev/null
d206 15
a220 6
vnconfig -s labels -c /dev/rvn0 fs.PICOBSD 2>/dev/null
#vnconfig -c /dev/rvn0 fs.PICOBSD 2>/dev/null
if [ "X$?" != "X0" ]
then
	echo "-> Error while doing vnconfig of fs.PICOBSD on /dev/rvn0..."
	echo "   Most probably your running kernel doesn't have the vn(4) device."
d225 3
a227 18
dd if=/boot/boot1 of=fs.PICOBSD conv=notrunc 2> /dev/null

# This command does weird things on 2.2.x systems. In such case use normal
# disktype here instead
if [ "${TYPE}" != "router" ]
then
	disklabel -rw vn0 auto
else
	if [ ${SIZE} -lt 1024 ]
	then
		disklabel -rw /dev/rvn0 fd${SIZE}
	else
		disklabel -rw vn0 auto
	fi
fi
if [ "X$?" != "X0" ]
then
	echo "-> Error while labeling fs.PICOBSD (vn0)..."
d232 3
a234 24
# Default setting for other (custom) setups.
INODES=4096
# You can save some space on MFS if you don't want so many inodes...
if [ "${TYPE}" = "dial" ]
then
	INODES=4096
fi
if [ "${TYPE}" = "router" ]
then
	INODES=3072
fi
if [ "${TYPE}" = "net" ]
then
	INODES=4096
fi
if [ "${TYPE}" = "isp" ]
then
	INODES=4096
fi
newfs -i $INODES -m 0 -p 0 -o space /dev/rvn0c 2>&1 >/dev/null
mount /dev/vn0c /mnt
if [ "X$?" != "X0" ]
then
	echo "-> Error while mounting fs.PICOBSD (/dev/vn0c) on /mnt..."
d238 34
@


1.7
log
@Next round of fixes before 3.1-RELEASE.
@
text
@d4 1
a4 1
#	$Id: stage1,v 1.6 1999/01/14 23:14:46 abial Exp $
d45 1
a45 1
dd if=/usr/mdec/boot1 of=fs.PICOBSD conv=notrunc 2> /dev/null
@


1.7.2.1
log
@MFC: Take boot1/boot2 from their new place (/boot).

Submitted by:	luigi
@
text
@d4 1
a4 1
#	$Id: stage1,v 1.7 1999/01/19 23:02:05 abial Exp $
d45 1
a45 1
dd if=/boot/boot1 of=fs.PICOBSD conv=notrunc 2> /dev/null
@


1.7.2.2
log
@MFC: PicoBSD mega-upgrade.  It actually works in -STABLE, let's hope I
didn't miss anything.  According to luigi, I have jkh's OK on this.

Submitted by:  luigi
@
text
@a2 1
#	$Id$
d4 1
a4 8
# stage1 -- this script fills the mfs for the picobsd kernel

. ../Version

set -e	# abort in case of untested errors

# fail errno errcode
# is the function used to trap errors and print msgs
a5 34
fail() {
    errno=$1
    errcode=$2
    echo "--> Error $errno code $errcode"
    case $errcode in
    no_vnconfig)
	echo "Error while doing vnconfig of fs.PICOBSD on /dev/rvn0..."
	echo "   Most probably your running kernel doesn't have the vn(4) device."
	;;
    disklabel)
	echo "Error while labeling fs.PICOBSD size $SIZE"
	;;
    no_mount)
	echo "Error while mounting fs.PICOBSD (/dev/vn0c) on /mnt"
	;;
    mtree)
	echo "Error while making hierarchy in /mnt"
	;;
    makedevs)
	echo "Error while making devices in /mnt"
	;;
    crunch)
	echo "Error while building ../${TYPE}/crunch1..."
	;;
    vnconfig2)
	echo "Error while doing vnconfig of floppy.img on /dev/rvn0..."
	;;
    disklabel)
	echo "Error while doing disklabel on of floppy.img size $FLOPPY_SIZE"
	;;
    esac
    echo "-> Aborting $0"
    exit 10
}
d7 1
d9 3
a11 86
echo "-> Preparing MFS filesystem..."
umount /dev/vn0 2> /dev/null || true
umount /mnt 2> /dev/null || true
vnconfig -u /dev/rvn0 2> /dev/null || true

dd of=fs.PICOBSD if=/dev/zero count=${SIZE} bs=1k 2> /dev/null

awk 'BEGIN {printf "%c%c", 85, 170}' | \
    dd of=fs.PICOBSD obs=1 seek=510 conv=notrunc  2> /dev/null

vnconfig -s labels -c /dev/rvn0 fs.PICOBSD 2>/dev/null || fail $? no_vnconfig

dd if=/boot/boot1 of=fs.PICOBSD conv=notrunc 2> /dev/null

# This command does weird things on 2.2.x systems.
# For small image sizes, use std disktypes
if [ ${SIZE} -lt 1024 ] ; then
	disklabel -rw /dev/rvn0 fd${SIZE} || fail $? disklabel
else
	disklabel -rw vn0 auto || fail $? disklabel
fi

newfs -i ${MFS_INODES} -m 0 -p 0 -o space /dev/rvn0c 2>&1 >/dev/null
mount /dev/vn0c /mnt || fail $? no_mount

pwd=`pwd`

echo "-> Populating MFS tree..."
cd ../${TYPE}
make -f Makefile.mfs || fail $? mtree
if [ X"${NO_DEVFS}" != X"" ] ; then
	make -f Makefile.mfs devnodes || fail $? makedevs
fi

# MY_ETC contains files which override the global config in DEFAULT_ETC

if [ -f floppy.tree/etc/mfs.rc ] ; then
    MFS_RC=floppy.tree/etc/mfs.rc
else
    MFS_RC=../floppy.tree/etc/mfs.rc
fi
if [ "${INIT}" = "oinit" ] ; then
    cat ${MFS_RC} | sed -e "s/@@VER@@/${VER}/g" > /mnt/etc/oinit.rc
else
    cat ${MFS_RC} | sed -e "s/@@VER@@/${VER}/g" > /mnt/etc/rc
    if [ -f floppy.tree/etc/mfs.login.conf ] ; then
	cp floppy.tree/etc/mfs.login.conf /mnt/etc/login.conf
    else
	cp ../floppy.tree/etc/mfs.login.conf /mnt/etc/login.conf
    fi
    cat lang/README.${LANGUAGE} | sed -e "s/@@VER@@/${VER}/g" > /mnt/README
fi
cp lang/update.${LANGUAGE} /mnt/stand/update
if [ "${TYPE}" = "dial" ] ; then
    for i in reboot login dialup; do
	cp lang/${i}.${LANGUAGE} /mnt/stand/${i}
    done
    ln -f /mnt/stand/reboot /mnt/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 /mnt/help.a)
fi

echo "-> Making and installing crunch1..."
cd crunch1
make "SRC=${SRC}" && make install 2>&1 >/dev/null || fail $? crunch

cd ${pwd}

(echo "-> Fixing permissions"; cd /mnt; chown -R root *)

# stage2

#if [ ! -f ${SRC}/sys/compile/PICOBSD${suffix}.${SIZE}/kernel ]; then
#    echo "-> ERROR: you must build PICOBSD${suffix}.${SIZE} first"
#    exit 1
#fi
if [ ! -f ${SRC}/sys/compile/PICOBSD${suffix}/kernel ]; then
    echo "-> ERROR: you must build PICOBSD${suffix} first"
    exit 1
d15 8
a22 14
cp -p ${SRC}/sys/compile/PICOBSD${suffix}/kernel kernel
if [ ! -f kernel ]; then
	echo "-> ERROR: you must build PICOBSD${suffix} kernel first"
	exit 1
fi

echo "-> Preparing kernel with MFS filesystem inside..."
df -ik /mnt
umount /mnt 2>&1 >/dev/null
fsck -p /dev/rvn0c
vnconfig -u /dev/rvn0 2>&1 >/dev/null

#if [ ! -f ../tools/write_mfs_in_kernel/wmik ]; then
#	(cd ../tools/write_mfs_in_kernel; make)
d25 1
a25 18
#../tools/write_mfs_in_kernel/wmik kernel fs.PICOBSD
strip kernel
strip --remove-section=.note --remove-section=.comment kernel
gzip -9 -n kernel
#rm fs.PICOBSD

#---- stage3

# stage3 -- prepare floppy filesystem and image.
# by default we are in /usr/src/release/build
#

if [ ! -f kernel.gz ]; then
	echo "-> ERROR: you must build kernel.gz first"
	exit 1
fi

echo "-> Preparing ${FLOPPY_SIZE}kB floppy filesystem..."
d30 1
a30 1
dd of=picobsd.bin if=/dev/zero count=${FLOPPY_SIZE} bs=1k 2> /dev/null
d33 1
a33 1
                dd of=picobsd.bin obs=1 seek=510 conv=notrunc  2> /dev/null
d35 8
a42 22
#vnconfig -s labels -c /dev/rvn0 picobsd.bin 2>/dev/null
vnconfig -c /dev/rvn0 picobsd.bin 2>/dev/null || fail $? vnconfig2

dd if=/boot/boot1 of=picobsd.bin conv=notrunc 2> /dev/null

# XXX todo: right floppy size!
disklabel -Brw -b /boot/boot1 -s /boot/boot2 /dev/rvn0 fd1440 2>&1 >/dev/null || fail $?  disklabel

newfs -i ${FLOPPY_INODES} -m 0 -p 0 -o space /dev/rvn0c 2>&1 >/dev/null

mount /dev/vn0c /mnt

echo "-> `pwd`: Populating floppy filesystem..."

# copy floppy tree excluding private files.
(cd ../floppy.tree ; \
    tar -cvf - --exclude-from ../${TYPE}/floppy.tree.exclude . ) | \
    (cd /mnt ; tar xvf - )

# update with private files
if [ -d ../${TYPE}/floppy.tree ] ; then
    (cd ../${TYPE}/floppy.tree ; tar cvf - . ) | (cd /mnt ; tar xvf - )
d45 1
a45 5
echo "-> `pwd`: Copying language dependent files..."
for i in hosts motd ; do
	cat ../${TYPE}/lang/${i}.${LANGUAGE} | \
		sed -e "s/@@VER@@/${VER}/g" > /mnt/etc/${i}
done
d47 16
a62 9
if [ "${TYPE}" = "dial" ] ; then
	cp -p /mnt/etc/master.passwd .
	pwd_mkdb -d . master.passwd
	mv spwd.db /mnt/etc/
	rm pwd.db master.passwd
fi

if [ "X$?" != "X0" ] ; then
	echo "-> ERROR while transferring ../${TYPE}/floppy.tree to /mnt..."
d67 18
a84 5
cp kernel.gz /mnt/kernel.gz
if [ "X$?" != "X0" ] ; then
	echo "-> ERROR while transferring kernel.gz to /mnt..."
	echo "-> Aborting $0"
	exit 10
d86 5
a90 4

gzip -9cv fs.PICOBSD > /mnt/fs.PICOBSD.gz
if [ "X$?" != "X0" ] ; then
	echo "\-> ERROR transferring MFS to /mnt"
a93 34

mkdir /mnt/boot
mkdir /mnt/boot/defaults
cp /boot/loader .
# Make sure we have the a.out stubs we need...
# This is deprecated for 3.X
if [ ! -f /usr/lib/aout/kzhead.o ] ; then
	(cd ${SRC}/sys/i386/boot/kzipboot && make all install clean)
fi
kzip -v loader
mv loader.kz /mnt/boot/loader
rm -f loader loader.o
# XXX is next line ok ?
echo "/boot/loader" >/mnt/boot.config
cp ${SRC}/sys/boot/forth/loader.4th /mnt/boot/
cp ${SRC}/sys/boot/forth/support.4th /mnt/boot/
cp ${SRC}/sys/boot/forth/loader.conf /mnt/boot/defaults
echo "userconfig_script_load=\"YES\"">/mnt/boot/loader.conf
echo "rootfs_load=\"YES\"" >>/mnt/boot/loader.conf
echo "rootfs_name=\"fs.PICOBSD\"" >>/mnt/boot/loader.conf
echo "rootfs_type=\"mfs_root\"" >>/mnt/boot/loader.conf
for i in frames screen
do
	cp ${SRC}/share/examples/bootforth/${i}.4th /mnt/boot/
done
cp ../forth/loader.rc /mnt/boot/loader.rc
cp ../forth/menu.4th /mnt/boot/menu.4th
(echo "-> Fixing permissions"; cd /mnt; chown -R root *)
rm kernel.gz

df -ik /mnt

umount /mnt
vnconfig -u /dev/rvn0
@


1.7.2.3
log
@MFC: cleanup in PicoBSD scripts, bump version to 0.445
@
text
@d3 1
a3 1
#	$Id: stage1,v 1.10 1999/08/23 08:33:08 luigi Exp $
a10 1
MFS_NAME=fs.PICOBSD
d12 1
a12 1
# This function is used to trap errors and print msgs
d20 1
a20 1
	echo "Error while doing vnconfig of ${MFS_NAME} on /dev/rvn0..."
d24 1
a24 1
	echo "Error while labeling ${MFS_NAME} size $SIZE"
d27 1
a27 1
	echo "Error while mounting ${MFS_NAME} (/dev/vn0c) on /mnt"
a43 9
    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"
	;;
d49 1
d55 1
a55 1
dd of=${MFS_NAME} if=/dev/zero count=${SIZE} bs=1k 2> /dev/null
d58 1
a58 1
    dd of=${MFS_NAME} obs=1 seek=510 conv=notrunc  2> /dev/null
d60 1
a60 1
vnconfig -s labels -c /dev/rvn0 ${MFS_NAME} 2>/dev/null || fail $? no_vnconfig
d62 1
a62 1
dd if=/boot/boot1 of=${MFS_NAME} conv=notrunc 2> /dev/null
d72 1
a72 1
newfs -i ${MFS_INODES} -m 0 -p 0 -o space /dev/rvn0c
d81 1
a81 1
    make -f Makefile.mfs devnodes || fail $? makedevs
d84 6
a89 3
MFS_RC=floppy.tree/etc/mfs.rc
if [ ! -f ${MFS_RC} ] ; then # no private version. use generic mfs.rc
    MFS_RC=../${MFS_RC}
d129 9
d139 5
a143 2
cp -p ${SRC}/sys/compile/PICOBSD${suffix}/kernel kernel || \
	fail $? missing_kernel
d147 1
a147 1
umount /mnt
d149 5
a153 1
vnconfig -u /dev/rvn0
d155 1
d158 2
a159 1
gzip -9 -v -n kernel
d167 5
d177 1
a177 1
dd of=picobsd.bin if=/dev/zero count=${FLOPPY_SIZE} bs=1k
d183 1
a183 1
vnconfig -c /dev/rvn0 picobsd.bin || fail $? vnconfig2
d188 1
a188 2
disklabel -Brw -b /boot/boot1 -s /boot/boot2 /dev/rvn0 fd1440 || \
	fail $?  disklabel
d190 1
a190 1
newfs -i ${FLOPPY_INODES} -m 0 -p 0 -o space /dev/rvn0c
d194 1
a194 1
echo "-> Populating floppy filesystem..."
d196 4
a199 11
### copy floppy tree excluding private files.
excl=../${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 ../floppy.tree ; tar -cf - ${excl} . ) | (cd /mnt ; tar xvf - )
d201 1
d203 1
a203 2
    echo "-> update with private files:"
    (cd ../${TYPE}/floppy.tree ; tar cf - . ) | (cd /mnt ; tar xvf - )
d206 2
a207 3
files="hosts motd"
echo "-> Copying language dependent files: ${files} -> /mnt/etc ..."
for i in ${files} ; do
d213 4
a216 4
    cp -p /mnt/etc/master.passwd .
    pwd_mkdb -d . master.passwd
    mv spwd.db /mnt/etc/
    rm pwd.db master.passwd
d219 5
a223 1
cp kernel.gz /mnt/kernel.gz || fail $? kernel_compress
d225 13
a237 1
gzip -9cv ${MFS_NAME} > /mnt/${MFS_NAME}.gz || fail $? mfs_compress
d255 6
a260 5
echo "userconfig_script_load=\"YES\""	>/mnt/boot/loader.conf
echo "rootfs_load=\"YES\""		>>/mnt/boot/loader.conf
echo "rootfs_name=\"${MFS_NAME}\""	>>/mnt/boot/loader.conf
echo "rootfs_type=\"mfs_root\""		>>/mnt/boot/loader.conf
for i in frames screen ; do
d266 1
d269 1
a271 1
rm kernel.gz ${MFS_NAME}
@


1.7.2.4
log
@MFC: Missing quote.
@
text
@d3 1
a3 1
#	$Id: stage1,v 1.7.2.3 1999/08/23 11:36:19 luigi Exp $
d186 1
a186 1
    echo "==="
@


1.7.2.5
log
@$Id$ -> $FreeBSD$
@
text
@d3 1
a3 1
# $FreeBSD$
@


1.7.2.6
log
@MFC: install floppy prep, misc. fixups.
@
text
@d95 1
a95 1
    MFS_RC=${BUILDDIR}/../${MFS_RC}
d104 1
a104 1
	cp ${BUILDDIR}/../floppy.tree/etc/mfs.login.conf /mnt/etc/login.conf
d181 1
a181 1
excl=${BUILDDIR}/../${TYPE}/floppy.tree.exclude
d190 1
a190 1
(cd ${BUILDDIR}/../floppy.tree ; tar -cf - ${excl} . ) | (cd /mnt ; tar xvf - )
d192 1
a192 1
if [ -d ${BUILDDIR}/../${TYPE}/floppy.tree ] ; then
d194 1
a194 1
    (cd ${BUILDDIR}/../${TYPE}/floppy.tree ; tar cf - . ) | (cd /mnt ; tar xvf - )
d200 1
a200 1
	cat ${BUILDDIR}/../${TYPE}/lang/${i}.${LANGUAGE} | \
d215 2
a216 3
if [ ! -d /mnt/boot/defaults ] ; then
    mkdir -p /mnt/boot/defaults
fi
d223 1
a223 1
/usr/bin/kzip -v loader
@


1.7.2.7
log
@MFC: sync Picobsd build structure with the one in -current.
This involves a cleanup of the build scripts, removing
common files from the individual trees and put them in a
common place, and remove unused stuff.
@
text
@d3 1
a3 1
# $FreeBSD: src/release/picobsd/build/stage1,v 1.7.2.6 1999/10/17 23:05:12 dwhite Exp $
a11 1
MFS_MOUNTPOINT=/mnt
d25 1
a25 1
	echo "Error while labeling ${MFS_NAME} size ${MFS_SIZE}"
d28 1
a28 1
	echo "Error while mounting ${MFS_NAME} (/dev/vn0c) on ${MFS_MOUNTPOINT}"
d31 1
a31 1
	echo "Error while making hierarchy in ${MFS_MOUNTPOINT}"
d34 1
a34 1
	echo "Error while making devices in ${MFS_MOUNTPOINT}"
d59 4
a62 1
rm -f kernel.gz ${MFS_NAME}	# cleanup...
d64 1
a64 5
create_mfs() {
    echo "-> Preparing MFS filesystem..."
    umount /dev/vn0 2> /dev/null || true
    umount ${MFS_MOUNTPOINT} 2> /dev/null || true
    vnconfig -u /dev/rvn0 2> /dev/null || true
d66 2
a67 1
    dd of=${MFS_NAME} if=/dev/zero count=${MFS_SIZE} bs=1k 2> /dev/null
d69 1
a69 2
    awk 'BEGIN {printf "%c%c", 85, 170}' | \
	dd of=${MFS_NAME} obs=1 seek=510 conv=notrunc  2> /dev/null
d71 1
a71 2
    vnconfig -s labels -c /dev/rvn0 ${MFS_NAME} 2>/dev/null || \
	fail $? no_vnconfig
d73 5
a77 7
    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/rvn0 fd${MFS_SIZE} || fail $? disklabel
    else
d79 1
a79 4
    fi

    newfs -i ${MFS_INODES} -m 0 -p 0 -o space /dev/rvn0c
    mount /dev/vn0c ${MFS_MOUNTPOINT} || fail $? no_mount
d81 2
a82 2
    pwd=`pwd`
}
d84 1
a84 9
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
d86 17
a102 6
    MFS_RC=floppy.tree/etc/mfs.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
d104 1
a104 7
	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
	fi
d106 22
d129 1
a129 27
    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-keygen1 -f ${MFS_MOUNTPOINT}/etc/ssh_host_key -N "" -C "root@@picobsd"
    fi
d131 1
a131 6
    (echo "-> Fixing permissions"; cd ${MFS_MOUNTPOINT}; chown -R root *)
    df -ik ${MFS_MOUNTPOINT}
    umount ${MFS_MOUNTPOINT}
    fsck -p /dev/rvn0c
    vnconfig -u /dev/rvn0
}
d135 2
a136 4
do_kernel() {
    echo "-> Preparing kernel..."
    (cd ../${TYPE}; make -f ${BUILDDIR}/Makefile.conf )
    cp -p ${SRC}/sys/compile/PICOBSD${suffix}/kernel kernel || \
a137 4
    strip kernel
    strip --remove-section=.note --remove-section=.comment kernel
    gzip -9 -v -n kernel
}
d139 15
a153 2
do_floppy() {
    # On entry we are in /usr/src/release/build.
d155 4
a158 1
    echo "==> Preparing ${FLOPPY_SIZE}kB floppy filesystem..."
d160 1
a160 1
    dd of=picobsd.bin if=/dev/zero count=${FLOPPY_SIZE} bs=1k
d162 1
a162 1
    awk 'BEGIN {printf "%c%c", 85, 170}' | \
d165 2
a166 1
    vnconfig -c /dev/rvn0 picobsd.bin || fail $? vnconfig2
d168 1
a168 1
    dd if=/boot/boot1 of=picobsd.bin conv=notrunc 2> /dev/null
d170 2
a171 2
    # XXX todo: use a type matching floppy size.
    disklabel -Brw -b /boot/boot1 -s /boot/boot2 /dev/rvn0 fd1440 || \
d174 1
a174 1
    newfs -i ${FLOPPY_INODES} -m 0 -p 0 -o space /dev/rvn0c
d176 1
a176 1
    mount /dev/vn0c ${MFS_MOUNTPOINT}
d178 1
a178 1
    echo "==> Populating floppy filesystem..."
d180 20
a199 31
    # 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 - ${excl} . ) | \
		(cd floppy.tree ; tar xvf - )

    if [ -d ${BUILDDIR}/../${TYPE}/floppy.tree ] ; then
	echo "-> update with private files:"
	(cd ${BUILDDIR}/../${TYPE}/floppy.tree ; tar cf - . ) | \
		(cd floppy.tree ; tar xvf - )
    fi
    if [ -d ${BUILDDIR}/../${TYPE}/floppy.tree.${SITE} ] ; then
	echo "-> update with site-specific (${SITE}) files:"
	(cd ${BUILDDIR}/../${TYPE}/floppy.tree.${SITE} ; tar cf - . ) | \
		(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
d201 2
a202 48
		sed -e "s/@@VER@@/${VER}/g" > floppy.tree/etc/${i}
    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, 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
    (echo "-> Fixing permissions"; cd ${MFS_MOUNTPOINT}; chown -R root *)

    df -ik ${MFS_MOUNTPOINT} > .build.reply
    umount ${MFS_MOUNTPOINT}
    vnconfig -u /dev/rvn0
    # rm kernel.gz ${MFS_NAME}
}
d204 43
a246 4
do_kernel
create_mfs
populate_mfs
do_floppy
@


1.7.2.8
log
@Minor cleanup of build script, handle kernel.conf properly
@
text
@d3 1
a3 1
# $FreeBSD: src/release/picobsd/build/stage1,v 1.7.2.7 2000/02/12 19:04:03 luigi Exp $
d102 1
a102 1
    MFS_RC=mfs_tree/etc/rc
d110 2
a111 2
	if [ -f mfs_tree/etc/login.conf ] ; then
	    cp mfs_tree/etc/login.conf ${MFS_MOUNTPOINT}/etc/login.conf
d113 1
a113 1
	    cp ${BUILDDIR}/../mfs_tree/etc/login.conf \
a144 1
    cp -Rp ../mfs_tree/stand/update ${MFS_MOUNTPOINT}/stand/update
a257 1
    echo "q" > ${MFS_MOUNTPOINT}/boot/kernel.conf
a259 1
load -t userconfig_script /boot/kernel.conf
@


1.6
log
@Make transition to ELF kernel. Fix the userconfig_script handling.
@
text
@d4 1
a4 1
#	$Id: stage1,v 1.5 1998/10/25 15:15:55 abial Exp $
d16 8
a23 8
if [ "${TYPE}" != "dial" ]
then
	echo "-> Preparing kvm database..."
	mv /var/db/kvm_kernel.db /var/db/old.db
	kvm_mkdb kernel
	cp /var/db/kvm_kernel.db kvm_kernel.db
	mv /var/db/old.db /var/db/kvm_kernel.db
fi
@


1.5
log
@Allow to use other floppy sizes for "router" floppy.
@
text
@d4 1
a4 1
#	$Id: stage1,v 1.4 1998/09/20 00:46:07 abial Exp $
d68 1
a68 1
INODES=16000
@


1.4
log
@Hmm... Let's make the switch to non-DEVFS actually work. :-/
@
text
@d4 1
a4 1
#	$Id: stage1,v 1.3 1998/09/11 13:14:25 abial Exp $
d53 6
a58 1
	disklabel -rw /dev/rvn0 fd820
@


1.3
log
@Fix to properly newfs the MFS in case of custom setup. Mention this in docs.

Submitted by:	Richard Wackerbarth <rkw@@Dataplex.NET>
@
text
@d4 1
a4 1
#	$Id: stage1,v 1.2 1998/09/07 06:46:25 abial Exp $
d67 1
a67 1
	INODES=10240
d71 1
a71 1
	INODES=12000
d75 1
a75 1
	INODES=16000
d79 1
a79 1
	INODES=15000
@


1.2
log
@Set the ${suffix} only once...
@
text
@d4 1
a4 1
#	$Id: stage1,v 1.1.1.1 1998/08/27 17:38:42 abial Exp $
d62 2
d67 1
a67 1
	newfs -i 10240 -m 0 -p 0 -o space /dev/rvn0c 2>&1 >/dev/null
d71 1
a71 1
	newfs -i 12000 -m 0 -p 0 -o space /dev/rvn0c 2>&1 >/dev/null
d75 1
a75 1
	newfs -i 16000 -m 0 -p 0 -o space /dev/rvn0c 2>&1 >/dev/null
d79 1
a79 1
	newfs -i 15000 -m 0 -p 0 -o space /dev/rvn0c 2>&1 >/dev/null
d81 1
@


1.1
log
@Initial revision
@
text
@d4 1
a4 1
#	$Id: stage1,v 1.4 1998/08/10 19:06:48 abial Exp $
a7 17

if [ "${TYPE}" = "dial" ]
then
	suffix="-D"
fi
if [ "${TYPE}" = "net" ]
then
	suffix="-N"
fi
if [ "${TYPE}" = "isp" ]
then
	suffix="-I"
fi
if [ "${TYPE}" = "router" ]
then
	suffix="-R"
fi
@


1.1.1.1
log
@Initial import of PicoBSD v0.4 tree.
@
text
@@
