Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ revision
*.html
ci/cache
ci/packages
# Generated from *.in by build-scripts/package
packaging/common/script-templates/*-script-common.sh
15 changes: 6 additions & 9 deletions build-scripts/package
Original file line number Diff line number Diff line change
Expand Up @@ -118,19 +118,16 @@ 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 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}"
done

# 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"
Expand Down
37 changes: 24 additions & 13 deletions packaging/common/produce-script
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@
# type = <deb|rpm|depot|bff|pkg>
# action = <install|remove>
#
# script-header.sh
# patched-<type>-script-common.sh
# note: patched- prefix files are not to be committed to the repository and are generated by build-scripts/package script
# script-header.sh (required)
# <type>-script-common.sh (required)
# note: generated from <type>-script-common.sh.in by build-scripts/package
# <type>-script-common-<action>.sh
# script-common.sh
# script-common.sh (required)
# script-common-<action>.sh
# script-common-header-last.sh
# script-common-header-last.sh (required)
# ../cfengine-PROJECT[-hub]/<pre|post><install|remove>.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] <pre|post><install|remove> pkg-type"
Expand All @@ -35,8 +35,18 @@ include_script()
fi
}

include_script "$TEMPLATEDIR/script-header.sh"
include_script "$TEMPLATEDIR/patched-$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)
Expand All @@ -52,26 +62,27 @@ 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
*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.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/ksh

PREFIX=/var/cfengine
PREFIX=@BUILD_PREFIX@

package_type()
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/sh

PREFIX=/var/cfengine
PREFIX=@BUILD_PREFIX@

package_type()
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/sh

PREFIX=/var/cfengine
PREFIX=@BUILD_PREFIX@

package_type()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ if broken_posix_shell >/dev/null 2>&1; then
exit 42
fi

PREFIX=/var/cfengine
PREFIX=@BUILD_PREFIX@

package_type()
{
Expand Down
Loading