Skip to content

Commit

Permalink
WIP: reusable script
Browse files Browse the repository at this point in the history
  • Loading branch information
ekohl committed Mar 4, 2024
1 parent c4c6ba0 commit d2a32e0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 35 deletions.
38 changes: 3 additions & 35 deletions packages/foreman/foreman/foreman.spec
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Group: Applications/System
License: GPLv3+ with exceptions
URL: https://theforeman.org
Source0: https://downloads.theforeman.org/%{name}/%{name}-%{version}%{?prerelease:-}%{?prerelease}.tar.bz2
Source1: gen-gem-buildreqs
Source3: %{name}.logrotate
Source4: %{name}.cron.d
Source5: %{name}.tmpfiles
Expand Down Expand Up @@ -216,41 +217,7 @@ BuildRequires: rubygem(facter)
%else
%generate_buildrequires
# TODO: Generate npm
# TODO: Make this reusable
ruby <<EOF
#!/usr/bin/env ruby
require 'bundler'
filename = ARGV.shift || 'Gemfile'

INCLUDED_GROUPS = [:default, :assets, :facter]

unless File.file?(filename)
STDERR.puts "File #{filename} is not an existing file"
exit 1
end

bundler = Dir.chdir(File.dirname(filename)) do
Bundler.load
end

bundler.dependencies.each do |dependency|
next unless (dependency.groups & INCLUDED_GROUPS).any?

name = "rubygem(#{dependency.name})"
reqs = []
dependency.requirement.requirements.each do |op, version|
if op == '~>'
reqs << "#{name} >= #{version}" << "#{name} < #{version.bump}.0"
elsif op == '>=' && version.to_s == '0'
# No real requirement, handled elsewhere
elsif op != '!=' # != is not supported in RPM
reqs << "#{name} #{op} #{version}"
end
end

puts reqs.any? ? "(#{reqs.join(' with ')})" : name
end
EOF
%{SOURCE1}
%endif

%package cli
Expand Down Expand Up @@ -432,6 +399,7 @@ Meta package with support for building RPMs in the Foreman release cycle.

%files build
%{_sysconfdir}/rpm/macros.%{name}-dist
# TODO: ship SOURCE1

%package console
Summary: Foreman console support
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
require 'bundler'
filename = ARGV.shift || 'Gemfile'

# TODO: ARGV
INCLUDED_GROUPS = [:default, :assets, :facter]

unless File.file?(filename)
Expand Down

0 comments on commit d2a32e0

Please sign in to comment.