7 use constant DOCKER => -e '/.dockerenv';
11 my @ignore = qw(vserver-packages python-devel-src);
14 push(@poldek, "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";
114 warn "Poldek: $cmd\n";
115 my $pid = open( READ, "-|", @poldek, "--shcmd=".$cmd );
120 return @read if wantarray;
125 my $check_config_log = undef;
132 next if $checked_files{ $_ };
133 $checked_files{ $_ } = 1;
136 return unless @files;
138 my $search = join "; ", map "search -f $_", @files;
139 warn "Reason: $reason\n";
140 my @read = poldek_cmd( $search );
144 while ( $_ = shift @read ) {
145 if ( /(\d+) package\(s\) found:$/ ) {
146 foreach my $i ( 1..$1 ) {
149 $_ =~ /^(.*)-.*?-.*?$/;
155 return unless @found;
157 my $found = $found[0];
160 my %pts = map { ( $_ => ( ($i += 0.001) + ( $preferred{ $_ } || 0 ) ) ) }
162 my @pref = sort { $pts{$b} <=> $pts{$a} } @found;
163 my $pref = join ", ", map "$_ => $pts{$_}", @pref;
164 warn "Multiple found: $pref\n";
168 $found = $translate{ $found } if $translate{ $found };
177 my $read = poldek_cmd( "ls" );
180 next unless /(\S+)-.*?-.*?\.[a-z0-9_]+$/;
182 $pkglist{ lc $pkg } = $pkg;
184 $pkglist = \%pkglist;
189 my $origname = shift;
190 get_pkglist() unless $pkglist;
191 return unless defined $origname;
192 my $name = lc $origname;
201 ".*-lib$name-.*-devel",
205 for my $k ( keys %$pkglist ) {
206 if ( $k =~ /$name/ ) {
210 @select = sort @select;
212 foreach my $try ( @try ) {
213 foreach my $pkg ( @select ) {
214 if ( $pkg =~ /^$try$/ ) {
215 warn "guessed: $origname => $pkglist->{ $pkg }\n";
216 return $pkglist->{ $pkg };
220 warn "$origname not guessed\n";
227 my $cmake_get_call = 0;
228 my $cmake_pkg_list = 0;
230 while ( $_ = shift @lines ) {
232 #next if $checked{ $_ };
235 # try to extract current python version from setup.py run
236 if (m{^copying .+ -> build-(\d+)/lib/}) {
238 warn "py_ver set to '$py_ver'\n";
242 if ( /^\S+: (\S+): (?:Command )?not found$/ or /.*configure\[\d+\]: (\S+): not found$/
243 or m{which: no (\S+) in \(.*/bin.*\)}
244 or m{\S+: (\S+): command not found$}
245 or m{(?:/usr/bin/)?env: (\S+): No such file or directory}
246 or m{flock: (\S+): No such file or directory}
247 or m{Can't exec "(\S+)": No such file or directory} ) {
249 $exec = $1 if $exec =~ m{^"(.*)"$};
250 next if $skip{ $exec };
251 warn "Looking for executable $exec\n";
252 if ( $exec =~ m#^/# ) {
253 poldek_file( $exec );
255 poldek_file( "/usr/bin/$exec", "/bin/$exec" );
258 if ( /\S+\.[ch](?:pp|xx|c)?:\d+:\d+: error: (\S+): No such file or directory$/ or
259 /\S+\.[ch](?:pp|xx|c)?:\d+:\d+: fatal error: (\S+): No such file or directory$/ or
260 /Can't find the '(\S+\.h)'? header/
263 warn "Looking for C(++) header $h\n";
264 poldek_file( "/usr/include*/$h" );
267 if (m{^ImportError: No module named (\S+)$}
268 or m{^ERROR: Cannot find .+: No module named (\S+)$}
269 or m{^ERROR: Failed to import the ".+" module: No module named (\S+)$}
270 or m{^distutils.errors.DistutilsError: Could not find suitable distribution for Requirement.parse\('([^'>=]+).*'\)}
271 or m{^error: Could not find suitable distribution for Requirement.parse\('([^'>=]+).*'\)}
272 or m{^Couldn't find index page for '(\S+)'}
276 warn "Looking for Python$py_ver module $mod\n";
278 "/usr/share/python$py_ver*/site-packages/$mod/__init__.py*",
279 "/usr/share/python$py_ver*/$mod/__init__.py*",
280 "/usr/share/python$py_ver*/site-packages/$mod.py*",
281 "/usr/share/python$py_ver*/$mod.py*",
282 "/usr/lib*/python$py_ver*/site-packages/$mod/__init__.py*",
283 "/usr/lib*/python$py_ver*/$mod/__init__.py*",
284 "/usr/lib*/python$py_ver*/site-packages/$mod.py*",
285 "/usr/lib*/python$py_ver*/$mod.py*",
286 "/usr/lib*/python$py_ver*/site-packages/_$mod.so",
287 "/usr/lib*/python$py_ver*/_$mod.so",
288 "/usr/lib*/python$py_ver*/site-packages/$mod.so",
289 "/usr/lib*/python$py_ver*/$mod.so",
294 m{^-- Could NOT find Sphinx \(missing: SPHINX_EXECUTABLE\)}
296 add_br("sphinx-pdg");
301 m{^You need to install the (\S+) module} or
302 m{\*\*\*Error\*\*\*: You must have (\S+) >= (\S+) installed}
309 m{^cannot load such file -- (\S+)} or
310 m{in `require': cannot load such file -- (\S+) \(LoadError\)}
313 warn "Looking for ruby module $mod\n";
315 "/usr/share/ruby/*/$mod.rb",
316 "/usr/share/ruby/vendor_ruby/*/$mod.rb",
317 "/usr/lib64/ruby/vendor_ruby/*/$mod.so",
321 if ( /configure(?:\.in|\.ac)?:\d+: error: possibly undefined macro: (\S+)/
322 or m{configure(?:\.in|\.ac)?:\d+: error: m4 macro `(\S+)' is not defined}
323 or m{warning: macro `(\S+)' not found in library} ) {
325 warn "Looking for autotools macro $macro\n";
326 if ( my $br = $ac2br{ $macro } ) {
333 if ( /^No package '(\S+)' found$/ or
334 /Package (\S+) was not found in the pkg-config search path/
335 or m{None of the required '(\S+?)(?:[<>=].*)?' found}
336 or m{--\s+package '(\S+?)(?:[<>=].*)?' not found}
337 or m{ERROR: cannot find a valid pkg-config package for \['(\S+?)(?:[<>=].*)?'\]}
340 warn "Looking for package $pkg\n";
341 poldek_file( "/usr/lib*/pkgconfig/$pkg.pc", "/usr/share/pkgconfig/$pkg.pc" );
344 if (/^ocamlfind: Package `(\S+)' not found - required by/
345 or m{Camlp4: Uncaught exception: DynLoader.Error \("(\S+)", "file not found in path"\)}
348 warn "Looking for ocaml package $pkg\n";
349 poldek_file( "/usr/lib*/ocaml/*/$pkg.a", "/usr/lib*/ocaml/*/$pkg");
352 if ( m{^cp: cannot stat `(/.*)': No such file or directory$} ) {
354 warn "Looking for file $f\n";
358 if ( m{ERROR: Could not find KDE4 (kde4-config)}) {
359 my $f = "/usr/bin/$1";
360 warn "Looking for file $f\n";
364 if (m{Ragel State Machine Compiler not found}) {
369 if (m{ERROR: CMake is required to build}) {
375 if (m{'yum install (\S+)'}) {
380 if ( m{^find-lang.sh: Error: international files not found for '}
381 or m{ gettext tools not found}
383 add_br( "gettext-tools" );
387 if ( m{ pkg-config .*not .*found}
388 or m{^checking for pkg-config\.\.\. no}
389 or m{^pkg-config unavailable, build terminated}
390 or m{^\*\*\*Error\*\*\*: You must have pkg-config >= .* installed}
391 or m{^-- Could NOT find PkgConfig \(missing: PKG_CONFIG_EXECUTABLE\)}
392 or m{exec: "pkg-config": executable file not found in \$PATH}
394 add_br( "pkgconfig" );
398 if ( m{Can't locate (.*?\.pm) in \@INC} ) {
400 warn "Looking for perl module $mod\n";
401 poldek_file( "/usr/lib*/perl*/$mod", "/usr/share/perl*/$mod" );
405 m{^(?:/usr/bin/ld: )?cannot find -l(.*?)$}
408 warn "Looking for library $lib\n";
409 poldek_file( "/usr/lib64/lib$lib.so", "/usr/lib/lib$lib.so",
410 "/usr/lib*/lib$lib.so" );
413 # full path to ldd files
415 m{^WARNING; can.*t resolve .* dependency: (.*?)$}
418 warn "Looking for library '$lib'\n";
419 poldek_file( "/usr/lib64/$lib", "/usr/lib/$lib", "/lib64/$lib", "/lib/$lib");
422 if ( m{^error: Couldn't exec (/\S+): No such file or directory$}
423 or m{^Can't open perl script "(/\S+)": No such file or directory$}
424 or m{unable to open (/\S+) \(No such file or directory\)$}
425 or m{GConf-CRITICAL \*\*: No such file `(/.\S+?)'$}
426 or m{make.*: \*\*\* No rule to make target `(/\S+)'}
427 or m{g(?:cc|\+\+): (/\S+): No such file or directory$}
428 or m{env: (/\S+): No such file or directory$}
431 warn "Looking for file $file\n";
432 poldek_file( $file );
435 if ( m{^ValueError: Couldn't find include '(.*\.gir)'} ) {
437 warn "Looking for gir file $file\n";
438 poldek_file( "/usr/share/gir-1.0/" . $file );
441 if ( m{^error: Package `(\S+)' not found in specified Vala API directories or GObject-Introspection GIR directories}
444 warn "Looking for gir file $file\n";
445 poldek_file( "/usr/share/vala/vapi/$file.vapi");
448 if ( m{failed.*http://www\.oasis-open\.org/docbook/xml/([\d\.]+/\S+\.dtd)} ) {
450 warn "Looking for docbook file $dtd\n";
451 poldek_file( "/usr/share/sgml/docbook/xml-dtd-$dtd" );
453 if ( m{http://docbook.sourceforge.net/release/xsl/current/(\S+\.xsl)} ) {
455 next if m{^\s*(/usr/bin/)?xsltproc };
456 warn "Looking for docbook file $db\n";
457 poldek_file( "/usr/share/sgml/*/$db" );
459 if (m{Could not find HTML docbook.xsl}) {
460 add_br("docbook-style-xsl");
463 if ( m{LaTeX Error: File `(\S+)' not found} ) {
465 warn "Looking for tex file $tex\n";
466 poldek_file( "/usr/share/tex*/$tex" );
468 if ( m{mv: cannot move `\S+' to `(/var/lib/texmf.*?)':} ) {
470 warn "Looking for tex file $tex\n";
474 if ( m{configure: error: C\+\+ preprocessor "/lib/cpp" fails sanity check} ) {
475 add_br( "gcc-c++", "try: %undefine\t__cxx" );
477 if ( m{configure: error: C\+\+ compiler cannot create executables} ) {
478 add_br( "libstdc++-devel", "maybe try: %undefine\t__cxx" );
480 if ( m{configure: error: XML::Parser perl module is required for intltool} ) {
481 add_br( "perl-XML-Parser" );
483 if ( m{iconv: conversion from `\S+' is not supported} ) {
487 if (m{rst2man \(python-docutils\) is required to build man pages}) {
491 if ( m{ (\S+) does not appear in AM_CONDITIONAL$} ) {
493 warn "Looking for autotools macro $macro\n";
494 if ( my $br = $ac2br{ $macro } ) {
502 if ( m{configure\[\d+\]: syntax error: }
503 or m{\./configure\[\d+\]: \S+_\S+: not found}
504 or m{./configure\[\d+\]: .*unexpected}
505 or m{does not appear in AM_CONDITIONAL$}
507 warn "Need to check configure source: $reason\n";
510 if ( m{^configure: error:} ) {
511 $check_config_log = 1 unless defined $check_config_log;
514 if ( m{^CMake (?:Error|Warning) at (?:\S+/)?(\S+?)\.cmake:(\d+) } ) {
515 my ( $module, $line ) = ( lc $1, $2 );
517 if ( $module eq "findqt4" ) {
520 if ( $l =~ /qmake/ ) {
521 add_br( "qt4-qmake", $l );
522 } elsif ( $l =~ /rcc/ ) {
523 add_br( "qt4-build", $l );
524 } elsif ( $l =~ /Could NOT find (Qt\S+) header/ ) {
525 add_br( "$1-devel", $l );
527 warn "unrecognized Qt requirement: $l\n";
529 } elsif ( $module eq "cmakedeterminecxxcompiler" ) {
530 add_br( "libstdc++-devel",
531 '"try: -DCMAKE_CXX_COMPILER_WORKS=1 -DCMAKE_CXX_COMPILER="%{__cc}"' );
532 } elsif ( $br = $cmake2br{ $module . ":" . $line } ) {
534 } elsif ( $br = $cmake2br{ $module } ) {
536 } elsif ( $br = guess_package( $module =~ /find(.+)/ ) ) {
540 warn "Unrecognized cmake error: $reason\n";
543 if ( m{^\s*ERROR: (?:\S+/)?(\S+?\.cmake) not found} ) {
545 warn "Looking for cmake file: $cmake\n";
546 poldek_file( "/usr/*/cmake/*/$cmake" )
548 if ( $cmake_get_call ) {
549 if ( m{^\s*/\S+/(\S+)\.cmake:(\d+) } ) {
550 my ( $module, $line ) = ( lc $1, $2 );
552 if ( $br = $cmake2br{ $module . ":" . $line } ) {
555 } elsif ( $br = $cmake2br{ $module } ) {
558 } elsif ( $br = guess_package( $module =~ /find(.+)/ ) ) {
562 } elsif (m{Can not use "(.+)" module which has not yet been found}
563 or m{Could not find a package configuration file provided by "(.+)"}) {
566 warn "Looking for cmake file: $cmake\n";
568 "/usr/*/cmake/*/$cmake.cmake",
569 "/usr/*/cmake/*/${cmake}Config.cmake",
570 "/usr/*/cmake/*/${cmake}-config.cmake",
575 if ( m{^-- WARNING: you are using the obsolete 'PKGCONFIG' macro} ) {
576 add_br( "pkgconfig" );
578 if ( m{QT_(QT\S+)_LIBRARY \(ADVANCED\)}
579 or m{X11_(\S+)_LIB \(ADVANCED\)}
580 or m{Qt (\S+) library not found} ) {
582 my $pkg = guess_package( $find );
586 warn "Cannot quess qt package: $find\n";
590 if ( m{Unable to find a javac compiler;$} ) {
593 if ( m{Could not find (\S+) Java extension for this JVM$} ) {
595 warn "Looking for jar file: $jar\n";
596 poldek_file( "/usr/share/java/$jar.jar", "*/$jar.jar" )
600 if ( m{^-- The following OPTIONAL packages could NOT be located on your system} ) {
603 if ( $cmake_pkg_list ) {
604 if ( /\s+\* (\S+) / ) {
606 my $pkg = guess_package( $find );
610 warn "Cannot quess optional package: $find\n";
612 } elsif ( /^\s*$/ ) {
617 # CMake Error at CMakeLists.txt:86 (find_package):
618 # By not providing "FindQt5LinguistTools.cmake" in CMAKE_MODULE_PATH this
619 # project has asked CMake to find a package configuration file provided by
620 # "Qt5LinguistTools", but CMake did not find one.
622 # Could not find a package configuration file provided by "Qt5LinguistTools"
623 # with any of the following names:
625 # Qt5LinguistToolsConfig.cmake
626 # qt5linguisttools-config.cmake
628 # Add the installation prefix of "Qt5LinguistTools" to CMAKE_PREFIX_PATH or
629 # set "Qt5LinguistTools_DIR" to a directory containing one of the above
630 # files. If "Qt5LinguistTools" provides a separate development package or
631 # SDK, be sure it has been installed.
633 #CMake Warning at /usr/lib64/cmake/Qt5Core/Qt5CoreMacros.cmake:273 (find_package):
634 # Could not find a package configuration file provided by "Qt5Network" with
635 # any of the following names:
637 # Qt5NetworkConfig.cmake
638 # qt5network-config.cmake
640 # Add the installation prefix of "Qt5Network" to CMAKE_PREFIX_PATH or set
641 # "Qt5Network_DIR" to a directory containing one of the above files. If
642 # "Qt5Network" provides a separate development package or SDK, be sure it has
644 # Can not use "Network" module which has not yet been found.
646 if (m{By not providing "Find(.+)\.cmake" in CMAKE_MODULE_PATH}
647 or m{Could not find a package configuration file provided by "(.+)"
650 my $lcmake = lc $cmake;
652 warn "Looking for cmake file: $cmake\n";
654 "/usr/*/cmake/*/$cmake.cmake",
655 "/usr/*/cmake/*/${cmake}Config.cmake",
656 "/usr/*/cmake/*/${cmake}-config.cmake",
657 "/usr/*/cmake/*/${lcmake}Config.cmake",
658 "/usr/*/cmake/*/${lcmake}-config.cmake",
662 if ( m{^configure:\d+: checking for (?:"(\S+)"|(\S+))$} ) {
664 if ( @lines and $lines[0] =~ m{^configure:\d+: result: no$} ) {
665 next if $skip{ $exec };
666 warn "Looking for executable $exec\n";
667 poldek_file( $exec ) if $exec =~ m#^/#;
668 poldek_file( "/usr/bin/$exec", "/bin/$exec" );
674 m{Could not find (\S+)}
677 poldek_file("/usr/bin/$exec", "/bin/$exec" );
685 return unless /^configure(\.(?:ac|in|in\.in))?$/;
688 warn "$File::Find::name\n";
693 if ( m{^\s*([A-Za-z0-9_]+)\s*(\(.*)?$} ) {
695 if ( my $br = $ac2br{ $def } ) {
696 add_br( $br, "$file: $_" );
697 } elsif ( $def !~ /^A[CM]_/ and $def =~ /^_?[A-Z]+_[A-Z_0-9a-z]+$/ ) {
698 #warn "Possible macro unrecognized: $def [[[$_]]]\n";
707 find( \&wanted, $builddir );
712 return unless /^config\.log$/;
715 warn "$File::Find::name\n";
721 if ( $check_config_log ) {
722 $check_config_log = 0;
723 find( \&wanted2, $builddir );
724 goto start_check if @lines;
727 foreach my $pkg ( sort keys %out ) {
728 print "$pkg -- $out{$pkg}\n";