build: refresh packages via set

Lots of changes, mostly to merge the cool layout of kernel and base
sets with the packages approach.  What happens now is that ports.sh
and core.sh generate a packages set all the time so that it is portable
and can be pushed to a web server too if needed.
This commit is contained in:
Franco Fichtner 2015-05-08 13:12:10 +02:00
parent f87635ed52
commit 3bb6fb6938
7 changed files with 95 additions and 109 deletions

View File

@ -111,17 +111,13 @@ the following works:
# cd /usr/tools/build && ./ports.sh [packagename ...]
Package sets (may be signed depending on whether the key is
found under /root) ready for web server deployment can be
built using:
# cd /usr/tools/build && ./packages.sh
found under /root) ready for web server deployment are automatically
generated and modified by ports.sh and core.sh.
Release sets can be built using:
# cd /usr/tools/build && ./release.sh [version]
All individual ports packages are stored under /tmp/packages
Kernel, base, packages and release sets are stored under /tmp/sets
All final images are stored under /tmp/images
@ -137,4 +133,3 @@ Available options are:
* obj: reset the kernel/base build directory
* images: remove all available images
* sets: remove all available sets
* packages: remove all available packages

View File

@ -45,9 +45,5 @@ for ARG in ${@}; do
echo ">>> Removing ${SETSDIR}"
rm -rf ${SETSDIR}
;;
packages)
echo ">>> Removing ${PACKAGESDIR}"
rm -rf ${PACKAGESDIR}
;;
esac
done

View File

@ -57,7 +57,7 @@ export IMAGESDIR="/tmp/images"
export SETSDIR="/tmp/sets"
# bootstrap target directories
mkdir -p ${STAGEDIR} ${PACKAGESDIR} ${IMAGESDIR} ${SETSDIR}
mkdir -p ${STAGEDIR} ${IMAGESDIR} ${SETSDIR}
# target files
export CDROM="${IMAGESDIR}/${PRODUCT_RELEASE}-cdrom-${ARCH}.iso"
@ -172,7 +172,31 @@ setup_kernel()
setup_marker ${1} ${KERNEL_VER%%.txz}
}
setup_packages()
extract_packages()
{
echo ">>> Extracting packages in ${1}"
BASEDIR=${1}
shift
PKGLIST=${@}
rm -rf ${BASEDIR}${PACKAGESDIR}/All
mkdir -p ${BASEDIR}${PACKAGESDIR}/All
PACKAGESET=$(ls ${SETSDIR}/packages-*_${PRODUCT_FLAVOUR}-${ARCH}.tar || true)
if [ -f "${PACKAGESET}" ]; then
tar -C ${BASEDIR}${PACKAGESDIR} -xpf ${PACKAGESET}
fi
if [ -n "${PKGLIST}" ]; then
for PKG in ${PKGLIST}; do
# clear out the ports that ought to be rebuilt
rm -f ${BASEDIR}${PACKAGESDIR}/All/${PKG}-*.txz
done
fi
}
install_packages()
{
echo ">>> Setting up packages in ${1}..."
@ -180,17 +204,13 @@ setup_packages()
shift
PKGLIST=${@}
mkdir -p ${BASEDIR}${PACKAGESDIR}
tar -C ${PACKAGESDIR} -cf - . | \
tar -C ${BASEDIR}${PACKAGESDIR} -xpf -
if [ -z "${PKGLIST}" ]; then
PKGLIST=$(ls ${PACKAGESDIR}/*.txz || true)
PKGLIST=$(cd ${BASEDIR}${PACKAGESDIR}/All; ls *.txz || true)
for PKG in ${PKGLIST}; do
# Adds all available packages but ignores the
# ones that cannot be installed due to missing
# dependencies. This behaviour is desired.
pkg -c ${BASEDIR} add ${PKG} || true
pkg -c ${BASEDIR} add ${PACKAGESDIR}/All/${PKG} || true
done
else
# always bootstrap pkg as the first package
@ -198,7 +218,8 @@ setup_packages()
# Adds all selected packages and fails if
# one cannot be installed. Used to build
# final images or regression test systems.
pkg -c ${BASEDIR} add ${PACKAGESDIR}/${PKG}-*.txz
PKG=$(chroot ${BASEDIR} /bin/sh -ec "cd ${PACKAGESDIR}/All; ls ${PKG}-*.txz")
pkg -c ${BASEDIR} add ${PACKAGESDIR}/All/${PKG}
done
fi
@ -210,9 +231,50 @@ setup_packages()
pkg -c ${BASEDIR} annotate -qyA ${PKG} \
repository ${PRODUCT_NAME}
done
}
bundle_packages()
{
rm -f ${SETSDIR}/packages-*_${PRODUCT_FLAVOUR}-${ARCH}.tar
# rebuild expected FreeBSD structure
mkdir -p ${1}/pkg-repo/Latest
mkdir -p ${1}/pkg-repo/All
# push packages to home location
cp ${1}${PACKAGESDIR}/All/* ${1}/pkg-repo/All
# needed bootstrap glue when no packages are on the system
(cd ${1}/pkg-repo/Latest; ln -s ../All/pkg-*.txz pkg.txz)
local SIGNARGS=
if [ -n "$(${TOOLSDIR}/scripts/pkg_fingerprint.sh)" ]; then
# XXX check if fingerprint is in core.git
SIGNARGS="signing_command: ${TOOLSDIR}/scripts/pkg_sign.sh"
fi
# generate index files
pkg repo ${1}/pkg-repo ${SIGNARGS}
echo -n ">>> Creating package mirror set for ${PRODUCT_RELEASE}... "
tar -C ${STAGEDIR}/pkg-repo -cf \
${SETSDIR}/packages-${PRODUCT_VERSION}_${PRODUCT_FLAVOUR}-${ARCH}.tar .
echo "done"
}
clean_packages()
{
# keep the directory!
rm -rf ${BASEDIR}${PACKAGESDIR}/*
rm -rf ${1}${PACKAGESDIR}/All/*
}
setup_packages()
{
extract_packages ${1}
install_packages ${@}
clean_packages ${1}
}
setup_mtree()

View File

@ -29,8 +29,6 @@ set -e
. ./common.sh
rm -f ${PACKAGESDIR}/opnsense-*.txz
git_clear ${PORTSDIR}
git_clear ${COREDIR}
git_describe ${COREDIR}
@ -63,7 +61,8 @@ while read PORT_NAME PORT_CAT PORT_OPT; do
PORT_LIST="${PORT_LIST} ${PORT_NAME}"
done < ${TOOLSDIR}/config/current/ports.conf
setup_packages ${STAGEDIR} ${PORT_LIST}
extract_packages ${STAGEDIR} opnsense
install_packages ${STAGEDIR} ${PORT_LIST}
for PORT_NAME in ${PORT_LIST}; do
echo -n ">>> Collecting depencency for ${PORT_NAME}... "
@ -81,7 +80,8 @@ sed -i "" -e '/%%REPO_DEPENDS%%/d' ${STAGEDIR}/+MANIFEST
echo -n ">>> Creating custom package for ${COREDIR}... "
pkg -c ${STAGEDIR} create -m / -r / -p /plist -o ${PACKAGESDIR}
mv ${STAGEDIR}${PACKAGESDIR}/opnsense-*.txz ${PACKAGESDIR}
pkg -c ${STAGEDIR} create -m / -r / -p /plist -o ${PACKAGESDIR}/All
echo "done"
bundle_packages ${STAGEDIR}

View File

@ -1,60 +0,0 @@
#!/bin/sh
# Copyright (c) 2014-2015 Franco Fichtner <franco@opnsense.org>
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
set -e
. ./common.sh
rm -f ${SETSDIR}/packages-*_${PRODUCT_FLAVOUR}-${ARCH}.tar
setup_stage ${STAGEDIR}
# rebuild expected FreeBSD structure
mkdir -p ${STAGEDIR}/Latest
mkdir -p ${STAGEDIR}/All
# push packages to home location
cp ${PACKAGESDIR}/* ${STAGEDIR}/All
# needed bootstrap glue when no packages are on the system
cd ${STAGEDIR}/Latest && ln -s ../All/pkg-*.txz pkg.txz
SIGNARGS=
if [ -n "$(${TOOLSDIR}/scripts/pkg_fingerprint.sh)" ]; then
# XXX check if fingerprint is in core.git
SIGNARGS="signing_command: ${TOOLSDIR}/scripts/pkg_sign.sh"
fi
# generate index files
pkg repo ${STAGEDIR} ${SIGNARGS}
echo -n ">>> Creating package mirror set for ${PRODUCT_RELEASE}... "
tar -C ${STAGEDIR} -cf \
${SETSDIR}/packages-${PRODUCT_VERSION}_${PRODUCT_FLAVOUR}-${ARCH}.tar .
echo "done"

View File

@ -30,25 +30,21 @@ set -e
. ./common.sh
PORT_LIST=$(cat ${TOOLSDIR}/config/current/ports.conf)
PORT_JOBS=${@}
git_clear ${PORTSDIR}
git_clear ${SRCDIR}
if [ -n "${PORT_JOBS}" ]; then
for PORT_JOB in ${PORT_JOBS}; do
# clear out the ports that ought to be rebuilt
rm -f ${PACKAGESDIR}/${PORT_JOB}-*.txz
done
fi
setup_stage ${STAGEDIR}
setup_base ${STAGEDIR}
setup_packages ${STAGEDIR}
setup_clone ${STAGEDIR} ${PORTSDIR}
setup_clone ${STAGEDIR} ${SRCDIR}
setup_chroot ${STAGEDIR}
# bootstrap the stage with the avilable set (minus opnsense and args)
extract_packages ${STAGEDIR} opnsense ${@}
install_packages ${STAGEDIR}
clean_packages ${STAGEDIR}
echo ">>> Building packages..."
MAKE_CONF="${TOOLSDIR}/config/current/make.conf"
@ -116,7 +112,7 @@ pkg_resolve_deps()
done
for PORT in \${PORTS}; do
pkg create -no ${PACKAGESDIR} -f txz \${PORT}
pkg create -no ${PACKAGESDIR}/All -f txz \${PORT}
done
}
@ -131,10 +127,9 @@ echo "${PORT_LIST}" | { while read PORT_NAME PORT_CAT PORT_OPT; do
done }
EOF
rm -rf ${PACKAGESDIR}/*
mv ${STAGEDIR}${PACKAGESDIR}/* ${PACKAGESDIR}
if [ -n "${PORT_ABORT}" ]; then
echo ">>> The ports build failed. Please inspect the log."
exit 1
fi
bundle_packages ${STAGEDIR}

View File

@ -36,25 +36,23 @@ fi
if [ -n "${1}" ]; then
# make sure the all-encompassing package is a release, too
if [ ! -f ${PACKAGESDIR}/opnsense-${1}.txz ]; then
setup_stage ${STAGEDIR}
extract_packages ${STAGEDIR}
if [ ! -f ${STAGEDIR}${PACKAGESDIR}/All/opnsense-${1}.txz ]; then
echo "Release version mismatch:"
ls ${PACKAGESDIR}/opnsense-*.txz
(cd ${STAGEDIR}${PACKAGESDIR}/All; ls opnsense-*.txz)
exit 1
fi
fi
rm -f ${SETSDIR}/release-*_${PRODUCT_FLAVOUR}-${ARCH}.tar
echo ">>> Creating packages for ${PRODUCT_RELEASE}"
cd ${TOOLSDIR}/build && ./packages.sh
echo ">>> Creating images for ${PRODUCT_RELEASE}"
cd ${TOOLSDIR}/build && ./clean.sh images
cd ${TOOLSDIR}/build && ./memstick.sh
cd ${TOOLSDIR}/build && ./nano.sh
cd ${TOOLSDIR}/build && ./iso.sh
./clean.sh images
./memstick.sh
./nano.sh
./iso.sh
setup_stage ${STAGEDIR}