Skip to content

Commit abb2bdb

Browse files
authored
release: Support spec files with pre-filled Version:
starter-kit based projects do release tarballs with spec files that already have a correct `Version:` instead of `0`. This makes them more self-contained and able to build working (s)rpms without the help of cockpituous. Support this mode with a new `release-srpm -V` option. By default, release-srpm would generate a spec file with `Release: 2` as it assumes that `XXX-1` was already released. `-V` tells it that the `Version:` is already correct and it should leave the `Release:` at 1. Closes #194
1 parent d5cffc0 commit abb2bdb

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

release/README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,13 @@ this:
7272

7373
## Spec file requirements
7474

75-
For a spec file to work with the scripts, it should be setup like this:
75+
For a spec file to work with `release-srpm`, it should have `Version: 0`.
76+
If your build system already puts the target release version into `Version:`,
77+
call `release-srpm` with the `-V` option instead, otherwise it will assume that
78+
this version was already released in a previous srpm and bump the `Release:`.
7679

77-
Version: 0
78-
79-
And not have any content after the following line:
80-
81-
%changelog
80+
The spec file must not have any content after `%changelog`. It will generate a
81+
changelog from the git tag description.
8282

8383
## Preparing secrets
8484

release/release-srpm

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
# -q RELEASE_QUIET=1 Make output more quiet
2121
# -s spec RELEASE_SPEC=spec Path to spec file
2222
# -t tag RELEASE_TAG=tag Tag to use for SRPM version and log
23+
# -V RELEASE_SPECVER=1 Spec file already has released Version: instead of 0
2324
# -v RELEASE_VERBOSE=1 Make output more verbose
2425
#
2526

@@ -30,6 +31,7 @@ QUIET=${RELEASE_QUIET:-0}
3031
VERBOSE=${RELEASE_VERBOSE:-0}
3132
SOURCE=${RELEASE_SOURCE:-}
3233
SPEC=${RELEASE_SPEC:-}
34+
SPECVER=${RELEASE_SPECVER:-0}
3335
SRPM=${RELEASE_SRPM:-}
3436
TAG=${RELEASE_TAG:-}
3537
TARBALL=${RELEASE_TARBALL:-}
@@ -130,7 +132,7 @@ calc_release()
130132
{
131133
# Asks rpm to print out the Release line of a spec file, without its 'dist' part
132134
rpm -q --specfile --queryformat '%{VERSION} %{RELEASE}\n' --undefine dist "$2" | while read ver rel; do
133-
if [ "$ver" = "$1" -a "$rel" -gt 0 ]; then
135+
if [ "$SPECVER" = 0 ] && [ "$ver" = "$1" -a "$rel" -gt 0 ]; then
134136
expr "$rel" \+ 1
135137
else
136138
echo "1" # different version restart release
@@ -261,7 +263,7 @@ prepare()
261263
rm -rf $workdir
262264
}
263265

264-
while getopts "f:qs:t:vp" opt; do
266+
while getopts "f:qs:t:vVp" opt; do
265267
case "$opt" in
266268
f)
267269
TARBALL="$OPTARG"
@@ -276,6 +278,9 @@ while getopts "f:qs:t:vp" opt; do
276278
s)
277279
SPEC="$OPTARG"
278280
;;
281+
V)
282+
SPECVER=1
283+
;;
279284
t)
280285
TAG="$OPTARG"
281286
;;

0 commit comments

Comments
 (0)