Skip to content

Instantly share code, notes, and snippets.

@dch
Created February 3, 2022 21:42
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dch/a3ca418402821e42c1a82129e3e36b6f to your computer and use it in GitHub Desktop.
Save dch/a3ca418402821e42c1a82129e3e36b6f to your computer and use it in GitHub Desktop.
#!/bin/sh -eu
sudo kldload filemon || /usr/bin/true
# echo 'WITH_CCACHE_BUILD=yes' > /etc/src.conf
echo 'WITH_META_MODE=yes' > /etc/src-env.conf
# echo 'WITH_DIRDEPS_BUILD=yes' >> /etc/src-env.conf
# umask 0022
cd /usr/src
NOW=$(date -u +%Y%m%d-%H%M)
NCPU=$(sysctl -n hw.ncpu)
GIT=g$(git rev-parse --verify --short=7 HEAD)
SVN=r$(git notes show HEAD | rg -o '\d+$' || /usr/bin/true)
if [ "${SVN}" = "r" ]; then
COMMIT=${GIT}
else
COMMIT=${SVN}
fi
STASH=/downloads/FreeBSD/current/${COMMIT}
echo STASH $STASH
RELEASE=/usr/obj/usr/src/amd64.amd64/release
mkdir -p -m0775 ${STASH}/amd64 || /usr/bin/true
#zfs rollback -r envy/usr/obj@empty
# zfs rollback -rRf embiggen/usr/obj/release@empty
chflags -R noschg ${RELEASE} || /usr/bin/true
chown -R dch:wheel ${RELEASE} || /usr/bin/true
rm -rf ${RELEASE}
# mount -t tmpfs tmpfs ${RELEASE}
git reset --hard
git clean -fdx
sudo zfs snapshot \
-r envy/usr/src@${NOW}:bebuild-${COMMIT} \
|| /usr/bin/true
time make -j${NCPU} buildworld -s
echo DONE BW
date -u +%Y%m%d-%H%M
time make -j${NCPU} buildkernel -s
echo DONE BK
date -u +%Y%m%d-%H%M
# grab latest makefs
#cd /usr/src/usr.sbin/makefs
#make depend all install
cd /usr/src/release
time make -DNOPORTS -s memstick ftp cdrom
cd ${RELEASE}
cp -av ftp/* memstick.img bootonly.iso ${STASH}/amd64
echo DONE IMG
date -u +%Y%m%d-%H%M
cd /usr/src
rm ${STASH}/../latest
ln -s ${STASH} ${STASH}/../latest
echo DONE SRC $STASH $RELEASE | wall
yes | poudriere jail -d -C all -j current_x64 \
|| /usr/bin/true
rm -rf /usr/local/poudriere/jails/current_x64 \
|| /usr/bin/true
poudriere jail -c\
-j current_x64 \
-v 14.0-CURRENT \
-a amd64 \
-S /usr/src \
-K GENERIC \
-m tar=${RELEASE}/base.txz \
|| /usr/bin/true
echo DONE POUDRIERE | wall
cd /usr/src
time /usr/bin/env NO_PKG_UPGRADE=1 /usr/src/tools/build/beinstall.sh
# time /usr/bin/env NO_PKG_UPGRADE=1 NO_CLEANUP_BE=1 /usr/src/tools/build/beinstall.sh
mv /boot/efi/EFI/FreeBSD/current.efi /boot/efi/EFI/FreeBSD/lastgood.efi
cp -av /usr/obj/usr/src/amd64.amd64/release/dist/base/boot/loader.efi /boot/efi/EFI/FreeBSD/current.efi
echo DONE BE | wall
date -u +%Y%m%d-%H%M
# umount ${RELEASE}
echo DONE ALL | wall
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment