From 338a40065633a65a2121c6119847b8199c2564fd Mon Sep 17 00:00:00 2001 From: Lars Erik Wik Date: Sun, 8 Nov 2026 15:35:20 +0100 Subject: [PATCH 1/5] `produce-script` now reads the LMDB version from the first mirror line only Since the GitHub mirror was added, `deps-packaging/lmdb/source` has two lines, so `LMDB_VERSION` got the version twice. The second copy became a line of its own in the generated install scripts, which failed with `1.0.3: not found` and broke package installation. Signed-off-by: Lars Erik Wik --- packaging/common/produce-script | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packaging/common/produce-script b/packaging/common/produce-script index 3609e5495..aba4758c3 100755 --- a/packaging/common/produce-script +++ b/packaging/common/produce-script @@ -52,8 +52,9 @@ BUILT_ON_OS_VERSION="`expr "$OS_VERSION" : "\([0-9]*\)"`" echo "BUILT_ON_OS_VERSION=$BUILT_ON_OS_VERSION" # Shipped LMDB version, compared against the installed one by -# lmdb_migration_needed() (CFE-4701). -LMDB_VERSION="`sed -e 's,/*$,,' -e 's,.*/LMDB_,,' "$SCRIPTDIR/../../deps-packaging/lmdb/source" 2>/dev/null`" +# lmdb_migration_needed() (CFE-4701). The source file lists one mirror URL per +# line, so the version is taken from the first. +LMDB_VERSION="$(sed -n -e 's,/$,,' -e 's,.*/LMDB_,,' -e '1p' "$SCRIPTDIR/../../deps-packaging/lmdb/source" 2>/dev/null)" echo "LMDB_VERSION=$LMDB_VERSION" case "$SCRIPT_TYPE" in From 54de7bb953997edf4f901ae2c8c351176c90893f Mon Sep 17 00:00:00 2001 From: Lars Erik Wik Date: Mon, 9 Nov 2026 10:37:46 +0100 Subject: [PATCH 2/5] Fixed missing helpers in package scripts on default build prefix Commit 403df915 changed build-scripts/package to generate a patched -script-common.sh, but only when the build prefix was not /var/cfengine. produce-script expects it to always be there. It is now always generated. Replacing the prefix with the same prefix does not matter. The templates are renamed to -script-common.sh.in to make it obvious that they are templates. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Lars Erik Wik --- .gitignore | 2 ++ build-scripts/package | 18 +++++++++--------- packaging/common/produce-script | 6 +++--- ...cript-common.sh => bff-script-common.sh.in} | 0 ...cript-common.sh => deb-script-common.sh.in} | 0 ...ipt-common.sh => depot-script-common.sh.in} | 0 ...ipt-common.sh => macos-script-common.sh.in} | 0 ...cript-common.sh => pkg-script-common.sh.in} | 0 ...cript-common.sh => rpm-script-common.sh.in} | 0 9 files changed, 14 insertions(+), 12 deletions(-) rename packaging/common/script-templates/{bff-script-common.sh => bff-script-common.sh.in} (100%) rename packaging/common/script-templates/{deb-script-common.sh => deb-script-common.sh.in} (100%) rename packaging/common/script-templates/{depot-script-common.sh => depot-script-common.sh.in} (100%) rename packaging/common/script-templates/{macos-script-common.sh => macos-script-common.sh.in} (100%) rename packaging/common/script-templates/{pkg-script-common.sh => pkg-script-common.sh.in} (100%) rename packaging/common/script-templates/{rpm-script-common.sh => rpm-script-common.sh.in} (100%) diff --git a/.gitignore b/.gitignore index 92e2d4b56..20bc565ca 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,5 @@ revision *.html ci/cache ci/packages +# Generated from *.in by build-scripts/package +packaging/common/script-templates/*-script-common.sh diff --git a/build-scripts/package b/build-scripts/package index 439121b14..8ce62ba12 100755 --- a/build-scripts/package +++ b/build-scripts/package @@ -118,19 +118,19 @@ P="$BASEDIR/buildscripts/packaging/$PKG" if [ "$BUILDPREFIX" != /var/cfengine ]; then log_debug "Custom prefix detected: $BUILDPREFIX" safe_prefix="$(echo "$BUILDPREFIX" | sed -e 's:/::g')" - source_script="$P/../common/script-templates/$PACKAGING-script-common.sh" - patched_script="$P/../common/script-templates/patched-$PACKAGING-script-common.sh" - if [ -f "$source_script" ]; then - # Patch installation scripts for custom prefix, create patched-$PACKAGING-script-common.sh which is not version tracked - log_debug "Patching from source: $source_script to patched script: $patched_script" - sed "s:/var/cfengine:$BUILDPREFIX:" "$source_script" >"$patched_script" - else - log_error "Source $PACKAGING-script-common.sh not available at $source_script" - fi else log_debug "Using default prefix: /var/cfengine" fi +# Generate $PACKAGING-script-common.sh (not version tracked) for the build prefix +template="$P/../common/script-templates/$PACKAGING-script-common.sh.in" +if [ -f "$template" ]; then + log_debug "Generating ${template%.in} from $template" + sed "s:/var/cfengine:$BUILDPREFIX:" "$template" >"${template%.in}" +else + log_error "Template $PACKAGING-script-common.sh.in not available at $template" +fi + # Parse version string to separate main version from supplementary version # Format: MAIN_VERSION~SUPP_VERSION (e.g., 3.27.0~build1) log_debug "Parsing version string: $VERSION" diff --git a/packaging/common/produce-script b/packaging/common/produce-script index aba4758c3..d1a660b68 100755 --- a/packaging/common/produce-script +++ b/packaging/common/produce-script @@ -7,8 +7,8 @@ # action = # # script-header.sh -# patched--script-common.sh -# note: patched- prefix files are not to be committed to the repository and are generated by build-scripts/package script +# -script-common.sh +# note: generated from -script-common.sh.in by build-scripts/package # -script-common-.sh # script-common.sh # script-common-.sh @@ -36,7 +36,7 @@ include_script() } include_script "$TEMPLATEDIR/script-header.sh" -include_script "$TEMPLATEDIR/patched-$PKG_TYPE-script-common.sh" +include_script "$TEMPLATEDIR/$PKG_TYPE-script-common.sh" case "$PKG_TYPE" in deb|rpm) diff --git a/packaging/common/script-templates/bff-script-common.sh b/packaging/common/script-templates/bff-script-common.sh.in similarity index 100% rename from packaging/common/script-templates/bff-script-common.sh rename to packaging/common/script-templates/bff-script-common.sh.in diff --git a/packaging/common/script-templates/deb-script-common.sh b/packaging/common/script-templates/deb-script-common.sh.in similarity index 100% rename from packaging/common/script-templates/deb-script-common.sh rename to packaging/common/script-templates/deb-script-common.sh.in diff --git a/packaging/common/script-templates/depot-script-common.sh b/packaging/common/script-templates/depot-script-common.sh.in similarity index 100% rename from packaging/common/script-templates/depot-script-common.sh rename to packaging/common/script-templates/depot-script-common.sh.in diff --git a/packaging/common/script-templates/macos-script-common.sh b/packaging/common/script-templates/macos-script-common.sh.in similarity index 100% rename from packaging/common/script-templates/macos-script-common.sh rename to packaging/common/script-templates/macos-script-common.sh.in diff --git a/packaging/common/script-templates/pkg-script-common.sh b/packaging/common/script-templates/pkg-script-common.sh.in similarity index 100% rename from packaging/common/script-templates/pkg-script-common.sh rename to packaging/common/script-templates/pkg-script-common.sh.in diff --git a/packaging/common/script-templates/rpm-script-common.sh b/packaging/common/script-templates/rpm-script-common.sh.in similarity index 100% rename from packaging/common/script-templates/rpm-script-common.sh rename to packaging/common/script-templates/rpm-script-common.sh.in From f3e245f6a4937d3e00ee3112ad4e6212127f9bea Mon Sep 17 00:00:00 2001 From: Lars Erik Wik Date: Mon, 9 Nov 2026 10:49:00 +0100 Subject: [PATCH 3/5] Changed script templates to use an @BUILD_PREFIX@ placeholder This makes it obvious what build-scripts/package substitutes, instead of rewriting /var/cfengine. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Lars Erik Wik --- build-scripts/package | 2 +- packaging/common/script-templates/bff-script-common.sh.in | 2 +- packaging/common/script-templates/deb-script-common.sh.in | 2 +- packaging/common/script-templates/depot-script-common.sh.in | 2 +- packaging/common/script-templates/macos-script-common.sh.in | 2 +- packaging/common/script-templates/pkg-script-common.sh.in | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/build-scripts/package b/build-scripts/package index 8ce62ba12..1acec3a04 100755 --- a/build-scripts/package +++ b/build-scripts/package @@ -126,7 +126,7 @@ fi template="$P/../common/script-templates/$PACKAGING-script-common.sh.in" if [ -f "$template" ]; then log_debug "Generating ${template%.in} from $template" - sed "s:/var/cfengine:$BUILDPREFIX:" "$template" >"${template%.in}" + sed "s:@BUILD_PREFIX@:$BUILDPREFIX:g" "$template" >"${template%.in}" else log_error "Template $PACKAGING-script-common.sh.in not available at $template" fi diff --git a/packaging/common/script-templates/bff-script-common.sh.in b/packaging/common/script-templates/bff-script-common.sh.in index 6c326ceb7..d229c9c15 100644 --- a/packaging/common/script-templates/bff-script-common.sh.in +++ b/packaging/common/script-templates/bff-script-common.sh.in @@ -1,6 +1,6 @@ #!/usr/bin/ksh -PREFIX=/var/cfengine +PREFIX=@BUILD_PREFIX@ package_type() { diff --git a/packaging/common/script-templates/deb-script-common.sh.in b/packaging/common/script-templates/deb-script-common.sh.in index e0075649e..52b1baee0 100644 --- a/packaging/common/script-templates/deb-script-common.sh.in +++ b/packaging/common/script-templates/deb-script-common.sh.in @@ -1,6 +1,6 @@ #!/bin/sh -PREFIX=/var/cfengine +PREFIX=@BUILD_PREFIX@ package_type() { diff --git a/packaging/common/script-templates/depot-script-common.sh.in b/packaging/common/script-templates/depot-script-common.sh.in index aec58a9d4..7b9ea9310 100644 --- a/packaging/common/script-templates/depot-script-common.sh.in +++ b/packaging/common/script-templates/depot-script-common.sh.in @@ -1,6 +1,6 @@ #!/bin/sh -PREFIX=/var/cfengine +PREFIX=@BUILD_PREFIX@ package_type() { diff --git a/packaging/common/script-templates/macos-script-common.sh.in b/packaging/common/script-templates/macos-script-common.sh.in index bef4fcb42..b51534d1a 100644 --- a/packaging/common/script-templates/macos-script-common.sh.in +++ b/packaging/common/script-templates/macos-script-common.sh.in @@ -8,7 +8,7 @@ # rpm/deb scriptlets -- upgrade detection has to be done by looking at what's # already on disk, same as HP-UX/AIX do. -PREFIX=/var/cfengine +PREFIX=@BUILD_PREFIX@ package_type() { diff --git a/packaging/common/script-templates/pkg-script-common.sh.in b/packaging/common/script-templates/pkg-script-common.sh.in index 6cfda8f09..cb6df5a3e 100644 --- a/packaging/common/script-templates/pkg-script-common.sh.in +++ b/packaging/common/script-templates/pkg-script-common.sh.in @@ -21,7 +21,7 @@ if broken_posix_shell >/dev/null 2>&1; then exit 42 fi -PREFIX=/var/cfengine +PREFIX=@BUILD_PREFIX@ package_type() { From ab87d21d642b7b21e4287140dbb4dcd6802a2a03 Mon Sep 17 00:00:00 2001 From: Lars Erik Wik Date: Mon, 9 Nov 2026 15:06:58 +0100 Subject: [PATCH 4/5] Fixed package scripts on AIX, Solaris and HP-UX The previous commit generated only the template named after $PACKAGING (lpp, solaris, hpux), but produce-script reads the one named after the package type (rpm, pkg, depot). Now all templates are generated. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Lars Erik Wik --- build-scripts/package | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/build-scripts/package b/build-scripts/package index 1acec3a04..5c7574d90 100755 --- a/build-scripts/package +++ b/build-scripts/package @@ -122,14 +122,11 @@ else log_debug "Using default prefix: /var/cfengine" fi -# Generate $PACKAGING-script-common.sh (not version tracked) for the build prefix -template="$P/../common/script-templates/$PACKAGING-script-common.sh.in" -if [ -f "$template" ]; then +# Generate the install script snippets for the build prefix +for template in "$P"/../common/script-templates/*.in; do log_debug "Generating ${template%.in} from $template" sed "s:@BUILD_PREFIX@:$BUILDPREFIX:g" "$template" >"${template%.in}" -else - log_error "Template $PACKAGING-script-common.sh.in not available at $template" -fi +done # Parse version string to separate main version from supplementary version # Format: MAIN_VERSION~SUPP_VERSION (e.g., 3.27.0~build1) From 6295cac0a28a6d923ca98ca30c030a275b5faf1f Mon Sep 17 00:00:00 2001 From: Lars Erik Wik Date: Mon, 9 Nov 2026 15:07:53 +0100 Subject: [PATCH 5/5] Now fails when a required install script snippet is missing produce-script silently skipped any missing snippet, so a build could succeed with broken install scripts. The four snippets every package needs now fail the build when missing. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Lars Erik Wik --- packaging/common/produce-script | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/packaging/common/produce-script b/packaging/common/produce-script index d1a660b68..f8573109c 100755 --- a/packaging/common/produce-script +++ b/packaging/common/produce-script @@ -6,16 +6,16 @@ # type = # action = # -# script-header.sh -# -script-common.sh +# script-header.sh (required) +# -script-common.sh (required) # note: generated from -script-common.sh.in by build-scripts/package # -script-common-.sh -# script-common.sh +# script-common.sh (required) # script-common-.sh -# script-common-header-last.sh +# script-common-header-last.sh (required) # ../cfengine-PROJECT[-hub]/.sh # -# Any script that is missing will simply be skipped. +# A missing required script is an error. Any other missing script is skipped. if [ $# -ne 3 ]; then echo "Usage: $0 cfengine-PROJECT[-hub] pkg-type" @@ -35,8 +35,18 @@ include_script() fi } -include_script "$TEMPLATEDIR/script-header.sh" -include_script "$TEMPLATEDIR/$PKG_TYPE-script-common.sh" +# Like include_script, but fails if the file is missing +require_script() +{ + if [ ! -f "$1" ]; then + echo "$0: error: required script $1 not found" >&2 + exit 1 + fi + cat "$1" +} + +require_script "$TEMPLATEDIR/script-header.sh" +require_script "$TEMPLATEDIR/$PKG_TYPE-script-common.sh" case "$PKG_TYPE" in deb|rpm) @@ -60,19 +70,19 @@ echo "LMDB_VERSION=$LMDB_VERSION" case "$SCRIPT_TYPE" in *install) include_script "$TEMPLATEDIR/$PKG_TYPE-script-common-install.sh" - include_script "$TEMPLATEDIR/script-common.sh" + require_script "$TEMPLATEDIR/script-common.sh" include_script "$TEMPLATEDIR/script-common-install.sh" include_script "$TEMPLATEDIR/script-common-$SCRIPT_TYPE.sh" ;; *remove) include_script "$TEMPLATEDIR/$PKG_TYPE-script-common-remove.sh" - include_script "$TEMPLATEDIR/script-common.sh" + require_script "$TEMPLATEDIR/script-common.sh" include_script "$TEMPLATEDIR/script-common-remove.sh" include_script "$TEMPLATEDIR/script-common-$SCRIPT_TYPE.sh" ;; esac -include_script "$TEMPLATEDIR/script-common-header-last.sh" +require_script "$TEMPLATEDIR/script-common-header-last.sh" # Not having a script is not an error. Not all scripts are used, # and not all projects are ported over.