mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-27 08:10:08 +01:00
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.
This commit is contained in:
parent
37eed6984b
commit
86a18b2df2
3 changed files with 22 additions and 12 deletions
|
|
@ -19,7 +19,7 @@
|
||||||
%global rpm_version __VERSION__
|
%global rpm_version __VERSION__
|
||||||
%global real_version __VERSION__
|
%global real_version __VERSION__
|
||||||
%global release_version __RELEASE_VERSION__
|
%global release_version __RELEASE_VERSION__
|
||||||
%global snapshot %{nil}
|
%global snapshot __SNAPSHOT__
|
||||||
%global git_sha __COMMIT__
|
%global git_sha __COMMIT__
|
||||||
|
|
||||||
%global obsoletes_device_plugins 1:0.9.9.95-1
|
%global obsoletes_device_plugins 1:0.9.9.95-1
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@
|
||||||
# BUILDTYPE=|SRPM
|
# BUILDTYPE=|SRPM
|
||||||
# NM_RPMBUILD_ARGS=<additional argus for rpmbuild>
|
# NM_RPMBUILD_ARGS=<additional argus for rpmbuild>
|
||||||
# RELEASE_VERSION=
|
# RELEASE_VERSION=
|
||||||
|
# SNAPSHOT=
|
||||||
# VERSION=
|
# VERSION=
|
||||||
# COMMIT_FULL=
|
# COMMIT_FULL=
|
||||||
# COMMIT=
|
# COMMIT=
|
||||||
|
|
@ -96,6 +97,7 @@ exec 2>&1
|
||||||
|
|
||||||
UUID=`uuidgen`
|
UUID=`uuidgen`
|
||||||
RELEASE_VERSION="${RELEASE_VERSION:-$(git rev-list HEAD | wc -l)}"
|
RELEASE_VERSION="${RELEASE_VERSION:-$(git rev-list HEAD | wc -l)}"
|
||||||
|
SNAPSHOT="${SNAPSHOT:-%{nil\}}"
|
||||||
VERSION="${VERSION:-$(get_version || die "Could not read $VERSION")}"
|
VERSION="${VERSION:-$(get_version || die "Could not read $VERSION")}"
|
||||||
COMMIT_FULL="${COMMIT_FULL:-$(git rev-parse --verify HEAD || die "Error reading HEAD revision")}"
|
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")}"
|
COMMIT="${COMMIT:-$(printf '%s' "$COMMIT_FULL" | sed 's/^\(.\{10\}\).*/\1/' || die "Error reading HEAD revision")}"
|
||||||
|
|
@ -131,6 +133,7 @@ fi
|
||||||
|
|
||||||
LOG "VERSION=$VERSION"
|
LOG "VERSION=$VERSION"
|
||||||
LOG "RELEASE_VERSION=$RELEASE_VERSION"
|
LOG "RELEASE_VERSION=$RELEASE_VERSION"
|
||||||
|
LOG "SNAPSHOT=$SNAPSHOT"
|
||||||
LOG "COMMIT_FULL=$COMMIT_FULL"
|
LOG "COMMIT_FULL=$COMMIT_FULL"
|
||||||
LOG "COMMIT=$COMMIT"
|
LOG "COMMIT=$COMMIT"
|
||||||
LOG "USERNAME=$USERNAME"
|
LOG "USERNAME=$USERNAME"
|
||||||
|
|
@ -164,6 +167,7 @@ write_changelog
|
||||||
|
|
||||||
sed -e "s/__VERSION__/$VERSION/g" \
|
sed -e "s/__VERSION__/$VERSION/g" \
|
||||||
-e "s/__RELEASE_VERSION__/$RELEASE_VERSION/g" \
|
-e "s/__RELEASE_VERSION__/$RELEASE_VERSION/g" \
|
||||||
|
-e "s/__SNAPSHOT__/$SNAPSHOT/g" \
|
||||||
-e "s/__COMMIT__/$COMMIT/g" \
|
-e "s/__COMMIT__/$COMMIT/g" \
|
||||||
-e "s/__COMMIT_FULL__/$COMMIT_FULL/g" \
|
-e "s/__COMMIT_FULL__/$COMMIT_FULL/g" \
|
||||||
-e "s/__SNAPSHOT__/$SNAPSHOT/g" \
|
-e "s/__SNAPSHOT__/$SNAPSHOT/g" \
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@ usage() {
|
||||||
echo " -N|--no-dist: skip creating the source tarball if you already did \`make dist\`"
|
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|--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 " -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
|
NO_DIST=0
|
||||||
WITH_LIST=()
|
WITH_LIST=()
|
||||||
SOURCE_FROM_GIT=0
|
SOURCE_FROM_GIT=0
|
||||||
|
SNAPSHOT="$NM_BUILD_SNAPSHOT"
|
||||||
|
|
||||||
_next_with=
|
while [[ $# -gt 0 ]]; do
|
||||||
for A; do
|
A="$1"
|
||||||
if [ -n "$_next_with" ]; then
|
shift
|
||||||
WITH_LIST=("${WITH_LIST[@]}" "$_next_with" "$A")
|
|
||||||
_next_with=
|
|
||||||
continue
|
|
||||||
fi
|
|
||||||
case "$A" in
|
case "$A" in
|
||||||
-h|--help|-\?|help)
|
-h|--help|-\?|help)
|
||||||
usage
|
usage
|
||||||
|
|
@ -63,6 +61,11 @@ for A; do
|
||||||
-S|--srpm)
|
-S|--srpm)
|
||||||
BUILDTYPE=SRPM
|
BUILDTYPE=SRPM
|
||||||
;;
|
;;
|
||||||
|
-s|--snapshot)
|
||||||
|
[[ $# -gt 0 ]] || die "Missing argument to $A"
|
||||||
|
SNAPSHOT="$1"
|
||||||
|
shift
|
||||||
|
;;
|
||||||
-g|--git)
|
-g|--git)
|
||||||
NO_DIST=1
|
NO_DIST=1
|
||||||
IGNORE_DIRTY=1
|
IGNORE_DIRTY=1
|
||||||
|
|
@ -77,10 +80,14 @@ for A; do
|
||||||
SOURCE_FROM_GIT=0
|
SOURCE_FROM_GIT=0
|
||||||
;;
|
;;
|
||||||
-w|--with)
|
-w|--with)
|
||||||
_next_with=--with
|
[[ $# -gt 0 ]] || die "Missing argument to $A"
|
||||||
|
WITH_LIST=("${WITH_LIST[@]}" "--with" "$1")
|
||||||
|
shift
|
||||||
;;
|
;;
|
||||||
-W|--without)
|
-W|--without)
|
||||||
_next_with=--without
|
[[ $# -gt 0 ]] || die "Missing argument to $A"
|
||||||
|
WITH_LIST=("${WITH_LIST[@]}" "--without" "$1")
|
||||||
|
shift
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
usage
|
usage
|
||||||
|
|
@ -89,8 +96,6 @@ for A; do
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
test -n "$_next_with" && die "Missing argument to $_next_with"
|
|
||||||
|
|
||||||
if [[ $GIT_CLEAN == 1 ]]; then
|
if [[ $GIT_CLEAN == 1 ]]; then
|
||||||
git clean -fdx :/
|
git clean -fdx :/
|
||||||
fi
|
fi
|
||||||
|
|
@ -151,6 +156,7 @@ fi
|
||||||
export SOURCE_FROM_GIT
|
export SOURCE_FROM_GIT
|
||||||
export BUILDTYPE
|
export BUILDTYPE
|
||||||
export NM_RPMBUILD_ARGS="${WITH_LIST[@]}"
|
export NM_RPMBUILD_ARGS="${WITH_LIST[@]}"
|
||||||
|
export SNAPSHOT
|
||||||
|
|
||||||
"$SCRIPTDIR"/build.sh
|
"$SCRIPTDIR"/build.sh
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue