10 my @ignore = qw(vserver-packages python-devel-src);
11 my @poldek = (qw(sudo poldek -n th-x86_64-ready), "--cachedir=$pwd/poldekcache",
12 "--skip-installed", "--conf=$pwd/poldekconf/poldek.conf",
13 "-O", "ignore=" . (join " ", @ignore)
16 # if multiple packages provide some funcionality those will be selected:
23 "python-modules" => +1,
29 "libstdc++-devel" => +1,
30 "libusb-compat-devel" => +1,
31 "libjpeg-devel" => +1,
33 "libsamplerate-devel" => +1,
34 "pulseaudio-devel" => +1,
35 "xorg-lib-libXrandr-devel" => +1,
39 # translate package name to provides name
41 "rarian-compat" => "scrollkeeper",
42 "Mesa-libGL" => "OpenGL",
43 "Mesa-libGL-devel" => "OpenGL-devel",
44 "Mesa-libGLU-devel" => "OpenGL-GLU-devel",
47 # for m4 in *.m4; do R=$(rpm -qf $m4); R=${R%-*-*}; \
48 # awk -vr=$R '/^\s*(AC_DEFUN|AU_ALIAS)/ { gsub(/\].*/,""); gsub(/.*\[/,""); print r " " $0}' $m4; \
49 # done | sort | awk '{print "\t\"" $2 "\" => \"" $1 "\","}'
50 my %ac2br = do "findbr-ac2br";
53 "findkde4:44" => "kde4-kdelibs",
54 "findmsgfmt" => "gettext-devel",
55 "findpythoninterp" => "python",
63 print STDERR "\033[31;1m" . $_ . "\033[0m\n"
67 my $builddir = shift @ARGV;
76 my $msg = shift || $reason;
78 foreach my $p ( @$pkg ) {
86 $pkg = $translate{ $pkg } || $pkg;
88 return if exists $out{ $pkg };
90 print STDERR "\033[33;1madding: $pkg => $msg\033[0m\n";
96 warn "Poldek: $cmd\n";
97 my $pid = open( READ, "-|", @poldek, "--shcmd=".$cmd );
102 return @read if wantarray;
107 my $check_config_log = undef;
114 next if $checked_files{ $_ };
115 $checked_files{ $_ } = 1;
118 return unless @files;
120 my $search = join "; ", map "search -f $_", @files;
121 warn "Reason: $reason\n";
122 my @read = poldek_cmd( $search );
126 while ( $_ = shift @read ) {
127 if ( /(\d+) package\(s\) found:$/ ) {
128 foreach my $i ( 1..$1 ) {
131 $_ =~ /^(.*)-.*?-.*?$/;
137 return unless @found;
139 my $found = $found[0];
142 my %pts = map { ( $_ => ( ($i += 0.001) + ( $preferred{ $_ } || 0 ) ) ) }
144 my @pref = sort { $pts{$b} <=> $pts{$a} } @found;
145 my $pref = join ", ", map "$_ => $pts{$_}", @pref;
146 warn "Multiple found: $pref\n";
150 $found = $translate{ $found } if $translate{ $found };
159 my $read = poldek_cmd( "ls" );
162 next unless /(\S+)-.*?-.*?\.[a-z0-9_]+$/;
164 $pkglist{ lc $pkg } = $pkg;
166 $pkglist = \%pkglist;
171 my $origname = shift;
172 get_pkglist() unless $pkglist;
173 return unless defined $origname;
174 my $name = lc $origname;
183 ".*-lib$name-.*-devel",
187 for my $k ( keys %$pkglist ) {
188 if ( $k =~ /$name/ ) {
192 @select = sort @select;
194 foreach my $try ( @try ) {
195 foreach my $pkg ( @select ) {
196 if ( $pkg =~ /^$try$/ ) {
197 warn "guessed: $origname => $pkglist->{ $pkg }\n";
198 return $pkglist->{ $pkg };
202 warn "$origname not guessed\n";
209 my $cmake_get_call = 0;
210 my $cmake_pkg_list = 0;
211 while ( $_ = shift @lines ) {
213 #next if $checked{ $_ };
217 if ( /^\S+: (\S+): (?:Command )?not found$/ or /.*configure\[\d+\]: (\S+): not found$/
218 or m{which: no (\S+) in \(.*/bin.*\)}
219 or m{\S+: (\S+): command not found$}
220 or m{Can't exec "(\S+)": No such file or directory} ) {
222 $exec = $1 if $exec =~ m{^"(.*)"$};
223 next if $exec eq "hostname";
224 warn "Looking for executable $exec\n";
225 if ( $exec =~ m#^/# ) {
226 poldek_file( $exec );
228 poldek_file( "/usr/bin/$exec", "/bin/$exec" );
232 if ( /\S+\.[ch](?:pp|xx|c)?:\d+:\d+: error: (\S+): No such file or directory$/ or
233 /\S+\.[ch](?:pp|xx|c)?:\d+:\d+: fatal error: (\S+): No such file or directory$/ ) {
235 warn "Looking for C(++) header $h\n";
236 poldek_file( "/usr/include*/$h" );
238 if ( m{^ImportError: No module named (\S+)$} ) {
241 warn "Looking for python module $mod\n";
242 poldek_file( "/usr/share/python2*/$mod/__init__.py*",
243 "/usr/share/python2*/$mod.py*",
244 "/usr/lib*/python2*/$mod.py*",
245 "/usr/lib*/python2*/_$mod.so" );
247 if ( /configure(?:\.in|\.ac)?:\d+: error: possibly undefined macro: (\S+)/
248 or m{configure(?:\.in|\.ac)?:\d+: error: m4 macro `(\S+)' is not defined} ) {
250 warn "Looking for autotools macro $macro\n";
251 if ( my $br = $ac2br{ $macro } ) {
258 if ( /^No package '(\S+)' found$/ or
259 /Package (\S+) was not found in the pkg-config search path/
260 or m{None of the required '(\S+?)(?:[<>=].*)?' found}
261 or m{--\s+package '(\S+?)(?:[<>=].*)?' not found}
264 warn "Looking for package $pkg\n";
265 poldek_file( "/usr/lib*/pkgconfig/$pkg.pc" );
267 if ( m{^cp: cannot stat `(/.*)': No such file or directory$} ) {
269 warn "Looking for file $f\n";
272 if ( m{^find-lang.sh: Error: international files not found for '}
273 or m{ gettext tools not found}
275 add_br( "gettext-devel" );
279 if ( m{ pkg-config .*not .*found}
280 or m{^checking for pkg-config\.\.\. no} ) {
281 add_br( "pkgconfig" );
285 if ( m{^Can't locate (.*?\.pm) in \@INC} ) {
287 warn "Looking for perl module $mod\n";
288 poldek_file( "/usr/lib*/perl*/$mod", "/usr/share/perl*/$mod" );
290 if ( m{^(?:/usr/bin/ld: )?cannot find -l(.*?)$} ) {
292 warn "Looking for library $lib\n";
293 poldek_file( "/usr/lib64/lib$lib.so", "/usr/lib/lib$lib.so",
294 "/usr/lib*/lib$lib.so" );
296 if ( m{^error: Couldn't exec (/\S+): No such file or directory$}
297 or m{^Can't open perl script "(/\S+)": No such file or directory$}
298 or m{unable to open (/\S+) \(No such file or directory\)$}
299 or m{GConf-CRITICAL \*\*: No such file `(/.\S+?)'$}
300 or m{make.*: \*\*\* No rule to make target `(/\S+)'}
301 or m{g(?:cc|\+\+): (/\S+): No such file or directory$}
302 or m{env: (/\S+): No such file or directory$}
305 warn "Looking for file $file\n";
306 poldek_file( $file );
308 if ( m{^ValueError: Couldn't find include '(.*\.gir)'} ) {
310 warn "Looking for gir file $file\n";
311 poldek_file( "/usr/share/gir-1.0/" . $file );
313 if ( m{failed.*http://www\.oasis-open\.org/docbook/xml/([\d\.]+/\S+\.dtd)} ) {
315 warn "Looking for docbook file $dtd\n";
316 poldek_file( "/usr/share/sgml/docbook/xml-dtd-$dtd" );
318 if ( m{http://docbook.sourceforge.net/release/xsl/current/(\S+\.xsl)} ) {
320 next if m{^\s*(/usr/bin/)?xsltproc };
321 warn "Looking for docbook file $db\n";
322 poldek_file( "/usr/share/sgml/*/$db" );
324 if ( m{configure: error: C\+\+ preprocessor "/lib/cpp" fails sanity check} ) {
325 add_br( "gcc-c++", "try: %undefine\t__cxx" );
327 if ( m{configure: error: C\+\+ compiler cannot create executables} ) {
328 add_br( "libstdc++-devel", "maybe try: %undefine\t__cxx" );
330 if ( m{configure: error: XML::Parser perl module is required for intltool} ) {
331 add_br( "perl-XML-Parser" );
334 if ( m{ (\S+) does not appear in AM_CONDITIONAL$} ) {
336 warn "Looking for autotools macro $macro\n";
337 if ( my $br = $ac2br{ $macro } ) {
345 if ( m{configure\[\d+\]: syntax error: }
346 or m{\./configure\[\d+\]: \S+_\S+: not found}
347 or m{./configure\[\d+\]: .*unexpected}
348 or m{does not appear in AM_CONDITIONAL$}
350 warn "Need to check configure source: $reason\n";
353 if ( m{^configure: error:} ) {
354 $check_config_log = 1 unless defined $check_config_log;
357 if ( m{^CMake Error at (?:\S+/)?(\S+?)\.cmake:(\d+) } ) {
358 my ( $module, $line ) = ( lc $1, $2 );
360 if ( $module eq "findqt4" ) {
363 if ( $l =~ /qmake/ ) {
364 add_br( "qt4-qmake", $l );
365 } elsif ( $l =~ /rcc/ ) {
366 add_br( "qt4-build", $l );
367 } elsif ( $l =~ /Could NOT find (Qt\S+) header/ ) {
368 add_br( "$1-devel", $l );
370 warn "unrecognized Qt requirement: $l\n";
372 } elsif ( $module eq "cmakedeterminecxxcompiler" ) {
373 add_br( "libstdc++-devel",
374 '"try: -DCMAKE_CXX_COMPILER_WORKS=1 -DCMAKE_CXX_COMPILER="%{__cc}"' );
375 } elsif ( $br = $cmake2br{ $module . ":" . $line } ) {
377 } elsif ( $br = $cmake2br{ $module } ) {
379 } elsif ( $br = guess_package( $module =~ /find(.+)/ ) ) {
383 warn "Unrecognized cmake error: $reason\n";
386 if ( m{^\s*ERROR: (?:\S+/)?(\S+?\.cmake) not found} ) {
388 warn "Looking for cmake file: $cmake\n";
389 poldek_file( "/usr/*/cmake/*/$cmake" )
391 if ( $cmake_get_call ) {
392 if ( m{^\s*/\S+/(\S+)\.cmake:(\d+) } ) {
393 my ( $module, $line ) = ( lc $1, $2 );
395 if ( $br = $cmake2br{ $module . ":" . $line } ) {
398 } elsif ( $br = $cmake2br{ $module } ) {
401 } elsif ( $br = guess_package( $module =~ /find(.+)/ ) ) {
407 if ( m{^-- WARNING: you are using the obsolete 'PKGCONFIG' macro} ) {
408 add_br( "pkgconfig" );
410 if ( m{QT_(QT\S+)_LIBRARY \(ADVANCED\)}
411 or m{X11_(\S+)_LIB \(ADVANCED\)}
412 or m{Qt (\S+) library not found} ) {
414 my $pkg = guess_package( $find );
418 warn "Cannot quess qt package: $find\n";
422 if ( m{^-- The following OPTIONAL packages could NOT be located on your system} ) {
425 if ( $cmake_pkg_list ) {
426 if ( /\s+\* (\S+) / ) {
428 my $pkg = guess_package( $find );
432 warn "Cannot quess optional package: $find\n";
434 } elsif ( /^\s*$/ ) {
439 if ( m{^configure:\d+: checking for (?:"(\S+)"|(\S+))$} ) {
441 if ( @lines and $lines[0] =~ m{^configure:\d+: result: no$} ) {
442 next if $exec eq "hostname";
443 warn "Looking for executable $exec\n";
444 poldek_file( $exec ) if $exec =~ m#^/#;
445 poldek_file( "/usr/bin/$exec", "/bin/$exec" );
454 return unless /^configure(\.(?:ac|in|in\.in))?$/;
457 warn "$File::Find::name\n";
462 if ( m{^\s*([A-Za-z0-9_]+)\s*(\(.*)?$} ) {
464 if ( my $br = $ac2br{ $def } ) {
465 add_br( $br, "$file: $_" );
466 } elsif ( $def !~ /^A[CM]_/ and $def =~ /^_?[A-Z]+_[A-Z_0-9a-z]+$/ ) {
467 #warn "Possible macro unrecognized: $def [[[$_]]]\n";
476 find( \&wanted, $builddir );
481 return unless /^config\.log$/;
484 warn "$File::Find::name\n";
490 if ( $check_config_log ) {
491 $check_config_log = 0;
492 find( \&wanted2, $builddir );
493 goto start_check if @lines;
496 foreach my $pkg ( sort keys %out ) {
497 print "$pkg -- $out{$pkg}\n";