head	1.8;
access;
symbols
	RELENG_8_4:1.7.0.2
	RELENG_9_1_0_RELEASE:1.5.2.2.2.2
	RELENG_9_1:1.5.2.2.0.2
	RELENG_9_1_BP:1.5.2.2
	RELENG_8_3_0_RELEASE:1.3.2.2.6.1
	RELENG_8_3:1.3.2.2.0.6
	RELENG_8_3_BP:1.3.2.2
	RELENG_9_0_0_RELEASE:1.5.2.1.2.1
	RELENG_9_0:1.5.2.1.0.2
	RELENG_9_0_BP:1.5.2.1
	RELENG_9:1.5.0.2
	RELENG_9_BP:1.5
	RELENG_8_2_0_RELEASE:1.3.2.2.4.1
	RELENG_8_2:1.3.2.2.0.4
	RELENG_8_2_BP:1.3.2.2
	RELENG_8_1_0_RELEASE:1.3.2.2.2.1
	RELENG_8_1:1.3.2.2.0.2
	RELENG_8_1_BP:1.3.2.2
	RELENG_8_0_0_RELEASE:1.3.2.1.2.1
	RELENG_8_0:1.3.2.1.0.2
	RELENG_8_0_BP:1.3.2.1
	RELENG_8:1.3.0.2
	RELENG_8_BP:1.3;
locks; strict;
comment	@# @;


1.8
date	2013.06.16.00.38.21;	author svnexp;	state Exp;
branches;
next	1.7;

1.7
date	2012.11.17.01.54.10;	author svnexp;	state Exp;
branches
	1.7.2.1;
next	1.6;

1.6
date	2011.10.11.01.11.57;	author thompsa;	state Exp;
branches;
next	1.5;

1.5
date	2011.01.03.20.32.08;	author imp;	state Exp;
branches
	1.5.2.1;
next	1.4;

1.4
date	2010.03.31.18.18.37;	author imp;	state Exp;
branches;
next	1.3;

1.3
date	2009.05.23.19.17.05;	author sam;	state Exp;
branches
	1.3.2.1;
next	1.2;

1.2
date	2009.04.18.15.59.09;	author sam;	state Exp;
branches;
next	1.1;

1.1
date	2009.01.09.21.39.44;	author sam;	state Exp;
branches;
next	;

1.7.2.1
date	2012.11.17.01.54.10;	author svnexp;	state dead;
branches;
next	1.7.2.2;

1.7.2.2
date	2013.03.28.13.05.58;	author svnexp;	state Exp;
branches;
next	;

1.5.2.1
date	2011.09.23.00.51.37;	author kensmith;	state Exp;
branches
	1.5.2.1.2.1;
next	1.5.2.2;

1.5.2.2
date	2012.01.09.21.51.50;	author thompsa;	state Exp;
branches
	1.5.2.2.2.1;
next	1.5.2.3;

1.5.2.3
date	2012.11.17.11.37.35;	author svnexp;	state Exp;
branches;
next	;

1.5.2.1.2.1
date	2011.11.11.04.20.22;	author kensmith;	state Exp;
branches;
next	1.5.2.1.2.2;

1.5.2.1.2.2
date	2012.11.17.08.37.32;	author svnexp;	state Exp;
branches;
next	;

1.5.2.2.2.1
date	2012.08.05.23.54.33;	author kensmith;	state Exp;
branches;
next	1.5.2.2.2.2;

1.5.2.2.2.2
date	2012.11.17.08.48.24;	author svnexp;	state Exp;
branches;
next	;

1.3.2.1
date	2009.08.03.08.13.06;	author kensmith;	state Exp;
branches
	1.3.2.1.2.1;
next	1.3.2.2;

1.3.2.2
date	2010.04.13.01.04.11;	author imp;	state Exp;
branches
	1.3.2.2.2.1
	1.3.2.2.4.1
	1.3.2.2.6.1;
next	1.3.2.3;

1.3.2.3
date	2012.11.17.10.37.14;	author svnexp;	state Exp;
branches;
next	;

1.3.2.1.2.1
date	2009.10.25.01.10.29;	author kensmith;	state Exp;
branches;
next	;

1.3.2.2.2.1
date	2010.06.14.02.09.06;	author kensmith;	state Exp;
branches;
next	;

1.3.2.2.4.1
date	2010.12.21.17.09.25;	author kensmith;	state Exp;
branches;
next	;

1.3.2.2.6.1
date	2012.03.03.06.15.13;	author kensmith;	state Exp;
branches;
next	1.3.2.2.6.2;

1.3.2.2.6.2
date	2012.11.17.08.25.48;	author svnexp;	state Exp;
branches;
next	;


desc
@@


1.8
log
@## SVN ## Exported commit - http://svnweb.freebsd.org/changeset/base/251794
## SVN ## CVS IS DEPRECATED: http://wiki.freebsd.org/CvsIsDeprecated
@
text
@# $FreeBSD: head/tools/tools/nanobsd/gateworks/common 251794 2013-06-15 20:29:07Z eadler $

NANO_CFGDIR=${NANO_CFGDIR:-${NANO_SRC}/${NANO_TOOLS}/gateworks/cfg}
test -d ${NANO_CFGDIR} || NANO_CFGDIR=/var/empty
NANO_PMAKE="make"					# NB: disable -j 3

NANO_ARCH=armeb
TARGET_CPUTYPE=xscale; export TARGET_CPUTYPE		# XXX

NANO_CUSTOMIZE="cust_allow_ssh_root"

clean_usr_local()
{
	LOCAL_DIR=${NANO_WORLDDIR}/usr/local
	pprint 2 "Clean and create world directory (${LOCAL_DIR})"
	if rm -rf ${LOCAL_DIR}/ > /dev/null 2>&1 ; then
		true
	else
		chflags -R noschg ${LOCAL_DIR}/
		rm -rf ${LOCAL_DIR}/
	fi
	for f in bin etc lib libdata libexec sbin share; do
		mkdir -p ${LOCAL_DIR}/$f
	done
}
NANO_CUSTOMIZE="$NANO_CUSTOMIZE clean_usr_local"

cust_install_machine_files()
{
	echo "cd ${NANO_TOOLS}/gateworks/Files"
	cd ${NANO_TOOLS}/gateworks/Files
	find . -print | grep -Ev '/(CVS|\.svn)' | cpio -dumpv ${NANO_WORLDDIR}
}
NANO_CUSTOMIZE="$NANO_CUSTOMIZE cust_install_files cust_install_machine_files"

buildenv()
{
	cd ${NANO_SRC}
	env TARGET_ARCH=${NANO_ARCH} __MAKE_CONF=${NANO_MAKE_CONF_BUILD} \
	    DESTDIR=${NANO_WORLDDIR} make buildenv
}

net80211_tools()
{
	for f in wlanstats wlanwds wlanwatch; do 
		echo "(cd tools/tools/net80211/$f; make $1)"; 
	done | buildenv
}
net80211_clean_tools()
{
	net80211_tools "clean"
}
net80211_build_tools()
{
	net80211_tools ""
}
net80211_install_tools()
{
	net80211_tools "install"
}
NANO_CUSTOMIZE="$NANO_CUSTOMIZE net80211_clean_tools"
NANO_CUSTOMIZE="$NANO_CUSTOMIZE net80211_build_tools"
NANO_CUSTOMIZE="$NANO_CUSTOMIZE net80211_install_tools"

ath_clean_tools()
{
	echo "cd tools/tools/ath; make clean" | buildenv
}
ath_build_tools()
{
	echo "cd tools/tools/ath; make" | buildenv
}
ath_install_tools()
{
	echo "cd tools/tools/ath; make install" | buildenv
}
NANO_CUSTOMIZE="$NANO_CUSTOMIZE ath_clean_tools"
NANO_CUSTOMIZE="$NANO_CUSTOMIZE ath_build_tools"
NANO_CUSTOMIZE="$NANO_CUSTOMIZE ath_install_tools"

npe_clean_tools()
{
	echo "cd tools/tools/npe; make clean" | buildenv
}
npe_build_tools()
{
	echo "cd tools/tools/npe; make" | buildenv
}
npe_install_tools()
{
	echo "cd tools/tools/npe; make install" | buildenv
}
NANO_CUSTOMIZE="$NANO_CUSTOMIZE npe_clean_tools"
NANO_CUSTOMIZE="$NANO_CUSTOMIZE npe_build_tools"
NANO_CUSTOMIZE="$NANO_CUSTOMIZE npe_install_tools"

NANO_MAKEFS="makefs -B big \
	-o bsize=4096,fsize=512,density=8192,optimization=space"
export NANO_MAKEFS

# NB: leave c++ enabled so devd can be built
CONF_BUILD="
WITHOUT_ACCT=true
WITHOUT_ACPI=true
WITHOUT_APM=true
WITHOUT_ATM=true
WITHOUT_AUDIT=true
WITHOUT_BIND_DNSSEC=true
WITHOUT_BIND_ETC=true
WITHOUT_BIND_LIBS_LWRES=true
WITHOUT_BLUETOOTH=true
WITHOUT_BSNMP=true
WITHOUT_CALENDAR=true
WITHOUT_CDDL=true
WITHOUT_CTM=true
WITHOUT_DICT=true
WITHOUT_EXAMPLES=true
WITHOUT_FLOPPY=true
WITHOUT_FORTRAN=true
WITHOUT_GAMES=true
WITHOUT_GCOV=true
WITHOUT_GPIB=true
WITHOUT_GROFF=true
WITHOUT_HTML=true
WITHOUT_INET6=true
WITHOUT_INFO=true
WITHOUT_IPFILTER=true
WITHOUT_IPX=true
WITHOUT_KERBEROS=true
WITHOUT_LOCALES=true
WITHOUT_LPR=true
WITHOUT_MAN=true
WITHOUT_MAIL=true
WITHOUT_MAILWRAPPER=true
WITHOUT_NETCAT=true
WITHOUT_NIS=true
WITHOUT_NLS=true
WITHOUT_NS_CACHING=true
WITHOUT_OBJC=true
WITHOUT_PMC=true
WITHOUT_PORTSNAP=true
WITHOUT_PROFILE=true
WITHOUT_QUOTAS=true
WITHOUT_RCMDS=true
WITHOUT_RCS=true
WITHOUT_RESCUE=true
WITHOUT_SENDMAIL=true
WITHOUT_SHAREDOCS=true
WITHOUT_SSP=true
WITHOUT_SYSCONS=true
WITHOUT_SYSINSTALL=true
WITHOUT_TCSH=true
WITHOUT_TFTPD=true
WITHOUT_ZFS=true
"
CONF_INSTALL="$CONF_BUILD
WITHOUT_TOOLCHAIN=true
WITHOUT_INSTALLLIB=true
INSTALL_NODEBUG=true
"

# NB: override to force / on s1 instead of s1a
setup_nanobsd_etc()
{
	pprint 2 "configure nanobsd /etc"

	(
	cd ${NANO_WORLDDIR}

	# create diskless marker file
	touch etc/diskless

	# Make root filesystem R/O by default
	echo "root_rw_mount=NO" >> etc/defaults/rc.conf

	# save config file for scripts
	echo "NANO_DRIVE=${NANO_DRIVE}" > etc/nanobsd.conf

	echo "/dev/${NANO_DRIVE}s1 / ufs ro 1 1" > etc/fstab
	echo "/dev/${NANO_DRIVE}s3 /cfg ufs rw,noauto 2 2" >> etc/fstab
	mkdir -p cfg
	)
}

create_arm_diskimage()
{
	pprint 2 "build diskimage"
	pprint 3 "log: ${MAKEOBJDIRPREFIX}/_.di"

	(
	echo "NANO_MEDIASIZE:	$NANO_MEDIASIZE"
	echo "NANO_IMAGES:	$NANO_IMAGES"
	echo "NANO_SECTS:	$NANO_SECTS"
	echo "NANO_HEADS:	$NANO_HEADS"
	echo "NANO_CODESIZE:	$NANO_CODESIZE"
	echo "NANO_CONFSIZE:	$NANO_CONFSIZE"
	echo "NANO_DATASIZE:	$NANO_DATASIZE"

	echo $NANO_MEDIASIZE $NANO_IMAGES \
		$NANO_SECTS $NANO_HEADS \
		$NANO_CODESIZE $NANO_CONFSIZE $NANO_DATASIZE |
	awk '
	{
		printf "# %s\n", $0

		# size of cylinder in sectors
		cs = $3 * $4

		# number of full cylinders on media
		cyl = int ($1 / cs)

		# output fdisk geometry spec, truncate cyls to 1023
		if (cyl <= 1023)
			print "g c" cyl " h" $4 " s" $3
		else
			print "g c" 1023 " h" $4 " s" $3

		if ($7 > 0) { 
			# size of data partition in full cylinders
			dsl = int (($7 + cs - 1) / cs)
		} else {
			dsl = 0;
		}

		# size of config partition in full cylinders
		csl = int (($6 + cs - 1) / cs)

		if ($5 == 0) {
			# size of image partition(s) in full cylinders
			isl = int ((cyl - dsl - csl) / $2)
		} else {
			isl = int (($5 + cs - 1) / cs)
		}

		# First image partition start at second track
		print "p 1 165 " $3, isl * cs - $3
		c = isl * cs;

		# Second image partition (if any) also starts offset one 
		# track to keep them identical.
		if ($2 > 1) {
			print "p 2 165 " $3 + c, isl * cs - $3
			c += isl * cs;
		}

		# Config partition starts at cylinder boundary.
		print "p 3 165 " c, csl * cs
		c += csl * cs

		# Data partition (if any) starts at cylinder boundary.
		if ($7 > 0) {
			print "p 4 165 " c, dsl * cs
		} else if ($7 < 0 && $1 > c) {
			print "p 4 165 " c, $1 - c
		} else if ($1 < c) {
			print "Disk space overcommitted by", \
			    c - $1, "sectors" > "/dev/stderr"
			exit 2
		}

		# Force slice 1 to be marked active. This is necessary
		# for booting the image from a USB device to work.
		print "a 1"
	}
	' > ${MAKEOBJDIRPREFIX}/_.fdisk

	IMG=${NANO_DISKIMGDIR}/${NANO_IMGNAME}
	BS=${NANO_SECTS}b

	if [ "${NANO_MD_BACKING}" = "swap" ] ; then
		MD=`mdconfig -a -t swap -s ${NANO_MEDIASIZE} -x ${NANO_SECTS} \
			-y ${NANO_HEADS}`
	else
		echo ""; echo "Creating md backing file ${IMG} ..."
		_c=`expr ${NANO_MEDIASIZE} / ${NANO_SECTS}`
		pprint 2 "dd if=/dev/zero of=${IMG} bs=${BS} count=${_c}"
		dd if=/dev/zero of=${IMG} bs=${BS} count=${_c}
		pprint 2 "mdconfig -a -t vnode -f ${IMG} -x ${NANO_SECTS} -y ${NANO_HEADS}"
		MD=`mdconfig -a -t vnode -f ${IMG} -x ${NANO_SECTS} \
			-y ${NANO_HEADS}`
	fi

	trap "mdconfig -d -u $MD" 1 2 15 EXIT

	echo ""; echo "Write partition table ..."
	FDISK=${MAKEOBJDIRPREFIX}/_.fdisk
	pprint 2 "fdisk -i -f ${FDISK} ${MD}"
	fdisk -i -f ${FDISK} ${MD}
	pprint 2 "fdisk ${MD}"
	fdisk ${MD}

	# Create first image
	IMG1=${NANO_DISKIMGDIR}/_.disk.image1
	echo ""; echo "Create first image ${IMG1} ..."
	SIZE=`awk '/^p 1/ { print $5 "b" }' ${FDISK}`
	pprint 2 "${NANO_MAKEFS} -s ${SIZE} ${IMG1} ${NANO_WORLDDIR}"
	${NANO_MAKEFS} -s ${SIZE} ${IMG1} ${NANO_WORLDDIR}
	pprint 2 "dd if=${IMG1} of=/dev/${MD}s1 bs=${BS}"
	dd if=${IMG1} of=/dev/${MD}s1 bs=${BS}

	if [ $NANO_IMAGES -gt 1 -a $NANO_INIT_IMG2 -gt 0 ] ; then
		IMG2=${NANO_DISKIMGDIR}/_.disk.image2
		echo ""; echo "Create second image ${IMG2}..."
		for f in ${NANO_WORLDDIR}/etc/fstab ${NANO_WORLDDIR}/conf/base/etc/fstab
		do
			sed -i "" "s/${NANO_DRIVE}s1/${NANO_DRIVE}s2/g" $f
		done

		SIZE=`awk '/^p 2/ { print $5 "b" }' ${FDISK}`
		pprint 2 "${NANO_MAKEFS} -s ${SIZE} ${IMG2} ${NANO_WORLDDIR}"
		${NANO_MAKEFS} -s ${SIZE} ${IMG2} ${NANO_WORLDDIR}
		pprint 2 "dd if=${IMG2} of=/dev/${MD}s2 bs=${BS}"
		dd if=${IMG2} of=/dev/${MD}s2 bs=${BS}
	fi

	# Create Config slice
	CFG=${NANO_DISKIMGDIR}/_.disk.cfg
	echo ""; echo "Creating config partition ${CFG}..."
	SIZE=`awk '/^p 3/ { print $5 "b" }' ${FDISK}`
	# XXX: fill from where ?
	pprint 2 "${NANO_MAKEFS} -s ${SIZE} ${CFG} ${NANO_CFGDIR}"
	${NANO_MAKEFS} -s ${SIZE} ${CFG} ${NANO_CFGDIR}
	pprint 2 "dd if=${CFG} of=/dev/${MD}s3 bs=${BS}"
	dd if=${CFG} of=/dev/${MD}s3 bs=${BS}
	pprint 2 "rm ${CFG}"
	rm ${CFG}; CFG=			# NB: disable printing below

	# Create Data slice, if any.
	if [ $NANO_DATASIZE -gt 0 ] ; then
		DATA=${NANO_DISKIMGDIR}/_.disk.data
		echo ""; echo "Creating data partition ${DATA}..."
		SIZE=`awk '/^p 4/ { print $5 "b" }' ${FDISK}`
		# XXX: fill from where ?
		pprint 2 "${NANO_MAKEFS} -s ${SIZE} ${DATA} /var/empty"
		${NANO_MAKEFS} -s ${SIZE} ${DATA} /var/empty
		pprint 2 "dd if=${DATA} of=/dev/${MD}s4 bs=${BS}"
		dd if=${DATA} of=/dev/${MD}s4 bs=${BS}
		pprint 2 "rm ${DATA}"
		rm ${DATA}; DATA=	# NB: disable printing below
	fi

	if [ "${NANO_MD_BACKING}" = "swap" ] ; then
		echo "Writing out _.disk.full..."
		dd if=/dev/${MD} of=${IMG} bs=${BS}
	fi

	echo ""
	echo "Completed images in:"
	echo ""
	echo "Full disk:         ${IMG}"
	echo "Primary partition: ${IMG1}"
	test "${IMG2}" && echo "2ndary partition:  ${IMG2}"
	test "${CFG}" &&  echo "/cfg partition:    ${CFG}"
	test "${DATA}" && echo "/data partition:   ${DATA}"
	echo ""
	echo "Use dd if=<file> of=/dev/<somewhere> bs=${BS} to transfer an"
	echo "image to bootable media /dev/<somewhere>."
	) > ${MAKEOBJDIRPREFIX}/_.di 2>&1
}
@


1.7
log
@Switching exporter and resync
@
text
@d1 1
a1 1
# $FreeBSD: head/tools/tools/nanobsd/gateworks/common 226242 2011-10-11 01:11:57Z thompsa $
a115 1
WITHOUT_CVS=true
@


1.7.2.1
log
@file common was added on branch RELENG_8_4 on 2013-03-28 13:05:58 +0000
@
text
@d1 360
@


1.7.2.2
log
@## SVN ## Exported commit - http://svnweb.freebsd.org/changeset/base/248810
## SVN ## CVS IS DEPRECATED: http://wiki.freebsd.org/CvsIsDeprecated
@
text
@a0 349
# $FreeBSD: releng/8.4/tools/tools/nanobsd/gateworks/common 206539 2010-04-13 01:04:11Z imp $

NANO_CFGDIR=${NANO_CFGDIR:-${NANO_SRC}/${NANO_TOOLS}/gateworks/cfg}
test -d ${NANO_CFGDIR} || NANO_CFGDIR=/var/empty
NANO_PMAKE="make"					# NB: disable -j 3

NANO_ARCH=arm
TARGET_CPUTYPE=xscale; export TARGET_CPUTYPE		# XXX
TARGET_BIG_ENDIAN=true; export TARGET_BIG_ENDIAN	# XXX

NANO_CUSTOMIZE="cust_allow_ssh_root"

clean_usr_local()
{
	LOCAL_DIR=${NANO_WORLDDIR}/usr/local
	pprint 2 "Clean and create world directory (${LOCAL_DIR})"
	if rm -rf ${LOCAL_DIR}/ > /dev/null 2>&1 ; then
		true
	else
		chflags -R noschg ${LOCAL_DIR}/
		rm -rf ${LOCAL_DIR}/
	fi
	for f in bin etc lib libdata libexec sbin share; do
		mkdir -p ${LOCAL_DIR}/$f
	done
}
NANO_CUSTOMIZE="$NANO_CUSTOMIZE clean_usr_local"

cust_install_machine_files()
{
	echo "cd ${NANO_TOOLS}/gateworks/Files"
	cd ${NANO_TOOLS}/gateworks/Files
	find . -print | grep -Ev '/(CVS|\.svn)' | cpio -dumpv ${NANO_WORLDDIR}
}
NANO_CUSTOMIZE="$NANO_CUSTOMIZE cust_install_files cust_install_machine_files"

buildenv()
{
	cd ${NANO_SRC}
	env TARGET_ARCH=${NANO_ARCH} __MAKE_CONF=${NANO_MAKE_CONF_BUILD} \
	    DESTDIR=${NANO_WORLDDIR} make buildenv
}

net80211_tools()
{
	for f in wlanstats wlanwds wlanwatch; do 
		echo "(cd tools/tools/net80211/$f; make $1)"; 
	done | buildenv
}
net80211_clean_tools()
{
	net80211_tools "clean"
}
net80211_build_tools()
{
	net80211_tools ""
}
net80211_install_tools()
{
	net80211_tools "install"
}
NANO_CUSTOMIZE="$NANO_CUSTOMIZE net80211_clean_tools"
NANO_CUSTOMIZE="$NANO_CUSTOMIZE net80211_build_tools"
NANO_CUSTOMIZE="$NANO_CUSTOMIZE net80211_install_tools"

ath_clean_tools()
{
	echo "cd tools/tools/ath; make clean" | buildenv
}
ath_build_tools()
{
	echo "cd tools/tools/ath; make" | buildenv
}
ath_install_tools()
{
	echo "cd tools/tools/ath; make install" | buildenv
}
NANO_CUSTOMIZE="$NANO_CUSTOMIZE ath_clean_tools"
NANO_CUSTOMIZE="$NANO_CUSTOMIZE ath_build_tools"
NANO_CUSTOMIZE="$NANO_CUSTOMIZE ath_install_tools"

npe_clean_tools()
{
	echo "cd tools/tools/npe; make clean" | buildenv
}
npe_build_tools()
{
	echo "cd tools/tools/npe; make" | buildenv
}
npe_install_tools()
{
	echo "cd tools/tools/npe; make install" | buildenv
}
NANO_CUSTOMIZE="$NANO_CUSTOMIZE npe_clean_tools"
NANO_CUSTOMIZE="$NANO_CUSTOMIZE npe_build_tools"
NANO_CUSTOMIZE="$NANO_CUSTOMIZE npe_install_tools"

NANO_MAKEFS="makefs -B big \
	-o bsize=4096,fsize=512,density=8192,optimization=space"
export NANO_MAKEFS

# NB: leave c++ enabled so devd can be built
CONF_BUILD="
WITHOUT_ACPI=true
WITHOUT_ATM=true
WITHOUT_AUDIT=true
WITHOUT_BIND_DNSSEC=true
WITHOUT_BIND_ETC=true
WITHOUT_BIND_LIBS_LWRES=true
WITHOUT_BLUETOOTH=true
WITHOUT_CALENDAR=true
WITHOUT_CDDL=true
WITHOUT_CVS=true
WITHOUT_DICT=true
WITHOUT_EXAMPLES=true
WITHOUT_FORTRAN=true
WITHOUT_GAMES=true
WITHOUT_GCOV=true
WITHOUT_GPIB=true
WITHOUT_HTML=true
WITHOUT_I4B=true
WITHOUT_INET6=true
WITHOUT_INFO=true
WITHOUT_IPFILTER=true
WITHOUT_IPX=true
WITHOUT_KERBEROS=true
WITHOUT_LIBKSE=true
WITHOUT_LOCALES=true
WITHOUT_LPR=true
WITHOUT_MAN=true
WITHOUT_NETCAT=true
WITHOUT_NIS=true
WITHOUT_NLS=true
WITHOUT_NS_CACHING=true
WITHOUT_OBJC=true
WITHOUT_PROFILE=true
WITHOUT_RCMDS=true
WITHOUT_RCS=true
WITHOUT_RESCUE=true
WITHOUT_SENDMAIL=true
WITHOUT_SHAREDOCS=true
WITHOUT_SSP=true
WITHOUT_SYSCONS=true
WITHOUT_TCSH=true
"
CONF_INSTALL="$CONF_BUILD
WITHOUT_TOOLCHAIN=true
WITHOUT_INSTALLLIB=true
INSTALL_NODEBUG=true
"

# NB: override to force / on s1 instead of s1a
setup_nanobsd_etc()
{
	pprint 2 "configure nanobsd /etc"

	(
	cd ${NANO_WORLDDIR}

	# create diskless marker file
	touch etc/diskless

	# Make root filesystem R/O by default
	echo "root_rw_mount=NO" >> etc/defaults/rc.conf

	# save config file for scripts
	echo "NANO_DRIVE=${NANO_DRIVE}" > etc/nanobsd.conf

	echo "/dev/${NANO_DRIVE}s1 / ufs ro 1 1" > etc/fstab
	echo "/dev/${NANO_DRIVE}s3 /cfg ufs rw,noauto 2 2" >> etc/fstab
	mkdir -p cfg
	)
}

create_arm_diskimage()
{
	pprint 2 "build diskimage"
	pprint 3 "log: ${MAKEOBJDIRPREFIX}/_.di"

	(
	echo "NANO_MEDIASIZE:	$NANO_MEDIASIZE"
	echo "NANO_IMAGES:	$NANO_IMAGES"
	echo "NANO_SECTS:	$NANO_SECTS"
	echo "NANO_HEADS:	$NANO_HEADS"
	echo "NANO_CODESIZE:	$NANO_CODESIZE"
	echo "NANO_CONFSIZE:	$NANO_CONFSIZE"
	echo "NANO_DATASIZE:	$NANO_DATASIZE"

	echo $NANO_MEDIASIZE $NANO_IMAGES \
		$NANO_SECTS $NANO_HEADS \
		$NANO_CODESIZE $NANO_CONFSIZE $NANO_DATASIZE |
	awk '
	{
		printf "# %s\n", $0

		# size of cylinder in sectors
		cs = $3 * $4

		# number of full cylinders on media
		cyl = int ($1 / cs)

		# output fdisk geometry spec, truncate cyls to 1023
		if (cyl <= 1023)
			print "g c" cyl " h" $4 " s" $3
		else
			print "g c" 1023 " h" $4 " s" $3

		if ($7 > 0) { 
			# size of data partition in full cylinders
			dsl = int (($7 + cs - 1) / cs)
		} else {
			dsl = 0;
		}

		# size of config partition in full cylinders
		csl = int (($6 + cs - 1) / cs)

		if ($5 == 0) {
			# size of image partition(s) in full cylinders
			isl = int ((cyl - dsl - csl) / $2)
		} else {
			isl = int (($5 + cs - 1) / cs)
		}

		# First image partition start at second track
		print "p 1 165 " $3, isl * cs - $3
		c = isl * cs;

		# Second image partition (if any) also starts offset one 
		# track to keep them identical.
		if ($2 > 1) {
			print "p 2 165 " $3 + c, isl * cs - $3
			c += isl * cs;
		}

		# Config partition starts at cylinder boundary.
		print "p 3 165 " c, csl * cs
		c += csl * cs

		# Data partition (if any) starts at cylinder boundary.
		if ($7 > 0) {
			print "p 4 165 " c, dsl * cs
		} else if ($7 < 0 && $1 > c) {
			print "p 4 165 " c, $1 - c
		} else if ($1 < c) {
			print "Disk space overcommitted by", \
			    c - $1, "sectors" > "/dev/stderr"
			exit 2
		}

		# Force slice 1 to be marked active. This is necessary
		# for booting the image from a USB device to work.
		print "a 1"
	}
	' > ${MAKEOBJDIRPREFIX}/_.fdisk

	IMG=${NANO_DISKIMGDIR}/${NANO_IMGNAME}
	BS=${NANO_SECTS}b

	if [ "${NANO_MD_BACKING}" = "swap" ] ; then
		MD=`mdconfig -a -t swap -s ${NANO_MEDIASIZE} -x ${NANO_SECTS} \
			-y ${NANO_HEADS}`
	else
		echo ""; echo "Creating md backing file ${IMG} ..."
		_c=`expr ${NANO_MEDIASIZE} / ${NANO_SECTS}`
		pprint 2 "dd if=/dev/zero of=${IMG} bs=${BS} count=${_c}"
		dd if=/dev/zero of=${IMG} bs=${BS} count=${_c}
		pprint 2 "mdconfig -a -t vnode -f ${IMG} -x ${NANO_SECTS} -y ${NANO_HEADS}"
		MD=`mdconfig -a -t vnode -f ${IMG} -x ${NANO_SECTS} \
			-y ${NANO_HEADS}`
	fi

	trap "mdconfig -d -u $MD" 1 2 15 EXIT

	echo ""; echo "Write partition table ..."
	FDISK=${MAKEOBJDIRPREFIX}/_.fdisk
	pprint 2 "fdisk -i -f ${FDISK} ${MD}"
	fdisk -i -f ${FDISK} ${MD}
	pprint 2 "fdisk ${MD}"
	fdisk ${MD}

	# Create first image
	IMG1=${NANO_DISKIMGDIR}/_.disk.image1
	echo ""; echo "Create first image ${IMG1} ..."
	SIZE=`awk '/^p 1/ { print $5 "b" }' ${FDISK}`
	pprint 2 "${NANO_MAKEFS} -s ${SIZE} ${IMG1} ${NANO_WORLDDIR}"
	${NANO_MAKEFS} -s ${SIZE} ${IMG1} ${NANO_WORLDDIR}
	pprint 2 "dd if=${IMG1} of=/dev/${MD}s1 bs=${BS}"
	dd if=${IMG1} of=/dev/${MD}s1 bs=${BS}

	if [ $NANO_IMAGES -gt 1 -a $NANO_INIT_IMG2 -gt 0 ] ; then
		IMG2=${NANO_DISKIMGDIR}/_.disk.image2
		echo ""; echo "Create second image ${IMG2}..."
		for f in ${NANO_WORLDDIR}/etc/fstab ${NANO_WORLDDIR}/conf/base/etc/fstab
		do
			sed -i "" "s/${NANO_DRIVE}s1/${NANO_DRIVE}s2/g" $f
		done

		SIZE=`awk '/^p 2/ { print $5 "b" }' ${FDISK}`
		pprint 2 "${NANO_MAKEFS} -s ${SIZE} ${IMG2} ${NANO_WORLDDIR}"
		${NANO_MAKEFS} -s ${SIZE} ${IMG2} ${NANO_WORLDDIR}
		pprint 2 "dd if=${IMG2} of=/dev/${MD}s2 bs=${BS}"
		dd if=${IMG2} of=/dev/${MD}s2 bs=${BS}
	fi

	# Create Config slice
	CFG=${NANO_DISKIMGDIR}/_.disk.cfg
	echo ""; echo "Creating config partition ${CFG}..."
	SIZE=`awk '/^p 3/ { print $5 "b" }' ${FDISK}`
	# XXX: fill from where ?
	pprint 2 "${NANO_MAKEFS} -s ${SIZE} ${CFG} ${NANO_CFGDIR}"
	${NANO_MAKEFS} -s ${SIZE} ${CFG} ${NANO_CFGDIR}
	pprint 2 "dd if=${CFG} of=/dev/${MD}s3 bs=${BS}"
	dd if=${CFG} of=/dev/${MD}s3 bs=${BS}
	pprint 2 "rm ${CFG}"
	rm ${CFG}; CFG=			# NB: disable printing below

	# Create Data slice, if any.
	if [ $NANO_DATASIZE -gt 0 ] ; then
		DATA=${NANO_DISKIMGDIR}/_.disk.data
		echo ""; echo "Creating data partition ${DATA}..."
		SIZE=`awk '/^p 4/ { print $5 "b" }' ${FDISK}`
		# XXX: fill from where ?
		pprint 2 "${NANO_MAKEFS} -s ${SIZE} ${DATA} /var/empty"
		${NANO_MAKEFS} -s ${SIZE} ${DATA} /var/empty
		pprint 2 "dd if=${DATA} of=/dev/${MD}s4 bs=${BS}"
		dd if=${DATA} of=/dev/${MD}s4 bs=${BS}
		pprint 2 "rm ${DATA}"
		rm ${DATA}; DATA=	# NB: disable printing below
	fi

	if [ "${NANO_MD_BACKING}" = "swap" ] ; then
		echo "Writing out _.disk.full..."
		dd if=/dev/${MD} of=${IMG} bs=${BS}
	fi

	echo ""
	echo "Completed images in:"
	echo ""
	echo "Full disk:         ${IMG}"
	echo "Primary partition: ${IMG1}"
	test "${IMG2}" && echo "2ndary partition:  ${IMG2}"
	test "${CFG}" &&  echo "/cfg partition:    ${CFG}"
	test "${DATA}" && echo "/data partition:   ${DATA}"
	echo ""
	echo "Use dd if=<file> of=/dev/<somewhere> bs=${BS} to transfer an"
	echo "image to bootable media /dev/<somewhere>."
	) > ${MAKEOBJDIRPREFIX}/_.di 2>&1
}
@


1.6
log
@SVN rev 226242 on 2011-10-11 01:11:57Z by thompsa

Fix build after TARGET_BIG_ENDIAN was nuked from orbit.
@
text
@d1 1
a1 1
# $FreeBSD$
@


1.5
log
@SVN rev 216930 on 2011-01-03 20:32:08Z by imp

Update gateworks exclusion list to match latest tree.
@
text
@d7 1
a7 1
NANO_ARCH=arm
a8 1
TARGET_BIG_ENDIAN=true; export TARGET_BIG_ENDIAN	# XXX
@


1.5.2.1
log
@SVN rev 225736 on 2011-09-23 00:51:37Z by kensmith

Copy head to stable/9 as part of 9.0-RELEASE release cycle.

Approved by:	re (implicit)
@
text
@@


1.5.2.2
log
@SVN rev 229884 on 2012-01-09 21:51:50Z by thompsa

MFC r226242

 Fix build after TARGET_BIG_ENDIAN was nuked from orbit.
@
text
@d7 1
a7 1
NANO_ARCH=armeb
d9 1
@


1.5.2.3
log
@## SVN ##
## SVN ## Exported commit - http://svnweb.freebsd.org/changeset/base/ 242902
## SVN ## CVS IS DEPRECATED: http://wiki.freebsd.org/CvsIsDeprecated
## SVN ##
## SVN ## ------------------------------------------------------------------------
## SVN ## r242902 | dteske | 2012-11-11 23:29:45 +0000 (Sun, 11 Nov 2012) | 10 lines
## SVN ##
## SVN ## Fix a regression introduced by SVN r211417 that saw the breakage of a feature
## SVN ## documented in usr.sbin/sysinstall/help/shortcuts.hlp (reproduced below):
## SVN ##
## SVN ## If /usr/sbin/sysinstall is linked to another filename, say
## SVN ## `/usr/local/bin/configPackages', then the basename will be used
## SVN ## as an implicit command name.
## SVN ##
## SVN ## Reviewed by:	adrian (co-mentor)
## SVN ## Approved by:	adrian (co-mentor)
## SVN ##
## SVN ## ------------------------------------------------------------------------
## SVN ##
@
text
@d1 1
a1 1
# $FreeBSD: stable/9/tools/tools/nanobsd/gateworks/common 229884 2012-01-09 21:51:50Z thompsa $
@


1.5.2.2.2.1
log
@SVN rev 239080 on 2012-08-05 23:54:33Z by kensmith

Copy stable/9 to releng/9.1 as part of the 9.1-RELEASE release process.

Approved by:	re (implicit)
@
text
@@


1.5.2.2.2.2
log
@Switch importer
@
text
@d1 1
a1 1
# $FreeBSD: releng/9.1/tools/tools/nanobsd/gateworks/common 229884 2012-01-09 21:51:50Z thompsa $
@


1.5.2.1.2.1
log
@SVN rev 227445 on 2011-11-11 04:20:22Z by kensmith

Copy stable/9 to releng/9.0 as part of the FreeBSD 9.0-RELEASE release
cycle.

Approved by:	re (implicit)
@
text
@@


1.5.2.1.2.2
log
@Switch importer
@
text
@d1 1
a1 1
# $FreeBSD: releng/9.0/tools/tools/nanobsd/gateworks/common 216930 2011-01-03 20:32:08Z imp $
@


1.4
log
@SVN rev 205994 on 2010-03-31 18:18:37Z by imp

Two fixes:

(1) We don't need a custom install_kernel.  We can install without
symbols by adding INSTALL_NODEBUG (which likely should be
WITHOUT_KERNEL_SYMBOLS_FILE, or something shorter) to CONF_INSTALL
(2) for make buildenv stage, use NANO_MAKE_CONF_BUILD rather than the
non-existant NANO_MAKE_CONF.

MFC after:	7 days
@
text
@d104 1
d106 1
d113 1
d116 1
d120 1
d125 1
a126 1
WITHOUT_I4B=true
a131 1
WITHOUT_LIBKSE=true
d135 2
d142 2
d145 1
d153 1
d155 2
@


1.3
log
@SVN rev 192662 on 2009-05-23 19:17:05Z by sam

add npe tools
@
text
@d40 1
a40 1
	env TARGET_ARCH=${NANO_ARCH} __MAKE_CONF=${NANO_MAKE_CONF} \
d149 1
a151 14
# NB: override to suppress install of kernel.symbols
install_kernel()
{
	pprint 2 "install kernel"
	pprint 3 "log: ${MAKEOBJDIRPREFIX}/_.ik"

	cd ${NANO_SRC}
	env TARGET_ARCH=${NANO_ARCH} ${NANO_PMAKE} installkernel \
		INSTALL_NODEBUG=true \
		DESTDIR=${NANO_WORLDDIR} \
		__MAKE_CONF=${NANO_MAKE_CONF} KERNCONF=`basename ${NANO_KERNEL}` \
		> ${MAKEOBJDIRPREFIX}/_.ik 2>&1
}

@


1.3.2.1
log
@SVN rev 196045 on 2009-08-03 08:13:06Z by kensmith

Copy head to stable/8 as part of 8.0 Release cycle.

Approved by:	re (Implicit)
@
text
@@


1.3.2.2
log
@SVN rev 206539 on 2010-04-13 01:04:11Z by imp

MFC: 205994

  Two fixes:

  (1) We don't need a custom install_kernel.  We can install without
  symbols by adding INSTALL_NODEBUG (which likely should be
  WITHOUT_KERNEL_SYMBOLS_FILE, or something shorter) to CONF_INSTALL
  (2) for make buildenv stage, use NANO_MAKE_CONF_BUILD rather than the
  non-existant NANO_MAKE_CONF.

  MFC after:	7 days
@
text
@d40 1
a40 1
	env TARGET_ARCH=${NANO_ARCH} __MAKE_CONF=${NANO_MAKE_CONF_BUILD} \
a148 1
INSTALL_NODEBUG=true
d151 14
@


1.3.2.3
log
@## SVN ##
## SVN ## Exported commit - http://svnweb.freebsd.org/changeset/base/ 242909
## SVN ## CVS IS DEPRECATED: http://wiki.freebsd.org/CvsIsDeprecated
## SVN ##
## SVN ## ------------------------------------------------------------------------
## SVN ## r242909 | dim | 2012-11-12 07:47:19 +0000 (Mon, 12 Nov 2012) | 20 lines
## SVN ##
## SVN ## MFC r242625:
## SVN ##
## SVN ## Remove duplicate const specifiers in many drivers (I hope I got all of
## SVN ## them, please let me know if not).  Most of these are of the form:
## SVN ##
## SVN ## static const struct bzzt_type {
## SVN ##       [...list of members...]
## SVN ## } const bzzt_devs[] = {
## SVN ##       [...list of initializers...]
## SVN ## };
## SVN ##
## SVN ## The second const is unnecessary, as arrays cannot be modified anyway,
## SVN ## and if the elements are const, the whole thing is const automatically
## SVN ## (e.g. it is placed in .rodata).
## SVN ##
## SVN ## I have verified this does not change the binary output of a full kernel
## SVN ## build (except for build timestamps embedded in the object files).
## SVN ##
## SVN ## Reviewed by:	yongari, marius
## SVN ##
## SVN ## ------------------------------------------------------------------------
## SVN ##
@
text
@d1 1
a1 1
# $FreeBSD: stable/8/tools/tools/nanobsd/gateworks/common 206539 2010-04-13 01:04:11Z imp $
@


1.3.2.2.6.1
log
@SVN rev 232438 on 2012-03-03 06:15:13Z by kensmith

Copy stable/8 to releng/8.3 as part of 8.3-RELEASE release cycle.

Approved by:	re (implicit)
@
text
@@


1.3.2.2.6.2
log
@Switch importer
@
text
@d1 1
a1 1
# $FreeBSD: releng/8.3/tools/tools/nanobsd/gateworks/common 206539 2010-04-13 01:04:11Z imp $
@


1.3.2.2.4.1
log
@SVN rev 216617 on 2010-12-21 17:09:25Z by kensmith

Copy stable/8 to releng/8.2 in preparation for FreeBSD-8.2 release.

Approved by:	re (implicit)
@
text
@@


1.3.2.2.2.1
log
@SVN rev 209145 on 2010-06-14 02:09:06Z by kensmith

Copy stable/8 to releng/8.1 in preparation for 8.1-RC1.

Approved by:	re (implicit)
@
text
@@


1.3.2.1.2.1
log
@SVN rev 198460 on 2009-10-25 01:10:29Z by kensmith

Copy stable/8 to releng/8.0 as part of 8.0-RELEASE release procedure.

Approved by:	re (implicit)
@
text
@@


1.2
log
@SVN rev 191246 on 2009-04-18 15:59:09Z by sam

allow NANO_CFGDIR to be overridden
@
text
@d82 16
@


1.1
log
@SVN rev 186979 on 2009-01-09 21:39:44Z by sam

example configurations for cross-building to Gateworks 2348 and 2358 boards;
probably needs cleanups to be less specific to my needs/uses

MFC after:	2 weeks
@
text
@d3 1
a3 1
NANO_CFGDIR=${NANO_SRC}/${NANO_TOOLS}/gateworks/cfg
@

