Skip to content

Commit c15517a

Browse files
authored
(SIMP-10415) Honor build/rpm_metadata/requires (#169)
Before this patch, the project's RPM .spec file used a hard-coded `Release:` number that could not be overridden by the optional `build/rpm_metadata/release` file used by other projects. The lack of this capability prevents GHA pkg:single builds from tagging & building pre-release RPMs for the assets when PRs are still pending for final release, which in turn prevents staging full yum repositories to start testing the product install and dep resolution. This patch adds support for `build/rpm_metadata/release`, and defaults to the standard `-1` Release value. This patch also * Removes %{dist} from highline Release * Removes %{dist} from Release [SIMP-10415] #comment Update rubygem-simp-cli [SIMP-10416] #close
1 parent 539d900 commit c15517a

2 files changed

Lines changed: 45 additions & 3 deletions

File tree

build/rubygem-simp-cli.spec

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,45 @@
1+
%{lua:
2+
--
3+
-- When building the RPM, declare macro 'pup_module_info_dir' with the path to
4+
-- the top-level project directory. This directory should contain the
5+
-- following items:
6+
-- * 'build' directory
7+
-- * 'README.md' file
8+
--
9+
package_release = '1'
10+
local potential_src_dirs = {
11+
rpm.expand('%{pup_module_info_dir}'),
12+
rpm.expand('%{_sourcedir}'),
13+
posix.getcwd(),
14+
}
15+
local src_dir = "\0"
16+
17+
for _k,dir in pairs(potential_src_dirs) do
18+
if (posix.stat(dir .. '/build', 'type') == 'directory') and (posix.stat(dir .. '/README.md', 'type') == 'regular') then
19+
src_dir = dir
20+
break
21+
end
22+
end
23+
24+
if src_dir == "\0" then
25+
error(
26+
"FATAL: Cannot determine RPM project's src_dir!\n" ..
27+
"\t* Paths tried: '" .. table.concat(potential_src_dirs, "', '") .."\n" ..
28+
"\t* PROTIP: Declare macro %pup_module_info_dir\n"
29+
)
30+
end
31+
32+
rel_file = (io.open(src_dir .. "/build/rpm_metadata/release", "r") or io.open(src_dir .. "/release", "r"))
33+
if rel_file then
34+
for line in rel_file:lines() do
35+
if not (line:match("^%s*#") or line:match("^%s*$")) then
36+
package_release = line
37+
break
38+
end
39+
end
40+
end
41+
}
42+
143
%global gemname simp-cli
244

345
%global gemdir /usr/share/simp/ruby
@@ -12,7 +54,7 @@
1254
Summary: a cli interface to configure/manage SIMP
1355
Name: rubygem-%{gemname}
1456
Version: %{cli_version}
15-
Release: 1%{?dist}
57+
Release: %{lua: print(package_release)}
1658
Group: Development/Languages
1759
License: Apache-2.0
1860
URL: https://github.com/simp/rubygem-simp-cli
@@ -65,7 +107,7 @@ Documentation for %{name}
65107
%package highline
66108
Summary: A highline Gem for use with the SIMP CLI
67109
Version: %{highline_version}
68-
Release: 0
110+
Release: %{lua: print(package_release)}
69111
License: GPL-2.0
70112
URL: https://github.com/JEG2/highline
71113
Source11: highline-%{highline_version}.gem

simp-cli.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ Gem::Specification.new do |s|
6262
s.add_development_dependency 'pry', '~> 0'
6363
s.add_development_dependency 'pry-doc', '~> 0'
6464
s.add_development_dependency 'dotenv', '~> 1'
65-
s.add_development_dependency 'rubocop', '~> 0.29'
65+
s.add_development_dependency 'rubocop', '~> 0.49'
6666

6767
# simple text description of external requirements (for humans to read)
6868
s.requirements << 'SIMP OS installation'

0 commit comments

Comments
 (0)