Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 05 May 2026 01:21:34 +0000
From:      Lexi Winter <ivy@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 8e8d87856241 - main - packages: Make create-sets.sh more robust during release
Message-ID:  <69f9461e.3ca3e.480fc28@gitrepo.freebsd.org>

index | next in thread | raw e-mail

The branch main has been updated by ivy:

URL: https://cgit.FreeBSD.org/src/commit/?id=8e8d87856241f69c277dc5fab48c5c66312475d6

commit 8e8d87856241f69c277dc5fab48c5c66312475d6
Author:     Lexi Winter <ivy@FreeBSD.org>
AuthorDate: 2026-05-05 00:31:20 +0000
Commit:     Lexi Winter <ivy@FreeBSD.org>
CommitDate: 2026-05-05 00:32:34 +0000

    packages: Make create-sets.sh more robust during release
    
    Commit d1c176fedfc9 made create-sets.sh exit when it encounters an
    error, instead of creating an empty repository.  However, this turns
    out to cause some issues:
    
    1. A package not having any sets is considered an error, but during
       the release build, we stuff a 'pkg' package into the repository
       which doesn't have any sets, which causes a failure.  Avoid this
       by simply ignoring the pkg package.
    
    2. No error was printed in this case, which made the problem hard
       to diagnose.  Add an explicit error message.
    
    3. A similar problem occurred running on a repository which already
       contained sets, which is not usually done during the build, but
       is not necessarly an inappropriate thing to do.  Fix this one by
       ignoring set packages when looking for sets.
    
    While here, fix another issue that might cause packages to be wrongly
    skipped if the path to the repository contains a '-' character, since
    we didn't strip the path before testing the package name.
    
    PR:     294966
    Fixes:  d1c176fedfc9 ("packages: Make create-sets.sh more robust")
    MFC after:      2 weeks
    Reported by:    Alastair Hogge <agh@riseup.net>
    Reviewed by:    emaste
    Sponsored by:   https://www.patreon.com/bsdivy
    Differential Revision:  https://reviews.freebsd.org/D56792
---
 release/packages/create-sets.sh | 52 +++++++++++++++++++++++++++++++++++++----
 1 file changed, 48 insertions(+), 4 deletions(-)

diff --git a/release/packages/create-sets.sh b/release/packages/create-sets.sh
index 3dfd8f1a3388..88d4020d8413 100755
--- a/release/packages/create-sets.sh
+++ b/release/packages/create-sets.sh
@@ -35,17 +35,61 @@ repodir="$1"; shift
 # generate-set-ucl.lua.
 UCL_VARS="$@"
 
+# Extract PKG_NAME_PREFIX so we can use it later.
+PKG_NAME_PREFIX=""
+set -- $UCL_VARS
+while [ -n "$1" ]; do
+	case "$1" in
+	PKG_NAME_PREFIX)
+		shift
+		PKG_NAME_PREFIX="$1"
+		break;;
+	*)
+		shift; shift;;
+	esac
+done
+if [ -z "$PKG_NAME_PREFIX" ]; then
+	printf >&2 '%s: PKG_NAME_PREFIX must be specified\n' "$0"
+	exit 1
+fi
+
 # Nothing is explicitly added to set-base, so it wouldn't get built unless
 # we list it here.
 SETS="base base-dbg base-jail base-jail-dbg"
 
 for pkg in "$repodir"/*.pkg; do
-	# If the package name doesn't containing a '-', then it's
-	# probably data.pkg or packagesite.pkg, which are not real
-	# packages.
-	{ echo "$pkg" | grep -q '-'; } || continue
+	# Check if we should process this package.
+	case "${pkg##*/}" in
 
+	# When building release, we add a 'pkg' package to the repository,
+	# but this isn't a base package and doesn't have a set.  To avoid
+	# this causing an error, skip it.
+	pkg-*)	continue;;
+
+	# Any existing set packages may also have no sets (and even if they
+	# do, they shouldn't be included here).
+	${PKG_NAME_PREFIX}-set-*)
+		continue;;
+
+	# If the package name contains a '-', process it.  All "real"
+	# packages contain a '-', because the package filename format
+	# is <pkgname>-<version>.pkg, so this skips files which aren't
+	# really packages, like data.pkg or packagesite.pkg.
+	#
+	*-*)	;;
+	*)	continue;;
+	esac
+
+	# Print a useful error message instead of failing silently if
+	# grep doesn't find any sets here.
+	set +e
 	_tmp="$(${PKG_CMD} query -F "$pkg" '%At %n %Av' | grep '^set ')"
+	if [ -z "$_tmp" ]; then
+		printf >&2 '%s: package has no sets: %s\n' "$0" "$pkg"
+		exit 1
+	fi
+	set -e
+
 	set -- $_tmp
 	pkgname="$2"
 	sets="$(echo "$3" | tr , ' ')"


home | help

Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?69f9461e.3ca3e.480fc28>