Fix duplicate special dependencies in tools/getrealdeps.rb (#12760)

This commit is contained in:
Maximilian Downey Twiss
2025-09-14 00:31:14 +10:00
committed by GitHub
parent bc0bfcceaf
commit fd0a29fb05
2 changed files with 6 additions and 8 deletions

View File

@@ -203,7 +203,6 @@ class GetRealDepsTest < Minitest::Test
test_wrapper(input_file, expected_pkg_file, deps)
end
# TODO: The expected output in this case could be improved.
def test_add_special_duplicate_dependency
deps = ['python3']
input_file = <<~EOF
@@ -220,7 +219,6 @@ class GetRealDepsTest < Minitest::Test
depends_on 'libnftnl'
depends_on 'python3' # R
depends_on 'python3' # R
end
EOF
pkg_class = Pip

View File

@@ -44,19 +44,19 @@ end
# Write the missing dependencies to the package file.
def write_deps(pkg_file, pkgdeps, pkg)
# Look for missing runtime dependencies, ignoring build and optional deps.
missingpkgdeps = pkgdeps.reject { |i| File.read(pkg_file).include?("depends_on '#{i}'") unless File.read(pkg_file).include?("depends_on '#{i}' => :build") || File.read(pkg_file).include?("# depends_on '#{i}' # R (optional)") }
# Add special deps for perl, pip, python, and ruby gem packages.
case pkg.superclass.to_s
when 'PERL'
missingpkgdeps << 'perl'
pkgdeps << 'perl'
when 'Pip', 'Python'
missingpkgdeps << 'python3'
pkgdeps << 'python3'
when 'RUBY'
missingpkgdeps << 'ruby'
pkgdeps << 'ruby'
end
# Look for missing runtime dependencies, ignoring build and optional deps.
missingpkgdeps = pkgdeps.reject { |i| File.read(pkg_file).include?("depends_on '#{i}'") unless File.read(pkg_file).include?("depends_on '#{i}' => :build") || File.read(pkg_file).include?("# depends_on '#{i}' # R (optional)") }
# These deps are sometimes architecture dependent or should not be
# removed for other reasons.
privileged_deps = %w[glibc glibc_lib gcc_lib perl python3 ruby]