From 534ca820c8d0163b9ce74c5331373d9cf6d15ec7 Mon Sep 17 00:00:00 2001 From: Lukas Holecek Date: Jan 13 2021 13:33:39 +0000 Subject: Allow automated spec file updates With the extra variable specifying version in the spec file, it cannot be automatically bumped to a newer version. See: https://bugzilla.redhat.com/show_bug.cgi?id=1811719#c8 --- diff --git a/rpmbuild.sh b/rpmbuild.sh index f4434a5..b94210f 100755 --- a/rpmbuild.sh +++ b/rpmbuild.sh @@ -27,9 +27,9 @@ git archive --format=tar HEAD | tar -C "$workdir" -xf - if [ -n "$WAIVERDB_RPM_RELEASE" ] ; then # need to hack the version in the spec sed --regexp-extended --in-place \ - -e "/%global upstream_version /c\%global upstream_version ${WAIVERDB_VERSION}" \ -e "/^Version:/cVersion: ${WAIVERDB_RPM_VERSION}" \ -e "/^Release:/cRelease: ${WAIVERDB_RPM_RELEASE}%{?dist}" \ + -e "/^Source0:/cSource0: waiverdb-${WAIVERDB_RPM_VERSION}.${WAIVERDB_RPM_RELEASE}.tar.gz" \ "$workdir/${name}.spec" # also hack the Python module version sed --regexp-extended --in-place \ diff --git a/tag-release.sh b/tag-release.sh index 332104a..942d545 100755 --- a/tag-release.sh +++ b/tag-release.sh @@ -18,7 +18,6 @@ if git status --porcelain | grep -q '^.M' ; then exit 1 fi -sed -i -e "/%global upstream_version /c\%global upstream_version ${version}${prerelease}" waiverdb.spec sed -i -e "/^Version:/c\Version: $version" waiverdb.spec if [ -n "$prerelease" ] ; then sed -i -e "/^Release:/c\Release: 0.$prerelease%{?dist}" waiverdb.spec diff --git a/version.sh b/version.sh index 6b29bdb..99c4ac7 100644 --- a/version.sh +++ b/version.sh @@ -6,15 +6,18 @@ set -e name=waiverdb if [ "$(git tag | wc -l)" -eq 0 ] ; then - # never been tagged since the project is just starting out - lastversion="0.0" + # if this is a shallow git clone, get the latest version from spec file + lastversion="$(sed -n '/^Version:/{s/.*:\s*//;p;q}' waiverdb.spec)" revbase="" + commitcount=99 else lasttag="$(git describe --tags --abbrev=0 HEAD)" lastversion="${lasttag##${name}-}" revbase="^$lasttag" + commitcount=$(git rev-list "$revbase" HEAD | wc -l) fi -if [ "$(git rev-list $revbase HEAD | wc -l)" -eq 0 ] ; then + +if [ "$(git rev-list "$revbase" HEAD | wc -l)" -eq 0 ] ; then # building a tag rpmver="" rpmrel="" @@ -25,7 +28,6 @@ else version="${version%%[a-z]*}" # strip non-numeric suffixes like "rc1" # increment the last portion of the version version="${version%.*}.$((${version##*.} + 1))" - commitcount=$(git rev-list $revbase HEAD | wc -l) commitsha=$(git rev-parse --short HEAD) rpmver="${version}" rpmrel="0.git.${commitcount}.${commitsha}" diff --git a/waiverdb.spec b/waiverdb.spec index fe83bfc..2a880d8 100644 --- a/waiverdb.spec +++ b/waiverdb.spec @@ -1,5 +1,3 @@ -%global upstream_version 1.2.0 - %if 0%{?fedora} || 0%{?rhel} > 7 %bcond_without server %else @@ -14,7 +12,7 @@ Release: 1%{?dist} Summary: Service for waiving results in ResultsDB License: GPLv2+ URL: https://pagure.io/waiverdb -Source0: https://files.pythonhosted.org/packages/source/w/%{name}/%{name}-%{upstream_version}.tar.gz +Source0: https://files.pythonhosted.org/packages/source/w/%{name}/%{name}-%{version}.tar.gz BuildArch: noarch BuildRequires: make @@ -101,7 +99,7 @@ This package contains a CLI tool for interacting with waiverdb. Primarily, submitting new waiverdbs. %prep -%setup -q -n %{name}-%{upstream_version} +%setup -q -n %{name}-%{version} # We guard against version flask-restful=0.3.6 in requirements.txt, # but the version in Fedora is patched to work.