From e660339f2e62efd5021df4e89bebf03dd7f238ce Mon Sep 17 00:00:00 2001 From: Oliver Smith Date: Tue, 27 Apr 2021 14:15:54 +0200 Subject: [PATCH] OBS: require PROJ environment variable to be set Uploading to network:osmocom:* should only be done when these scripts are running in the Osmocom jenkins. Remove the default and require users of the script to explicitly set PROJ. Related: SYS#5370 Change-Id: If49ce217e77716b63dfde9139e869672a54b66a2 --- jobs/osmocom-obs.yml | 3 ++- scripts/common-obs.sh | 4 ++++ scripts/osmocom-latest-packages.sh | 5 ++--- scripts/osmocom-nightly-packages.sh | 25 +++++++------------------ 4 files changed, 15 insertions(+), 22 deletions(-) diff --git a/jobs/osmocom-obs.yml b/jobs/osmocom-obs.yml index 4d165d6d..9bdadeba 100644 --- a/jobs/osmocom-obs.yml +++ b/jobs/osmocom-obs.yml @@ -26,7 +26,8 @@ description: osmo-ci.git branch default: 'refs/remotes/origin/master' builders: - - shell: + - shell: | + export PROJ=network:osmocom:{type} ./scripts/osmocom-{type}-packages.sh scm: - git: diff --git a/scripts/common-obs.sh b/scripts/common-obs.sh index 38719c8b..c5b03f9f 100644 --- a/scripts/common-obs.sh +++ b/scripts/common-obs.sh @@ -15,6 +15,10 @@ osmo_cmd_require \ sed \ wget +if [ -z "$PROJ" ]; then + echo "PROJ environment variable is not set" + exit 1 +fi # Add dependency to all (sub)packages in debian/control and commit the change. # $1: path to debian/control file diff --git a/scripts/osmocom-latest-packages.sh b/scripts/osmocom-latest-packages.sh index 8c979ef2..a4a1aa92 100755 --- a/scripts/osmocom-latest-packages.sh +++ b/scripts/osmocom-latest-packages.sh @@ -1,14 +1,13 @@ #!/bin/sh # Generate source packages and upload them to OBS, for the latest feed. +# Environment variables: +# * PROJ: the OBS namespace to upload to (e.g. "network:osmocom:latest") . "$(dirname "$0")/common.sh" . "$(dirname "$0")/common-obs.sh" set -e set -x -# OBS project name -PROJ=network:osmocom:latest - DT=$(date +%Y%m%d%H%M) TOP=$(pwd) DEBSRCDIR="$TOP/debsrc" diff --git a/scripts/osmocom-nightly-packages.sh b/scripts/osmocom-nightly-packages.sh index 86f406e3..5490e58e 100755 --- a/scripts/osmocom-nightly-packages.sh +++ b/scripts/osmocom-nightly-packages.sh @@ -1,7 +1,8 @@ #!/bin/bash # Generate source packages and upload them to OBS, for the nightly or next feed. # Environment variables: -# * FEED: the binary package feed to upload to, this also controls the source branch that is used: +# * PROJ: the OBS namespace to upload to (e.g. "network:osmocom:nightly") +# * FEED: controls the source branch that is used: # * "nightly": use "master" branch (default) # * "next": use "next" branch if it exists, otherwise use "master" branch . "$(dirname "$0")/common.sh" @@ -13,23 +14,12 @@ set -x DT=$(date +%Y%m%d%H%M) OSMO_OBS_CONFLICT_PKGVER="$OSMO_OBS_CONFLICT_PKGVER.$DT" TOP=$(pwd)/$(mktemp -d nightly-3g_XXXXXX) +FEED="${FEED:-nightly}" -# Set FEED and PROJ, based on the FEED env var -parse_feed_proj() { - FEED="${FEED:-nightly}" - case "$FEED" in - nightly) - PROJ=network:osmocom:nightly - ;; - next) - PROJ=network:osmocom:next - ;; - *) - echo "unsupported feed: $FEED" - exit 1 - ;; - esac -} +if [ "$FEED" != "nightly" ] && [ "$FEED" != "next" ]; then + echo "unsupported feed: $FEED" + exit 1 +fi ### OBS build prepare() { @@ -286,5 +276,4 @@ build_osmocom() { post } -parse_feed_proj build_osmocom