Skip to content

Commit

Permalink
Fix default system packages detection
Browse files Browse the repository at this point in the history
  • Loading branch information
kou committed Jan 7, 2025
1 parent b7aa464 commit a313fba
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
8 changes: 8 additions & 0 deletions lib/rubygems-requirements-system/installer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ def install

private
def parse_requirements(gemspec_requirements)
all_packages_set = {}
requirements = {}
gemspec_requirements.each do |gemspec_requirement|
components = gemspec_requirement.split(/: +/, 4)
Expand All @@ -83,10 +84,17 @@ def parse_requirements(gemspec_requirements)
packages = parse_packages(raw_packages)
next if packages.empty?

all_packages_set[packages] = true

next unless @platform.target?(platform)
requirements[packages] ||= []
requirements[packages] << system_package
end
(all_packages_set.keys - requirements.keys).each do |not_used_packages|
system_packages = @platform.default_system_packages(not_used_packages)
next if system_packages.nil?
requirements[not_used_packages] = system_packages
end
requirements.collect do |packages, system_packages|
Requirement.new(packages, system_packages)
end
Expand Down
10 changes: 5 additions & 5 deletions lib/rubygems-requirements-system/platform/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,13 @@ def target?(platform)
raise NotImpelementedError
end

def default_system_packages(packages)
nil
end

def install(requirement)
synchronize do
target_packages(requirement).any? do |package|
requirement.system_packages.any? do |package|
install_package(package) and requirement.satisfied?
end
end
Expand Down Expand Up @@ -75,10 +79,6 @@ def have_priviledge?
super_user?
end

def target_packages(requirement)
requirement.system_packages
end

def install_package(package)
command_line = prepare_command_line(package)
if command_line
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ def target?(platform)
end
end

private
def target_packages(requirement)
super +
requirement.packages.collect {|package| "pkgconfig(#{package.id})"}
def default_system_packages(packages)
packages.collect {|package| "pkgconfig(#{package.id})"}
end

private

def install_command_line(package)
if major_version >= 9
["dnf", "install", "--enablerepo=crb", "-y", package]
Expand Down

0 comments on commit a313fba

Please sign in to comment.