Remove the old Makefile based nanobsd build method, the new shell script

based is far better and the only one supported from now on.
This commit is contained in:
Poul-Henning Kamp 2005-09-26 14:57:27 +00:00
parent 2b7182c6b7
commit bce8140d46
10 changed files with 0 additions and 600 deletions

View File

@ -1,27 +0,0 @@
#! /bin/sh
#
# Customize a nanoBSD flash image for Soekris NET4801
#
# Copyright (c) 2004 Poul-Henning Kamp
#
# See /usr/share/examples/etc/bsd-style-copyright for license terms.
#
# $FreeBSD$
#
# Usage:
#
# ${CUSTOMIZE} ${WD} ${WORLDDIR} ${.CURDIR} [ ${LOCAL_FILES_LIST} ]
WD=$1
WORLDDIR=$2
CURDIR=$3
LOCAL_FILES_LIST=$4
# Older NET4801s do not have the necessary wires on the PCB to run DMA
# mode against the CF card. Disable ata_dma so we can boot.
touch ${WD}/boot/loader.conf
sed -i "" -e '/hw.ata.ata_dma/d' ${WD}/boot/loader.conf
echo 'hw.ata.ata_dma="0"' >> ${WD}/boot/loader.conf

View File

@ -1,30 +0,0 @@
#! /bin/sh
#
# Customize a nanoBSD flash image for serial console
#
# Copyright (c) 2004 Poul-Henning Kamp
#
# See /usr/share/examples/etc/bsd-style-copyright for license terms.
#
# $FreeBSD$
#
# Usage:
#
# ${CUSTOMIZE} ${WD} ${WORLDDIR} ${.CURDIR} [ ${LOCAL_FILES_LIST} ]
WD=$1
WORLDDIR=$2
CURDIR=$3
LOCAL_FILES_LIST=$4
PKG_DBDIR=${WD}/var/db/pkg
export PKG_DBDIR
# Enable getty on console
sed -i "" -e /ttyd0/s/off/on/ ${WD}/etc/ttys
# Disable getty on syscons devices
sed -i "" -e '/^ttyv[0-8]/s/ on/ off/' ${WD}/etc/ttys
# Tell loader to use serial console early.
echo " -h" > ${WD}/boot.config

View File

@ -1,64 +0,0 @@
#! /bin/sh
#
# Customize a nanoBSD flash image
#
# Copyright (c) 2004 Thomas Quinot
#
# See /usr/share/examples/etc/bsd-style-copyright for license terms.
#
# $FreeBSD$
#
# Usage:
#
# ${CUSTOMIZE} ${WD} ${WORLDDIR} ${.CURDIR} [ ${LOCAL_FILES_LIST} ]
WD=$1
WORLDDIR=$2
CURDIR=$3
LOCAL_FILES_LIST=$4
PKG_DBDIR=${WD}/var/db/pkg
export PKG_DBDIR
add_CURDIR() {
case "$1" in
/*) echo "$1" ;;
*) echo "${CURDIR}/$1" ;;
esac
}
pkg_relocate() {
sed -e "1,/^@cwd/s#^@cwd #&${WD}#"
}
installlocalfiles() {
if [ -n "${LOCAL_FILES_LIST}" ]; then
while read src dest;
do
case "x${src}" in
x#*|x)
;;
x@*)
eval "for pkg in `add_CURDIR \"\`echo ${src} | sed 's/^@//'\`\"`;
do pkg_add -M \${pkg} | pkg_relocate | pkg_add -S;
done"
;;
*)
dest="${dest:-${src}}"
mkdir -p ${WD}/`dirname "${dest}x"`
eval cp -fp `add_CURDIR ${src}` "${WD}/${dest}"
;;
esac
done < ${LOCAL_FILES_LIST}
fi
}
movelocaletc() {
if [ ! -d ${WD}/etc/local -a -d ${WD}/usr/local/etc ]; then
mv ${WD}/usr/local/etc ${WD}/etc/local
ln -s ../../etc/local ${WD}/usr/local/etc
fi
}
installlocalfiles
movelocaletc

View File

@ -1,15 +0,0 @@
#!/bin/sh
#
# Install whatever files are in ${.CURDIR}/Files
#
# Copyright (c) 2004 Poul-Henning Kamp
#
# See /usr/share/examples/etc/bsd-style-copyright for license terms.
#
# $FreeBSD$
#
# Usage:
# ${CUSTOMIZE} ${WD} ${WORLDDIR} ${.CURDIR} [ ${LOCAL_FILES_LIST} ]
cd $3/Files
find . ! -path \*/CVS\* -print | cpio -dumpv $1

View File

@ -1,25 +0,0 @@
#! /bin/sh
#
# Customize a nanoBSD flash image to disable the loaders ascii-art beastie
#
# Copyright (c) 2004 Poul-Henning Kamp
#
# See /usr/share/examples/etc/bsd-style-copyright for license terms.
#
# $FreeBSD$
#
# Usage:
#
# ${CUSTOMIZE} ${WD} ${WORLDDIR} ${.CURDIR} [ ${LOCAL_FILES_LIST} ]
WD=$1
WORLDDIR=$2
CURDIR=$3
LOCAL_FILES_LIST=$4
PKG_DBDIR=${WD}/var/db/pkg
export PKG_DBDIR
touch ${WD}/boot/loader.conf
sed -i "" -e '/beastie_disable/d' ${WD}/boot/loader.conf
echo 'beastie_disable="YES"' >> ${WD}/boot/loader.conf

View File

@ -1,18 +0,0 @@
#!/bin/sh
#
# Install whatever packages are in ${.CURDIR}/Pkg
#
# Copyright (c) 2004 Poul-Henning Kamp
#
# See /usr/share/examples/etc/bsd-style-copyright for license terms.
#
# $FreeBSD$
#
# Usage:
# ${CUSTOMIZE} ${WD} ${WORLDDIR} ${.CURDIR} [ ${LOCAL_FILES_LIST} ]
rm -rf $1/tmp/Pkg $1/var/db/pkg/* $1/usr/local/*
mkdir $1/tmp/Pkg
ln $3/Pkg/* $1/tmp/Pkg
( chroot $1 sh -c "cd /tmp/Pkg && pkg_add -v *" )
rm -rf $1/tmp/Pkg

View File

@ -1,191 +0,0 @@
# Copyright (c) 2003-2004 Poul-Henning Kamp.
# Copyright (c) 2004 Thomas Quinot.
#
# See /usr/share/examples/etc/bsd-style-copyright for license terms.
#
# $FreeBSD$
MAKE_CONF?= ${.CURDIR}/make.conf
.include "${MAKE_CONF}"
# parallism flag for make.
MAKEJ?="-j3"
.if defined(WITH_GEOM_VOL)
# Do not hardcode device names, use FFS volume labels instead.
# Requires 'options GEOM_VOL' in kernel.
PRIROOTSLICE= vol/sysflash1
ALTROOTSLICE= vol/sysflash2
CFGSLICE= vol/cfgflash
.else
# Some CF cards behave as slaves, (eg Lexar) and are assigned ad1.
DEVICE?= ad0
PRIROOTSLICE= ${DEVICE}s1a
ALTROOTSLICE= ${DEVICE}s2a
CFGSLICE= ${DEVICE}s3
.endif
# 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)
DATASIZE?=10240
# 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
#CUSTOMIZE_ARGS?= some_arguments
# Set this to the name of a directory used to populate the
# configuration slice.
#CFGMASTER?= ${.CURDIR}/cfgmaster
.for cust in CFGMASTER
.if !empty(${cust})
.if exists(${.CURDIR}/${${cust}})
${cust}_PATH= ${.CURDIR}/${${cust}}
.elif exists(${${cust}})
${cust}_PATH= ${${cust}}
.endif
.endif
.endfor
#
# 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
rm -f _.cs.tmp
touch _.cs.tmp
.for cust in ${CUSTOMIZE}
.if exists(${.CURDIR}/Customize/${${cust}})
sh -e ${.CURDIR}/Customize/${cust} ${WD} ${WORLDDIR} ${.CURDIR} ${CUSTOMIZE_ARGS} >> _.cs.tmp 2>&1
.elif exists(${.CURDIR}/${${cust}})
sh -e ${.CURDIR}/${cust} ${WD} ${WORLDDIR} ${.CURDIR} ${CUSTOMIZE_ARGS} >> _.cs.tmp 2>&1
.else
sh -e ${cust} ${WD} ${WORLDDIR} ${.CURDIR} ${CUSTOMIZE_ARGS} >> _.cs.tmp 2>&1
.endif
.endfor
mv _.cs.tmp _.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=${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=${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=${MAKE_CONF} \
) > _.di.tmp 2>&1
mv _.di.tmp _.di
# Build kernel
_.bk:
(cd ${WORLDDIR} && \
make ${MAKEJ} -s buildkernel \
__MAKE_CONF=${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 \
DESTDIR=${WD} \
__MAKE_CONF=${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}/dev/* ${WD}/tmp
# create trigger file for etc/rc.d/initdiskless
touch ${WD}/etc/diskless
mkdir -p ${WD}/conf/base/var
( cd ${WD}/var && find . -print | cpio -dumpl ../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/${CFGSLICE}" > ${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
.if defined(NANOBSD_PRUNE)
( cd ${WD} ; rm -rf ${NANOBSD_PRUNE} )
.endif
(cd ${WD} && mtree -c -Kmd5digest ) > _.mtree.tmp
sh -e ${.CURDIR}/i386.diskimage \
${SECTS} \
${HD} \
${SC} \
${DATASIZE} \
${PRIROOTSLICE} \
${ALTROOTSLICE} \
${CFGSLICE} \
${WD} ${.OBJDIR}/_.i \
${CFGMASTER_PATH} \
> _.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>

View File

@ -1,72 +0,0 @@
#! /bin/sh
#
# Customize a nanoBSD flash image
#
# Copyright (c) 2004 Thomas Quinot
#
# See /usr/share/examples/etc/bsd-style-copyright for license terms.
#
# $FreeBSD$
#
# Usage:
#
# ${CUSTOMIZE} ${WD} ${WORLDDIR} ${.CURDIR} [ ${LOCAL_FILES_LIST} ]
WD=$1
WORLDDIR=$2
CURDIR=$3
LOCAL_FILES_LIST=$4
PKG_DBDIR=${WD}/var/db/pkg
export PKG_DBDIR
# Useful stuff for diskless boot
customizecfg() {
sed -i "" -e /beastie/d ${WD}/boot/loader.rc
sed -i "" -e /ttyd0/s/off/on/ ${WD}/etc/ttys
echo " -h" > ${WD}/boot.config
}
add_CURDIR() {
case "$1" in
/*) echo "$1" ;;
*) echo "${CURDIR}/$1" ;;
esac
}
pkg_relocate() {
sed -e "1,/^@cwd/s#^@cwd #&${WD}#"
}
installlocalfiles() {
if [ -n "${LOCAL_FILES_LIST}" ]; then
while read src dest;
do
case "x${src}" in
x#*|x)
;;
x@*)
eval "for pkg in `add_CURDIR \"\`echo ${src} | sed 's/^@//'\`\"`;
do pkg_add -M \${pkg} | pkg_relocate | pkg_add -S;
done"
;;
*)
dest="${dest:-${src}}"
mkdir -p ${WD}/`dirname "${dest}x"`
eval cp -fp `add_CURDIR ${src}` "${WD}/${dest}"
;;
esac
done < ${LOCAL_FILES_LIST}
fi
}
movelocaletc() {
if [ ! -d ${WD}/etc/local -a -d ${WD}/usr/local/etc ]; then
mv ${WD}/usr/local/etc ${WD}/etc/local
ln -s ../../etc/local ${WD}/usr/local/etc
fi
}
customizecfg
installlocalfiles
movelocaletc

View File

@ -1,124 +0,0 @@
#!/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 $DATASIZE \
# $PRIROOTSLICE $ALTROOTSLICE $CFGSLICE \
# ${.OBJDIR}/_.w ${.OBJDIR}/_.i [ ${.CURDIR}/cfgmaster ]
#
# XXX: newfs params.
set -ex
SECTS=$1
HD=$2
SC=$3
DATASIZE=$4
PRIROOTSLICE=$5
ALTROOTSLICE=$6
CFGSLICE=$7
WD=$8
IMG=$9
CFGMASTER=${10}
NEWFSPARAM="-b 4096 -f 512 -i 8192"
TMPFILE0=`mktemp -t nanobsd`
TMPFILE1=`mktemp -t nanobsd`
TMPMNT=`mktemp -d -t nanobsd`
make_fstab () {
echo "/dev/$1 / ufs ro 1 1" > $4/etc/fstab
echo "/dev/$2 /alt ufs ro,noauto 1 1" >> $4/etc/fstab
echo "/dev/$3 /cfg ufs ro,noauto 1 1" >> $4/etc/fstab
ln -f $4/etc/fstab $4/conf/base/etc/fstab
}
get_label () {
case "$1" in
vol/*)
echo -n "-L "; basename $1
;;
*)
echo ""
;;
esac
}
PRIROOTLABEL=`get_label ${PRIROOTSLICE}`
ALTROOTLABEL=`get_label ${ALTROOTSLICE}`
CFGLABEL=`get_label ${CFGSLICE}`
# Attach MD device and prepare slices
dd if=/dev/zero of=${TMPFILE0} count=${SECTS}
MD=`mdconfig -a -t vnode -f ${TMPFILE0} -x ${SC} -y ${HD}`
rm -f ${TMPFILE0}
echo ${SECTS} ${SC} ${HD} ${DATASIZE} | awk '
{
# size of cylinder in sectors
cs = $2 * $3
# number of full cylinders
cyl = int ($1 / cs)
print "g c" cyl " h" $3 " s" $2
# Size of data/conf patition, round up to full cylinder
dsl = int (($4 + cs - 1) / cs)
# Size of code partition cylinder = half the remainder
csl = int ((cyl - dsl) / 2)
# ... But that could round down, so make the data/conf
# use whatever the code partitions do not use.
dsl = cyl - csl * 2
print "p 1 165 " $2, csl * cs - $2
print "p 2 165 " $2 + csl * cs, csl * cs - $2
print "p 3 165 " 2 * csl * cs, dsl * cs
}
' > ${TMPFILE1}
cat ${TMPFILE1}
fdisk -i -f ${TMPFILE1} ${MD}
fdisk ${MD}
boot0cfg -B -b ${WD}/boot/boot0sio -o packet -s 1 -m 3 ${MD}
rm -f ${TMPFILE1}
bsdlabel -w -B ${MD}s1
# Prepare primary root slice
newfs ${NEWFSPARAM} ${PRIROOTLABEL} -O1 -U ${MD}s1a
mount /dev/${MD}s1a ${TMPMNT}
(cd ${WD} && find . -print | cpio -dump ${TMPMNT}) || true
make_fstab ${PRIROOTSLICE} ${ALTROOTSLICE} ${CFGSLICE} ${TMPMNT}
df -i ${TMPMNT}
umount ${TMPMNT}
# Prepare alternative root slice
dd if=/dev/${MD}s1 of=/dev/${MD}s2 bs=64k
if [ -n "${ALTROOTLABEL}" ]; then
tunefs ${ALTROOTLABEL} /dev/${MD}s2a
fi
mount /dev/${MD}s2a ${TMPMNT}
make_fstab ${ALTROOTSLICE} ${PRIROOTSLICE} ${CFGSLICE} ${TMPMNT}
umount ${TMPMNT}
# Prepare configuration slice
newfs ${NEWFSPARAM} ${CFGLABEL} -O1 -U ${MD}s3
if [ -d "${CFGMASTER}" ]; then
mount /dev/${MD}s3 ${TMPMNT}
( cd ${CFGMASTER} && find . -print | cpio -dumpl ${TMPMNT} )
umount ${TMPMNT}
fi
# Create flash images
dd if=/dev/${MD} of=${IMG} bs=64k
dd if=/dev/${MD}s1 of=${IMG}.s1 bs=64k
# Detach MD device
mdconfig -d -u ${MD}

View File

@ -1,34 +0,0 @@
#
# Example installation list to be used with nanoBSD customization script.
#
# Copyright (c) 2004 Thomas Quinot
#
# See /usr/share/examples/etc/bsd-style-copyright for license terms.
#
# $FreeBSD$
#
#
# Syntax:
#
# SRC DEST
# Copy SRC to DEST
#
# SRC
# Copy SRC to `dirname SRC`
#
# @PKG
# Install package PKG
#
# Both SRC and PKG may contain shell wildcards.
#
# Examples:
#
# Copy a file from the local system to the same location on the image
#/usr/local/libexec/foo
#
# Copy a file from $CURDIR to a specified location on the image
#bar /usr/local/sbin/
#
# Install packages from a directory relative to $CURDIR
# on the image
#@mypackages/*