From c45488dd732889749796928872b2c40caef548d9 Mon Sep 17 00:00:00 2001 From: Robur Date: Tue, 9 Jan 2024 15:05:09 +0000 Subject: [PATCH] hook scripts & repo scripts: provide and use --main-binary-filepath --- lib/model.ml | 1 + packaging/FreeBSD-repo.sh | 9 ++++++++- packaging/dpkg-repo.sh | 9 ++++++++- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/lib/model.ml b/lib/model.ml index acdd695..59ad22e 100644 --- a/lib/model.ml +++ b/lib/model.ml @@ -493,6 +493,7 @@ let add_build "--uuid=" ^ uuid ; "--platform=" ^ platform ; "--cache-dir=" ^ Fpath.to_string cachedir ; "--data-dir=" ^ Fpath.to_string datadir ; + "--main-binary-filepath=" ^ Fpath.to_string main_binary.filepath ; fp_str Fpath.(datadir // artifact_path main_binary) ]) in Log.debug (fun m -> m "executing hooks with %s" args); diff --git a/packaging/FreeBSD-repo.sh b/packaging/FreeBSD-repo.sh index 9d76033..05e3a69 100755 --- a/packaging/FreeBSD-repo.sh +++ b/packaging/FreeBSD-repo.sh @@ -32,6 +32,8 @@ Options: Hex encoded SHA256 digest of the main binary. --job=STRING Job name that was built. + --main-binary-filepath=STRING + The file path of the main binary. EOM exit 1 } @@ -39,6 +41,7 @@ EOM BUILD_TIME= SHA= JOB= +FILEPATH= while [ $# -gt 1 ]; do OPT="$1" @@ -53,6 +56,9 @@ while [ $# -gt 1 ]; do --job=*) JOB="${OPT##*=}" ;; + --main-binary-filepath=*) + FILEPATH="${OPT##*=}" + ;; --*) warn "Ignoring unknown option: '${OPT}'" ;; @@ -67,13 +73,14 @@ done [ -z "${BUILD_TIME}" ] && die "The --build-time option must be specified" [ -z "${SHA}" ] && die "The --sha256 option must be specified" [ -z "${JOB}" ] && die "The --job option must be specified" +[ -z "${FILEPATH}" ] && die "The --main-binary-filepath option must be specified" FILENAME="${1}" : "${REPO:="/usr/local/www/pkg"}" : "${REPO_KEY:="/usr/local/etc/builder-web/repo.key"}" -if [ "$(basename "${FILENAME}" .pkg)" = "$(basename "${FILENAME}")" ]; then +if [ "$(basename "${FILEPATH}" .pkg)" = "$(basename "${FILEPATH}")" ]; then echo "Not a FreeBSD package" exit 0 fi diff --git a/packaging/dpkg-repo.sh b/packaging/dpkg-repo.sh index 4cfd61d..6b47cf0 100755 --- a/packaging/dpkg-repo.sh +++ b/packaging/dpkg-repo.sh @@ -36,6 +36,8 @@ Options: Job name that was built. --platform=STRING Platform name on which the build was performed. + --main-binary-filepath=STRING + The file path of the main binary. EOM exit 1 } @@ -44,6 +46,7 @@ BUILD_TIME= SHA= JOB= PLATFORM= +FILEPATH= while [ $# -gt 1 ]; do OPT="$1" @@ -61,6 +64,9 @@ while [ $# -gt 1 ]; do --platform=*) PLATFORM="${OPT##*=}" ;; + --main-binary-filepath=*) + FILEPATH="${OPT##*=}" + ;; --*) warn "Ignoring unknown option: '${OPT}'" ;; @@ -76,10 +82,11 @@ done [ -z "${SHA}" ] && die "The --sha256 option must be specified" [ -z "${JOB}" ] && die "The --job option must be specified" [ -z "${PLATFORM}" ] && die "The --platform option must be specified" +[ -z "${FILEPATH}" ] && die "The --main-binary-filepath option must be specified" FILENAME="${1}" -if [ $(basename "${FILENAME}" .deb) = $(basename "${FILENAME}") ]; then +if [ $(basename "${FILEPATH}" .deb) = $(basename "${FILEPATH}") ]; then echo "Not a Debian package" exit 0 fi