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