Skip to content

Commit dd4d77d

Browse files
committed
image: fix pkgbase repo location
1 parent 3a37ba8 commit dd4d77d

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
@@ -239,21 +239,18 @@ convert_package_list() {
239239

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

@@ -272,7 +269,6 @@ install_world()
272269
}
273270

274271
HOSTNAME=poudriere-image
275-
INSTALLWORLD=install_world
276272
PKG_QUIET="-q"
277273

278274
: ${PRE_BUILD_SCRIPT:=""}
@@ -344,7 +340,6 @@ while getopts "A:bB:c:f:h:i:j:m:n:o:p:P:R:s:S:t:vw:X:z:" FLAG; do
344340
OPTARG="${SAVED_PWD}/${OPTARG}"
345341
[ -r "${OPTARG}" ] || err 1 "No such package list: ${OPTARG}"
346342
PKGBASELIST=${OPTARG}
347-
INSTALLWORLD=install_world_from_pkgbase
348343
;;
349344
R)
350345
ZFS_SEND_FLAGS="-${OPTARG}"
@@ -437,7 +432,6 @@ WRKDIR=$(mktemp -d ${POUDRIERE_DATA}/images/${IMAGENAME}-XXXX)
437432
if [ "${TMPFS_IMAGE:-0}" -eq 1 -o "${TMPFS_ALL}" -eq 1 ]; then
438433
mnt_tmpfs image "${WRKDIR:?}"
439434
fi
440-
_jget mnt ${JAILNAME} mnt || err 1 "Missing mnt metadata for jail"
441435
excludelist=$(mktemp -t excludelist)
442436
mkdir -p ${WRKDIR:?}/world
443437
mkdir -p ${WRKDIR:?}/out
@@ -452,6 +446,14 @@ boot/kernel.old
452446
nxb-bin
453447
EOF
454448

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

0 commit comments

Comments
 (0)