head	1.15;
access;
symbols
	RELENG_6_4_0_RELEASE:1.14.2.1
	RELENG_6_4:1.14.2.1.0.10
	RELENG_6_4_BP:1.14.2.1
	RELENG_6_3_0_RELEASE:1.14.2.1
	RELENG_6_3:1.14.2.1.0.8
	RELENG_6_3_BP:1.14.2.1
	RELENG_6_2_0_RELEASE:1.14.2.1
	RELENG_6_2:1.14.2.1.0.6
	RELENG_6_2_BP:1.14.2.1
	RELENG_5_5_0_RELEASE:1.8.2.4
	RELENG_5_5:1.8.2.4.0.2
	RELENG_5_5_BP:1.8.2.4
	RELENG_6_1_0_RELEASE:1.14.2.1
	RELENG_6_1:1.14.2.1.0.4
	RELENG_6_1_BP:1.14.2.1
	RELENG_6_0_0_RELEASE:1.14.2.1
	RELENG_6_0:1.14.2.1.0.2
	RELENG_6_0_BP:1.14.2.1
	RELENG_6:1.14.0.2
	RELENG_6_BP:1.14
	RELENG_5_4_0_RELEASE:1.8.2.2
	RELENG_5_4:1.8.2.2.0.2
	RELENG_5_4_BP:1.8.2.2
	RELENG_5_3_0_RELEASE:1.8
	RELENG_5_3:1.8.0.4
	RELENG_5_3_BP:1.8
	RELENG_5:1.8.0.2
	RELENG_5_BP:1.8;
locks; strict;
comment	@# @;


1.15
date	2005.09.26.14.57.26;	author phk;	state dead;
branches;
next	1.14;

1.14
date	2005.05.19.15.34.36;	author phk;	state Exp;
branches
	1.14.2.1;
next	1.13;

1.13
date	2005.04.13.21.20.16;	author phk;	state Exp;
branches;
next	1.12;

1.12
date	2005.03.17.19.45.05;	author phk;	state Exp;
branches;
next	1.11;

1.11
date	2005.03.12.20.41.26;	author phk;	state Exp;
branches;
next	1.10;

1.10
date	2004.11.28.17.12.15;	author phk;	state Exp;
branches;
next	1.9;

1.9
date	2004.11.28.13.28.04;	author phk;	state Exp;
branches;
next	1.8;

1.8
date	2004.08.16.22.41.58;	author thomas;	state Exp;
branches
	1.8.2.1;
next	1.7;

1.7
date	2004.08.08.13.05.03;	author thomas;	state Exp;
branches;
next	1.6;

1.6
date	2004.05.28.21.26.49;	author thomas;	state Exp;
branches;
next	1.5;

1.5
date	2004.05.28.21.23.23;	author thomas;	state Exp;
branches;
next	1.4;

1.4
date	2004.05.28.21.16.14;	author thomas;	state Exp;
branches;
next	1.3;

1.3
date	2004.04.27.16.04.41;	author phk;	state Exp;
branches;
next	1.2;

1.2
date	2004.03.10.11.11.58;	author phk;	state Exp;
branches;
next	1.1;

1.1
date	2004.03.10.10.28.33;	author phk;	state Exp;
branches;
next	;

1.8.2.1
date	2005.02.28.10.01.45;	author phk;	state Exp;
branches;
next	1.8.2.2;

1.8.2.2
date	2005.03.21.17.14.24;	author phk;	state Exp;
branches;
next	1.8.2.3;

1.8.2.3
date	2005.05.19.11.26.25;	author phk;	state Exp;
branches;
next	1.8.2.4;

1.8.2.4
date	2005.05.20.11.04.50;	author phk;	state Exp;
branches;
next	;

1.14.2.1
date	2005.09.26.15.00.48;	author phk;	state dead;
branches;
next	;


desc
@@


1.15
log
@Remove the old Makefile based nanobsd build method, the new shell script
based is far better and the only one supported from now on.
@
text
@# Copyright (c) 2003-2004 Poul-Henning Kamp.
# Copyright (c) 2004      Thomas Quinot.
#
# See /usr/share/examples/etc/bsd-style-copyright for license terms.
#
# $FreeBSD: src/tools/tools/nanobsd/Makefile,v 1.14 2005/05/19 15:34:36 phk Exp $

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


1.14
log
@Make the path to make.conf a parameter which can be overridden.

NB: you have to use absolute path!
@
text
@d6 1
a6 1
# $FreeBSD$
@


1.14.2.1
log
@MFC:
	nanobsd conversion to shell script.

Approved by:	re@@ (scottl)
@
text
@d6 1
a6 1
# $FreeBSD: src/tools/tools/nanobsd/Makefile,v 1.14 2005/05/19 15:34:36 phk Exp $
@


1.13
log
@Introduce NANOBSD_PRUNE which can be used to zap out bits we don't
want to carry forward.
@
text
@d8 3
a10 1
.include "${.CURDIR}/make.conf"
d100 1
a100 1
		make ${MAKEJ} -s buildworld __MAKE_CONF=${.CURDIR}/make.conf \
d114 1
a114 1
		__MAKE_CONF=${.CURDIR}/make.conf \
d124 1
a124 1
		__MAKE_CONF=${.CURDIR}/make.conf \
d132 1
a132 1
		__MAKE_CONF=${.CURDIR}/make.conf \
d142 1
a142 1
		__MAKE_CONF=${.CURDIR}/make.conf \
@


1.12
log
@I keep forgetting that I wanted the customize logs collected too.

Reminded by:	Lennart Sorth, Andrea Campi and others.
@
text
@d166 3
@


1.11
log
@DTRT with /var so that any packages installed are correctly recorded.
@
text
@d74 2
d78 1
a78 1
	sh -e ${.CURDIR}/Customize/${cust} ${WD} ${WORLDDIR} ${.CURDIR} ${CUSTOMIZE_ARGS}
d80 1
a80 1
	sh -e ${.CURDIR}/${cust} ${WD} ${WORLDDIR} ${.CURDIR} ${CUSTOMIZE_ARGS}
d82 1
a82 1
	sh -e ${cust} ${WD} ${WORLDDIR} ${.CURDIR} ${CUSTOMIZE_ARGS}
d85 1
a85 1
	touch _.cs
@


1.10
log
@Make it possible to specify a list of customize scripts.

Look for them in ./Customize first, then relative to . and then absolute.
@
text
@d148 1
a148 1
	rm -rf ${WD}/var/* ${WD}/dev/* ${WD}/tmp
d152 1
a152 1
	mtree -deU -f ${WD}/etc/mtree/BSD.var.dist -p ${WD}/conf/base/var
@


1.9
log
@Reduce -j12 to -j3
@
text
@d50 1
a50 1
.for cust in CUSTOMIZE CFGMASTER
d74 5
a78 5
.if empty(CUSTOMIZE_PATH)
	# 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
d80 1
a80 1
	sh -e ${CUSTOMIZE_PATH} ${WD} ${WORLDDIR} ${.CURDIR} ${CUSTOMIZE_ARGS}
d82 1
@


1.8
log
@Properly identify the root filesystem to be used in /etc/fstab in each
slice of the flash card, ensuring that the loader will mount the root fs
from the booted slice by default.

Allow usage of FFS volume labels instead of hardcoded device names through
WITH_GEOM_VOL Makefile knob.

Approved by:	re (scottl)
@
text
@d11 1
a11 1
MAKEJ?="-j12"
@


1.8.2.1
log
@MFC:
	Bring nanobsd in like with the stuff in -current.
@
text
@d11 1
a11 1
MAKEJ?="-j3"
d50 1
a50 1
.for cust in CFGMASTER
d74 5
a78 5
.for cust in ${CUSTOMIZE}
.if exists(${.CURDIR}/Customize/${${cust}})
	sh -e ${.CURDIR}/Customize/${cust} ${WD} ${WORLDDIR} ${.CURDIR} ${CUSTOMIZE_ARGS}
.elif exists(${.CURDIR}/${${cust}})
	sh -e ${.CURDIR}/${cust} ${WD} ${WORLDDIR} ${.CURDIR} ${CUSTOMIZE_ARGS}
d80 1
a80 1
	sh -e ${cust} ${WD} ${WORLDDIR} ${.CURDIR} ${CUSTOMIZE_ARGS}
a81 1
.endfor
@


1.8.2.2
log
@MFC:
	record customization script output in _.cs
	preserve /var contents to retain pkg database
	Fix a comment to make more sense.

Approved by:	re@@
@
text
@a73 2
	rm -f _.cs.tmp
	touch _.cs.tmp
d76 1
a76 1
	sh -e ${.CURDIR}/Customize/${cust} ${WD} ${WORLDDIR} ${.CURDIR} ${CUSTOMIZE_ARGS}  >> _.cs.tmp 2>&1
d78 1
a78 1
	sh -e ${.CURDIR}/${cust} ${WD} ${WORLDDIR} ${.CURDIR} ${CUSTOMIZE_ARGS} >> _.cs.tmp 2>&1
d80 1
a80 1
	sh -e ${cust} ${WD} ${WORLDDIR} ${.CURDIR} ${CUSTOMIZE_ARGS} >> _.cs.tmp 2>&1
d83 1
a83 1
	mv _.cs.tmp _.cs
d148 1
a148 1
	rm -rf ${WD}/dev/* ${WD}/tmp
d152 1
a152 1
	( cd ${WD}/var && find . -print | cpio -dumpl ../conf/base/var )
@


1.8.2.3
log
@MFC:
	add NANOBSD_PRUNE support
@
text
@a165 3
.if defined(NANOBSD_PRUNE)
	( cd ${WD} ; rm -rf ${NANOBSD_PRUNE} )
.endif
@


1.8.2.4
log
@MFC:
	Make make.conf overridable (remember absolute path!)
	Add newfs params for space saving
	call Customize/files by default
@
text
@d8 1
a8 3
MAKE_CONF?=	${.CURDIR}/make.conf

.include "${MAKE_CONF}"
d98 1
a98 1
		make ${MAKEJ} -s buildworld __MAKE_CONF=${MAKE_CONF} \
d112 1
a112 1
		__MAKE_CONF=${MAKE_CONF} \
d122 1
a122 1
		__MAKE_CONF=${MAKE_CONF} \
d130 1
a130 1
		__MAKE_CONF=${MAKE_CONF} \
d140 1
a140 1
		__MAKE_CONF=${MAKE_CONF} \
@


1.7
log
@Include the nanoBSD make.conf in the top-level nanoBSD Makefile, so
all configuration knobs (both system settings and nanoBSD-specific ones)
can be tuned by modifying a single file. Move KERNCONF default value
to make.conf.

Attempt to resolve CFGMASTER like CUSTOMIZE, first relative to ${.CURDIR},
then as an absolute path.

Allow optional additional arguments to be passed to the CUSTOMIZE script.
@
text
@d13 7
d22 4
a25 2
ROOTSLICE=	${DEVICE}s1a
CONFSLICE=	${DEVICE}s3
d35 1
a35 1
DATASLICE?=10240
a73 1
	echo "/dev/${ROOTSLICE} / ufs ro 1 1" >  ${WD}/etc/fstab
d155 1
a155 1
	echo "mount -o ro /dev/${CONFSLICE}" > ${WD}/conf/default/etc/remount
d168 4
a171 1
		${DATASLICE} \
@


1.6
log
@Add trailing backslash missing from previous checkin.
@
text
@d2 1
d8 2
d13 5
a27 3
# Name of kernel configuration file to use.
KERNCONF?= GENERIC

d34 2
a35 1
#CUSTOMIZE?=	${.CURDIR}/somescript.sh
d41 10
d65 2
a66 2
	echo "/dev/ad0s1a / ufs ro 1 1" >  ${WD}/etc/fstab
.if empty(CUSTOMIZE)
a70 4
.elif exists(${.CURDIR}/${CUSTOMIZE})
	sh -e ${.CURDIR}/${CUSTOMIZE} ${WD} ${WORLDDIR} ${.CURDIR}
.elif exists(${CUSTOMIZE})
	sh -e ${CUSTOMIZE} ${WD} ${WORLDDIR} ${.CURDIR}
d72 1
a72 2
	echo "CUSTOMIZE script not found" 1>&2
	false
d116 1
a116 1
_.bk:	${WORLDDIR}/sys/i386/conf/${KERNCONF}
a118 1
		KERNCONF=${KERNCONF} \
a127 1
		KERNCONF=${KERNCONF} \
d147 1
a147 1
	echo "mount -o ro /dev/ad0s3" > ${WD}/conf/default/etc/remount
d162 1
a162 1
		${CFGMASTER} \
@


1.5
log
@Support for optional initialization of the configuration slice by
specifying the name of a directory to be copied there in Makefile
variable CFGMASTER.
@
text
@d153 1
a153 1
		${CFGMASTER}
@


1.4
log
@Look up ${CUSTOMIZE} in ${.CURDIR} first, and then as a path name by itself,
assuming in the latter case that it is an absolute path name.
@
text
@d31 4
d153 1
@


1.3
log
@More POLA handling of CUSTOMIZE variable
@
text
@d34 1
a34 1

d51 2
a54 2
.elif exists(${.CURDIR}/${CUSTOMIZE})
	sh -e ${.CURDIR}/${CUSTOMIZE} ${WD} ${WORLDDIR} ${.CURDIR}
@


1.2
log
@We don't retain 'x' bits in CVS so explicity use sh to run script.
@
text
@d46 1
a46 3
.if exists(${CUSTOMIZE})
	sh -e ${CUSTOMIZE} ${WD} ${WORLDDIR} ${.CURDIR}
.else
d51 7
@


1.1
log
@Add first cut at "nanobsd":

Nanobsd should make it very simple for people to create (CF-)disk images
for embedded us of FreeBSD.

Currently only works for 256MB disks.  More agrressive shaving of the
build image can reduce that much further.
@
text
@d138 1
a138 1
	${.CURDIR}/i386.diskimage \
@

