git: 6b5adf33873a - main - Include a pkg package in the pkgbase repo
Date: Wed, 17 Sep 2025 22:39:24 UTC
The branch main has been updated by cperciva:
URL: https://cgit.FreeBSD.org/src/commit/?id=6b5adf33873a309523dc4e585ff08d70bb6c6f2f
commit 6b5adf33873a309523dc4e585ff08d70bb6c6f2f
Author: Colin Percival <cperciva@FreeBSD.org>
AuthorDate: 2025-09-17 22:34:25 +0000
Commit: Colin Percival <cperciva@FreeBSD.org>
CommitDate: 2025-09-17 22:34:25 +0000
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 97a0b00cc517..65631c2e8eb8 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 68172c47f326..a0ac0fc16305 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}