2014-11-09 11:04:44 +01:00
|
|
|
#!/bin/sh
|
|
|
|
|
2015-01-03 19:46:33 +01:00
|
|
|
# Copyright (c) 2014-2015 Franco Fichtner <franco@opnsense.org>
|
2014-11-09 11:04:44 +01:00
|
|
|
#
|
|
|
|
# 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.
|
2014-11-09 11:06:26 +01:00
|
|
|
#
|
2014-11-09 11:04:44 +01:00
|
|
|
# 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
|
|
|
|
|
2015-05-16 12:48:14 +02:00
|
|
|
SCRUB_ARGS=:
|
|
|
|
|
2015-06-09 10:22:01 +02:00
|
|
|
usage()
|
|
|
|
{
|
2015-06-10 08:46:59 +02:00
|
|
|
echo "Usage: ${0} -f flavour -n name -v version -R freebsd-ports.git" >&2
|
2015-09-09 15:54:26 +02:00
|
|
|
echo " -C core.git -P ports.git -S src.git -T tools.git -t type" >&2
|
2015-06-09 10:22:01 +02:00
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
2015-09-09 15:54:26 +02:00
|
|
|
while getopts C:f:n:P:p:R:S:s:T:t:v: OPT; do
|
2015-05-16 11:35:18 +02:00
|
|
|
case ${OPT} in
|
2015-06-09 10:14:37 +02:00
|
|
|
C)
|
|
|
|
export COREDIR=${OPTARG}
|
|
|
|
SCRUB_ARGS=${SCRUB_ARGS};shift;shift
|
|
|
|
;;
|
2015-05-16 11:35:18 +02:00
|
|
|
f)
|
|
|
|
export PRODUCT_FLAVOUR=${OPTARG}
|
2015-05-16 12:48:14 +02:00
|
|
|
SCRUB_ARGS=${SCRUB_ARGS};shift;shift
|
2015-05-16 11:35:18 +02:00
|
|
|
;;
|
|
|
|
n)
|
|
|
|
export PRODUCT_NAME=${OPTARG}
|
2015-05-16 12:48:14 +02:00
|
|
|
SCRUB_ARGS=${SCRUB_ARGS};shift;shift
|
2015-05-16 11:35:18 +02:00
|
|
|
;;
|
2015-06-09 10:14:37 +02:00
|
|
|
P)
|
|
|
|
export PORTSDIR=${OPTARG}
|
|
|
|
SCRUB_ARGS=${SCRUB_ARGS};shift;shift
|
|
|
|
;;
|
2015-07-09 14:32:50 +02:00
|
|
|
p)
|
|
|
|
export PLUGINSDIR=${OPTARG}
|
|
|
|
SCRUB_ARGS=${SCRUB_ARGS};shift;shift
|
|
|
|
;;
|
2015-06-10 08:46:59 +02:00
|
|
|
R)
|
|
|
|
export PORTSREFDIR=${OPTARG}
|
|
|
|
SCRUB_ARGS=${SCRUB_ARGS};shift;shift
|
|
|
|
;;
|
2015-06-09 10:14:37 +02:00
|
|
|
S)
|
|
|
|
export SRCDIR=${OPTARG}
|
|
|
|
SCRUB_ARGS=${SCRUB_ARGS};shift;shift
|
|
|
|
;;
|
2015-06-12 08:01:54 +02:00
|
|
|
s)
|
|
|
|
export PRODUCT_SETTINGS=${OPTARG}
|
|
|
|
SCRUB_ARGS=${SCRUB_ARGS};shift;shift
|
|
|
|
;;
|
2015-06-09 10:14:37 +02:00
|
|
|
T)
|
|
|
|
export TOOLSDIR=${OPTARG}
|
|
|
|
SCRUB_ARGS=${SCRUB_ARGS};shift;shift
|
|
|
|
;;
|
2015-09-09 15:54:26 +02:00
|
|
|
t)
|
|
|
|
export PRODUCT_TYPE=${OPTARG}
|
|
|
|
SCRUB_ARGS=${SCRUB_ARGS};shift;shift
|
|
|
|
;;
|
2015-05-16 11:35:18 +02:00
|
|
|
v)
|
|
|
|
export PRODUCT_VERSION=${OPTARG}
|
2015-05-16 12:48:14 +02:00
|
|
|
SCRUB_ARGS=${SCRUB_ARGS};shift;shift
|
2015-05-16 11:35:18 +02:00
|
|
|
;;
|
|
|
|
*)
|
2015-06-09 10:22:01 +02:00
|
|
|
usage
|
2015-05-16 11:35:18 +02:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
2015-06-09 10:14:37 +02:00
|
|
|
if [ -z "${PRODUCT_NAME}" -o \
|
2015-09-09 15:54:26 +02:00
|
|
|
-z "${PRODUCT_TYPE}" -o \
|
2015-06-09 10:14:37 +02:00
|
|
|
-z "${PRODUCT_FLAVOUR}" -o \
|
|
|
|
-z "${PRODUCT_VERSION}" -o \
|
2015-06-12 08:01:54 +02:00
|
|
|
-z "${PRODUCT_SETTINGS}" -o \
|
2015-06-09 10:14:37 +02:00
|
|
|
-z "${TOOLSDIR}" -o \
|
2015-07-09 14:32:50 +02:00
|
|
|
-z "${PLUGINSDIR}" -o \
|
2015-06-09 10:14:37 +02:00
|
|
|
-z "${PORTSDIR}" -o \
|
2015-06-10 08:46:59 +02:00
|
|
|
-z "${PORTSREFDIR}" -o \
|
2015-06-09 10:14:37 +02:00
|
|
|
-z "${COREDIR}" -o \
|
|
|
|
-z "${SRCDIR}" ]; then
|
2015-06-09 10:22:01 +02:00
|
|
|
usage
|
2015-05-12 11:07:47 +02:00
|
|
|
fi
|
|
|
|
|
2015-06-11 00:59:48 +02:00
|
|
|
# full name for easy use and actual config directory
|
2015-07-24 07:40:53 +02:00
|
|
|
export PRODUCT_RELEASE="${PRODUCT_NAME}-${PRODUCT_VERSION}-${PRODUCT_FLAVOUR}"
|
2015-05-07 10:51:35 +02:00
|
|
|
|
2014-11-09 13:14:07 +01:00
|
|
|
# misc. foo
|
2015-06-12 07:34:31 +02:00
|
|
|
export CONFIG_PKG="/usr/local/etc/pkg/repos/origin.conf"
|
2015-05-07 14:07:03 +02:00
|
|
|
export CPUS=$(sysctl kern.smp.cpus | awk '{ print $2 }')
|
2015-05-07 08:11:21 +02:00
|
|
|
export CONFIG_XML="/usr/local/etc/config.xml"
|
2015-05-07 14:07:03 +02:00
|
|
|
export ARCH=${ARCH:-$(uname -m)}
|
2015-05-07 08:11:21 +02:00
|
|
|
export LABEL=${PRODUCT_NAME}
|
2014-11-15 15:54:43 +01:00
|
|
|
export TARGET_ARCH=${ARCH}
|
2015-01-12 17:50:15 +01:00
|
|
|
export TARGETARCH=${ARCH}
|
2014-11-09 11:04:44 +01:00
|
|
|
|
2015-05-07 09:00:32 +02:00
|
|
|
# define target directories
|
2015-06-12 08:01:54 +02:00
|
|
|
export CONFIGDIR="${TOOLSDIR}/config/${PRODUCT_SETTINGS}"
|
2015-05-07 09:00:32 +02:00
|
|
|
export STAGEDIR="/usr/local/stage"
|
|
|
|
export IMAGESDIR="/tmp/images"
|
|
|
|
export SETSDIR="/tmp/sets"
|
2015-06-12 08:01:54 +02:00
|
|
|
export PACKAGESDIR="/.pkg"
|
2015-05-07 09:00:32 +02:00
|
|
|
|
|
|
|
# bootstrap target directories
|
2015-05-08 13:12:10 +02:00
|
|
|
mkdir -p ${STAGEDIR} ${IMAGESDIR} ${SETSDIR}
|
2015-05-07 09:00:32 +02:00
|
|
|
|
2014-11-15 21:12:09 +01:00
|
|
|
# target files
|
2015-05-07 10:51:35 +02:00
|
|
|
export CDROM="${IMAGESDIR}/${PRODUCT_RELEASE}-cdrom-${ARCH}.iso"
|
|
|
|
export SERIALIMG="${IMAGESDIR}/${PRODUCT_RELEASE}-serial-${ARCH}.img"
|
|
|
|
export VGAIMG="${IMAGESDIR}/${PRODUCT_RELEASE}-vga-${ARCH}.img"
|
|
|
|
export NANOIMG="${IMAGESDIR}/${PRODUCT_RELEASE}-nano-${ARCH}.img"
|
2014-11-15 21:12:09 +01:00
|
|
|
|
2014-11-09 11:06:26 +01:00
|
|
|
# print environment to showcase all of our variables
|
2015-05-12 11:07:47 +02:00
|
|
|
env | sort
|
|
|
|
|
2015-06-09 09:05:10 +02:00
|
|
|
git_checkout()
|
2014-11-09 11:04:44 +01:00
|
|
|
{
|
|
|
|
git -C ${1} clean -xdqf .
|
2015-06-09 09:05:10 +02:00
|
|
|
REPO_TAG=${2}
|
|
|
|
if [ -z "${REPO_TAG}" ]; then
|
|
|
|
git_tag ${1} ${PRODUCT_VERSION}
|
|
|
|
fi
|
|
|
|
git -C ${1} reset --hard ${REPO_TAG}
|
2014-11-09 11:04:44 +01:00
|
|
|
}
|
2014-11-09 11:15:01 +01:00
|
|
|
|
2015-06-10 08:46:59 +02:00
|
|
|
git_update()
|
|
|
|
{
|
|
|
|
git -C ${1} fetch --all --prune
|
|
|
|
if [ -n "${2}" ]; then
|
|
|
|
git_checkout ${1} ${2}
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2014-12-11 15:23:35 +01:00
|
|
|
git_describe()
|
|
|
|
{
|
2015-05-07 19:26:01 +02:00
|
|
|
VERSION=$(git -C ${1} describe --abbrev=0 --always)
|
2014-12-11 15:23:35 +01:00
|
|
|
REVISION=$(git -C ${1} rev-list ${VERSION}.. --count)
|
2014-12-20 12:14:23 +01:00
|
|
|
COMMENT=$(git -C ${1} rev-list HEAD --max-count=1 | cut -c1-9)
|
2014-12-11 15:23:35 +01:00
|
|
|
if [ "${REVISION}" != "0" ]; then
|
|
|
|
# must construct full version string manually
|
|
|
|
VERSION=${VERSION}_${REVISION}
|
|
|
|
fi
|
|
|
|
|
|
|
|
export REPO_VERSION=${VERSION}
|
|
|
|
export REPO_COMMENT=${COMMENT}
|
|
|
|
}
|
|
|
|
|
2015-06-09 09:05:10 +02:00
|
|
|
git_tag()
|
|
|
|
{
|
|
|
|
# Fuzzy-match a tag and return it for the caller.
|
|
|
|
|
|
|
|
POOL=$(git -C ${1} tag | grep ^${2}\$ || true)
|
|
|
|
if [ -z "${POOL}" ]; then
|
|
|
|
VERSION=${2%.*}
|
|
|
|
FUZZY=${2##${VERSION}.}
|
|
|
|
|
|
|
|
for _POOL in $(git -C ${1} tag | grep ^${VERSION} | sort -r); do
|
|
|
|
_POOL=${_POOL##${VERSION}}
|
|
|
|
if [ -z "${_POOL}" ]; then
|
|
|
|
POOL=${VERSION}${_POOL}
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
if [ ${_POOL##.} -lt ${FUZZY} ]; then
|
|
|
|
POOL=${VERSION}${_POOL}
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -z "${POOL}" ]; then
|
|
|
|
echo ">>> ${1} doesn't match tag ${2}"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo ">>> ${1} matches tag ${2} -> ${POOL}"
|
|
|
|
|
|
|
|
export REPO_TAG=${POOL}
|
|
|
|
}
|
|
|
|
|
2014-12-28 11:01:40 +01:00
|
|
|
setup_clone()
|
|
|
|
{
|
2015-07-24 10:20:05 +02:00
|
|
|
echo ">>> Setting up ${2} clone in ${1}"
|
2014-12-28 11:01:40 +01:00
|
|
|
|
2015-01-07 06:56:10 +01:00
|
|
|
# repositories may be huge so avoid the copy :)
|
|
|
|
mkdir -p ${1}${2} && mount_unionfs -o below ${2} ${1}${2}
|
2014-12-28 11:01:40 +01:00
|
|
|
}
|
|
|
|
|
2015-07-24 10:20:05 +02:00
|
|
|
setup_copy()
|
|
|
|
{
|
|
|
|
echo ">>> Setting up ${2} copy in ${1}"
|
|
|
|
|
|
|
|
# in case we want to clobber HEAD
|
2015-08-10 10:33:35 +02:00
|
|
|
rm -rf ${1}${2}
|
2015-08-05 08:58:23 +02:00
|
|
|
mkdir -p $(dirname ${1}${2})
|
|
|
|
cp -r ${2} ${1}${2}
|
2015-07-24 10:20:05 +02:00
|
|
|
}
|
|
|
|
|
2014-12-20 22:34:42 +01:00
|
|
|
setup_chroot()
|
|
|
|
{
|
|
|
|
echo ">>> Setting up chroot in ${1}"
|
|
|
|
|
|
|
|
cp /etc/resolv.conf ${1}/etc
|
|
|
|
mount -t devfs devfs ${1}/dev
|
|
|
|
chroot ${1} /etc/rc.d/ldconfig start
|
|
|
|
}
|
|
|
|
|
2015-03-13 09:11:36 +01:00
|
|
|
setup_marker()
|
|
|
|
{
|
|
|
|
# Let opnsense-update(8) know it's up to date
|
2015-08-25 11:30:47 +02:00
|
|
|
local MARKER="/usr/local/opnsense/version/opnsense-update.${3}"
|
2015-03-13 09:11:36 +01:00
|
|
|
|
|
|
|
if [ ! -f ${1}${MARKER} ]; then
|
|
|
|
# first call means bootstrap the marker file
|
|
|
|
mkdir -p ${1}$(dirname ${MARKER})
|
|
|
|
echo ${2} > ${1}${MARKER}
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2014-11-09 13:14:07 +01:00
|
|
|
setup_base()
|
|
|
|
{
|
2015-05-07 13:08:21 +02:00
|
|
|
local BASE_SET BASE_VER
|
|
|
|
|
2014-11-09 13:14:07 +01:00
|
|
|
echo ">>> Setting up world in ${1}"
|
|
|
|
|
2015-07-24 08:13:53 +02:00
|
|
|
BASE_SET=$(find ${SETSDIR} -name "base-*-${ARCH}.txz")
|
2015-05-07 13:08:21 +02:00
|
|
|
|
|
|
|
tar -C ${1} -xpf ${BASE_SET}
|
2015-03-13 09:11:36 +01:00
|
|
|
|
2015-03-09 08:01:50 +01:00
|
|
|
# /home is needed for LiveCD images, and since it
|
|
|
|
# belongs to the base system, we create it from here.
|
2014-11-15 11:29:03 +01:00
|
|
|
mkdir -p ${1}/home
|
|
|
|
|
2015-04-03 12:08:03 +02:00
|
|
|
# /conf is needed for the config subsystem at this
|
|
|
|
# point as the storage location. We ought to add
|
|
|
|
# this here, because otherwise read-only install
|
|
|
|
# media wouldn't be able to bootstrap the directory.
|
|
|
|
mkdir -p ${1}/conf
|
|
|
|
|
2015-05-07 13:08:21 +02:00
|
|
|
BASE_VER=${BASE_SET##${SETSDIR}/base-}
|
2015-03-13 09:11:36 +01:00
|
|
|
|
2015-06-18 11:57:20 +02:00
|
|
|
setup_marker ${1} ${BASE_VER%%.txz} base
|
2014-11-09 13:14:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
setup_kernel()
|
|
|
|
{
|
2015-05-07 13:08:21 +02:00
|
|
|
local KERNEL_SET KERNEL_VER
|
2015-05-07 14:07:03 +02:00
|
|
|
|
2014-11-09 13:14:07 +01:00
|
|
|
echo ">>> Setting up kernel in ${1}"
|
|
|
|
|
2015-07-24 08:13:53 +02:00
|
|
|
KERNEL_SET=$(find ${SETSDIR} -name "kernel-*-${ARCH}.txz")
|
2015-03-13 09:11:36 +01:00
|
|
|
|
2015-04-28 13:58:28 +02:00
|
|
|
tar -C ${1} -xpf ${KERNEL_SET}
|
2015-03-13 09:11:36 +01:00
|
|
|
|
2015-05-07 13:08:21 +02:00
|
|
|
KERNEL_VER=${KERNEL_SET##${SETSDIR}/kernel-}
|
2015-03-13 09:11:36 +01:00
|
|
|
|
2015-06-18 11:57:20 +02:00
|
|
|
setup_marker ${1} ${KERNEL_VER%%.txz} kernel
|
2014-11-09 13:14:07 +01:00
|
|
|
}
|
|
|
|
|
2015-05-08 13:12:10 +02:00
|
|
|
extract_packages()
|
2014-11-15 10:55:32 +01:00
|
|
|
{
|
2015-05-08 13:12:10 +02:00
|
|
|
echo ">>> Extracting packages in ${1}"
|
2014-11-15 10:55:32 +01:00
|
|
|
|
2014-12-23 18:36:52 +01:00
|
|
|
BASEDIR=${1}
|
|
|
|
|
2015-05-08 13:12:10 +02:00
|
|
|
rm -rf ${BASEDIR}${PACKAGESDIR}/All
|
|
|
|
mkdir -p ${BASEDIR}${PACKAGESDIR}/All
|
|
|
|
|
2015-07-24 08:13:53 +02:00
|
|
|
PACKAGESET=$(find ${SETSDIR} -name "packages-*-${PRODUCT_FLAVOUR}-${ARCH}.tar")
|
2015-05-08 13:12:10 +02:00
|
|
|
if [ -f "${PACKAGESET}" ]; then
|
|
|
|
tar -C ${BASEDIR}${PACKAGESDIR} -xpf ${PACKAGESET}
|
|
|
|
fi
|
2015-07-18 18:47:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
remove_packages()
|
|
|
|
{
|
|
|
|
echo ">>> Removing packages in ${1}"
|
|
|
|
|
|
|
|
BASEDIR=${1}
|
|
|
|
shift
|
|
|
|
PKGLIST=${@}
|
2015-05-08 13:12:10 +02:00
|
|
|
|
2015-07-16 18:13:34 +02:00
|
|
|
for PKG in ${PKGLIST}; do
|
|
|
|
# clear out the ports that ought to be rebuilt
|
2015-07-24 13:28:03 +02:00
|
|
|
for PKGFILE in $(cd ${BASEDIR}${PACKAGESDIR}; find All -type f); do
|
|
|
|
PKGINFO=$(pkg -c ${BASEDIR} info -F ${PACKAGESDIR}/${PKGFILE} | grep ^Name | awk '{ print $3; }')
|
2015-07-16 18:13:34 +02:00
|
|
|
if [ ${PKG} = ${PKGINFO} ]; then
|
2015-07-24 13:28:03 +02:00
|
|
|
rm ${BASEDIR}${PACKAGESDIR}/${PKGFILE}
|
2015-07-16 18:13:34 +02:00
|
|
|
fi
|
2015-05-08 13:12:10 +02:00
|
|
|
done
|
2015-07-16 18:13:34 +02:00
|
|
|
done
|
2015-05-08 13:12:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
install_packages()
|
|
|
|
{
|
2015-05-12 10:12:56 +02:00
|
|
|
echo ">>> Installing packages in ${1}..."
|
2015-05-08 13:12:10 +02:00
|
|
|
|
|
|
|
BASEDIR=${1}
|
|
|
|
shift
|
|
|
|
PKGLIST=${@}
|
2014-12-23 18:36:52 +01:00
|
|
|
|
2015-07-24 08:13:53 +02:00
|
|
|
# remove previous packages for a clean environment
|
2015-07-17 17:51:48 +02:00
|
|
|
pkg -c ${BASEDIR} remove -fya
|
|
|
|
|
2014-12-23 18:36:52 +01:00
|
|
|
if [ -z "${PKGLIST}" ]; then
|
2015-07-24 08:13:53 +02:00
|
|
|
for PKG in $({
|
|
|
|
cd ${BASEDIR}
|
2015-09-10 19:02:01 +02:00
|
|
|
# find all package files, omitting plugins
|
|
|
|
find .${PACKAGESDIR}/All -type f \! -name "os-*"
|
2015-07-24 08:13:53 +02:00
|
|
|
}); do
|
2015-04-27 21:55:23 +02:00
|
|
|
# Adds all available packages but ignores the
|
|
|
|
# ones that cannot be installed due to missing
|
|
|
|
# dependencies. This behaviour is desired.
|
2015-07-24 08:13:53 +02:00
|
|
|
pkg -c ${BASEDIR} add ${PKG} || true
|
2015-04-27 21:55:23 +02:00
|
|
|
done
|
2014-12-23 18:36:52 +01:00
|
|
|
else
|
2015-04-27 21:55:23 +02:00
|
|
|
# always bootstrap pkg as the first package
|
|
|
|
for PKG in pkg ${PKGLIST}; do
|
|
|
|
# Adds all selected packages and fails if
|
|
|
|
# one cannot be installed. Used to build
|
|
|
|
# final images or regression test systems.
|
2015-07-24 08:13:53 +02:00
|
|
|
PKGFOUND=
|
|
|
|
for PKGFILE in $({
|
|
|
|
cd ${BASEDIR}
|
|
|
|
find .${PACKAGESDIR}/All -name "${PKG}-*.txz"
|
|
|
|
}); do
|
|
|
|
PKGINFO=$(pkg -c ${BASEDIR} info -F ${PKGFILE} | grep ^Name | awk '{ print $3; }')
|
|
|
|
if [ ${PKG} = ${PKGINFO} ]; then
|
|
|
|
PKGFOUND=${PKGFILE}
|
|
|
|
fi
|
|
|
|
done
|
2015-09-10 17:41:01 +02:00
|
|
|
if [ -n "${PKGFOUND}" ]; then
|
2015-09-10 15:50:04 +02:00
|
|
|
pkg -c ${BASEDIR} add ${PKGFOUND}
|
|
|
|
else
|
|
|
|
echo "Could not find package: ${PKG}" >&2
|
|
|
|
exit 1
|
|
|
|
fi
|
2014-12-23 18:36:52 +01:00
|
|
|
done
|
2015-04-27 10:35:01 +02:00
|
|
|
fi
|
2015-02-19 08:38:53 +01:00
|
|
|
|
2015-04-27 10:35:01 +02:00
|
|
|
# collect all installed packages
|
|
|
|
PKGLIST="$(pkg -c ${BASEDIR} query %n)"
|
|
|
|
|
|
|
|
for PKG in ${PKGLIST}; do
|
|
|
|
# add, unlike install, is not aware of repositories :(
|
2015-05-07 08:11:21 +02:00
|
|
|
pkg -c ${BASEDIR} annotate -qyA ${PKG} \
|
|
|
|
repository ${PRODUCT_NAME}
|
2015-04-27 10:35:01 +02:00
|
|
|
done
|
2015-05-08 13:12:10 +02:00
|
|
|
}
|
2014-11-15 10:55:32 +01:00
|
|
|
|
2015-07-17 17:37:31 +02:00
|
|
|
custom_packages()
|
2015-07-16 17:34:35 +02:00
|
|
|
{
|
|
|
|
chroot ${1} /bin/sh -es << EOF
|
|
|
|
# clear the internal staging area and package files
|
|
|
|
rm -rf ${1}
|
2015-07-17 17:37:31 +02:00
|
|
|
|
|
|
|
# run the package build process
|
|
|
|
make -C ${2} DESTDIR=${1} FLAVOUR=${PRODUCT_FLAVOUR} install
|
|
|
|
make -C ${2} DESTDIR=${1} scripts
|
|
|
|
make -C ${2} DESTDIR=${1} manifest > ${1}/+MANIFEST
|
|
|
|
make -C ${2} DESTDIR=${1} plist > ${1}/plist
|
|
|
|
|
|
|
|
echo -n ">>> Creating custom package for \$(make -C ${2} name)... "
|
|
|
|
pkg create -m ${1} -r ${1} -p ${1}/plist -o ${PACKAGESDIR}/All
|
|
|
|
echo "done"
|
2015-07-16 17:34:35 +02:00
|
|
|
EOF
|
|
|
|
}
|
|
|
|
|
2015-05-08 13:12:10 +02:00
|
|
|
bundle_packages()
|
|
|
|
{
|
2015-05-16 13:25:53 +02:00
|
|
|
sh ./clean.sh packages
|
2015-05-08 13:12:10 +02:00
|
|
|
|
2015-07-24 07:40:53 +02:00
|
|
|
git_describe ${PORTSDIR}
|
|
|
|
|
2015-05-08 13:12:10 +02:00
|
|
|
# rebuild expected FreeBSD structure
|
2015-06-11 10:00:03 +02:00
|
|
|
mkdir -p ${1}${PACKAGESDIR}-new/Latest
|
|
|
|
mkdir -p ${1}${PACKAGESDIR}-new/All
|
2015-05-08 13:12:10 +02:00
|
|
|
|
|
|
|
# push packages to home location
|
2015-06-11 10:00:03 +02:00
|
|
|
cp ${1}${PACKAGESDIR}/All/* ${1}${PACKAGESDIR}-new/All
|
2015-05-08 13:12:10 +02:00
|
|
|
|
|
|
|
# needed bootstrap glue when no packages are on the system
|
2015-06-11 10:00:03 +02:00
|
|
|
(cd ${1}${PACKAGESDIR}-new/Latest; ln -s ../All/pkg-*.txz pkg.txz)
|
2015-05-08 13:12:10 +02:00
|
|
|
|
|
|
|
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
|
2015-06-11 10:00:03 +02:00
|
|
|
pkg repo ${1}${PACKAGESDIR}-new/ ${SIGNARGS}
|
2015-05-08 13:12:10 +02:00
|
|
|
|
2015-07-24 09:54:46 +02:00
|
|
|
REPO_RELEASE="${REPO_VERSION}-${PRODUCT_FLAVOUR}-${ARCH}"
|
|
|
|
echo -n ">>> Creating package mirror set for ${REPO_RELEASE}... "
|
2015-06-11 10:00:03 +02:00
|
|
|
tar -C ${STAGEDIR}${PACKAGESDIR}-new -cf \
|
2015-07-24 09:54:46 +02:00
|
|
|
${SETSDIR}/packages-${REPO_RELEASE}.tar .
|
2015-05-08 13:12:10 +02:00
|
|
|
echo "done"
|
|
|
|
}
|
|
|
|
|
|
|
|
clean_packages()
|
|
|
|
{
|
2015-05-10 13:59:51 +02:00
|
|
|
rm -rf ${1}${PACKAGESDIR}
|
2015-05-08 13:12:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
setup_packages()
|
|
|
|
{
|
2015-05-10 13:59:51 +02:00
|
|
|
# legacy package extract
|
2015-05-08 13:12:10 +02:00
|
|
|
extract_packages ${1}
|
2015-09-09 15:54:26 +02:00
|
|
|
install_packages ${@} ${PRODUCT_TYPE}
|
2015-05-08 13:12:10 +02:00
|
|
|
clean_packages ${1}
|
2014-11-15 10:55:32 +01:00
|
|
|
}
|
|
|
|
|
2014-11-16 16:20:27 +01:00
|
|
|
setup_mtree()
|
|
|
|
{
|
|
|
|
echo ">>> Creating mtree summary of files present..."
|
|
|
|
|
|
|
|
cat > ${1}/tmp/installed_filesystem.mtree.exclude <<EOF
|
|
|
|
./dev
|
|
|
|
./tmp
|
|
|
|
EOF
|
2015-05-04 09:13:58 +02:00
|
|
|
chroot ${1} /bin/sh -es <<EOF
|
2014-11-16 16:20:27 +01:00
|
|
|
/usr/sbin/mtree -c -k uid,gid,mode,size,sha256digest -p / -X /tmp/installed_filesystem.mtree.exclude > /tmp/installed_filesystem.mtree
|
|
|
|
/bin/chmod 600 /tmp/installed_filesystem.mtree
|
|
|
|
/bin/mv /tmp/installed_filesystem.mtree /etc/
|
|
|
|
/bin/rm /tmp/installed_filesystem.mtree.exclude
|
|
|
|
EOF
|
|
|
|
}
|
|
|
|
|
2014-11-09 11:15:01 +01:00
|
|
|
setup_stage()
|
|
|
|
{
|
2014-12-21 09:30:41 +01:00
|
|
|
echo ">>> Setting up stage in ${1}"
|
|
|
|
|
2015-07-09 14:32:50 +02:00
|
|
|
local MOUNTDIRS="/dev ${SRCDIR} ${PORTSDIR} ${COREDIR} ${PLUGINSDIR}"
|
2015-01-07 06:56:10 +01:00
|
|
|
|
2014-12-20 22:31:37 +01:00
|
|
|
# might have been a chroot
|
2015-01-07 06:56:10 +01:00
|
|
|
for DIR in ${MOUNTDIRS}; do
|
|
|
|
if [ -d ${1}${DIR} ]; then
|
|
|
|
umount ${1}${DIR} 2> /dev/null || true
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
2014-12-20 22:31:37 +01:00
|
|
|
# remove base system files
|
|
|
|
rm -rf ${1} 2> /dev/null ||
|
|
|
|
(chflags -R noschg ${1}; rm -rf ${1} 2> /dev/null)
|
2015-01-07 06:56:10 +01:00
|
|
|
|
2014-12-20 22:31:37 +01:00
|
|
|
# revive directory for next run
|
|
|
|
mkdir -p ${1}
|
2014-11-09 11:15:01 +01:00
|
|
|
}
|