nrelease: Support to use binary packages

Operating Systems / DragonFlyBSD - Aaron LI [aaronly.me] - 31 October 2019 23:18 EDT

Add the new optional target "binpkgs" to allow to use binary packages, i.e., installing them with pkg(8), instead of building them from dports(7). This can be handy for end users who want to quickly build a custom image with custom packages.

As pointed out by Sascha Wildner, one port may have multiple binary packages (e.g., Python flavors) or have a different name that may not be found by pkg(8). Therefore, allow to specify the exact binary package name for a port by setting 'PKG_='.

This feature is disabled by default, as suggested by Sascha Wildner, because the release process should be self-contained as much as possible.

Update the help text and man page accordingly.

###

diff --git a/nrelease/Makefile b/nrelease/Makefile
index de8ddaece2..6f61f87ae0 100644
--- a/nrelease/Makefile
+++ b/nrelease/Makefile
@@ -5,7 +5,7 @@
# Optional targets may be specified which set make variables which enhance
# the build in various ways.
#
-gui nopkgs:
+gui nopkgs binpkgs:

#########################################################################
# SETUP #
@@ -100,6 +100,18 @@ DPORTS_PACKAGES+= x11/xorg \
ROOTSKELS+= ${.CURDIR}/gui
.endif # make(gui)

+# one port may have multiple binary packages (e.g., Python flavors) or have a
+# different name that may not be found by pkg(8), therefore, allow to specify
+# the exact binary package name for a port by setting 'PKG_='.
+#
+.for PORT in ${DPORTS_PACKAGES}
+.if defined(PKG_${PORT})
+PACKAGES+= ${PKG_${PORT}}
+.else
+PACKAGES+= ${PORT}
+.endif
+.endfor
+
#########################################################################
# BASE ISO TARGETS #
#########################################################################
@@ -224,7 +236,7 @@ customizeiso:
cp -R ${SRCDIR}/etc/${UPGRADE_ITEM} ${ISOROOT}/etc/${UPGRADE_ITEM}
.endfor

-# Install packages by building from dports.
+# Install packages by using pkg(8) or building from dports.
#
pkgs:
.if !empty(DPORTS_PACKAGES)
@@ -232,6 +244,21 @@ pkgs:
-@umount ${ISOROOT}/dev
mount_null /dev ${ISOROOT}/dev

+.if make(binpkgs)
+ ${CHROOT_CMD} "cd /usr && make pkg-bootstrap-force"
+ ${CHROOT_CMD} "pkg update"
+.for PKG in ${PACKAGES}
+ @${CHROOT_CMD} "pkg search --exact --search name ${PKG}" || \
+ ${CHROOT_CMD} "pkg search --exact --search origin ${PKG}" || \
+ { \
+ echo "ERROR: Cannot find the package for port '${PKG}'!"; \
+ echo "-----> Use 'pkg_${PKG}=' to specify the package name."; \
+ false; \
+ }
+.endfor
+ ${CHROOT_CMD} "pkg install --yes ${PACKAGES}"
+
+.else # !make(binpkgs)
-@umount ${ISOROOT}/usr/distfiles
-@umount ${ISOROOT}/usr/dports
rm -rf ${ISOROOT}/usr/obj/dports
@@ -265,6 +292,7 @@ pkgs:
rm -rf ${ISOROOT}/usr/dports
rm -rf ${ISOROOT}/usr/distfiles
rm -rf ${ISOROOT}/usr/obj/dports
+.endif # make(binpkgs)

# Update the locate(8) and whatis(1) databases, allow ISODIR
# to be on tmpfs (fails to create locate database then)
@@ -400,6 +428,7 @@ help all:
@echo ""
@echo "Optional targets:"
@echo " nopkgs - do not install any packages"
+ @echo " binpkgs - use binary packages with pkg(8)"
@echo " gui - do a GUI release"
@echo ""
@echo "Variables:"
@@ -408,6 +437,8 @@ help all:
@echo " GITURL_DPORTS: override the Git URL to dports repository"
@echo " IMGSIZE: override the size of .img (in 512-byte sectors)"
@echo " MAKE_JOBS: override the default value (sysctl hw.ncpu)"
+ @echo " PKG_: specify the package name for port "
+ @echo " WITHOUT_SRCS: do not package source code if set"
@echo ""

.PHONY: release quickrel realquickrel
diff --git a/share/man/man7/release.7 b/share/man/man7/release.7
index b9cbfd1d35..f4b892b920 100644
--- a/share/man/man7/release.7
+++ b/share/man/man7/release.7
@@ -30,7 +30,7 @@
.\"
.\" $FreeBSD: src/share/man/man7/release.7,v 1.3.2.6 2003/04/12 20:42:30 murray Exp $
.\"
-.Dd May 9, 2015
+.Dd November 1, 2019
.Dt NRELEASE 7
.Os
.Sh NAME
@@ -113,6 +113,11 @@ Do not add any packages (for debugging purposes).
This is equivalent to setting
.Va DPORTS_PACKAGES
empty.
+.It Cm binpkgs
+Install binary packages using
+.Xr pkg 8
+instead of building them from
+.Xr dports 7 .
.El
.Pp
During the process of rolling a release a check is performed to find
@@ -169,6 +174,9 @@ The is also the volume ID of the ISO file.
.It Va MAKE_JOBS
The number of make jobs (default is the value of sysctl
.Va hw.ncpu ) .
+.It Va PKG_ Ns Aq Ar port
+Specify the binary package name for port
+.Dq port .
.It Va WITHOUT_SRCS
If set, this variable will prevent source code from being copied to
the ISO image.

632d862bfe nrelease: Support to use binary packages
nrelease/Makefile | 35 +++++++++++++++++++++++++++++++++--
share/man/man7/release.7 | 10 +++++++++-
2 files changed, 42 insertions(+), 3 deletions(-)

Upstream: gitweb.dragonflybsd.org


  • Share