diff options
| author | Colin Percival <cperciva@FreeBSD.org> | 2025-09-18 19:21:29 +0000 |
|---|---|---|
| committer | Colin Percival <cperciva@FreeBSD.org> | 2025-09-18 19:21:29 +0000 |
| commit | 2c06b824436df6177545cc0f1603e5c3bfbf3365 (patch) | |
| tree | 6cffc0a60805ff506b50d71679fd67ef32003c80 | |
| parent | d5984d5f29a7c717b88ccd17a85a747792403cdf (diff) | |
pkgbootstrap: Build pkg if PORTSDIR exists
If we don't already have the pkg tool installed, we need to install it
before we can build packages for pkgbase. (This arises in release
builds which run in clean chroots; most users will have pkg installed
already.) Installing it from pkg.freebsd.org via "pkg bootstrap" runs
into two problems: First, it's an external dependency with security
implications; and second, there's a bootstrapping problem on new major
versions where pkg.freebsd.org does not have packages yet.
Instead, if we have a ports tree, use it to build pkg ourselves.
With hat: re
MFC after: 6 hours
Sponsored by: https://www.patreon.com/cperciva
| -rw-r--r-- | Makefile.inc1 | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/Makefile.inc1 b/Makefile.inc1 index cd0385ea32ac..d41741d15384 100644 --- a/Makefile.inc1 +++ b/Makefile.inc1 @@ -1992,8 +1992,16 @@ PKG_ABI!= ${PKG_CMD} -o ABI_FILE=${PKG_ABI_FILE} config ABI _pkgbootstrap: .PHONY .if make(*package*) && !exists(${LOCALBASE}/sbin/pkg) +.if exists(${PORTSDIR}/ports-mgmt/pkg/Makefile) + env - UNAME_r=${UNAME_r} PATH=$$PATH \ + make -C ${PORTSDIR}/ports-mgmt/pkg \ + I_DONT_CARE_IF_MY_BUILDS_TARGET_THE_WRONG_RELEASE=1 \ + BATCH=1 WRKDIRPREFIX=/tmp/ports DISTDIR=/tmp/distfiles \ + all install clean +.else @env ASSUME_ALWAYS_YES=YES pkg bootstrap .endif +.endif PKG_BIN_VERSION!=${PKG_CMD} --version </dev/null 2>/dev/null |\ awk -F. '/^[0-9.]+$$/ {print $$1 * 10000 + $$2 * 100 + $$3}' |
