|
2 | 2 | %global version @VERSION@
|
3 | 3 | %global release %{rel}%{?dist}
|
4 | 4 |
|
| 5 | +### Macros to populate RPM %{RELEASE} field with useful info |
| 6 | +# {gitrelease} holds the ./configure-generated version of the same |
| 7 | +# info that's calculated for {spec_rel} below. This allows us to |
| 8 | +# build out-of-tree with the same Git info. |
5 | 9 | %global gitrelease @GITRELEASE@
|
| 10 | +# {gd_rel_delta} uses "git describe" to return a string in the form |
| 11 | +# "<commits>.g<hash>[.1]?" to be used in {spec_rel} below. |
6 | 12 | %{expand:%%global gd_rel_delta %(GD1=`git describe --abbrev=4 --always --tags --long --match '[[:digit:]][[:alnum:].]*[[:alnum:]]' --dirty=.1 2>/dev/null` ; test -n "${GD1}" && echo "${GD1}" | cut -d- -f 2- | tr '-' '.')%%{nil}}
|
| 13 | +# {rel_pre_post} gets set to either "1." or "0." based on whether the |
| 14 | +# source was built from a commit before ("0.") or after ("1.") the |
| 15 | +# tagged release specified by {version} above. |
7 | 16 | %{expand:%%global rel_pre_post %(GD2=`git describe --tags HEAD 2>/dev/null` ; if test -n "${GD2}" ; then echo "${GD2}" | grep -Eq '^%{version}' >&/dev/null && echo 1. || echo 0. ; fi)%%{nil}}
|
| 17 | +# {spec_rel} combines the two values above into a single string for |
| 18 | +# use in the "Release:" field. The resulting string, when used at the |
| 19 | +# beginning of the "Release:" header value, not only guarantees |
| 20 | +# correct RPM NEVR ordering (i.e., newer packages will always upgrade |
| 21 | +# older ones) but also shows how many <commits> were made since the |
| 22 | +# last tagged release, the Git commit <hash> from which the source |
| 23 | +# tarball ("Source:" below) was built, and whether the tarball also |
| 24 | +# contains some uncommitted changes from a "dirty" working tree (".1" |
| 25 | +# on the end). |
8 | 26 | %{expand:%%global spec_rel %{?rel_pre_post}%{?gd_rel_delta}%%{nil}}
|
9 |
| -%{!?rel:%{expand:%%global rel %(if test -z "%{spec_rel}" ; then echo "%{gitrelease}" ; else echo "%{spec_rel}" ; fi)}} |
| 27 | +# {rel} ultimately determines what the release string will be; only |
| 28 | +# the disttag gets appended to it. If the user specifies their own |
| 29 | +# value (e.g., "rpmbuild --define 'rel 1'"), that value is used |
| 30 | +# instead. If not, the string described above is pulled either from |
| 31 | +# {spec_rel} (if building from Git repo) or {gitrelease} (if building |
| 32 | +# from SRPM or source tarball). |
| 33 | +# As a special case, if the commit being built exactly matches the Git |
| 34 | +# tag for the specified version, {rel} is set to either "1" (clean |
| 35 | +# working directory) or "1.1" (dirty working directory). |
| 36 | +%{!?rel:%{expand:%%global rel %(REL="%{?spec_rel}%{!?spec_rel:%{gitrelease}}" ; if (echo "${REL:-nope}" | grep -Fq "1.0.g" 2>/dev/null) ; then if (echo "${REL:-nope}" | grep -q '\.1$' 2>/dev/null) ; then echo "1.1" ; else echo 1 ; fi ; elif test -z "%{spec_rel}" ; then echo "%{gitrelease}" ; else echo "%{spec_rel}" ; fi)%{nil}}} |
10 | 37 |
|
11 | 38 | %{!?sname:%global sname nhc}
|
12 | 39 | %{!?nhc_script_dir:%global nhc_script_dir %{_sysconfdir}/%{sname}/scripts}
|
|
0 commit comments