Skip to content

Commit 6b9882f

Browse files
committed
image: fix pkgbase repo location
1 parent a02d3f5 commit 6b9882f

File tree

1 file changed

+19
-17
lines changed

1 file changed

+19
-17
lines changed

src/share/poudriere/image.sh

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -238,21 +238,18 @@ convert_package_list() {
238238

239239
install_world_from_pkgbase()
240240
{
241-
OSVERSION=$(awk -F '"' '/REVISION=/ { print $2 }' ${mnt}/usr/src/sys/conf/newvers.sh | cut -d '.' -f 1)
242-
mkdir -p ${WRKDIR:?}/world/etc/pkg/
243-
pkg_abi=$(get_pkg_abi)
244-
cat << -EOF > ${WRKDIR:?}/world/etc/pkg/FreeBSD-base.conf
245-
local: {
246-
url: file://${POUDRIERE_DATA}/images/${JAILNAME}-repo/FreeBSD:${OSVERSION}:${pkg_abi}/latest,
247-
enabled: true
248-
}
249-
-EOF
250-
pkg -o ABI_FILE="${mnt}/usr/lib/crt1.o" -o REPOS_DIR=${WRKDIR}/world/etc/pkg/ -o ASSUME_ALWAYS_YES=yes -r ${WRKDIR:?}/world update ${PKG_QUIET}
241+
_repos_dir="${WRKDIR:?}/world/etc/pkg"
242+
_pkg_cmd="pkg -o ABI_FILE='${mnt:?}/usr/lib/crt1.o' -o REPOS_DIR='${_repos_dir}' -o ASSUME_ALWAYS_YES=yes -r '${WRKDIR}/world'"
243+
mkdir -p "${_repos_dir}"
244+
cp "${mnt}/etc/pkg/pkgbase.conf" "${_repos_dir}/FreeBSD-base.conf"
245+
${_pkg_cmd} update ${PKG_QUIET}
251246
msg "Installing base packages"
252-
while read line; do
253-
pkg -o ABI_FILE="${mnt}/usr/lib/crt1.o" -o REPOS_DIR=${WRKDIR}/world/etc/pkg/ -o ASSUME_ALWAYS_YES=yes -r ${WRKDIR:?}/world install -r local ${PKG_QUIET} -y ${line}
254-
done < ${PKGBASELIST}
255-
rm ${WRKDIR:?}/world/etc/pkg/FreeBSD-base.conf
247+
if [ -n "${PKGBASELIST}" ]; then
248+
xargs ${_pkg_cmd} install -r local ${PKG_QUIET} -y < ${PKGBASELIST}
249+
else
250+
${_pkg_cmd} install -r local ${PKG_QUIET} -y -g 'FreeBSD-*'
251+
fi
252+
rm "${_repos_dir}/FreeBSD-base.conf"
256253
msg "Base packages installed"
257254
}
258255

@@ -271,7 +268,6 @@ install_world()
271268
}
272269

273270
HOSTNAME=poudriere-image
274-
INSTALLWORLD=install_world
275271
PKG_QUIET="-q"
276272

277273
: ${PRE_BUILD_SCRIPT:=""}
@@ -343,7 +339,6 @@ while getopts "A:bB:c:f:h:i:j:m:n:o:p:P:R:s:S:t:vw:X:z:" FLAG; do
343339
OPTARG="${SAVED_PWD}/${OPTARG}"
344340
[ -r "${OPTARG}" ] || err 1 "No such package list: ${OPTARG}"
345341
PKGBASELIST=${OPTARG}
346-
INSTALLWORLD=install_world_from_pkgbase
347342
;;
348343
R)
349344
ZFS_SEND_FLAGS="-${OPTARG}"
@@ -433,7 +428,6 @@ CLEANUP_HOOK=cleanup_image
433428
[ -d "${POUDRIERE_DATA}/images" ] || \
434429
mkdir "${POUDRIERE_DATA:?}/images"
435430
WRKDIR=$(mktemp -d ${POUDRIERE_DATA}/images/${IMAGENAME}-XXXX)
436-
_jget mnt ${JAILNAME} mnt || err 1 "Missing mnt metadata for jail"
437431
excludelist=$(mktemp -t excludelist)
438432
mkdir -p ${WRKDIR:?}/world
439433
mkdir -p ${WRKDIR:?}/out
@@ -448,6 +442,14 @@ boot/kernel.old
448442
nxb-bin
449443
EOF
450444

445+
_jget method ${JAILNAME} method || err 1 "Missing method metadata for jail"
446+
if [ "${method}" = "pkgbase" ]; then
447+
INSTALLWORLD=install_world_from_pkgbase
448+
else
449+
[ -n "${PKGBASELIST}" ] && err 1 "-P used for a non-pkgbase jail!"
450+
INSTALLWORLD=install_world
451+
fi
452+
451453
# Need to convert IMAGESIZE from bytes to bibytes
452454
# This conversion is needed to be compliant with marketing 'unit'
453455
# without this, a 2GiB image will not fit into a 2GB flash disk (=1862MiB)

0 commit comments

Comments
 (0)