Debian Codegraph @

bin/dh_ruby_fixdepends

raw
1 #!/usr/bin/ruby -EUTF-8
2 #
3 # Copyright © 2011, Lucas Nussbaum <[email protected]>
4 #
5 # This program is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation, either version 3 of the License, or
8 # (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 require 'gem2deb'
19 require 'gem2deb/dh_ruby'
20 include Gem2Deb
21
22 `dh_listpackages`.split.each do |package|
23 next if not File::exist?("debian/#{package}.substvars")
24 s = IO::read("debian/#{package}.substvars")
25 fd = File::new("debian/#{package}.substvars", "w")
26 s.each_line do |l|
27 if l =~ /^shlibs:Depends=/
28 deps = l.chomp.split('=', 2)[1].split(', ')
29 std_deps = []
30 libruby_deps = []
31 ruby_deps = []
32 deps.each do |dep|
33 pkg = dep.split.first
34 pkg.gsub!(/t64$/, '') # FIXME remove this after libruby3.1t64 is gone
35 if SUPPORTED_RUBY_SHARED_LIBRARIES.include?(pkg)
36 libruby_deps << dep
37 rdep = RubyDebianDev.min_ruby_dependency_for(pkg)
38 if rdep
39 ruby_deps << rdep
40 end
41 else
42 std_deps << dep
43 end
44 end
45 if ruby_deps.empty? && libruby_deps.empty?
46 fd.puts l
47 else
48 upper_bound = RubyDebianDev.ruby_upper_bound
49 newdeps = (std_deps + [libruby_deps.join(' | ')] + [ruby_deps.join(' | ')] + [upper_bound]).join(', ')
50 fd.puts "shlibs:Depends=#{newdeps}"
51 end
52 else
53 fd.puts l
54 end
55 end
56 fd.close
57 end
58 __END__
59 =head1 NAME
60
61 dh_ruby_fixdepends - fix dependencies in shlibs file after dh_shlibdeps
62
63 =head1 SYNOPSIS
64
65 B<dh_ruby_fixdepends>
66
67 =head1 DESCRIPTION
68
69 B<dh_ruby_fixdepends> is called by the I<ruby> dh sequence. You should
70 not call it directly.
71
72 =head1 SEE ALSO
73
74 L<B<gem2deb>>(1), L<B<dh_ruby>>(1)
75
76 =head1 COPYRIGHT AND AUTHORS
77
78 Copyright (c) 2011, Lucas Nussbaum <[email protected]>
79
80 This program is free software: you can redistribute it and/or modify
81 it under the terms of the GNU General Public License as published by
82 the Free Software Foundation, either version 3 of the License, or
83 (at your option) any later version.
84
85 This program is distributed in the hope that it will be useful,
86 but WITHOUT ANY WARRANTY; without even the implied warranty of
87 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
88 GNU General Public License for more details.
89
90 You should have received a copy of the GNU General Public License
91 along with this program. If not, see <http://www.gnu.org/licenses/>.