diff options
-rw-r--r-- | tools/tools/nanobsd/Makefile | 153 | ||||
-rw-r--r-- | tools/tools/nanobsd/i386.diskimage | 41 | ||||
-rw-r--r-- | tools/tools/nanobsd/make.conf | 38 |
3 files changed, 232 insertions, 0 deletions
diff --git a/tools/tools/nanobsd/Makefile b/tools/tools/nanobsd/Makefile new file mode 100644 index 0000000..793b585 --- /dev/null +++ b/tools/tools/nanobsd/Makefile @@ -0,0 +1,153 @@ +# Copyright (c) 2003-2004 Poul-Henning Kamp. +# +# See /usr/share/examples/etc/bsd-style-copyright for license terms. +# +# $FreeBSD$ + +# parallism flag for make. +MAKEJ?="-j12" + +# Physical disk paramters. Use diskinfo(8) on the target platform +# to find the correct numbers. We assume 512 bytes sectors. +HD?=16 +SC?=32 +SECTS?=501760 + +# Number of sectors in the data slice (ad0s3). The rest of the disk +# will be split evenly between the two image slices (ad0s1/ad0s2) +DATASLICE?=10240 + +# Name of kernel configuration file to use. +KERNCONF?= GENERIC + +# You probably do not need to change these. +WORLDDIR?= ${.CURDIR}/../../.. +WD?= ${.OBJDIR}/_.w + +# Set this to the name of a script if you want to customize the +# contents of the image filesystems. +#CUSTOMIZE?= ${.CURDIR}/somescript.sh + +# +# The final resulting image is in ${.OBJDIR}/_.i and the single slice +# image in ${.OBJDIR}/_.i.s1 + + +# Main target +all: buildworld installworld buildimage + +# +# This is where you customizations to the image can be performed +# Please make sure to do everything relative to ${WD} here. +# +Customize: _.cs +_.cs: _.iw _.di _.ik _.di + echo "/dev/ad0s1a / ufs ro 1 1" > ${WD}/etc/fstab +.if exists(${CUSTOMIZE}) + sh -e ${CUSTOMIZE} ${WD} ${WORLDDIR} ${.CURDIR} +.else + # useful stuff for diskless boot + sed -i "" -e /beastie/d ${WD}/boot/loader.rc + sed -i "" -e /ttyd0/s/off/on/ ${WD}/etc/ttys + echo " -h" > ${WD}/boot.config +.endif + touch _.cs + +########################################################################### +# +# The rest is pretty (or ugly if you prefer) magic, and should generally +# not need to be fiddled with. Good luck if you need to venture past this +# point. +# + +# Run a buildworld with our private make.conf +buildworld: _.bw +_.bw: + (cd ${WORLDDIR} && \ + make ${MAKEJ} -s buildworld __MAKE_CONF=${.CURDIR}/make.conf \ + ) > _.bw.tmp 2>&1 + mv _.bw.tmp _.bw + +# Run installworld and install into our object directory +installworld: _.iw +_.iw: _.bw + -rm -rf ${WD} > /dev/null 2>&1 + -chflags -R noschg ${WD} > /dev/null 2>&1 + rm -rf ${WD} + mkdir -p ${WD} + (cd ${WORLDDIR} && \ + make ${MAKEJ} -s installworld \ + DESTDIR=${WD} \ + __MAKE_CONF=${.CURDIR}/make.conf \ + ) > _.iw.tmp 2>&1 + mv _.iw.tmp _.iw + +# Run distribution target in /etc. +_.di: _.iw + mkdir -p ${WD} + (cd ${WORLDDIR}/etc && \ + make ${MAKEJ} -s distribution \ + DESTDIR=${WD} \ + __MAKE_CONF=${.CURDIR}/make.conf \ + ) > _.di.tmp 2>&1 + mv _.di.tmp _.di + +# Build kernel +_.bk: ${WORLDDIR}/sys/i386/conf/${KERNCONF} + (cd ${WORLDDIR} && \ + make ${MAKEJ} -s buildkernel \ + KERNCONF=${KERNCONF} \ + __MAKE_CONF=${.CURDIR}/make.conf \ + ) > _.bk.tmp 2>&1 + mv _.bk.tmp _.bk + +# Install kernel and hints file +_.ik: _.bk _.di + cp ${WORLDDIR}/sys/i386/conf/GENERIC.hints ${WD}/boot/device.hints + (cd ${WORLDDIR} && \ + make ${MAKEJ} installkernel \ + KERNCONF=${KERNCONF} \ + DESTDIR=${WD} \ + __MAKE_CONF=${.CURDIR}/make.conf \ + ) > _.ik.tmp 2>&1 + mv _.ik.tmp _.ik + + +# Create a disk image from the installed image +buildimage: _.md +_.md: _.cs + -umount ${WD}/dev > /dev/null 2>&1 + chflags -R noschg ${WD} > /dev/null 2>&1 + rm -rf ${WD}/var/* ${WD}/dev/* ${WD}/tmp + # create trigger file for etc/rc.d/initdiskless + touch ${WD}/etc/diskless + mkdir -p ${WD}/conf/base/var + mtree -deU -f ${WD}/etc/mtree/BSD.var.dist -p ${WD}/conf/base/var + mkdir -p ${WD}/conf/base/etc + ( cd ${WD}/etc && find . -print | cpio -dumpl ../conf/base/etc ) + mkdir -p ${WD}/conf/default/etc + echo "mount -o ro /dev/ad0s3" > ${WD}/conf/default/etc/remount + ln -s var/tmp ${WD}/tmp + mtree -deU -f ${WD}/etc/mtree/BSD.root.dist -p ${WD}/ + mtree -deU -f ${WD}/etc/mtree/BSD.usr.dist -p ${WD}/usr + mtree -deU -f ${WD}/etc/mtree/BSD.include.dist -p ${WD}/usr/include +.if exists(${WD}/etc/mtree/BSD.sendmail.dist) + mtree -deU -f ${WD}/etc/mtree/BSD.sendmail.dist -p ${WD}/ +.endif + (cd ${WD} && mtree -c -Kmd5digest ) > _.mtree.tmp + ${.CURDIR}/i386.diskimage \ + ${SECTS} \ + ${HD} \ + ${SC} \ + ${DATASLICE} \ + ${WD} ${.OBJDIR}/_.i \ + > _.md.tmp 2>&1 + mv _.mtree.tmp _.mtree + mv _.md.tmp _.md + +clean: + -rm -rf _.* > /dev/null 2>&1 + -chflags -R noschg _.* > /dev/null 2>&1 + rm -rf _.* + +.include <bsd.obj.mk> diff --git a/tools/tools/nanobsd/i386.diskimage b/tools/tools/nanobsd/i386.diskimage new file mode 100644 index 0000000..31323fa --- /dev/null +++ b/tools/tools/nanobsd/i386.diskimage @@ -0,0 +1,41 @@ +#!/bin/sh +# +# Copyright (c) 2003-2004 Poul-Henning Kamp. +# +# See /usr/share/examples/etc/bsd-style-copyright for license terms. +# +# $FreeBSD$ +# +# Called as: +# +# ${.CURDIR}/i386.diskimage $SECTS $HD $SC $DATASLICE ${.OBJDIR}/_.w ${.OBJDIR}/_.i +# +# XXX: newfs params. + +set -ex + +dd if=/dev/zero of=/tmp/$$.d count=$1 +MD=`mdconfig -a -t vnode -f /tmp/$$.d -x $3 -y $2` +rm -f /tmp/$$.d +( +sl=`expr "(" $1 - $3 - $4 ")" / 2` +echo p 1 165 $3 $sl +echo p 2 165 `expr $3 + $sl` $sl +echo p 3 165 `expr $3 + $sl + $sl` $4 +) > /tmp/$$ +cat /tmp/$$ +fdisk -i -f /tmp/$$ $MD +fdisk $MD +boot0cfg -B -b /boot/boot0sio -s 1 -m 3 $MD +rm -f /tmp/$$ +bsdlabel -w -B ${MD}s1 +newfs -O1 -U ${MD}s1a +newfs -O1 -U ${MD}s3 +mount /dev/${MD}s1a /mnt +(cd $5 && find . -print | cpio -dump /mnt) || true +df /mnt +umount /mnt +dd if=/dev/${MD}s1 of=/dev/${MD}s2 bs=64k +dd if=/dev/${MD} of=$6 bs=64k +dd if=/dev/${MD}s1 of=${6}.s1 bs=64k +mdconfig -d -u ${MD} diff --git a/tools/tools/nanobsd/make.conf b/tools/tools/nanobsd/make.conf new file mode 100644 index 0000000..c6c804a --- /dev/null +++ b/tools/tools/nanobsd/make.conf @@ -0,0 +1,38 @@ +# +# Copyright (c) 2003-2004 Poul-Henning Kamp. +# +# See /usr/share/examples/etc/bsd-style-copyright for license terms. +# +# $FreeBSD$ +# +NO_SENDMAIL=yes +NO_KERBEROS=yes +NO_IPFILTER=yes +NO_LPR=yes +NO_I4B=yes +NO_CXX=yes +NO_FORTRAN=yes +NO_OBJC=yes +NOHTML=yes +NO_GDB=yes +NO_GCOV=yes +NOINET6=yes +NORADIUS=yes +NOPROFILE=yes +NOLIBPTHREAD=yes +NOLIBTHR=yes +#NO_YP_LIBC=yes +NO_HESIOD_LIBC=yes +NO_SHAREDOCS=yes +NO_CVS=yes +NOMAN=yes +NOATM=yes +NO_USB=yes +NO_VINUM=yes +NO_TOOLCHAIN=yes +NO_ACPI=yes +NO_RESCUE=yes +NOGAMES=yes +NOINFO=yes +NO_MODULES=yes +NO_PF=YES |