From 6b5adf33873a309523dc4e585ff08d70bb6c6f2f Mon Sep 17 00:00:00 2001 From: Colin Percival Date: Wed, 17 Sep 2025 15:34:25 -0700 Subject: [PATCH] Include a pkg package in the pkgbase repo It is essential that users be able to install the FreeBSD base system from release media and have all the bits needed to update the FreeBSD base system without touching the ports tree or pkg.freebsd.org. To that end, resurrect (and heavily rewrite) the make-pkg-package.sh script and hook it into the create-packages target; if /usr/ports exists when building pkgbase packages, we'll also (cross)build pkg and include it in the repository. Scripting for actually installing this package as part of the FreeBSD installation process to come later, but I wanted this in the tree in time to test it in this week's snapshots. MFC after: 1 day Sponsored by: https://www.patreon.com/cperciva --- Makefile.inc1 | 6 ++++-- release/scripts/make-pkg-package.sh | 28 ++++++++++++---------------- 2 files changed, 16 insertions(+), 18 deletions(-) diff --git a/Makefile.inc1 b/Makefile.inc1 index 97a0b00cc51..65631c2e8eb 100644 --- a/Makefile.inc1 +++ b/Makefile.inc1 @@ -2039,12 +2039,14 @@ update-packages: .PHONY ${_+_}${MAKE} -C ${.CURDIR} ${PKGMAKEARGS} real-update-packages package-pkg: .PHONY +.if exists(${PORTSDIR}) rm -rf /tmp/ports.${TARGET} || : - env ${WMAKEENV:Q} SRCDIR=${.CURDIR} PORTSDIR=${PORTSDIR} REVISION=${_REVISION} \ + env ${WMAKEENV} SRCDIR=${.CURDIR} PORTSDIR=${PORTSDIR} REVISION=${_REVISION} \ PKG_CMD=${PKG_CMD} PKG_VERSION=${PKG_VERSION} REPODIR=${REPODIR} \ WSTAGEDIR=${WSTAGEDIR} \ OSVERSION="${SRCRELDATE}" \ sh ${.CURDIR}/release/scripts/make-pkg-package.sh +.endif real-packages: stage-packages create-packages sign-packages .PHONY @@ -2127,7 +2129,7 @@ create-packages-source: _pkgbootstrap _repodir .PHONY SOURCE_DATE_EPOCH=${SOURCE_DATE_EPOCH} \ create-source-packages -create-packages: .PHONY create-packages-world create-packages-kernel create-packages-source create-packages-sets +create-packages: .PHONY create-packages-world create-packages-kernel create-packages-source package-pkg create-packages-sets create-source-src-package: _pkgbootstrap .PHONY rm -f ${SSTAGEDIR}/src.plist 2>/dev/null || : diff --git a/release/scripts/make-pkg-package.sh b/release/scripts/make-pkg-package.sh index 68172c47f32..a0ac0fc1630 100755 --- a/release/scripts/make-pkg-package.sh +++ b/release/scripts/make-pkg-package.sh @@ -1,26 +1,22 @@ #!/bin/sh -# -# -# Simulate the build environment. -eval $(make -C ${SRCDIR} TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} buildenvvars) +# Simulate the build environment. Note that we need to unset some variables +# which are set in the src tree since they have different (unwanted) effects +# in the ports tree. +SRC_PKG_VERSION=${PKG_VERSION} +PKG_ABI=$(${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI) +unset PKG_VERSION +unset MAKEFLAGS +unset PKGBASE export WRKDIRPREFIX=/tmp/ports.${TARGET} -export WSTAGEDIR=${WSTAGEDIR} -export REPODIR=${REPODIR} -export PKG_CMD=${PKG_CMD} -export PKG_VERSION=${PKG_VERSION} -export OSVERSION=${OSVERSION} export WRKDIR=$(make -C ${PORTSDIR}/ports-mgmt/pkg -V WRKDIR) make -C ${PORTSDIR}/ports-mgmt/pkg TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \ CONFIGURE_ARGS="--host=$(uname -m)-portbld-freebsd${REVISION}" \ - stage create-manifest + BATCH=YES stage create-manifest -${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/bin/sh \ - create -v -m ${WRKDIR}/.metadir/ \ +${PKG_CMD} -o ABI=${PKG_ABI} \ + create -v -m ${WRKDIR}/.metadir.pkg/ \ -r ${WRKDIR}/stage \ -p ${WRKDIR}/.PLIST.mktmp \ - -o ${REPODIR}/$(${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/${PKG_VERSION} -mkdir -p ${REPODIR}/$(${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/${PKG_VERSION}/Latest/ -cd ${REPODIR}/$(${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/${PKG_VERSION}/Latest/ && \ - ln -s ../pkg-*.txz + -o ${REPODIR}/${PKG_ABI}/${SRC_PKG_VERSION}