]> git.pld-linux.org Git - projects/cleanbuild.git/blob - findbr
Add instructions how to cleanup docker images
[projects/cleanbuild.git] / findbr
1 #!/usr/bin/perl
2
3 use strict;
4 use warnings;
5 use IPC::Open2;
6 use Cwd;
7 use constant DOCKER => -e '/.dockerenv';
8
9 my $pwd = getcwd();
10 # how to run poldek
11 my @ignore = qw(vserver-packages python-devel-src);
12 my @poldek;
13 if (DOCKER) {
14         push(@poldek, qw[poldek]);
15 } else {
16         push(@poldek, qw[sudo poldek -n th-x86_64-ready],
17                 "--cachedir=$pwd/poldekcache",
18                 "--conf=$pwd/poldekconf/poldek.conf",
19         );
20 }
21 push(@poldek, (
22         "--skip-installed",
23         "-O", "ignore=" . (join " ", @ignore)
24 ));
25
26 # if multiple packages provide some funcionality those will be selected:
27 my %preferred = (
28         "automake" => +1,
29         "autoconf" => +1,
30         "pkgconfig" => +1,
31
32         "python" => +1,
33         "python-modules" => +1,
34         "python-setuptools" => +1,
35
36         "perl-modules" => +1,
37         "perl-Encode" => +2,
38
39         "zlib-devel" => +1,
40         "libstdc++-devel" => +1,
41         "libusb-compat-devel" => +1,
42         "libjpeg-devel" => +1,
43         "libpng-devel" => +1,
44         "libsamplerate-devel" => +1,
45         "pulseaudio-devel" => +1,
46         "xorg-lib-libXrandr-devel" => +1,
47         "sqlite-devel" => +1,
48
49         "ice-devel" => -1,
50 );
51
52 # translate package name to provides name
53 my %translate = (
54         "gcc-c++" => "libstdc++-devel",
55         "rarian-compat" => "scrollkeeper",
56         "Mesa-libGL" => "OpenGL",
57         "Mesa-libGL-devel" => "OpenGL-devel",
58         "Mesa-libGLU-devel" => "OpenGL-GLU-devel",
59 );
60
61 my @skip = qw(hostname git svn svnversion mt gawk);
62 my %skip;
63 @skip{ @skip } = (1) x scalar @skip;
64
65 # for m4 in *.m4; do R=$(rpm -qf $m4); R=${R%-*-*}; \
66 #   awk -vr=$R '/^\s*(AC_DEFUN|AU_ALIAS)/ { gsub(/\].*/,""); gsub(/.*\[/,""); print r " " $0}' $m4; \
67 # done | sort | awk '{print "\t\"" $2 "\" => \"" $1 "\","}'
68 my %ac2br = do (DOCKER ? './cleanbuild/findbr-ac2br' : './findbr-ac2br');
69
70 my %cmake2br = (
71         "findkde4:44" => "kde4-kdelibs",
72         "findmsgfmt" => "gettext-tools",
73         "findpythoninterp" => "python",
74 );
75
76 BEGIN {
77         $SIG{__WARN__} = sub
78         {
79                 local $_ = shift;
80                 chomp;
81                 print STDERR "\033[31;1m" . $_ . "\033[0m\n"
82         };
83 }
84
85 my $builddir = shift @ARGV;
86 my @lines = <ARGV>;
87
88 my $reason;
89
90 my %out;
91 sub add_br
92 {
93         my $pkg = shift;
94         my $msg = shift || $reason;
95         if ( ref $pkg ) {
96                 foreach my $p ( @$pkg ) {
97                         add_br( $p, $msg );
98                 }
99                 return;
100         }
101
102         $msg =~ s/\n/ # /sg;
103
104         $pkg = $translate{ $pkg } || $pkg;
105
106         return if exists $out{ $pkg };
107         $out{ $pkg } = $msg;
108         print STDERR "\033[33;1madding: $pkg => $msg\033[0m\n";
109 }
110
111 sub poldek_cmd
112 {
113         my $cmd = shift;
114
115         warn "Poldek: $cmd\n";
116
117         my @cmd = (@poldek, "--shcmd=".$cmd);
118         open my $fh, '-|', @cmd or die "$!: @cmd";
119         my @read = <$fh>;
120         close $fh or die $!;
121
122         return wantarray ? @read : \@read;
123 }
124
125 my $check_ac = 0;
126 my $check_config_log = undef;
127 my $check_mkmf_log = undef;
128
129 my %checked_files;
130 sub poldek_file
131 {
132         my @files;
133         foreach ( @_ ) {
134                 next if $checked_files{ $_ };
135                 $checked_files{ $_ } = 1;
136                 push @files, $_;
137         }
138         return unless @files;
139
140         my $search = join "; ", map "search -f $_", @files;
141         warn "Reason: $reason\n";
142         my @read = poldek_cmd( $search );
143
144         local $_;
145         my @found;
146         while ( $_ = shift @read ) {
147                 if ( /(\d+) package\(s\) found:$/ ) {
148                         foreach my $i ( 1..$1 ) {
149                                 $_ = shift @read;
150                                 chomp;
151                                 $_ =~ /^(.*)-.*?-.*?$/;
152                                 push @found, $1;
153                         }
154                 }
155         }
156
157         return unless @found;
158
159         my $found = $found[0];
160         if ( @found > 1 ) {
161                 my $i = 0.0;
162                 my %pts = map { ( $_ => ( ($i += 0.001) + ( $preferred{ $_ } || 0 ) ) ) }
163                         reverse @found;
164                 my @pref = sort { $pts{$b} <=> $pts{$a} } @found;
165                 my $pref = join ", ", map "$_ => $pts{$_}", @pref;
166                 warn "Multiple found: $pref\n";
167                 $found = $pref[0];
168         }
169
170         $found = $translate{ $found } if $translate{ $found };
171
172         add_br( $found );
173 }
174
175 my $pkglist;
176 sub get_pkglist
177 {
178         my %pkglist;
179         my $read = poldek_cmd( "ls" );
180         foreach ( @$read ) {
181                 chomp;
182                 next unless /(\S+)-.*?-.*?\.[a-z0-9_]+$/;
183                 my $pkg = $1;
184                 $pkglist{ lc $pkg } = $pkg;
185         }
186         $pkglist = \%pkglist;
187 }
188
189 sub guess_package
190 {
191         my $origname = shift;
192         get_pkglist() unless $pkglist;
193         return unless defined $origname;
194         my $name = lc $origname;
195         my @try = (
196                 "lib$name-devel",
197                 "$name-devel",
198                 "$name",
199                 "lib$name-.*-devel",
200                 "$name-.*-devel",
201                 ".*-lib$name-devel",
202                 ".*-$name-devel",
203                 ".*-lib$name-.*-devel",
204                 ".*-$name-.*-devel",
205         );
206         my @select;
207         for my $k ( keys %$pkglist ) {
208                 if ( $k =~ /$name/ ) {
209                         push @select, $k;
210                 }
211         }
212         @select = sort @select;
213
214         foreach my $try ( @try ) {
215                 foreach my $pkg ( @select ) {
216                         if ( $pkg =~ /^$try$/ ) {
217                                 warn "guessed: $origname => $pkglist->{ $pkg }\n";
218                                 return $pkglist->{ $pkg };
219                         }
220                 }
221         }
222         warn "$origname not guessed\n";
223         return undef;
224 }
225
226 start_check:
227
228 my %checked;
229 my $cmake_get_call = 0;
230 my $cmake_pkg_list = 0;
231 my $py_ver = undef;
232 while ( $_ = shift @lines ) {
233         chomp;
234         #next if $checked{ $_ };
235         #$checked{ $_ } = 1;
236
237         # try to extract current python version from setup.py run
238         if (m{^copying .+ -> build-(\d+)/lib/}) {
239                 $py_ver = $1;
240                 warn "py_ver set to '$py_ver'\n";
241         }
242
243         $reason = $_;
244         if ( /^\S+: (\S+): (?:Command )?not found$/ or /.*configure\[\d+\]: (\S+): not found$/
245                         or m{which: no (\S+) in \(.*/bin.*\)}
246                         or m{\S+: (\S+): command not found$}
247                         or m{(?:/usr/bin/)?env: (\S+): No such file or directory}
248                         or m{flock: (\S+): No such file or directory}
249                         or m{Can't exec "(\S+)": No such file or directory} ) {
250                 my $exec = $1;
251                 $exec = $1 if $exec =~ m{^"(.*)"$};
252                 next if $skip{ $exec };
253                 warn "Looking for executable $exec\n";
254                 if ( $exec =~ m#^/# ) {
255                         poldek_file( $exec );
256                 }
257                 poldek_file( "/usr/bin/$exec", "/bin/$exec" );
258         }
259
260         if ( /\S+\.[ch](?:pp|xx|c)?:\d+:\d+: error: (\S+): No such file or directory$/ or
261                 /\S+\.[ch](?:pp|xx|c)?:\d+:\d+: fatal error: (\S+): No such file or directory$/ or
262                 /Can't find the '(\S+\.h)'? header/
263         ) {
264                 my $h = $1;
265                 warn "Looking for C(++) header $h\n";
266                 poldek_file( "/usr/include*/$h" );
267         }
268
269         if (m{^ImportError: No module named (\S+)$}
270                 or m{^ERROR: Cannot find .+: No module named (\S+)$}
271                 or m{^ERROR: Failed to import the ".+" module: No module named (\S+)$}
272                 or m{^distutils.errors.DistutilsError: Could not find suitable distribution for Requirement.parse\('([^'>=]+).*'\)}
273                 or                           m{^error: Could not find suitable distribution for Requirement.parse\('([^'>=]+).*'\)}
274                 or m{^Couldn't find index page for '(\S+)'}
275                 ) {
276                 my $mod = $1;
277                 $mod =~ s#\.#/#g;
278                 warn "Looking for Python$py_ver module $mod\n";
279                 poldek_file(
280                                 "/usr/share/python$py_ver*/site-packages/$mod/__init__.py*",
281                                 "/usr/share/python$py_ver*/$mod/__init__.py*",
282                                 "/usr/share/python$py_ver*/site-packages/$mod.py*",
283                                 "/usr/share/python$py_ver*/$mod.py*",
284                                 "/usr/lib*/python$py_ver*/site-packages/$mod/__init__.py*",
285                                 "/usr/lib*/python$py_ver*/$mod/__init__.py*",
286                                 "/usr/lib*/python$py_ver*/site-packages/$mod.py*",
287                                 "/usr/lib*/python$py_ver*/$mod.py*",
288                                 "/usr/lib*/python$py_ver*/site-packages/_$mod.so",
289                                 "/usr/lib*/python$py_ver*/_$mod.so",
290                                 "/usr/lib*/python$py_ver*/site-packages/$mod.so",
291                                 "/usr/lib*/python$py_ver*/$mod.so",
292                 );
293         }
294
295         if (
296                 m{^-- Could NOT find Sphinx \(missing:  SPHINX_EXECUTABLE\)}
297         ) {
298                 add_br("sphinx-pdg");
299                 next;
300         }
301
302         if (
303                 m{^You need to install the (\S+) module} or
304                 m{\*\*\*Error\*\*\*: You must have (\S+) >= (\S+) installed}
305         ) {
306                 add_br($1);
307                 next;
308         }
309
310         if (
311                 m{^cannot load such file -- (\S+)} or
312                 m{in `require': cannot load such file -- (\S+) \(LoadError\)}
313         ) {
314                 my $mod = $1;
315                 warn "Looking for ruby module $mod\n";
316                 poldek_file(
317                         "/usr/share/ruby/*/$mod.rb",
318                         "/usr/share/ruby/vendor_ruby/*/$mod.rb",
319                         "/usr/lib64/ruby/vendor_ruby/*/$mod.so",
320                 );
321         }
322
323         if ( /configure(?:\.in|\.ac)?:\d+: error: possibly undefined macro: (\S+)/
324                         or m{configure(?:\.in|\.ac)?:\d+: error: m4 macro `(\S+)' is not defined}
325                         or m{warning: macro `(\S+)' not found in library} ) {
326                 my $macro = $1;
327                 warn "Looking for autotools macro $macro\n";
328                 if ( my $br = $ac2br{ $macro } ) {
329                         add_br( $br );
330                         next;
331                 } else {
332                         $check_ac = 1;
333                 }
334         }
335         if ( /^No package '(\S+)' found$/ or
336                         /Package (\S+) was not found in the pkg-config search path/
337                                 or m{None of the required '(\S+?)(?:[<>=].*)?' found}
338                                 or m{--\s+package '(\S+?)(?:[<>=].*)?' not found}
339                                 or m{ERROR: cannot find a valid pkg-config package for \['(\S+?)(?:[<>=].*)?'\]}
340                 ) {
341                 my $pkg = $1;
342                 warn "Looking for package $pkg\n";
343                 poldek_file( "/usr/lib*/pkgconfig/$pkg.pc", "/usr/share/pkgconfig/$pkg.pc" );
344         }
345
346         if (/^ocamlfind: Package `(\S+)' not found - required by/
347                 or m{Camlp4: Uncaught exception: DynLoader.Error \("(\S+)", "file not found in path"\)}
348                 ) {
349                 my $pkg = $1;
350                 warn "Looking for ocaml package $pkg\n";
351                 poldek_file( "/usr/lib*/ocaml/*/$pkg.a", "/usr/lib*/ocaml/*/$pkg");
352         }
353
354         if ( m{^cp: cannot stat `(/.*)': No such file or directory$} ) {
355                 my $f = $1;
356                 warn "Looking for file $f\n";
357                 poldek_file( $f );
358         }
359
360         if ( m{ERROR: Could not find KDE4 (kde4-config)}) {
361                 my $f = "/usr/bin/$1";
362                 warn "Looking for file $f\n";
363                 poldek_file( $f );
364         }
365
366         if (m{Ragel State Machine Compiler not found}) {
367                 add_br( "ragel" );
368                 next;
369         }
370
371         if (m{ERROR: CMake is required to build}) {
372                 add_br("cmake");
373                 next;
374         }
375
376         # lucky guessing
377         if (m{'yum install (\S+)'}) {
378                 add_br($1);
379                 next;
380         }
381
382         if ( m{^find-lang.sh: Error: international files not found for '}
383                         or m{ gettext tools not found}
384                         ) {
385                 add_br( "gettext-tools" );
386                 next;
387         }
388
389         if ( m{ pkg-config .*not .*found}
390                 or m{^checking for pkg-config\.\.\. no}
391                 or m{^pkg-config unavailable, build terminated}
392                 or m{^\*\*\*Error\*\*\*: You must have pkg-config >= .* installed}
393                 or m{^-- Could NOT find PkgConfig \(missing:  PKG_CONFIG_EXECUTABLE\)}
394                 or m{exec: "pkg-config": executable file not found in \$PATH}
395         ) {
396                 add_br( "pkgconfig" );
397                 next;
398         }
399
400         if ( m{Can't locate (.*?\.pm) in \@INC} ) {
401                 my $mod = $1;
402                 warn "Looking for perl module $mod\n";
403                 poldek_file( "/usr/lib*/perl*/$mod", "/usr/share/perl*/$mod" );
404         }
405
406         if (
407                 m{^(?:/usr/bin/ld: )?cannot find -l(.*?)$}
408         ) {
409                 my $lib = $1;
410                 warn "Looking for library $lib\n";
411                 poldek_file( "/usr/lib64/lib$lib.so", "/usr/lib/lib$lib.so",
412                         "/usr/lib*/lib$lib.so" );
413         }
414
415         # full path to ldd files
416         if (
417                 m{^WARNING; can.*t resolve .* dependency: (.*?)$}
418         ) {
419                 my $lib = $1;
420                 warn "Looking for library '$lib'\n";
421                 poldek_file( "/usr/lib64/$lib", "/usr/lib/$lib", "/lib64/$lib", "/lib/$lib");
422         }
423
424         if ( m{^error: Couldn't exec (/\S+): No such file or directory$}
425                         or m{^Can't open perl script "(/\S+)": No such file or directory$}
426                         or m{unable to open (/\S+) \(No such file or directory\)$}
427                         or m{GConf-CRITICAL \*\*: No such file `(/.\S+?)'$}
428                         or m{make.*: \*\*\* No rule to make target `(/\S+)'}
429                         or m{g(?:cc|\+\+): (/\S+): No such file or directory$}
430                         or m{env: (/\S+): No such file or directory$}
431                         ) {
432                 my $file = $1;
433                 warn "Looking for file $file\n";
434                 poldek_file( $file );
435         }
436
437         if ( m{^ValueError: Couldn't find include '(.*\.gir)'} ) {
438                 my $file = $1;
439                 warn "Looking for gir file $file\n";
440                 poldek_file( "/usr/share/gir-1.0/" . $file );
441         }
442
443         if ( m{^error: Package `(\S+)' not found in specified Vala API directories or GObject-Introspection GIR directories}
444         ) {
445                 my $file = $1;
446                 warn "Looking for gir file $file\n";
447                 poldek_file( "/usr/share/vala/vapi/$file.vapi");
448         }
449
450         if ( m{failed.*http://www\.oasis-open\.org/docbook/xml/([\d\.]+/\S+\.dtd)} ) {
451                 my $dtd = $1;
452                 warn "Looking for docbook file $dtd\n";
453                 poldek_file( "/usr/share/sgml/docbook/xml-dtd-$dtd" );
454         }
455         if ( m{http://docbook.sourceforge.net/release/xsl/current/(\S+\.xsl)} ) {
456                 my $db = $1;
457                 next if m{^\s*(/usr/bin/)?xsltproc };
458                 warn "Looking for docbook file $db\n";
459                 poldek_file( "/usr/share/sgml/*/$db" );
460         }
461         if (m{Could not find HTML docbook.xsl}) {
462                 add_br("docbook-style-xsl");
463         }
464
465         if ( m{LaTeX Error: File `(\S+)' not found} ) {
466                 my $tex = $1;
467                 warn "Looking for tex file $tex\n";
468                 poldek_file( "/usr/share/tex*/$tex" );
469         }
470         if ( m{mv: cannot move `\S+' to `(/var/lib/texmf.*?)':} ) {
471                 my $tex = $1;
472                 warn "Looking for tex file $tex\n";
473                 poldek_file( $tex );
474         }
475
476         if ( m{configure: error: C\+\+ preprocessor "/lib/cpp" fails sanity check} ) {
477                 add_br( "gcc-c++", "try: %undefine\t__cxx" );
478         }
479         if ( m{configure: error: C\+\+ compiler cannot create executables} ) {
480                 add_br( "libstdc++-devel", "maybe try: %undefine\t__cxx" );
481         }
482         if ( m{ccache: error: Could not find compiler ".+-g\+\+" in PATH}) {
483                 add_br("libstdc++-devel");
484         }
485         if ( m{configure: error: XML::Parser perl module is required for intltool} ) {
486                 add_br( "perl-XML-Parser" );
487         }
488         if ( m{iconv: conversion from `\S+' is not supported} ) {
489                 add_br( "iconv" );
490         }
491
492         if (m{rst2man \(python-docutils\) is required to build man pages}) {
493                 add_br("docutils");
494         }
495
496         if ( m{ (\S+) does not appear in AM_CONDITIONAL$} ) {
497                 my $macro = $1;
498                 warn "Looking for autotools macro $macro\n";
499                 if ( my $br = $ac2br{ $macro } ) {
500                         add_br( $br );
501                         next;
502                 } else {
503                         $check_ac = 1;
504                 }
505         }
506
507         if ( m{configure\[\d+\]: syntax error: }
508                         or m{\./configure\[\d+\]: \S+_\S+: not found}
509                         or m{./configure\[\d+\]: .*unexpected}
510                         or m{does not appear in AM_CONDITIONAL$}
511                         ) {
512                 warn "Need to check configure source: $reason\n";
513                 $check_ac = 1;
514         }
515         if ( m{^configure: error:} ) {
516                 $check_config_log = 1 unless defined $check_config_log;
517         }
518
519         if ( m{Check the mkmf.log file for more details} ) {
520                 $check_mkmf_log = 1 unless defined $check_mkmf_log;
521         }
522
523         if ( m{^CMake (?:Error|Warning) at (?:\S+/)?(\S+?)\.cmake:(\d+) } ) {
524                 my ( $module, $line ) = ( lc $1, $2 );
525                 my $br;
526                 if ( $module eq "findqt4" ) {
527                         my $l = $lines[0];
528                         chomp $l;
529                         if ( $l =~ /qmake/ ) {
530                                 add_br( "qt4-qmake", $l );
531                         } elsif ( $l =~ /rcc/ ) {
532                                 add_br( "qt4-build", $l );
533                         } elsif ( $l =~ /Could NOT find (Qt\S+) header/ ) {
534                                 add_br( "$1-devel", $l );
535                         } else {
536                                 warn "unrecognized Qt requirement: $l\n";
537                         }
538                 } elsif ( $module eq "qt5coreconfig" ) {
539                         my $l = $lines[2];
540                         chomp $l;
541                         if ( $l =~ /qmake/ ) {
542                                 add_br( "qt5-qmake", $l );
543                         } elsif ( $l =~ /moc/) {
544                                 add_br( "qt5-build", $l );
545                         } else {
546                                 warn "Unrecognized Qt requirement: $l\n";
547                         }
548                 } elsif ( $module eq "cmakedeterminecxxcompiler" ) {
549                         add_br( "libstdc++-devel",
550                                 '"try: -DCMAKE_CXX_COMPILER_WORKS=1 -DCMAKE_CXX_COMPILER="%{__cc}"' );
551                 } elsif ( $br = $cmake2br{ $module . ":" . $line } ) {
552                         add_br( $br );
553                 } elsif ( $br = $cmake2br{ $module } ) {
554                         add_br( $br );
555                 } elsif ( $br = guess_package( $module =~ /find(.+)/ ) ) {
556                         add_br( $br );
557                 } else {
558                         $cmake_get_call = 1;
559                         warn "Unrecognized cmake error: $reason\n";
560                 }
561         }
562
563         if ( m{^CMake Error at (?:\S+/)?(\S+?):(\d+) \(find_package\):} ) {
564                 my ($file, $line) = (lc $1, $2);
565
566                 #CMake Error at CMakeLists.txt:29 (find_package):
567                 #  Could not find a package configuration file provided by "LLVM" with any of the following names:
568                 #
569                 #    LLVMConfig.cmake
570                 #    llvm-config.cmake
571                 my @files = grep { /\.cmake$/ } @lines;
572                 my @find = map { chomp; s/^\s+//; "/usr/*/cmake/*/$_" } @files;
573                 poldek_file(@find);
574         }
575
576         if ( m{^\s*ERROR: (?:\S+/)?(\S+?\.cmake) not found} ) {
577                 my $cmake = $1;
578                 warn "Looking for cmake file: $cmake\n";
579                 poldek_file( "/usr/*/cmake/*/$cmake" )
580         }
581         if ( $cmake_get_call ) {
582                 if ( m{^\s*/\S+/(\S+)\.cmake:(\d+) } ) {
583                         my ( $module, $line ) = ( lc $1, $2 );
584                         my $br;
585                         if ( $br = $cmake2br{ $module . ":" . $line } ) {
586                                 add_br( $br );
587                                 $cmake_get_call = 0;
588                         } elsif ( $br = $cmake2br{ $module } ) {
589                                 add_br( $br );
590                                 $cmake_get_call = 0;
591                         } elsif ( $br = guess_package( $module =~ /find(.+)/ ) ) {
592                                 add_br( $br );
593                                 $cmake_get_call = 0;
594                         }
595                 } elsif (m{Can not use "(.+)" module which has not yet been found}
596                         or m{Could not find a package configuration file provided by "(.+)"}) {
597                         my $cmake = $1;
598
599                         warn "Looking for cmake file: $cmake\n";
600                         poldek_file(
601                                 "/usr/*/cmake/*/$cmake.cmake",
602                                 "/usr/*/cmake/*/${cmake}Config.cmake",
603                                 "/usr/*/cmake/*/${cmake}-config.cmake",
604                         );
605                         $cmake_get_call = 0;
606                 }
607         }
608         if ( m{^-- WARNING: you are using the obsolete 'PKGCONFIG' macro} ) {
609                 add_br( "pkgconfig" );
610         }
611         if ( m{QT_(QT\S+)_LIBRARY \(ADVANCED\)}
612                         or m{X11_(\S+)_LIB \(ADVANCED\)}
613                         or m{Qt (\S+) library not found} ) {
614                 my $find = $1;
615                 my $pkg = guess_package( $find );
616                 if ( $pkg ) {
617                         add_br( $pkg );
618                 } else {
619                         warn "Cannot quess qt package: $find\n";
620                 }
621         }
622
623         if ( m{Unable to find a javac compiler;$} ) {
624                 add_br( "jdk" );
625         }
626         if ( m{Could not find (\S+) Java extension for this JVM$} ) {
627                 my $jar = $1;
628                 warn "Looking for jar file: $jar\n";
629                 poldek_file( "/usr/share/java/$jar.jar", "*/$jar.jar" )
630         }
631
632
633         if ( m{^-- The following OPTIONAL packages could NOT be located on your system} ) {
634                 $cmake_pkg_list = 1;
635         }
636         if ( $cmake_pkg_list ) {
637                 if ( /\s+\* (\S+) / ) {
638                         my $find = $1;
639                         my $pkg = guess_package( $find );
640                         if ( $pkg ) {
641                                 add_br( $pkg );
642                         } else {
643                                 warn "Cannot quess optional package: $find\n";
644                         }
645                 } elsif ( /^\s*$/ ) {
646                         $cmake_pkg_list = 0;
647                 }
648         }
649
650         if (m{By not providing "Find(.+)\.cmake" in CMAKE_MODULE_PATH}
651                 or m{Could not find a package configuration file provided by "(.+)"
652                 }) {
653                 my $cmake = $1;
654                 my $lcmake = lc $cmake;
655
656                 warn "Looking for cmake file: $cmake\n";
657                 poldek_file(
658                         "/usr/*/cmake/*/$cmake.cmake",
659                         "/usr/*/cmake/*/${cmake}Config.cmake",
660                         "/usr/*/cmake/*/${cmake}-config.cmake",
661                         "/usr/*/cmake/*/${lcmake}Config.cmake",
662                         "/usr/*/cmake/*/${lcmake}-config.cmake",
663                 )
664         }
665
666         if ( m{^configure:\d+: checking for (?:"(\S+)"|(\S+))$} ) {
667                 my $exec = $1 || $2;
668                 if ( @lines and $lines[0] =~ m{^configure:\d+: result: no$} ) {
669                         next if $skip{ $exec };
670                         warn "Looking for executable $exec\n";
671                         poldek_file( $exec ) if $exec =~ m#^/#;
672                         poldek_file( "/usr/bin/$exec", "/bin/$exec" );
673                 }
674         }
675
676
677         if (
678                 m{Could not find (\S+)}
679         ) {
680                 my $exec = $1;
681                 poldek_file("/usr/bin/$exec", "/bin/$exec" );
682         }
683 }
684
685
686
687 sub find_configure
688 {
689         return unless /^configure(\.(?:ac|in|in\.in))?$/;
690         return unless -r;
691
692         warn "$File::Find::name\n";
693         open F_IN, "<", $_;
694         my $file = $_;
695         while ( <F_IN> ) {
696                 chomp;
697                 if ( m{^\s*([A-Za-z0-9_]+)\s*(\(.*)?$} ) {
698                         my $def = $1;
699                         if ( my $br = $ac2br{ $def } ) {
700                                 add_br( $br, "$file: $_" );
701                         } elsif ( $def !~ /^A[CM]_/ and $def =~ /^_?[A-Z]+_[A-Z_0-9a-z]+$/ ) {
702                                 #warn "Possible macro unrecognized: $def [[[$_]]]\n";
703                         }
704                 }
705         }
706         close F_IN;
707 }
708
709 use File::Find;
710 if ( $check_ac ) {
711         find( \&find_configure, $builddir );
712 }
713
714 sub find_config_log
715 {
716         return unless /^config\.log$/;
717         return unless -r;
718
719         warn "$File::Find::name\n";
720         open F_IN, "<", $_;
721         push @lines, <F_IN>;
722         close F_IN;
723 }
724
725 if ( $check_config_log ) {
726         $check_config_log = 0;
727         find( \&find_config_log, $builddir );
728         goto start_check if @lines;
729 }
730
731 if ($check_mkmf_log) {
732         $check_mkmf_log = 0;
733         find(sub {
734                 return unless /^mkmf\.log$/;
735                 return unless -r;
736
737                 warn "$File::Find::name\n";
738                 open F_IN, "<", $_;
739                 push @lines, <F_IN>;
740                 close F_IN;
741         }, $builddir);
742         goto start_check if @lines;
743 }
744
745 foreach my $pkg ( sort keys %out ) {
746         print "$pkg -- $out{$pkg}\n";
747 }
748 # vim: ts=4 sw=4
This page took 0.086958 seconds and 3 git commands to generate.