2014-11-15 08:55:43 +01:00
|
|
|
#!/bin/sh
|
|
|
|
|
2017-01-05 20:12:24 +01:00
|
|
|
# Copyright (c) 2014-2017 Franco Fichtner <franco@opnsense.org>
|
2014-11-15 08:55:43 +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.
|
|
|
|
#
|
|
|
|
# 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
|
|
|
|
|
2016-05-05 17:11:45 +02:00
|
|
|
SELF=ports
|
|
|
|
|
2017-04-27 19:14:36 +02:00
|
|
|
. ./common.sh
|
2015-05-16 12:39:09 +02:00
|
|
|
|
2016-07-19 09:58:04 +02:00
|
|
|
PORTS_LIST=$(
|
2016-12-24 09:28:49 +01:00
|
|
|
cat ${CONFIGDIR}/ports.conf | while read PORT_ORIGIN PORT_IGNORE; do
|
2016-07-19 09:58:04 +02:00
|
|
|
if [ "$(echo ${PORT_ORIGIN} | colrm 2)" = "#" ]; then
|
|
|
|
continue
|
|
|
|
fi
|
2016-12-24 09:28:49 +01:00
|
|
|
if [ -n "${PORT_IGNORE}" ]; then
|
|
|
|
for PORT_QUIRK in $(echo ${PORT_IGNORE} | tr ',' ' '); do
|
2017-01-06 16:58:14 +01:00
|
|
|
if [ ${PORT_QUIRK} = ${PRODUCT_TARGET} -o \
|
|
|
|
${PORT_QUIRK} = ${PRODUCT_ARCH} -o \
|
|
|
|
${PORT_QUIRK} = ${PRODUCT_FLAVOUR} ]; then
|
2016-07-19 09:58:04 +02:00
|
|
|
continue 2
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo ${PORT_ORIGIN}
|
|
|
|
done
|
|
|
|
)
|
2014-12-08 22:01:32 +01:00
|
|
|
|
2016-05-05 17:11:45 +02:00
|
|
|
check_packages ${SELF} ${@}
|
2016-01-20 10:24:20 +01:00
|
|
|
|
2017-01-11 07:31:06 +01:00
|
|
|
git_branch ${SRCDIR} ${SRCBRANCH} SRCBRANCH
|
|
|
|
git_branch ${PORTSDIR} ${PORTSBRANCH} PORTSBRANCH
|
2016-12-23 16:27:48 +01:00
|
|
|
|
2016-01-25 07:38:07 +01:00
|
|
|
setup_stage ${STAGEDIR}
|
2014-12-20 22:31:37 +01:00
|
|
|
setup_base ${STAGEDIR}
|
2014-12-28 11:01:40 +01:00
|
|
|
setup_clone ${STAGEDIR} ${PORTSDIR}
|
|
|
|
setup_clone ${STAGEDIR} ${SRCDIR}
|
2014-12-20 22:34:42 +01:00
|
|
|
setup_chroot ${STAGEDIR}
|
2015-09-11 22:18:34 +02:00
|
|
|
setup_distfiles ${STAGEDIR}
|
2014-12-20 22:31:37 +01:00
|
|
|
|
2016-01-25 07:38:07 +01:00
|
|
|
extract_packages ${STAGEDIR}
|
2017-02-16 09:25:53 +01:00
|
|
|
remove_packages ${STAGEDIR} ${@} ${PRODUCT_PKGNAMES} "os-*"
|
2015-05-08 13:12:10 +02:00
|
|
|
|
2017-04-19 19:37:55 +02:00
|
|
|
for PKG in $(cd ${STAGEDIR}; find .${PACKAGESDIR}/All -type f); do
|
2017-04-20 10:33:19 +02:00
|
|
|
# all packages that install have their dependencies fulfilled
|
|
|
|
if pkg -c ${STAGEDIR} add ${PKG}; then
|
|
|
|
continue
|
2017-04-19 19:37:55 +02:00
|
|
|
fi
|
2017-04-20 10:33:19 +02:00
|
|
|
|
|
|
|
# some packages clash in files with others, check for conflicts
|
|
|
|
PKGORIGIN=$(pkg -c ${STAGEDIR} info -F ${PKG} | grep ^Origin | awk '{ print $3; }')
|
|
|
|
PKGGLOBS=
|
|
|
|
for CONFLICTS in CONFLICTS CONFLICTS_INSTALL; do
|
|
|
|
PKGGLOBS="${PKGGLOBS} $(make -C ${PORTSDIR}/${PKGORIGIN} -V ${CONFLICTS})"
|
|
|
|
done
|
|
|
|
for PKGGLOB in ${PKGGLOBS}; do
|
2017-04-21 08:24:53 +02:00
|
|
|
pkg -c ${STAGEDIR} remove -gy "${PKGGLOB}" || true
|
2017-04-20 10:33:19 +02:00
|
|
|
done
|
|
|
|
|
|
|
|
# if the conflicts are resolved this works now, but remove
|
|
|
|
# the package again as it may clash again later...
|
|
|
|
if pkg -c ${STAGEDIR} add ${PKG}; then
|
|
|
|
pkg -c ${STAGEDIR} remove -y ${PKGORIGIN}
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
|
|
|
|
# if nothing worked, we are missing a dependency and force a rebuild
|
|
|
|
rm -f ${STAGEDIR}/${PKG}
|
2017-04-19 19:37:55 +02:00
|
|
|
done
|
2014-12-20 22:31:37 +01:00
|
|
|
|
2015-06-12 08:01:54 +02:00
|
|
|
MAKE_CONF="${CONFIGDIR}/make.conf"
|
2014-12-20 22:31:37 +01:00
|
|
|
if [ -f ${MAKE_CONF} ]; then
|
|
|
|
cp ${MAKE_CONF} ${STAGEDIR}/etc/make.conf
|
|
|
|
fi
|
2014-12-08 21:41:34 +01:00
|
|
|
|
2014-12-30 16:08:16 +01:00
|
|
|
# block SIGINT to allow for collecting port progress (use with care)
|
|
|
|
trap : 2
|
|
|
|
|
2016-07-19 16:39:54 +02:00
|
|
|
if ! ${ENV_FILTER} chroot ${STAGEDIR} /bin/sh -es << EOF; then SELF=; fi
|
2017-04-21 08:39:20 +02:00
|
|
|
PKG_ORIGIN="ports-mgmt/pkg"
|
|
|
|
|
2016-07-19 20:00:39 +02:00
|
|
|
if ! pkg -N; then
|
2017-04-21 08:39:20 +02:00
|
|
|
make -C ${PORTSDIR}/\${PKG_ORIGIN} install \
|
2016-07-30 09:42:31 +02:00
|
|
|
UNAME_r=\$(freebsd-version)
|
2014-11-15 08:55:43 +01:00
|
|
|
fi
|
|
|
|
|
2017-04-20 10:33:19 +02:00
|
|
|
pkg set -yaA1
|
2017-04-21 08:39:20 +02:00
|
|
|
pkg set -yA0 \${PKG_ORIGIN}
|
2017-04-20 10:33:19 +02:00
|
|
|
pkg autoremove -y
|
|
|
|
|
|
|
|
pkg create -nao ${PACKAGESDIR}/All -f txz
|
2017-04-19 19:37:55 +02:00
|
|
|
|
2017-04-20 10:33:19 +02:00
|
|
|
echo "${PORTS_LIST}" | while read PORT_ORIGIN; do
|
2017-04-19 19:37:55 +02:00
|
|
|
PKGFILE=\$(make -C ${PORTSDIR}/\${PORT_ORIGIN} -V PKGFILE \
|
|
|
|
PRODUCT_FLAVOUR=${PRODUCT_FLAVOUR} PACKAGES=${PACKAGESDIR} \
|
|
|
|
UNAME_r=\$(freebsd-version))
|
|
|
|
|
2017-04-21 08:39:20 +02:00
|
|
|
# XXX a different version of the same package may exist though
|
2017-04-19 19:37:55 +02:00
|
|
|
if [ -f \${PKGFILE} ]; then
|
2014-11-16 10:14:05 +01:00
|
|
|
continue
|
2014-11-15 08:55:43 +01:00
|
|
|
fi
|
|
|
|
|
2017-04-20 10:33:19 +02:00
|
|
|
make -C ${PORTSDIR}/\${PORT_ORIGIN} install \
|
2017-04-19 19:37:55 +02:00
|
|
|
PRODUCT_FLAVOUR=${PRODUCT_FLAVOUR} PACKAGES=${PACKAGESDIR} \
|
|
|
|
USE_PACKAGE_DEPENDS=yes UNAME_r=\$(freebsd-version)
|
|
|
|
|
|
|
|
echo "${PORTS_LIST}" | while read PORT_DEPENDS; do
|
2017-04-21 08:39:20 +02:00
|
|
|
PORT_DEPNAME=\$(pkg query -e "%o == \${PORT_DEPENDS}" %n)
|
|
|
|
if [ -n "\${PORT_DEPNAME}" ]; then
|
|
|
|
pkg set -yA0 \${PORT_DEPNAME}
|
2017-04-19 19:37:55 +02:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
pkg autoremove -y
|
|
|
|
pkg create -nao ${PACKAGESDIR}/All -f txz
|
2017-04-20 10:33:19 +02:00
|
|
|
|
|
|
|
make -C ${PORTSDIR}/\${PORT_ORIGIN} clean \
|
|
|
|
PRODUCT_FLAVOUR=${PRODUCT_FLAVOUR} \
|
|
|
|
UNAME_r=\$(freebsd-version)
|
|
|
|
|
|
|
|
pkg set -yaA1
|
2017-04-21 08:39:20 +02:00
|
|
|
pkg set -yA0 \${PKG_ORIGIN}
|
2017-04-20 10:33:19 +02:00
|
|
|
pkg autoremove -y
|
2015-07-18 07:47:01 +02:00
|
|
|
done
|
2014-12-20 22:31:37 +01:00
|
|
|
EOF
|
2014-11-15 08:55:43 +01:00
|
|
|
|
2014-12-30 16:08:16 +01:00
|
|
|
# unblock SIGINT
|
|
|
|
trap - 2
|
|
|
|
|
2017-04-19 19:37:55 +02:00
|
|
|
bundle_packages ${STAGEDIR} "${SELF}" ports plugins core
|
2014-12-20 22:31:37 +01:00
|
|
|
|
2016-12-10 15:11:02 +01:00
|
|
|
if [ "${SELF}" != "ports" ]; then
|
2015-05-08 16:55:34 +02:00
|
|
|
echo ">>> The ports build did not finish properly :("
|
2015-05-04 08:45:48 +02:00
|
|
|
exit 1
|
|
|
|
fi
|