Skip to content

Commit 40be811

Browse files
committed
Generate spec file when creating srpm
1 parent 96bc6d6 commit 40be811

File tree

4 files changed

+36
-19
lines changed

4 files changed

+36
-19
lines changed

.packit.yaml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,15 @@
1414

1515
# https://packit.dev/docs/configuration/
1616

17-
specfile_path: packages/fedora/openarm-can.spec
17+
specfile_path: openarm-can.spec
18+
19+
actions:
20+
post-upstream-clone:
21+
- rake spec
22+
23+
srpm_build_deps:
24+
- rubygem-json
25+
- rubygem-rake
1826

1927
notifications:
2028
pull_request:

Rakefile

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
# limitations under the License.
1414

1515
require "date"
16+
require "fileutils"
1617

1718
require_relative "helper"
1819

@@ -110,7 +111,6 @@ namespace :release do
110111
"CMakeLists.txt",
111112
"package.xml",
112113
"packages/debian/changelog",
113-
"packages/fedora/openarm-can.spec",
114114
"python/CMakeLists.txt",
115115
"python/openarm_can/__init__.py",
116116
"python/pyproject.toml",
@@ -165,3 +165,27 @@ task release: [
165165
"release:tag",
166166
"release:ubuntu",
167167
]
168+
169+
desc "Create RPM spec file"
170+
task :spec do
171+
FileUtils.copy_file("packages/fedora/openarm-can.spec.in", "openarm-can.spec")
172+
current_version = Helper.detect_version
173+
Helper.update_content("openarm-can.spec") do |content|
174+
content.sub!("%{VERSION}", current_version)
175+
end
176+
executable_files = Array.new()
177+
File.readlines('CMakeLists.txt', chomp: true).each do |line|
178+
if !!(line =~ /install\(TARGETS openarm-can-*.* DESTINATION \${CMAKE_INSTALL_BINDIR}\)/)
179+
executable_name=line.delete_prefix("install(TARGETS ").delete_suffix(" DESTINATION ${CMAKE_INSTALL_BINDIR})")
180+
executable_files.append(executable_name)
181+
end
182+
if !!(line =~ /setup\/openarm-can-[a-z0-9\-]/)
183+
/(?<rhs>.+)\s*setup\/\s*(?<executable>.+)/ =~ line
184+
executable_files.append(executable)
185+
end
186+
end
187+
executable_files.sort!
188+
Helper.update_content("openarm-can.spec") do |content|
189+
content.sub!("%{EXECUTABLES}", executable_files.join("\n"))
190+
end
191+
end

packages/Rakefile

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -89,14 +89,6 @@ class OpenArmCANPackageTask < PackageTask
8989
false
9090
end
9191

92-
def update_spec
93-
update_content("fedora/openarm-can.spec") do |content|
94-
content.gsub!(/^(Version:\s+)[\d.]+$/) do
95-
"#{$1}#{@version}"
96-
end
97-
end
98-
end
99-
10092
def define_archive_task
10193
file @archive_name do
10294
if File.exist?("../#{@archive_name}")
Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
# limitations under the License.
1414

1515
Name: openarm-can
16-
Version: 1.2.2
16+
Version: %{VERSION}
1717
Release: %{autorelease}
1818
Summary: OpenArm CAN control library
1919

@@ -68,14 +68,7 @@ Setup and configuration utility scripts.
6868

6969
%files utils
7070
%license LICENSE.txt
71-
%{_bindir}/openarm-can-change-baudrate
72-
%{_bindir}/openarm-can-configure-socketcan
73-
%{_bindir}/openarm-can-configure-socketcan-4-arms
74-
%{_bindir}/openarm-can-demo
75-
%{_bindir}/openarm-can-diagnosis
76-
%{_bindir}/openarm-can-motor-check
77-
%{_bindir}/openarm-can-set-zero
78-
%{_bindir}/openarm-can-zero-position-calibration
71+
%{EXECUTABLES}
7972

8073
%changelog
8174
%autochangelog

0 commit comments

Comments
 (0)