build: stagify remaining pieces

This will not taint the build system except for the final
sets and image dirs.  Helps in keeping the build system
clean and that it's easier to inspect the build step.

While there, expand chroot to take a subdir argument as
some build steps need the STAGEDIR root for more than a
single purpose.
This commit is contained in:
Franco Fichtner 2016-05-21 10:53:24 +02:00
parent 02936668d7
commit 9aa9108ae5
9 changed files with 60 additions and 59 deletions

View File

@ -244,4 +244,4 @@ files need to be regenerated. This is done using:
Shall any debugging be needed inside the build jail, the following
command will use chroot(8) to enter the active build jail:
# make chroot
# make chroot[-<subdir>]

View File

@ -44,6 +44,8 @@ BASE_SET=${SETSDIR}/base-${REPO_VERSION}-${ARCH}
sh ./clean.sh ${SELF}
setup_stage ${STAGEDIR}
MAKE_ARGS="SRCCONF=${CONFIGDIR}/src.conf COMPILER_TYPE=clang __MAKE_CONF="
ENV_FILTER="env -i USER=${USER} LOGNAME=${LOGNAME} HOME=${HOME} \
SHELL=${SHELL} BLOCKSIZE=${BLOCKSIZE} MAIL=${MAIL} PATH=${PATH} \
@ -60,27 +62,25 @@ mv $(make -C${SRCDIR}/release -V .OBJDIR)/base.txz ${BASE_SET}.txz
echo -n ">>> Generating obsolete file list... "
tar -tf ${BASE_SET}.txz | \
sed -e 's/^\.//g' -e '/\/$/d' | sort > /tmp/setdiff.new.${$}
sed -e 's/^\.//g' -e '/\/$/d' | sort > ${STAGEDIR}/setdiff.new
: > /tmp/setdiff.old.${$}
: > ${STAGEDIR}/setdiff.old
if [ -s ${CONFIGDIR}/plist.base.${ARCH} ]; then
cat ${CONFIGDIR}/plist.base.${ARCH} | \
sed -e 's/^\.//g' -e '/\/$/d' | sort > /tmp/setdiff.old.${$}
sed -e 's/^\.//g' -e '/\/$/d' | sort > ${STAGEDIR}/setdiff.old
fi
: > /tmp/setdiff.tmp.${$}
: > ${STAGEDIR}/setdiff.tmp
if [ -s ${CONFIGDIR}/plist.obsolete.${ARCH} ]; then
diff -u ${CONFIGDIR}/plist.obsolete.${ARCH} \
/tmp/setdiff.new.${$} | grep '^-/' | \
cut -b 2- > /tmp/setdiff.tmp.${$}
${STAGEDIR}/setdiff.new | grep '^-/' | \
cut -b 2- > ${STAGEDIR}/setdiff.tmp
fi
(cat /tmp/setdiff.tmp.${$}; diff -u /tmp/setdiff.old.${$} \
/tmp/setdiff.new.${$} | grep '^-/' | cut -b 2-) | \
(cat ${STAGEDIR}/setdiff.tmp; diff -u ${STAGEDIR}/setdiff.old \
${STAGEDIR}/setdiff.new | grep '^-/' | cut -b 2-) | \
sort -u > ${BASE_SET}.obsolete
rm -f /tmp/setdiff.*
echo "done"
generate_signature ${BASE_SET}.txz

View File

@ -31,6 +31,6 @@ SELF=chroot
. ./common.sh && $(${SCRUB_ARGS})
echo ">>> chroot'ing into ${STAGEDIR}..."
echo ">>> chroot'ing into ${STAGEDIR}/${1}..."
chroot ${STAGEDIR} /bin/csh
chroot ${STAGEDIR}/${1} /bin/csh

View File

@ -35,10 +35,7 @@ for ARG in ${@}; do
case ${ARG} in
base)
echo ">>> Removing base set"
rm -f ${SETSDIR}/base-*-${ARCH}.txz
rm -f ${SETSDIR}/base-*-${ARCH}.txz.sig
rm -f ${SETSDIR}/base-*-${ARCH}.obsolete
rm -f ${SETSDIR}/base-*-${ARCH}.obsolete.sig
rm -f ${SETSDIR}/base-*-${ARCH}.*
;;
distfiles)
echo ">>> Removing distfiles set"
@ -50,8 +47,7 @@ for ARG in ${@}; do
;;
kernel)
echo ">>> Removing kernel set"
rm -f ${SETSDIR}/kernel-*-${ARCH}.txz
rm -f ${SETSDIR}/kernel-*-${ARCH}.txz.sig
rm -f ${SETSDIR}/kernel-*-${ARCH}.*
;;
nano)
echo ">>> Removing nano image"
@ -71,9 +67,11 @@ for ARG in ${@}; do
;;
stage)
setup_stage ${STAGEDIR}
rm -r ${STAGEDIR}
;;
src)
setup_stage /usr/obj${SRCDIR}
rm -r /usr/obj${SRCDIR}
;;
vga)
echo ">>> Removing vga image"

View File

@ -164,16 +164,16 @@ export LABEL=${PRODUCT_NAME}
export TARGET_ARCH=${ARCH}
export TARGETARCH=${ARCH}
# define target directories
# define build and config directories
export CONFIGDIR="${TOOLSDIR}/config/${PRODUCT_SETTINGS}"
export STAGEDIR="${STAGEDIRPREFIX}${CONFIGDIR}/${PRODUCT_FLAVOUR}"
export DEVICEDIR="${TOOLSDIR}/device"
export IMAGESDIR="/tmp/images"
export SETSDIR="/tmp/sets"
export PACKAGESDIR="/.pkg"
# bootstrap target directories
mkdir -p ${STAGEDIR} ${IMAGESDIR} ${SETSDIR}
# define and bootstrap target directories
export IMAGESDIR="/tmp/images"
export SETSDIR="/tmp/sets"
mkdir -p ${IMAGESDIR} ${SETSDIR}
# print environment to showcase all of our variables
env | sort
@ -629,18 +629,26 @@ setup_stage()
echo ">>> Setting up stage in ${1}"
MOUNTDIRS="/dev /mnt ${SRCDIR} ${PORTSDIR} ${COREDIR} ${PLUGINSDIR}"
STAGE=${1}
shift
# might have been a chroot
for DIR in ${MOUNTDIRS}; do
if [ -d ${1}${DIR} ]; then
umount ${1}${DIR} 2> /dev/null || true
if [ -d ${STAGE}${DIR} ]; then
umount ${STAGE}${DIR} 2> /dev/null || true
fi
done
# remove base system files
rm -rf ${1} 2> /dev/null ||
(chflags -R noschg ${1}; rm -rf ${1} 2> /dev/null)
rm -rf ${STAGE} 2> /dev/null ||
(chflags -R noschg ${STAGE}; rm -rf ${STAGE} 2> /dev/null)
# revive directory for next run
mkdir -p ${1}
mkdir -p ${STAGE}
# additional directories if requested
for DIR in ${@}; do
mkdir -p ${STAGE}/${DIR}
done
}

View File

@ -43,11 +43,11 @@ sub_FlashDevice generic 4g
# chop off excess bytes that do not align to 8 byte boundary
NANO_MEDIASIZE=$(expr ${NANO_MEDIASIZE} - \( ${NANO_MEDIASIZE} % 8 \))
setup_stage ${STAGEDIR}
setup_base ${STAGEDIR}
setup_kernel ${STAGEDIR}
setup_packages ${STAGEDIR}
setup_extras ${STAGEDIR} ${SELF}
setup_stage ${STAGEDIR} mnt work
setup_base ${STAGEDIR}/work
setup_kernel ${STAGEDIR}/work
setup_packages ${STAGEDIR}/work
setup_extras ${STAGEDIR}/work ${SELF}
MD=$(mdconfig -a -t swap -s ${NANO_MEDIASIZE} -x ${NANO_SECTS} -y ${NANO_HEADS})
@ -125,9 +125,7 @@ awk '
}
' | fdisk -i -f - ${MD}
boot0cfg -B -b ${STAGEDIR}/boot/boot0sio -o packet -s 1 -m 3 ${MD}
MNT=/tmp/nanobsd.${$}
mkdir -p ${MNT}
boot0cfg -B -b ${STAGEDIR}/work/boot/boot0sio -o packet -s 1 -m 3 ${MD}
setup_partition()
{
@ -145,16 +143,14 @@ setup_partition()
umount ${3}
}
setup_entropy ${STAGEDIR}
setup_partition /dev/${MD}s1 ${LABEL}0 ${MNT} ${STAGEDIR}
setup_entropy ${STAGEDIR}/work
setup_partition /dev/${MD}s1 ${LABEL}0 ${STAGEDIR}/mnt ${STAGEDIR}/work
if [ ${NANO_IMAGES} -gt 1 ]; then
setup_entropy ${STAGEDIR}
setup_partition /dev/${MD}s2 ${LABEL}1 ${MNT} ${STAGEDIR}
setup_entropy ${STAGEDIR}/work
setup_partition /dev/${MD}s2 ${LABEL}1 ${STAGEDIR}/mnt ${STAGEDIR}/work
fi
rm -rf /tmp/nanobsd.*
# move image from RAM to output file
dd if=/dev/${MD} of=${NANOIMG} bs=64k

View File

@ -1,6 +1,6 @@
#!/bin/sh
# Copyright (c) 2015 Franco Fichtner <franco@opnsense.org>
# Copyright (c) 2015-2016 Franco Fichtner <franco@opnsense.org>
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
@ -42,12 +42,12 @@ fi
sh ./clean.sh ${SELF}
setup_stage ${STAGEDIR}
setup_stage ${STAGEDIR} tmp work
echo -n ">>> Compressing images for ${PRODUCT_RELEASE}... "
mv ${IMAGESDIR}/${PRODUCT_RELEASE}-* ${STAGEDIR}
for IMAGE in $(find ${STAGEDIR} -name "${PRODUCT_RELEASE}-*"); do
mv ${IMAGESDIR}/${PRODUCT_RELEASE}-* ${STAGEDIR}/work
for IMAGE in $(find ${STAGEDIR}/work -name "${PRODUCT_RELEASE}-*"); do
bzip2 ${IMAGE} &
done
wait
@ -56,15 +56,15 @@ echo "done"
echo -n ">>> Checksumming images for ${PRODUCT_RELEASE}... "
mkdir -p ${STAGEDIR}/tmp
cd ${STAGEDIR} && sha256 ${PRODUCT_RELEASE}-* > tmp/${PRODUCT_RELEASE}-checksums-${ARCH}.sha256
cd ${STAGEDIR} && md5 ${PRODUCT_RELEASE}-* > tmp/${PRODUCT_RELEASE}-checksums-${ARCH}.md5
(cd ${STAGEDIR}/work && sha256 ${PRODUCT_RELEASE}-*) \
> ${STAGEDIR}/tmp/${PRODUCT_RELEASE}-checksums-${ARCH}.sha256
(cd ${STAGEDIR}/work && md5 ${PRODUCT_RELEASE}-*) \
> ${STAGEDIR}/tmp/${PRODUCT_RELEASE}-checksums-${ARCH}.md5
mv tmp/* .
rm -rf tmp
mv ${STAGEDIR}/tmp/* ${STAGEDIR}/work/
echo "done"
echo -n ">>> Bundling images for ${PRODUCT_RELEASE}... "
tar -cf ${SETSDIR}/release-${PRODUCT_VERSION}-${PRODUCT_FLAVOUR}-${ARCH}.tar .
tar -C ${STAGEDIR}/work -cf ${SETSDIR}/release-${PRODUCT_VERSION}-${PRODUCT_FLAVOUR}-${ARCH}.tar .
echo "done"

View File

@ -31,6 +31,8 @@ SELF=skim
. ./common.sh && $(${SCRUB_ARGS})
setup_stage ${STAGEDIR}
export __MAKE_CONF=${CONFIGDIR}/make.conf
PORTS_LIST=$({
@ -64,7 +66,7 @@ done
echo -n ">>> Gathering dependencies"
echo "${PORTS_LIST}" > /tmp/skim.${$}
echo "${PORTS_LIST}" > ${STAGEDIR}/skim
while read PORT_ORIGIN PORT_BROKEN; do
if [ "$(echo ${PORT_ORIGIN} | colrm 2)" = "#" ]; then
@ -113,9 +115,7 @@ while read PORT_ORIGIN PORT_BROKEN; do
PORTS_CHANGED="${PORTS_CHANGED} ${PORT}"
fi
done
done < /tmp/skim.${$}
rm -f /tmp/skim.*
done < ${STAGEDIR}/skim
echo "done"

View File

@ -56,12 +56,11 @@ VMBASE="${STAGEDIR}/vmbase"
sh ./clean.sh ${SELF}
setup_stage ${STAGEDIR}
setup_stage ${STAGEDIR} mnt
truncate -s ${VMSIZE} ${VMBASE}
MD=$(mdconfig -f ${VMBASE})
newfs /dev/${MD}
mkdir ${STAGEDIR}/mnt
mount /dev/${MD} ${STAGEDIR}/mnt
setup_base ${STAGEDIR}/mnt