7 use constant DOCKER => -e '/.dockerenv';
11 my @ignore = qw(vserver-packages python-devel-src);
14 push(@poldek, qw[poldek]);
16 push(@poldek, qw[sudo poldek -n th-x86_64-ready],
17 "--cachedir=$pwd/poldekcache",
18 "--conf=$pwd/poldekconf/poldek.conf",
23 "-O", "ignore=" . (join " ", @ignore)
26 # if multiple packages provide some funcionality those will be selected:
33 "python-modules" => +1,
34 "python-setuptools" => +1,
40 "libstdc++-devel" => +1,
41 "libusb-compat-devel" => +1,
42 "libjpeg-devel" => +1,
44 "libsamplerate-devel" => +1,
45 "pulseaudio-devel" => +1,
46 "xorg-lib-libXrandr-devel" => +1,
52 # translate package name to provides name
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",
61 my @skip = qw(hostname git svn svnversion mt gawk);
63 @skip{ @skip } = (1) x scalar @skip;
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');
71 "findkde4:44" => "kde4-kdelibs",
72 "findmsgfmt" => "gettext-tools",
73 "findpythoninterp" => "python",
81 print STDERR "\033[31;1m" . $_ . "\033[0m\n"
85 my $builddir = shift @ARGV;
94 my $msg = shift || $reason;
96 foreach my $p ( @$pkg ) {
104 $pkg = $translate{ $pkg } || $pkg;
106 return if exists $out{ $pkg };
108 print STDERR "\033[33;1madding: $pkg => $msg\033[0m\n";
115 warn "Poldek: $cmd\n";
117 my @cmd = (@poldek, "--shcmd=".$cmd);
118 open my $fh, '-|', @cmd or die "$!: @cmd";
122 return wantarray ? @read : \@read;
126 my $check_config_log = undef;
133 next if $checked_files{ $_ };
134 $checked_files{ $_ } = 1;
137 return unless @files;
139 my $search = join "; ", map "search -f $_", @files;
140 warn "Reason: $reason\n";
141 my @read = poldek_cmd( $search );
145 while ( $_ = shift @read ) {
146 if ( /(\d+) package\(s\) found:$/ ) {
147 foreach my $i ( 1..$1 ) {
150 $_ =~ /^(.*)-.*?-.*?$/;
156 return unless @found;
158 my $found = $found[0];
161 my %pts = map { ( $_ => ( ($i += 0.001) + ( $preferred{ $_ } || 0 ) ) ) }
163 my @pref = sort { $pts{$b} <=> $pts{$a} } @found;
164 my $pref = join ", ", map "$_ => $pts{$_}", @pref;
165 warn "Multiple found: $pref\n";
169 $found = $translate{ $found } if $translate{ $found };
178 my $read = poldek_cmd( "ls" );
181 next unless /(\S+)-.*?-.*?\.[a-z0-9_]+$/;
183 $pkglist{ lc $pkg } = $pkg;
185 $pkglist = \%pkglist;
190 my $origname = shift;
191 get_pkglist() unless $pkglist;
192 return unless defined $origname;
193 my $name = lc $origname;
202 ".*-lib$name-.*-devel",
206 for my $k ( keys %$pkglist ) {
207 if ( $k =~ /$name/ ) {
211 @select = sort @select;
213 foreach my $try ( @try ) {
214 foreach my $pkg ( @select ) {
215 if ( $pkg =~ /^$try$/ ) {
216 warn "guessed: $origname => $pkglist->{ $pkg }\n";
217 return $pkglist->{ $pkg };
221 warn "$origname not guessed\n";
228 my $cmake_get_call = 0;
229 my $cmake_pkg_list = 0;
231 while ( $_ = shift @lines ) {
233 #next if $checked{ $_ };
236 # try to extract current python version from setup.py run
237 if (m{^copying .+ -> build-(\d+)/lib/}) {
239 warn "py_ver set to '$py_ver'\n";
243 if ( /^\S+: (\S+): (?:Command )?not found$/ or /.*configure\[\d+\]: (\S+): not found$/
244 or m{which: no (\S+) in \(.*/bin.*\)}
245 or m{\S+: (\S+): command not found$}
246 or m{(?:/usr/bin/)?env: (\S+): No such file or directory}
247 or m{flock: (\S+): No such file or directory}
248 or m{Can't exec "(\S+)": No such file or directory} ) {
250 $exec = $1 if $exec =~ m{^"(.*)"$};
251 next if $skip{ $exec };
252 warn "Looking for executable $exec\n";
253 if ( $exec =~ m#^/# ) {
254 poldek_file( $exec );
256 poldek_file( "/usr/bin/$exec", "/bin/$exec" );
259 if ( /\S+\.[ch](?:pp|xx|c)?:\d+:\d+: error: (\S+): No such file or directory$/ or
260 /\S+\.[ch](?:pp|xx|c)?:\d+:\d+: fatal error: (\S+): No such file or directory$/ or
261 /Can't find the '(\S+\.h)'? header/
264 warn "Looking for C(++) header $h\n";
265 poldek_file( "/usr/include*/$h" );
268 if (m{^ImportError: No module named (\S+)$}
269 or m{^ERROR: Cannot find .+: No module named (\S+)$}
270 or m{^ERROR: Failed to import the ".+" module: No module named (\S+)$}
271 or m{^distutils.errors.DistutilsError: Could not find suitable distribution for Requirement.parse\('([^'>=]+).*'\)}
272 or m{^error: Could not find suitable distribution for Requirement.parse\('([^'>=]+).*'\)}
273 or m{^Couldn't find index page for '(\S+)'}
277 warn "Looking for Python$py_ver module $mod\n";
279 "/usr/share/python$py_ver*/site-packages/$mod/__init__.py*",
280 "/usr/share/python$py_ver*/$mod/__init__.py*",
281 "/usr/share/python$py_ver*/site-packages/$mod.py*",
282 "/usr/share/python$py_ver*/$mod.py*",
283 "/usr/lib*/python$py_ver*/site-packages/$mod/__init__.py*",
284 "/usr/lib*/python$py_ver*/$mod/__init__.py*",
285 "/usr/lib*/python$py_ver*/site-packages/$mod.py*",
286 "/usr/lib*/python$py_ver*/$mod.py*",
287 "/usr/lib*/python$py_ver*/site-packages/_$mod.so",
288 "/usr/lib*/python$py_ver*/_$mod.so",
289 "/usr/lib*/python$py_ver*/site-packages/$mod.so",
290 "/usr/lib*/python$py_ver*/$mod.so",
295 m{^-- Could NOT find Sphinx \(missing: SPHINX_EXECUTABLE\)}
297 add_br("sphinx-pdg");
302 m{^You need to install the (\S+) module} or
303 m{\*\*\*Error\*\*\*: You must have (\S+) >= (\S+) installed}
310 m{^cannot load such file -- (\S+)} or
311 m{in `require': cannot load such file -- (\S+) \(LoadError\)}
314 warn "Looking for ruby module $mod\n";
316 "/usr/share/ruby/*/$mod.rb",
317 "/usr/share/ruby/vendor_ruby/*/$mod.rb",
318 "/usr/lib64/ruby/vendor_ruby/*/$mod.so",
322 if ( /configure(?:\.in|\.ac)?:\d+: error: possibly undefined macro: (\S+)/
323 or m{configure(?:\.in|\.ac)?:\d+: error: m4 macro `(\S+)' is not defined}
324 or m{warning: macro `(\S+)' not found in library} ) {
326 warn "Looking for autotools macro $macro\n";
327 if ( my $br = $ac2br{ $macro } ) {
334 if ( /^No package '(\S+)' found$/ or
335 /Package (\S+) was not found in the pkg-config search path/
336 or m{None of the required '(\S+?)(?:[<>=].*)?' found}
337 or m{--\s+package '(\S+?)(?:[<>=].*)?' not found}
338 or m{ERROR: cannot find a valid pkg-config package for \['(\S+?)(?:[<>=].*)?'\]}
341 warn "Looking for package $pkg\n";
342 poldek_file( "/usr/lib*/pkgconfig/$pkg.pc", "/usr/share/pkgconfig/$pkg.pc" );
345 if (/^ocamlfind: Package `(\S+)' not found - required by/
346 or m{Camlp4: Uncaught exception: DynLoader.Error \("(\S+)", "file not found in path"\)}
349 warn "Looking for ocaml package $pkg\n";
350 poldek_file( "/usr/lib*/ocaml/*/$pkg.a", "/usr/lib*/ocaml/*/$pkg");
353 if ( m{^cp: cannot stat `(/.*)': No such file or directory$} ) {
355 warn "Looking for file $f\n";
359 if ( m{ERROR: Could not find KDE4 (kde4-config)}) {
360 my $f = "/usr/bin/$1";
361 warn "Looking for file $f\n";
365 if (m{Ragel State Machine Compiler not found}) {
370 if (m{ERROR: CMake is required to build}) {
376 if (m{'yum install (\S+)'}) {
381 if ( m{^find-lang.sh: Error: international files not found for '}
382 or m{ gettext tools not found}
384 add_br( "gettext-tools" );
388 if ( m{ pkg-config .*not .*found}
389 or m{^checking for pkg-config\.\.\. no}
390 or m{^pkg-config unavailable, build terminated}
391 or m{^\*\*\*Error\*\*\*: You must have pkg-config >= .* installed}
392 or m{^-- Could NOT find PkgConfig \(missing: PKG_CONFIG_EXECUTABLE\)}
393 or m{exec: "pkg-config": executable file not found in \$PATH}
395 add_br( "pkgconfig" );
399 if ( m{Can't locate (.*?\.pm) in \@INC} ) {
401 warn "Looking for perl module $mod\n";
402 poldek_file( "/usr/lib*/perl*/$mod", "/usr/share/perl*/$mod" );
406 m{^(?:/usr/bin/ld: )?cannot find -l(.*?)$}
409 warn "Looking for library $lib\n";
410 poldek_file( "/usr/lib64/lib$lib.so", "/usr/lib/lib$lib.so",
411 "/usr/lib*/lib$lib.so" );
414 # full path to ldd files
416 m{^WARNING; can.*t resolve .* dependency: (.*?)$}
419 warn "Looking for library '$lib'\n";
420 poldek_file( "/usr/lib64/$lib", "/usr/lib/$lib", "/lib64/$lib", "/lib/$lib");
423 if ( m{^error: Couldn't exec (/\S+): No such file or directory$}
424 or m{^Can't open perl script "(/\S+)": No such file or directory$}
425 or m{unable to open (/\S+) \(No such file or directory\)$}
426 or m{GConf-CRITICAL \*\*: No such file `(/.\S+?)'$}
427 or m{make.*: \*\*\* No rule to make target `(/\S+)'}
428 or m{g(?:cc|\+\+): (/\S+): No such file or directory$}
429 or m{env: (/\S+): No such file or directory$}
432 warn "Looking for file $file\n";
433 poldek_file( $file );
436 if ( m{^ValueError: Couldn't find include '(.*\.gir)'} ) {
438 warn "Looking for gir file $file\n";
439 poldek_file( "/usr/share/gir-1.0/" . $file );
442 if ( m{^error: Package `(\S+)' not found in specified Vala API directories or GObject-Introspection GIR directories}
445 warn "Looking for gir file $file\n";
446 poldek_file( "/usr/share/vala/vapi/$file.vapi");
449 if ( m{failed.*http://www\.oasis-open\.org/docbook/xml/([\d\.]+/\S+\.dtd)} ) {
451 warn "Looking for docbook file $dtd\n";
452 poldek_file( "/usr/share/sgml/docbook/xml-dtd-$dtd" );
454 if ( m{http://docbook.sourceforge.net/release/xsl/current/(\S+\.xsl)} ) {
456 next if m{^\s*(/usr/bin/)?xsltproc };
457 warn "Looking for docbook file $db\n";
458 poldek_file( "/usr/share/sgml/*/$db" );
460 if (m{Could not find HTML docbook.xsl}) {
461 add_br("docbook-style-xsl");
464 if ( m{LaTeX Error: File `(\S+)' not found} ) {
466 warn "Looking for tex file $tex\n";
467 poldek_file( "/usr/share/tex*/$tex" );
469 if ( m{mv: cannot move `\S+' to `(/var/lib/texmf.*?)':} ) {
471 warn "Looking for tex file $tex\n";
475 if ( m{configure: error: C\+\+ preprocessor "/lib/cpp" fails sanity check} ) {
476 add_br( "gcc-c++", "try: %undefine\t__cxx" );
478 if ( m{configure: error: C\+\+ compiler cannot create executables} ) {
479 add_br( "libstdc++-devel", "maybe try: %undefine\t__cxx" );
481 if ( m{configure: error: XML::Parser perl module is required for intltool} ) {
482 add_br( "perl-XML-Parser" );
484 if ( m{iconv: conversion from `\S+' is not supported} ) {
488 if (m{rst2man \(python-docutils\) is required to build man pages}) {
492 if ( m{ (\S+) does not appear in AM_CONDITIONAL$} ) {
494 warn "Looking for autotools macro $macro\n";
495 if ( my $br = $ac2br{ $macro } ) {
503 if ( m{configure\[\d+\]: syntax error: }
504 or m{\./configure\[\d+\]: \S+_\S+: not found}
505 or m{./configure\[\d+\]: .*unexpected}
506 or m{does not appear in AM_CONDITIONAL$}
508 warn "Need to check configure source: $reason\n";
511 if ( m{^configure: error:} ) {
512 $check_config_log = 1 unless defined $check_config_log;
515 if ( m{^CMake (?:Error|Warning) at (?:\S+/)?(\S+?)\.cmake:(\d+) } ) {
516 my ( $module, $line ) = ( lc $1, $2 );
518 if ( $module eq "findqt4" ) {
521 if ( $l =~ /qmake/ ) {
522 add_br( "qt4-qmake", $l );
523 } elsif ( $l =~ /rcc/ ) {
524 add_br( "qt4-build", $l );
525 } elsif ( $l =~ /Could NOT find (Qt\S+) header/ ) {
526 add_br( "$1-devel", $l );
528 warn "unrecognized Qt requirement: $l\n";
530 } elsif ( $module eq "cmakedeterminecxxcompiler" ) {
531 add_br( "libstdc++-devel",
532 '"try: -DCMAKE_CXX_COMPILER_WORKS=1 -DCMAKE_CXX_COMPILER="%{__cc}"' );
533 } elsif ( $br = $cmake2br{ $module . ":" . $line } ) {
535 } elsif ( $br = $cmake2br{ $module } ) {
537 } elsif ( $br = guess_package( $module =~ /find(.+)/ ) ) {
541 warn "Unrecognized cmake error: $reason\n";
544 if ( m{^\s*ERROR: (?:\S+/)?(\S+?\.cmake) not found} ) {
546 warn "Looking for cmake file: $cmake\n";
547 poldek_file( "/usr/*/cmake/*/$cmake" )
549 if ( $cmake_get_call ) {
550 if ( m{^\s*/\S+/(\S+)\.cmake:(\d+) } ) {
551 my ( $module, $line ) = ( lc $1, $2 );
553 if ( $br = $cmake2br{ $module . ":" . $line } ) {
556 } elsif ( $br = $cmake2br{ $module } ) {
559 } elsif ( $br = guess_package( $module =~ /find(.+)/ ) ) {
563 } elsif (m{Can not use "(.+)" module which has not yet been found}
564 or m{Could not find a package configuration file provided by "(.+)"}) {
567 warn "Looking for cmake file: $cmake\n";
569 "/usr/*/cmake/*/$cmake.cmake",
570 "/usr/*/cmake/*/${cmake}Config.cmake",
571 "/usr/*/cmake/*/${cmake}-config.cmake",
576 if ( m{^-- WARNING: you are using the obsolete 'PKGCONFIG' macro} ) {
577 add_br( "pkgconfig" );
579 if ( m{QT_(QT\S+)_LIBRARY \(ADVANCED\)}
580 or m{X11_(\S+)_LIB \(ADVANCED\)}
581 or m{Qt (\S+) library not found} ) {
583 my $pkg = guess_package( $find );
587 warn "Cannot quess qt package: $find\n";
591 if ( m{Unable to find a javac compiler;$} ) {
594 if ( m{Could not find (\S+) Java extension for this JVM$} ) {
596 warn "Looking for jar file: $jar\n";
597 poldek_file( "/usr/share/java/$jar.jar", "*/$jar.jar" )
601 if ( m{^-- The following OPTIONAL packages could NOT be located on your system} ) {
604 if ( $cmake_pkg_list ) {
605 if ( /\s+\* (\S+) / ) {
607 my $pkg = guess_package( $find );
611 warn "Cannot quess optional package: $find\n";
613 } elsif ( /^\s*$/ ) {
618 # CMake Error at CMakeLists.txt:86 (find_package):
619 # By not providing "FindQt5LinguistTools.cmake" in CMAKE_MODULE_PATH this
620 # project has asked CMake to find a package configuration file provided by
621 # "Qt5LinguistTools", but CMake did not find one.
623 # Could not find a package configuration file provided by "Qt5LinguistTools"
624 # with any of the following names:
626 # Qt5LinguistToolsConfig.cmake
627 # qt5linguisttools-config.cmake
629 # Add the installation prefix of "Qt5LinguistTools" to CMAKE_PREFIX_PATH or
630 # set "Qt5LinguistTools_DIR" to a directory containing one of the above
631 # files. If "Qt5LinguistTools" provides a separate development package or
632 # SDK, be sure it has been installed.
634 #CMake Warning at /usr/lib64/cmake/Qt5Core/Qt5CoreMacros.cmake:273 (find_package):
635 # Could not find a package configuration file provided by "Qt5Network" with
636 # any of the following names:
638 # Qt5NetworkConfig.cmake
639 # qt5network-config.cmake
641 # Add the installation prefix of "Qt5Network" to CMAKE_PREFIX_PATH or set
642 # "Qt5Network_DIR" to a directory containing one of the above files. If
643 # "Qt5Network" provides a separate development package or SDK, be sure it has
645 # Can not use "Network" module which has not yet been found.
647 if (m{By not providing "Find(.+)\.cmake" in CMAKE_MODULE_PATH}
648 or m{Could not find a package configuration file provided by "(.+)"
651 my $lcmake = lc $cmake;
653 warn "Looking for cmake file: $cmake\n";
655 "/usr/*/cmake/*/$cmake.cmake",
656 "/usr/*/cmake/*/${cmake}Config.cmake",
657 "/usr/*/cmake/*/${cmake}-config.cmake",
658 "/usr/*/cmake/*/${lcmake}Config.cmake",
659 "/usr/*/cmake/*/${lcmake}-config.cmake",
663 if ( m{^configure:\d+: checking for (?:"(\S+)"|(\S+))$} ) {
665 if ( @lines and $lines[0] =~ m{^configure:\d+: result: no$} ) {
666 next if $skip{ $exec };
667 warn "Looking for executable $exec\n";
668 poldek_file( $exec ) if $exec =~ m#^/#;
669 poldek_file( "/usr/bin/$exec", "/bin/$exec" );
675 m{Could not find (\S+)}
678 poldek_file("/usr/bin/$exec", "/bin/$exec" );
686 return unless /^configure(\.(?:ac|in|in\.in))?$/;
689 warn "$File::Find::name\n";
694 if ( m{^\s*([A-Za-z0-9_]+)\s*(\(.*)?$} ) {
696 if ( my $br = $ac2br{ $def } ) {
697 add_br( $br, "$file: $_" );
698 } elsif ( $def !~ /^A[CM]_/ and $def =~ /^_?[A-Z]+_[A-Z_0-9a-z]+$/ ) {
699 #warn "Possible macro unrecognized: $def [[[$_]]]\n";
708 find( \&wanted, $builddir );
713 return unless /^config\.log$/;
716 warn "$File::Find::name\n";
722 if ( $check_config_log ) {
723 $check_config_log = 0;
724 find( \&wanted2, $builddir );
725 goto start_check if @lines;
728 foreach my $pkg ( sort keys %out ) {
729 print "$pkg -- $out{$pkg}\n";