]> git.pld-linux.org Git - projects/cleanbuild.git/blobdiff - findbr
skip loading empty poldek sources dir
[projects/cleanbuild.git] / findbr
diff --git a/findbr b/findbr
index a4aaa12f5517ce29a9694a892e972f9721385e65..d049390f4d5cc6ca4922c31decd6ab60dfe479a8 100755 (executable)
--- a/findbr
+++ b/findbr
@@ -4,14 +4,24 @@ use strict;
 use warnings;
 use IPC::Open2;
 use Cwd;
+use constant DOCKER => -e '/.dockerenv';
 
 my $pwd = getcwd();
 # how to run poldek
 my @ignore = qw(vserver-packages python-devel-src);
-my @poldek = (qw(sudo poldek -n th-x86_64-ready), "--cachedir=$pwd/poldekcache",
-       "--skip-installed", "--conf=$pwd/poldekconf/poldek.conf",
+my @poldek;
+if (DOCKER) {
+       push(@poldek, qw[poldek]);
+} else {
+       push(@poldek, qw[sudo poldek -n th-x86_64-ready],
+               "--cachedir=$pwd/poldekcache",
+               "--conf=$pwd/poldekconf/poldek.conf",
+       );
+}
+push(@poldek, (
+       "--skip-installed",
        "-O", "ignore=" . (join " ", @ignore)
-);
+));
 
 # if multiple packages provide some funcionality those will be selected:
 my %preferred = (
@@ -55,7 +65,7 @@ my %skip;
 # for m4 in *.m4; do R=$(rpm -qf $m4); R=${R%-*-*}; \
 #   awk -vr=$R '/^\s*(AC_DEFUN|AU_ALIAS)/ { gsub(/\].*/,""); gsub(/.*\[/,""); print r " " $0}' $m4; \
 # done | sort | awk '{print "\t\"" $2 "\" => \"" $1 "\","}'
-my %ac2br = do "findbr-ac2br";
+my %ac2br = do (DOCKER ? 'cleanbuild/findbr-ac2br' : 'findbr-ac2br');
 
 my %cmake2br = (
        "findkde4:44" => "kde4-kdelibs",
@@ -101,14 +111,15 @@ sub add_br
 sub poldek_cmd
 {
        my $cmd = shift;
+
        warn "Poldek: $cmd\n";
-       my $pid = open( READ, "-|", @poldek, "--shcmd=".$cmd );
 
-       my @read = <READ>;
-       close READ;
+       my @cmd = (@poldek, "--shcmd=".$cmd);
+       open my $fh, '-|', @cmd or die "$!: @cmd";
+       my @read = <$fh>;
+       close $fh or die $!;
 
-       return @read if wantarray;
-       return \@read;
+       return wantarray ? @read : \@read;
 }
 
 my $check_ac = 0;
@@ -216,11 +227,18 @@ start_check:
 my %checked;
 my $cmake_get_call = 0;
 my $cmake_pkg_list = 0;
+my $py_ver = undef;
 while ( $_ = shift @lines ) {
        chomp;
        #next if $checked{ $_ };
        #$checked{ $_ } = 1;
 
+       # try to extract current python version from setup.py run
+       if (m{^copying .+ -> build-(\d+)/lib/}) {
+               $py_ver = $1;
+               warn "py_ver set to '$py_ver'\n";
+       }
+
        $reason = $_;
        if ( /^\S+: (\S+): (?:Command )?not found$/ or /.*configure\[\d+\]: (\S+): not found$/
                        or m{which: no (\S+) in \(.*/bin.*\)}
@@ -239,7 +257,9 @@ while ( $_ = shift @lines ) {
        }
 
        if ( /\S+\.[ch](?:pp|xx|c)?:\d+:\d+: error: (\S+): No such file or directory$/ or
-               /\S+\.[ch](?:pp|xx|c)?:\d+:\d+: fatal error: (\S+): No such file or directory$/ ) {
+               /\S+\.[ch](?:pp|xx|c)?:\d+:\d+: fatal error: (\S+): No such file or directory$/ or
+               /Can't find the '(\S+\.h)'? header/
+       ) {
                my $h = $1;
                warn "Looking for C(++) header $h\n";
                poldek_file( "/usr/include*/$h" );
@@ -249,18 +269,26 @@ while ( $_ = shift @lines ) {
                or m{^ERROR: Cannot find .+: No module named (\S+)$}
                or m{^ERROR: Failed to import the ".+" module: No module named (\S+)$}
                or m{^distutils.errors.DistutilsError: Could not find suitable distribution for Requirement.parse\('([^'>=]+).*'\)}
+               or                           m{^error: Could not find suitable distribution for Requirement.parse\('([^'>=]+).*'\)}
                or m{^Couldn't find index page for '(\S+)'}
                ) {
                my $mod = $1;
                $mod =~ s#\.#/#g;
-               warn "Looking for python module $mod\n";
+               warn "Looking for Python$py_ver module $mod\n";
                poldek_file(
-                               "/usr/share/python2*/$mod/__init__.py*",
-                               "/usr/share/python2*/$mod.py*",
-                               "/usr/lib*/python2*/$mod/__init__.py*",
-                               "/usr/lib*/python2*/$mod.py*",
-                               "/usr/lib*/python2*/_$mod.so",
-                               "/usr/lib*/python2*/$mod.so" );
+                               "/usr/share/python$py_ver*/site-packages/$mod/__init__.py*",
+                               "/usr/share/python$py_ver*/$mod/__init__.py*",
+                               "/usr/share/python$py_ver*/site-packages/$mod.py*",
+                               "/usr/share/python$py_ver*/$mod.py*",
+                               "/usr/lib*/python$py_ver*/site-packages/$mod/__init__.py*",
+                               "/usr/lib*/python$py_ver*/$mod/__init__.py*",
+                               "/usr/lib*/python$py_ver*/site-packages/$mod.py*",
+                               "/usr/lib*/python$py_ver*/$mod.py*",
+                               "/usr/lib*/python$py_ver*/site-packages/_$mod.so",
+                               "/usr/lib*/python$py_ver*/_$mod.so",
+                               "/usr/lib*/python$py_ver*/site-packages/$mod.so",
+                               "/usr/lib*/python$py_ver*/$mod.so",
+               );
        }
 
        if (
@@ -270,6 +298,14 @@ while ( $_ = shift @lines ) {
                next;
        }
 
+       if (
+               m{^You need to install the (\S+) module} or
+               m{\*\*\*Error\*\*\*: You must have (\S+) >= (\S+) installed}
+       ) {
+               add_br($1);
+               next;
+       }
+
        if (
                m{^cannot load such file -- (\S+)} or
                m{in `require': cannot load such file -- (\S+) \(LoadError\)}
@@ -331,6 +367,17 @@ while ( $_ = shift @lines ) {
                next;
        }
 
+       if (m{ERROR: CMake is required to build}) {
+               add_br("cmake");
+               next;
+       }
+
+       # lucky guessing
+       if (m{'yum install (\S+)'}) {
+               add_br($1);
+               next;
+       }
+
        if ( m{^find-lang.sh: Error: international files not found for '}
                        or m{ gettext tools not found}
                        ) {
@@ -343,6 +390,7 @@ while ( $_ = shift @lines ) {
                or m{^pkg-config unavailable, build terminated}
                or m{^\*\*\*Error\*\*\*: You must have pkg-config >= .* installed}
                or m{^-- Could NOT find PkgConfig \(missing:  PKG_CONFIG_EXECUTABLE\)}
+               or m{exec: "pkg-config": executable file not found in \$PATH}
        ) {
                add_br( "pkgconfig" );
                next;
@@ -409,6 +457,9 @@ while ( $_ = shift @lines ) {
                warn "Looking for docbook file $db\n";
                poldek_file( "/usr/share/sgml/*/$db" );
        }
+       if (m{Could not find HTML docbook.xsl}) {
+               add_br("docbook-style-xsl");
+       }
 
        if ( m{LaTeX Error: File `(\S+)' not found} ) {
                my $tex = $1;
@@ -597,12 +648,15 @@ while ( $_ = shift @lines ) {
                or m{Could not find a package configuration file provided by "(.+)"
                }) {
                my $cmake = $1;
+               my $lcmake = lc $cmake;
 
                warn "Looking for cmake file: $cmake\n";
                poldek_file(
                        "/usr/*/cmake/*/$cmake.cmake",
                        "/usr/*/cmake/*/${cmake}Config.cmake",
                        "/usr/*/cmake/*/${cmake}-config.cmake",
+                       "/usr/*/cmake/*/${lcmake}Config.cmake",
+                       "/usr/*/cmake/*/${lcmake}-config.cmake",
                )
        }
 
@@ -615,6 +669,14 @@ while ( $_ = shift @lines ) {
                        poldek_file( "/usr/bin/$exec", "/bin/$exec" );
                }
        }
+
+
+       if (
+               m{Could not find (\S+)}
+       ) {
+               my $exec = $1;
+               poldek_file("/usr/bin/$exec", "/bin/$exec" );
+       }
 }
 
 
This page took 0.07401 seconds and 4 git commands to generate.