8 my @ignore = qw(vserver-packages python-devel-src);
9 my @poldek = (qw(sudo poldek -n th -n th-ready --cachedir=./poldekcache --skip-installed),
10 qw(-O keep_downloads=yes -O suggests=no -O unique_package_names=yes),
11 "-O", "ignore=" . (join " ", @ignore)
14 # if multiple packages provide some funcionality those will be selected:
21 "python-modules" => +1,
27 "libstdc++-devel" => +1,
30 # translate package name to privodes name
32 "rarian-compat" => "scrollkeeper",
33 "Mesa-libGLU-devel" => "OpenGL-GLU-devel",
36 # for m4 in *.m4; do R=$(rpm -qf $m4); R=${R%-*-*}; \
37 # awk -vr=$R '/^\s*(AC_DEFUN|AU_ALIAS)/ { gsub(/\].*/,""); gsub(/.*\[/,""); print r " " $0}' $m4; \
38 # done | sort | awk '{print "\t\"" $2 "\" => \"" $1 "\","}'
39 my %ac2br = do "findbr-ac2br";
42 "findkde4:44" => "kde4-kdelibs",
43 "findmsgfmt" => "gettext-devel",
44 "findpythoninterp" => "python",
52 print STDERR "\033[31;1m" . $_ . "\033[0m\n"
56 my $builddir = shift @ARGV;
65 my $msg = shift || $reason;
67 foreach my $p ( @$pkg ) {
75 $pkg = $translate{ $pkg } || $pkg;
77 return if exists $out{ $pkg };
79 print STDERR "\033[33;1madding: $pkg => $msg\033[0m\n";
85 warn "Poldek: $cmd\n";
86 my $pid = open( READ, "-|", @poldek, "--shcmd=".$cmd );
91 return @read if wantarray;
102 next if $checked_files{ $_ };
103 $checked_files{ $_ } = 1;
106 return unless @files;
108 my $search = join "; ", map "search -f $_", @files;
109 warn "Reason: $reason\n";
110 my @read = poldek_cmd( $search );
114 while ( $_ = shift @read ) {
115 if ( /(\d+) package\(s\) found:$/ ) {
116 foreach my $i ( 1..$1 ) {
119 $_ =~ /^(.*)-.*?-.*?$/;
125 return unless @found;
127 my $found = $found[0];
130 my %pts = map { ( $_ => ( ($i += 0.001) + ( $preferred{ $_ } || 0 ) ) ) }
132 my @pref = sort { $pts{$b} <=> $pts{$a} } @found;
133 my $pref = join ", ", map "$_ => $pts{$_}", @pref;
134 warn "Multiple found: $pref\n";
138 $found = $translate{ $found } if $translate{ $found };
147 my $read = poldek_cmd( "ls" );
150 next unless /(\S+)-.*?-.*?\.[a-z0-9_]+$/;
152 $pkglist{ lc $pkg } = $pkg;
154 $pkglist = \%pkglist;
159 my $origname = shift;
160 get_pkglist() unless $pkglist;
161 return unless defined $origname;
162 my $name = lc $origname;
171 ".*-lib$name-.*-devel",
175 for my $k ( keys %$pkglist ) {
176 if ( $k =~ /$name/ ) {
180 @select = sort @select;
182 foreach my $try ( @try ) {
183 foreach my $pkg ( @select ) {
184 if ( $pkg =~ /^$try$/ ) {
185 warn "guessed: $origname => $pkglist->{ $pkg }\n";
186 return $pkglist->{ $pkg };
190 warn "$origname not guessed\n";
195 my $cmake_get_call = 0;
196 my $cmake_pkg_list = 0;
197 while ( $_ = shift @lines ) {
199 #next if $checked{ $_ };
203 if ( /^\S+: (\S+): (?:Command )?not found$/ or /.*configure\[\d+\]: (\S+): not found$/
204 or m{which: no (\S+) in \(.*/bin.*\)}
205 or m{\S+: (\S+): command not found$}
206 or m{Can't exec "(\S+)": No such file or directory} ) {
208 next if $exec eq "hostname";
209 warn "Looking for executable $exec\n";
210 if ( $exec =~ m#^/# ) {
211 poldek_file( $exec );
213 poldek_file( "/usr/bin/$exec", "/bin/$exec" );
217 if ( /\S+\.[ch](?:pp|xx)?:\d+:\d+: error: (\S+): No such file or directory$/ ) {
219 warn "Looking for C(++) header $h\n";
220 poldek_file( "/usr/include*/$h" );
222 if ( m{^ImportError: No module named (\S+)$} ) {
225 warn "Looking for python module $mod\n";
226 poldek_file( "/usr/share/python2*/$mod/__init__.py*",
227 "/usr/share/python2*/$mod.py*",
228 "/usr/lib*/python2*/$mod.py*",
229 "/usr/lib*/python2*/_$mod.so" );
231 if ( /configure(?:\.in|\.ac)?:\d+: error: possibly undefined macro: (\S+)/
232 or m{configure(?:\.in|\.ac)?:\d+: error: m4 macro `(\S+)' is not defined} ) {
234 warn "Looking for autotools macro $macro\n";
235 if ( my $br = $ac2br{ $macro } ) {
240 if ( /^No package '(\S+)' found$/ or
241 /Package (\S+) was not found in the pkg-config search path/
242 or m{None of the required '(\S+?)(?:[<>=].*)?' found}
243 or m{--\s+package '(\S+?)(?:[<>=].*)?' not found}
246 warn "Looking for package $pkg\n";
247 poldek_file( "/usr/lib*/pkgconfig/$pkg.pc" );
249 if ( m{^cp: cannot stat `(/.*)': No such file or directory$} ) {
251 warn "Looking for file $f\n";
254 if ( m{^find-lang.sh: Error: international files not found for '}
255 or m{ gettext tools not found}
257 add_br( "gettext-devel" );
261 if ( m{ pkg-config .*not .*found}
262 or m{^checking for pkg-config\.\.\. no} ) {
263 add_br( "pkgconfig" );
267 if ( m{^Can't locate (.*?\.pm) in \@INC} ) {
269 warn "Looking for perl module $mod\n";
270 poldek_file( "/usr/lib*/perl*/$mod", "/usr/share/perl*/$mod" );
272 if ( m{^/usr/bin/ld: cannot find -l(.*?)$} ) {
274 warn "Looking for library $lib\n";
275 poldek_file( "/usr/lib*/lib$lib.so" );
277 if ( m{^error: Couldn't exec (/\S+): No such file or directory$}
278 or m{^Can't open perl script "(/\S+)": No such file or directory$}
279 or m{unable to open (/\S+) \(No such file or directory\)$}
280 or m{GConf-CRITICAL \*\*: No such file `(/.\S+?)'$}
281 or m{make.*: \*\*\* No rule to make target `(/\S+)'}
282 or m{g(?:cc|\+\+): (/\S+): No such file or directory$}
285 warn "Looking for file $file\n";
286 poldek_file( $file );
288 if ( m{failed.*http://www\.oasis-open\.org/docbook/xml/([\d\.]+/\S+\.dtd)} ) {
290 warn "Looking for docbook file $dtd\n";
291 poldek_file( "/usr/share/sgml/docbook/xml-dtd-$dtd" );
293 if ( m{http://docbook.sourceforge.net/release/xsl/current/(\S+\.xsl)} ) {
295 next if m{^\s*(/usr/bin/)?xsltproc };
296 warn "Looking for docbook file $db\n";
297 poldek_file( "/usr/share/sgml/*/$db" );
299 if ( m{configure: error: C\+\+ preprocessor "/lib/cpp" fails sanity check} ) {
300 add_br( "gcc-c++", "try: %undefine\t__cxx" );
302 if ( m{configure: error: C\+\+ compiler cannot create executables} ) {
303 add_br( "libstdc++-devel", "maybe try: %undefine\t__cxx" );
305 if ( m{configure: error: XML::Parser perl module is required for intltool} ) {
306 add_br( "perl-XML-Parser" );
309 if ( m{configure\[\d+\]: syntax error: }
310 or m{\./configure\[\d+\]: \S+_\S+: not found} ) {
311 warn "Need to check configure source: $reason\n";
315 if ( m{^CMake Error at (?:\S+/)?(\S+?)\.cmake:(\d+) } ) {
316 my ( $module, $line ) = ( lc $1, $2 );
318 if ( $module eq "findqt4" ) {
321 if ( $l =~ /qmake/ ) {
322 add_br( "qt4-qmake", $l );
323 } elsif ( $l =~ /rcc/ ) {
324 add_br( "qt4-build", $l );
325 } elsif ( $l =~ /Could NOT find (Qt\S+) header/ ) {
326 add_br( "$1-devel", $l );
328 warn "unrecognized Qt requirement: $l\n";
330 } elsif ( $module eq "cmakedeterminecxxcompiler" ) {
331 add_br( "libstdc++-devel",
332 '"try: -DCMAKE_CXX_COMPILER_WORKS=1 -DCMAKE_CXX_COMPILER="%{__cc}"' );
333 } elsif ( $br = $cmake2br{ $module . ":" . $line } ) {
335 } elsif ( $br = $cmake2br{ $module } ) {
337 } elsif ( $br = guess_package( $module =~ /find(.+)/ ) ) {
341 warn "Unrecognized cmake error: $reason\n";
344 if ( m{^\s*ERROR: (?:\S+/)?(\S+?\.cmake) not found} ) {
346 warn "Looking for cmake file: $cmake\n";
347 poldek_file( "/usr/*/cmake/*/$cmake" )
349 if ( $cmake_get_call ) {
350 if ( m{^\s*/\S+/(\S+)\.cmake:(\d+) } ) {
351 my ( $module, $line ) = ( lc $1, $2 );
353 if ( $br = $cmake2br{ $module . ":" . $line } ) {
356 } elsif ( $br = $cmake2br{ $module } ) {
359 } elsif ( $br = guess_package( $module =~ /find(.+)/ ) ) {
365 if ( m{^-- WARNING: you are using the obsolete 'PKGCONFIG' macro} ) {
366 add_br( "pkgconfig" );
368 if ( m{QT_(QT\S+)_LIBRARY \(ADVANCED\)}
369 or m{X11_(\S+)_LIB \(ADVANCED\)}
370 or m{Qt (\S+) library not found} ) {
372 my $pkg = guess_package( $find );
376 warn "Cannot quess qt package: $find\n";
380 if ( m{^-- The following OPTIONAL packages could NOT be located on your system} ) {
383 if ( $cmake_pkg_list ) {
384 if ( /\s+\* (\S+) / ) {
386 my $pkg = guess_package( $find );
390 warn "Cannot quess optional package: $find\n";
392 } elsif ( /^\s*$/ ) {
402 return unless /^configure(\.(?:ac|in|in\.in))?$/;
405 warn "$File::Find::name\n";
410 if ( m{^\s*([A-Za-z0-9_]+)\s*(\(.*)?$} ) {
412 if ( my $br = $ac2br{ $def } ) {
413 add_br( $br, "$file: $_" );
414 } elsif ( $def !~ /^A[CM]_/ and $def =~ /^_?[A-Z]+_[A-Z_0-9a-z]+$/ ) {
415 #warn "Possible macro unrecognized: $def [[[$_]]]\n";
424 find( \&wanted, $builddir );
427 foreach my $pkg ( sort keys %out ) {
428 print "$pkg -- $out{$pkg}\n";