contrib/rpm: refactor specifying package version in spec file

Similar to what we do for RHEL and Fedora's spec file.
This commit is contained in:
Thomas Haller
2016-05-05 21:56:20 +02:00
parent 831038a5c7
commit 13ab20fe8c
2 changed files with 11 additions and 3 deletions

View File

@@ -30,7 +30,14 @@
%global _hardened_build 1
%global git_sha_version %{?git_sha:.%{git_sha}}
%if x%{?snapshot} != x
%global snapshot_dot .%{snapshot}
%endif
%if x%{?git_sha} != x
%global git_sha_dot .%{git_sha}
%endif
%global snap %{?git_sha_dot}%{?snapshot_dot}
###############################################################################
@@ -89,7 +96,7 @@ Name: NetworkManager
Summary: Network connection manager and user applications
Epoch: %{epoch_version}
Version: %{rpm_version}
Release: %{release_version}%{snapshot}%{git_sha_version}%{?dist}
Release: %{release_version}%{?snap}%{?dist}
Group: System Environment/Base
License: GPLv2+
URL: http://www.gnome.org/projects/NetworkManager/

View File

@@ -70,7 +70,7 @@ get_version() {
write_changelog() {
if [[ "x$CHANGELOG" == x ]]; then
cat <<- EOF
* $(LC_TIME=C date '+%a %b %d %Y') $USERNAME - %{epoch_version}:%{version}-%{release_version}%{snapshot}%{git_sha_version}
* $(LC_TIME=C date '+%a %b %d %Y') $USERNAME - %{epoch_version}:%{version}-%{release_version}%{?snap}
- build of NetworkManager ($DATE, uuid: $UUID, git: $COMMIT_FULL)
$(git log -n20 --date=local --format='- %h %s [%an] (%ci)')
- ...
@@ -163,6 +163,7 @@ sed -e "s/__VERSION__/$VERSION/g" \
-e "s/__RELEASE_VERSION__/$RELEASE_VERSION/g" \
-e "s/__COMMIT__/$COMMIT/g" \
-e "s/__COMMIT_FULL__/$COMMIT_FULL/g" \
-e "s/__SNAPSHOT__/$SNAPSHOT/g" \
-e "s/__SOURCE1__/$(basename "$SOURCE")/g" \
"$SPECFILE" |
sed -e "/^__CHANGELOG__$/ \