build: remember packages progress

This implements the usual "memory" we have when using make(1) to run
a build: progress is remembered and repeated steps are thus skipped,
especially useful for errors coupled with subsequent invokes of the
infamous `make everything'.
This commit is contained in:
Franco Fichtner 2016-01-20 10:24:20 +01:00
parent a6632135b8
commit e828219a8c
6 changed files with 59 additions and 30 deletions

View File

@ -1,6 +1,6 @@
#!/bin/sh
# Copyright (c) 2014-2015 Franco Fichtner <franco@opnsense.org>
# Copyright (c) 2014-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
@ -309,6 +309,7 @@ extract_packages()
echo ">>> Extracting packages in ${1}"
BASEDIR=${1}
MARKER=${2}
rm -rf ${BASEDIR}${PACKAGESDIR}/All
mkdir -p ${BASEDIR}${PACKAGESDIR}/All
@ -317,6 +318,11 @@ extract_packages()
if [ -f "${PACKAGESET}" ]; then
tar -C ${BASEDIR}${PACKAGESDIR} -xpf ${PACKAGESET}
fi
if [ -n "${MARKER}" -a -f ${BASEDIR}${PACKAGESDIR}/.${MARKER}_done ]; then
echo ">>> Packages are up to date"
exit 0
fi
}
remove_packages()
@ -415,19 +421,34 @@ EOF
bundle_packages()
{
BASEDIR=${1}
MARKER=${2}
sh ./clean.sh packages
git_describe ${PORTSDIR}
# rebuild expected FreeBSD structure
mkdir -p ${1}${PACKAGESDIR}-new/Latest
mkdir -p ${1}${PACKAGESDIR}-new/All
mkdir -p ${BASEDIR}${PACKAGESDIR}-new/Latest
mkdir -p ${BASEDIR}${PACKAGESDIR}-new/All
for PROGRESS in $({
find ${BASEDIR}${PACKAGESDIR} -type f -name ".*_done"
}); do
# push previous markers to home location
cp ${PROGRESS} ${BASEDIR}${PACKAGESDIR}-new
done
if [ -n "${MARKER}" ]; then
# add build marker to set
touch ${BASEDIR}${PACKAGESDIR}-new/.${MARKER}_done
fi
# push packages to home location
cp ${1}${PACKAGESDIR}/All/* ${1}${PACKAGESDIR}-new/All
cp ${BASEDIR}${PACKAGESDIR}/All/* ${BASEDIR}${PACKAGESDIR}-new/All
# needed bootstrap glue when no packages are on the system
(cd ${1}${PACKAGESDIR}-new/Latest; ln -s ../All/pkg-*.txz pkg.txz)
(cd ${BASEDIR}${PACKAGESDIR}-new/Latest; ln -s ../All/pkg-*.txz pkg.txz)
local SIGNARGS=
if [ -n "$(${TOOLSDIR}/scripts/pkg_fingerprint.sh)" ]; then
@ -436,11 +457,11 @@ bundle_packages()
SIGNARGS="signing_command: ${SIGNCMD}"
# generate pkg bootstrap signature
generate_signature ${1}${PACKAGESDIR}-new/Latest/pkg.txz
generate_signature ${BASEDIR}${PACKAGESDIR}-new/Latest/pkg.txz
fi
# generate index files
pkg repo ${1}${PACKAGESDIR}-new/ ${SIGNARGS}
pkg repo ${BASEDIR}${PACKAGESDIR}-new/ ${SIGNARGS}
REPO_RELEASE="${REPO_VERSION}-${PRODUCT_FLAVOUR}-${ARCH}"
echo -n ">>> Creating package mirror set for ${REPO_RELEASE}... "

View File

@ -1,6 +1,6 @@
#!/bin/sh
# Copyright (c) 2014-2015 Franco Fichtner <franco@opnsense.org>
# Copyright (c) 2014-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
@ -29,7 +29,12 @@ set -e
. ./common.sh && $(${SCRUB_ARGS})
CORE_MARKER="core"
setup_stage ${STAGEDIR}
extract_packages ${STAGEDIR} ${CORE_MARKER}
setup_base ${STAGEDIR}
setup_clone ${STAGEDIR} ${PORTSDIR}
@ -40,8 +45,6 @@ else
CORE_TAGS="${*}"
fi
extract_packages ${STAGEDIR}
for CORE_TAG in ${CORE_TAGS}; do
if [ -n "${*}" ]; then
setup_copy ${STAGEDIR} ${COREDIR}
@ -54,4 +57,4 @@ for CORE_TAG in ${CORE_TAGS}; do
custom_packages ${STAGEDIR} ${COREDIR}
done
bundle_packages ${STAGEDIR}
bundle_packages ${STAGEDIR} ${CORE_MARKER}

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
@ -29,7 +29,7 @@ set -e
. ./common.sh && $(${SCRUB_ARGS})
PORT_LIST="ports-mgmt/pkg
PORTS_LIST="ports-mgmt/pkg
security/openssl
security/libressl
$(cat ${CONFIGDIR}/ports.conf)"
@ -50,7 +50,7 @@ if [ -f ${MAKE_CONF} ]; then
fi
chroot ${STAGEDIR} /bin/sh -es << EOF
echo "${PORT_LIST}" | while read PORT_ORIGIN PORT_BROKEN; do
echo "${PORTS_LIST}" | while read PORT_ORIGIN PORT_BROKEN; do
if [ "\$(echo \${PORT_ORIGIN} | colrm 2)" = "#" ]; then
continue
fi

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
@ -29,15 +29,17 @@ set -e
. ./common.sh && $(${SCRUB_ARGS})
PLUGINS=$(make -C ${PLUGINSDIR} list)
PLUGINS_LIST=$(make -C ${PLUGINSDIR} list)
PLUGINS_MARKER="plugins"
setup_stage ${STAGEDIR}
extract_packages ${STAGEDIR} ${PLUGINS_MARKER}
setup_base ${STAGEDIR}
setup_clone ${STAGEDIR} ${PLUGINSDIR}
extract_packages ${STAGEDIR}
for PLUGIN in ${PLUGINS}; do
for PLUGIN in ${PLUGINS_LIST}; do
PLUGIN_NAME=$(make -C ${PLUGINSDIR}/${PLUGIN} name)
PLUGIN_DEPS=$(make -C ${PLUGINSDIR}/${PLUGIN} depends)
@ -46,4 +48,4 @@ for PLUGIN in ${PLUGINS}; do
custom_packages ${STAGEDIR} ${PLUGINSDIR}/${PLUGIN}
done
bundle_packages ${STAGEDIR}
bundle_packages ${STAGEDIR} ${PLUGINS_MARKER}

View File

@ -1,6 +1,6 @@
#!/bin/sh
# Copyright (c) 2014-2015 Franco Fichtner <franco@opnsense.org>
# Copyright (c) 2014-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
@ -29,16 +29,19 @@ set -e
. ./common.sh && $(${SCRUB_ARGS})
PORT_LIST=$(cat ${CONFIGDIR}/ports.conf)
PORTS_LIST=$(cat ${CONFIGDIR}/ports.conf)
PORTS_MARKER="ports"
setup_stage ${STAGEDIR}
extract_packages ${STAGEDIR} ${PORTS_MARKER}
setup_base ${STAGEDIR}
setup_clone ${STAGEDIR} ${PORTSDIR}
setup_clone ${STAGEDIR} ${SRCDIR}
setup_chroot ${STAGEDIR}
setup_distfiles ${STAGEDIR}
extract_packages ${STAGEDIR}
remove_packages ${STAGEDIR} ${@}
install_packages ${STAGEDIR}
clean_packages ${STAGEDIR}
@ -53,7 +56,7 @@ fi
# block SIGINT to allow for collecting port progress (use with care)
trap : 2
if ! chroot ${STAGEDIR} /bin/sh -es << EOF; then PORT_ABORT=1; fi
if ! chroot ${STAGEDIR} /bin/sh -es << EOF; then PORTS_MARKER=; fi
# overwrites the ports tree variable, behaviour is unwanted...
unset STAGEDIR
# ...and this unbreaks the nmap build
@ -65,7 +68,7 @@ else
make -C ${PORTSDIR}/ports-mgmt/pkg clean all install
fi
echo "${PORT_LIST}" | while read PORT_ORIGIN PORT_BROKEN; do
echo "${PORTS_LIST}" | while read PORT_ORIGIN PORT_BROKEN; do
if [ "\$(echo \${PORT_ORIGIN} | colrm 2)" = "#" ]; then
continue
fi
@ -105,12 +108,12 @@ trap - 2
echo ">>> Creating binary packages..."
chroot ${STAGEDIR} /bin/sh -es << EOF && bundle_packages ${STAGEDIR}
chroot ${STAGEDIR} /bin/sh -es << EOF && bundle_packages ${STAGEDIR} ${PORTS_MARKER}
pkg autoremove -qy
pkg create -ao ${PACKAGESDIR}/All -f txz
EOF
if [ -n "${PORT_ABORT}" ]; then
if [ -z "${PORTS_MARKER}" ]; then
echo ">>> The ports build did not finish properly :("
exit 1
fi

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
@ -31,7 +31,7 @@ set -e
export __MAKE_CONF=${CONFIGDIR}/make.conf
PORT_LIST=$({
PORTS_LIST=$({
# the ports formerly known as `sync'
echo devel/gettext
echo security/libressl
@ -62,7 +62,7 @@ done
echo -n ">>> Gathering dependencies"
echo "${PORT_LIST}" > /tmp/skim.${$}
echo "${PORTS_LIST}" > /tmp/skim.${$}
while read PORT_ORIGIN PORT_BROKEN; do
if [ "$(echo ${PORT_ORIGIN} | colrm 2)" = "#" ]; then