summaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2018-02-09 17:14:34 +0100
committerThomas Haller <thaller@redhat.com>2018-02-09 17:35:19 +0100
commit86a18b2df2dafdd6cdb120e07509d473d498a591 (patch)
treec301957f8967932e1a2e74e0df5cf22929930fba /contrib
parent37eed6984bff6bd8dd903d480dc260005eabd132 (diff)
contrib/rpm: make "snapshot" for package version configurable via script
Will be used by CI trigger to name packages that are build during testing of a github pull request with the corresponding pull request ID. "build_clean.sh" now supports a command line option -s|--snapshot. But the same paramter can also be set via $NM_BUILD_SNAPSHOT environment variable. Using the environment variable is useful to support older versions and new versions of "build_clean.sh", so that the script can just ignore the snapshot setting if it doesn't understand it yet.
Diffstat (limited to 'contrib')
-rw-r--r--contrib/fedora/rpm/NetworkManager.spec2
-rwxr-xr-xcontrib/fedora/rpm/build.sh4
-rwxr-xr-xcontrib/fedora/rpm/build_clean.sh28
3 files changed, 22 insertions, 12 deletions
diff --git a/contrib/fedora/rpm/NetworkManager.spec b/contrib/fedora/rpm/NetworkManager.spec
index f9f3c95d3f..17fff3cef9 100644
--- a/contrib/fedora/rpm/NetworkManager.spec
+++ b/contrib/fedora/rpm/NetworkManager.spec
@@ -19,7 +19,7 @@
%global rpm_version __VERSION__
%global real_version __VERSION__
%global release_version __RELEASE_VERSION__
-%global snapshot %{nil}
+%global snapshot __SNAPSHOT__
%global git_sha __COMMIT__
%global obsoletes_device_plugins 1:0.9.9.95-1
diff --git a/contrib/fedora/rpm/build.sh b/contrib/fedora/rpm/build.sh
index 513d9f2f1f..34ec42943e 100755
--- a/contrib/fedora/rpm/build.sh
+++ b/contrib/fedora/rpm/build.sh
@@ -8,6 +8,7 @@
# BUILDTYPE=|SRPM
# NM_RPMBUILD_ARGS=<additional argus for rpmbuild>
# RELEASE_VERSION=
+# SNAPSHOT=
# VERSION=
# COMMIT_FULL=
# COMMIT=
@@ -96,6 +97,7 @@ exec 2>&1
UUID=`uuidgen`
RELEASE_VERSION="${RELEASE_VERSION:-$(git rev-list HEAD | wc -l)}"
+SNAPSHOT="${SNAPSHOT:-%{nil\}}"
VERSION="${VERSION:-$(get_version || die "Could not read $VERSION")}"
COMMIT_FULL="${COMMIT_FULL:-$(git rev-parse --verify HEAD || die "Error reading HEAD revision")}"
COMMIT="${COMMIT:-$(printf '%s' "$COMMIT_FULL" | sed 's/^\(.\{10\}\).*/\1/' || die "Error reading HEAD revision")}"
@@ -131,6 +133,7 @@ fi
LOG "VERSION=$VERSION"
LOG "RELEASE_VERSION=$RELEASE_VERSION"
+LOG "SNAPSHOT=$SNAPSHOT"
LOG "COMMIT_FULL=$COMMIT_FULL"
LOG "COMMIT=$COMMIT"
LOG "USERNAME=$USERNAME"
@@ -164,6 +167,7 @@ write_changelog
sed -e "s/__VERSION__/$VERSION/g" \
-e "s/__RELEASE_VERSION__/$RELEASE_VERSION/g" \
+ -e "s/__SNAPSHOT__/$SNAPSHOT/g" \
-e "s/__COMMIT__/$COMMIT/g" \
-e "s/__COMMIT_FULL__/$COMMIT_FULL/g" \
-e "s/__SNAPSHOT__/$SNAPSHOT/g" \
diff --git a/contrib/fedora/rpm/build_clean.sh b/contrib/fedora/rpm/build_clean.sh
index 9d64c5b148..1bf932f5cb 100755
--- a/contrib/fedora/rpm/build_clean.sh
+++ b/contrib/fedora/rpm/build_clean.sh
@@ -23,6 +23,7 @@ usage() {
echo " -N|--no-dist: skip creating the source tarball if you already did \`make dist\`"
echo " -w|--with \$OPTION: pass --with \$OPTION to rpmbuild. For example --with debug"
echo " -W|--without \$OPTION: pass --without \$OPTION to rpmbuild. For example --without debug"
+ echo " -s|--snapshot TEXT: use TEXT as the snapshot version for the new package (overwrites \$NM_BUILD_SNAPSHOT environment)"
}
@@ -41,14 +42,11 @@ QUICK=0
NO_DIST=0
WITH_LIST=()
SOURCE_FROM_GIT=0
+SNAPSHOT="$NM_BUILD_SNAPSHOT"
-_next_with=
-for A; do
- if [ -n "$_next_with" ]; then
- WITH_LIST=("${WITH_LIST[@]}" "$_next_with" "$A")
- _next_with=
- continue
- fi
+while [[ $# -gt 0 ]]; do
+ A="$1"
+ shift
case "$A" in
-h|--help|-\?|help)
usage
@@ -63,6 +61,11 @@ for A; do
-S|--srpm)
BUILDTYPE=SRPM
;;
+ -s|--snapshot)
+ [[ $# -gt 0 ]] || die "Missing argument to $A"
+ SNAPSHOT="$1"
+ shift
+ ;;
-g|--git)
NO_DIST=1
IGNORE_DIRTY=1
@@ -77,10 +80,14 @@ for A; do
SOURCE_FROM_GIT=0
;;
-w|--with)
- _next_with=--with
+ [[ $# -gt 0 ]] || die "Missing argument to $A"
+ WITH_LIST=("${WITH_LIST[@]}" "--with" "$1")
+ shift
;;
-W|--without)
- _next_with=--without
+ [[ $# -gt 0 ]] || die "Missing argument to $A"
+ WITH_LIST=("${WITH_LIST[@]}" "--without" "$1")
+ shift
;;
*)
usage
@@ -89,8 +96,6 @@ for A; do
esac
done
-test -n "$_next_with" && die "Missing argument to $_next_with"
-
if [[ $GIT_CLEAN == 1 ]]; then
git clean -fdx :/
fi
@@ -151,6 +156,7 @@ fi
export SOURCE_FROM_GIT
export BUILDTYPE
export NM_RPMBUILD_ARGS="${WITH_LIST[@]}"
+export SNAPSHOT
"$SCRIPTDIR"/build.sh