Use new NANO_LOG to put the logs some place reasonable. Also, share

the object directory among all builds where it makes sense. When
building with NANO_CPUTYPE, separate that out to its own object
directory. Put disk files in their own directories.

This should make having multiple variants of the same architecture
saner.
This commit is contained in:
Warner Losh 2016-02-07 16:44:13 +00:00
parent c2c06cfaa9
commit 6894d3f809
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=295377

View File

@ -88,23 +88,30 @@ NANO_CFG_BASE=$(pwd)
NANO_CFG_BASE=$(realpath ${NANO_CFG_BASE}/..)
NANO_SRC=$(realpath ${NANO_CFG_BASE}/../../..)
#### XXX share obj
NANO_OBJ=${NANO_SRC}/../$NANO_NAME/obj
# Where cust_pkg() finds packages to install
#XXX: Is this the right place?
#NANO_PORTS=$(realpath ${NANO_SRC}/../ports)
NANO_PORTS=/usr/ports
NANO_PACKAGE_DIR=${NANO_SRC}/${NANO_TOOLS}/Pkg
if [ -z ${NANO_CPUTYPE} ]; then
NANO_OBJ=${NANO_SRC}/../embedded/obj
else
# Alas, I can't set OBJTREE to ${MACHINE}.${MACHINE_ARCH}.${CPUTYPE}
# so this will have to do until I can.
NANO_OBJ=${NANO_SRC}/../embedded/obj.${NANO_CPUTYPE}
fi
NANO_LOG=${NANO_OBJ}/../${NANO_NAME}
NANO_DISKIMGDIR=${NANO_OBJ}/../images
NANO_WORLDDIR=${NANO_LOG}/_.w
NANO_INIT_IMG2=0
NANO_NOPRIV_BUILD=t
unset MAKEOBJDIRPREFIX
# this to go into nanobsd.sh
NANO_PORTS=${NANO_PORTS:-/usr/ports}
mkdir -p ${NANO_OBJ}
NANO_OBJ=$(realpath ${NANO_OBJ})
mkdir -p ${NANO_LOG}
NANO_LOG=$(realpath ${NANO_LOG})
mkdir -p ${NANO_IMAGES}
NANO_IMAGES=$(realpath ${NANO_IMAGES})
mkdir -p ${NANO_WORLDDIR}
NANO_WORLDDIR=$(realpath ${NANO_WORLDDIR})
NANO_FAT_DIR=${NANO_OBJ}/_.fat
NANO_FAT_DIR=${NANO_LOG}/_.fat
customize_cmd cust_allow_ssh_root
@ -191,7 +198,7 @@ create_diskimage_gpt ( ) (
create_diskimage_mbr ( ) (
pprint 2 "build diskimage ${NANO_NAME}"
pprint 3 "log: ${NANO_OBJ}/_.di"
pprint 3 "log: ${NANO_LOG}/_.di"
(
local extra i sz fmt fmtarg bootmbr bootbsd skiparg
@ -204,36 +211,36 @@ create_diskimage_mbr ( ) (
skiparg=${NANO_MBR_FIRST_SKIP:+-S ${NANO_MBR_FIRST_SKIP}}
for i in s1 s2 s3 s4 p1 p2 p3 p4 p5 empty; do
rm -fr ${NANO_OBJ}/_.${i}*
rm -fr ${NANO_LOG}/_.${i}*
done
# Populate the FAT partition, if needed
if [ -n "${NANO_SLICE_FAT}" ]; then
echo Creating MSDOS partition for kernel
newfs_msdos -C ${NANO_SLICE_FAT_SIZE} -F 16 -L ${NANO_NAME} \
${NANO_OBJ}/_.${NANO_SLICE_FAT}
${NANO_LOG}/_.${NANO_SLICE_FAT}
if [ -d ${NANO_FAT_DIR} ]; then
# Need to copy files from ${NANO_FATDIR} with mtools, or use
# makefs -t msdos once that's supported
mcopy -i ${NANO_OBJ}/_.${NANO_SLICE_FAT} ${NANO_FAT_DIR}/* ::
mcopy -i ${NANO_LOG}/_.${NANO_SLICE_FAT} ${NANO_FAT_DIR}/* ::
fi
fi
# Populate the Powerpc boot image, if needed
if [ "${NANO_LAYOUT}" = powerpc64-ibm ]; then
dd if=${NANO_WORLDDIR}/boot/boot1.elf of=${NANO_OBJ}/_.s1 bs=800k count=1 conv=sync
dd if=${NANO_WORLDDIR}/boot/boot1.elf of=${NANO_LOG}/_.s1 bs=800k count=1 conv=sync
fi
# Populate the / partition, and place it into a slice with a
# bsd label
[ -z ${NANO_NOPRIV_BUILD} ] || extra="-F ${NANO_METALOG}"
sz=${NANO_SLICE_ROOT_SIZE:+-s ${NANO_SLICE_ROOT_SIZE}}
eval "${NANO_MAKEFS_UFS}" ${extra} $sz "${NANO_OBJ}/_.${NANO_ROOT}" \
eval "${NANO_MAKEFS_UFS}" ${extra} $sz "${NANO_LOG}/_.${NANO_ROOT}" \
"${NANO_WORLDDIR}"
case ${NANO_DISK_SCHEME} in
mbr)
mkimg -s bsd ${bootbsd} -p freebsd-ufs:=${NANO_OBJ}/_.${NANO_ROOT} \
-o ${NANO_OBJ}/_.${NANO_SLICE_ROOT}
mkimg -s bsd ${bootbsd} -p freebsd-ufs:=${NANO_LOG}/_.${NANO_ROOT} \
-o ${NANO_LOG}/_.${NANO_SLICE_ROOT}
eval $NANO_SLICE_CFG=freebsd
eval $NANO_SLICE_ROOT=freebsd
;;
@ -246,12 +253,12 @@ create_diskimage_mbr ( ) (
# Populate the /cfg partition, empty if none given
if [ -z "${NANO_CFGDIR}" ]; then
echo "Faking cfg dir, it's empty"
NANO_CFGDIR=${NANO_OBJ}/_.empty
NANO_CFGDIR=${NANO_LOG}/_.empty
mkdir -p ${NANO_CFGDIR}
fi
# XXX -F cfg-mtree
eval "${NANO_MAKEFS_UFS}" -s ${NANO_SLICE_CFG_SIZE} \
"${NANO_OBJ}/_.${NANO_SLICE_CFG}" "${NANO_CFGDIR}"
"${NANO_LOG}/_.${NANO_SLICE_CFG}" "${NANO_CFGDIR}"
# data slice not supported since we need the part for FAT for
# booting
@ -261,31 +268,32 @@ create_diskimage_mbr ( ) (
eval $NANO_SLICE_FAT=fat16b
fi
out=${NANO_DISKIMGDIR}/_.disk.image.${NANO_NAME}${fmt}
# below depends on https://reviews.freebsd.org/D4403 not yet in the tree
# but there's problems: it marks all partitions as active, so you have to
# boot off parittion 3 or 2 by hand if you're playing around with this WIP
case ${NANO_LAYOUT} in
std-embedded)
mkimg -a 3 ${skiparg} ${fmtarg} ${bootmbr} -s mbr -p ${s1}:=${NANO_OBJ}/_.s1 \
-p ${s2}:=${NANO_OBJ}/_.s2 \
-p ${s3}:=${NANO_OBJ}/_.s3 \
-o ${NANO_OBJ}/_.disk.image.${NANO_NAME}${fmt}
mkimg -a 3 ${skiparg} ${fmtarg} ${bootmbr} -s mbr -p ${s1}:=${NANO_LOG}/_.s1 \
-p ${s2}:=${NANO_LOG}/_.s2 \
-p ${s3}:=${NANO_LOG}/_.s3 \
-o ${out}
;;
std-x86)
# s1 is cfg, s2 is /, not sure how to make that
# boot (marked as active) with mkimg yet
mkimg -a 2 ${fmtarg} ${bootmbr} -s mbr -p ${s1}:=${NANO_OBJ}/_.s1 \
-p ${s2}:=${NANO_OBJ}/_.s2 \
-o ${NANO_OBJ}/_.disk.image.${NANO_NAME}${fmt}
mkimg -a 2 ${fmtarg} ${bootmbr} -s mbr -p ${s1}:=${NANO_LOG}/_.s1 \
-p ${s2}:=${NANO_LOG}/_.s2 \
-o ${out}
;;
std-uefi)
# s1 is boot, s2 is cfg, s3 is /, not sure how to make that
# boot (marked as active) with mkimg yet
mkimg -a 2 ${fmtarg} ${bootmbr} -s mbr \
-p efi:=${NANO_WORLDDIR}/boot/boot1.efifat \
-p ${s2}:=${NANO_OBJ}/_.s2 \
-p ${s3}:=${NANO_OBJ}/_.s3 \
-o ${NANO_OBJ}/_.disk.image.${NANO_NAME}${fmt}
-p ${s2}:=${NANO_LOG}/_.s2 \
-p ${s3}:=${NANO_LOG}/_.s3 \
-o ${out}
;;
std-uefi-bios)
# p1 is boot for uefi, p2 is boot for gpt, p3 is cfg, p4 is /
@ -293,9 +301,9 @@ create_diskimage_mbr ( ) (
mkimg -a 2 ${fmtarg} ${bootmbr} -s gpt \
-p efi:=${NANO_WORLDDIR}/boot/boot1.efifat \
-p freebsd-boot:=${NAANO_WORLDDIR}/boot/gptboot \
-p ${p3}:=${NANO_OBJ}/_.p3 \
-p ${p4}:=${NANO_OBJ}/_.p4 \
-o ${NANO_OBJ}/_.disk.image.${NANO_NAME}${fmt}
-p ${p3}:=${NANO_LOG}/_.p3 \
-p ${p4}:=${NANO_LOG}/_.p4 \
-o ${out}
;;
powerpc64-ibm)
# A lie to make the boot loader work, it boots the first BSD partition
@ -304,13 +312,14 @@ create_diskimage_mbr ( ) (
# boot image is on a special partition, ala std-embedded, but that
# partition isn't FAT with special files, but a copy of the boot
# loader itself.
mkimg -a 1 ${fmtarg} -s mbr -p prepboot:=${NANO_OBJ}/_.s1 \
-p ${s2}:=${NANO_OBJ}/_.s2 \
-p ${s3}:=${NANO_OBJ}/_.s3a \
-o ${NANO_OBJ}/_.disk.image.${NANO_NAME}${fmt}
mkimg -a 1 ${fmtarg} -s mbr -p prepboot:=${NANO_LOG}/_.s1 \
-p ${s2}:=${NANO_LOG}/_.s2 \
-p ${s3}:=${NANO_LOG}/_.s3a \
-o ${out}
;;
esac
) > ${NANO_OBJ}/_.di 2>&1
xz -9 --keep ${out}
) > ${NANO_LOG}/_.di 2>&1
)
die( ) {