better dep resolver
authorAnas Nashif <anas.nashif@intel.com>
Mon, 23 Jul 2012 19:28:49 +0000 (20:28 +0100)
committerAnas Nashif <anas.nashif@intel.com>
Mon, 23 Jul 2012 19:28:49 +0000 (20:28 +0100)
Change-Id: I14d59d9b73f6a8be3bb0269b04a238b4c8fd2227

Makefile
depanneur

index 0c661cbe5ee5cb937b719e4e7edd01f50cc45b7f..ad2833ec78f2849798fd58afb59380aa159887c1 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -14,6 +14,7 @@ install:
            $(DESTDIR)$(bindir)
        install -m755 \
            depanneur  \
+               do_expanddeps \
         check_unresolved \
            $(DESTDIR)$(bindir)
 
index fe520599ecb53616a580c434ba8e379749fc0869..eb6258d044b46f4637eb36a77f0c62d833c6f40a 100755 (executable)
--- a/depanneur
+++ b/depanneur
@@ -146,6 +146,10 @@ my @packs = @ARGV;
 my $package_path = "";
 # FIXME
 my @archs = ("i586", "i686", "noarch");
+my $archpath;
+foreach my $ap (@archs) {
+    $archpath .= $ap.":"; 
+}
 
 my $Config = LoadFile($config_filename);
 my @package_repos = ();
@@ -757,6 +761,18 @@ while (! $TERM) {
     }
     foreach my $name (keys %to_build) {
         if( ! (grep $_ eq $name, @done) && ! (grep $_ eq $name, @exclude)) {
+            my $fn = $to_build{$name}->{filename};
+            my $version = $to_build{$name}->{version};
+            my $release = $to_build{$name}->{release};
+            my $pattern = "$localrepo/$dist/src/SRPMS/$name-$version-$release.*.rpm";
+            my @binaries = glob $pattern;
+            if (@binaries != 0 && ! $overwrite) {
+                push(@skipped, $name);
+            }
+        }
+    }
+    foreach my $name (keys %to_build) {
+        if( ! (grep $_ eq $name, @done) && ! (grep $_ eq $name, @exclude) && ! (grep $_ eq $name, @skipped)) {
             my $fn = $to_build{$name}->{filename};
             my $version = $to_build{$name}->{version};
             my $release = $to_build{$name}->{release};
@@ -771,22 +787,35 @@ while (! $TERM) {
                 if ( $debug ) {
                     $dd = "--debug";
                 }
-                if ( system("$virtualenv/usr/bin/check_unresolved $dd --depfile $order_dir/.repo.cache --configdir $dist_configs --dist $dist --archpath i586:i686:noarch $fn") == 0 ) {
+                if ( system("$virtualenv/usr/bin/check_unresolved $dd --depfile $order_dir/.repo.cache --configdir $dist_configs --dist $dist --archpath $archpath $fn") == 0 ) {
                     my $stop =  0;
                     my @deps = @{$to_build{$name}->{deps}};
+                    print "now looking into $name\n";
                     foreach my $dep (@deps) {
-                        foreach my $n2 (keys %to_build) {
-                            my @subs = @{$to_build{$n2}->{subpacks}};
-                            if (! grep($_ eq $n2, @done)) {
-                                foreach my $sub (@subs) {
-                                    my $so = source_of($sub, %to_build);
-                                    $dep =~ m/([^\s]+).*/;
-                                    if ( $sub eq $1 && ! grep($_ eq $so, @skipped) ) {
-                                        $stop = 1;
-                                    }
-                                }
+                        open(EXPAND,"$virtualenv/usr/bin/do_expanddeps --dist $dist --depfile $order_dir/.repo.cache --archpath $archpath --configdir $dist_configs \"$dep\" |") || die "Failed: $!\n";
+                        while ( <EXPAND> ) {
+                            chomp;
+                            my $ddep = $_;
+                            my $so = source_of($ddep, %to_build);
+                            if ( defined($so) && ($so ne $name) && (! grep($_ eq $so, @skipped)) && (! grep($_ eq $so, @done)) ) {
+                                print "Not adding $name for now, it needs $dep -> $ddep ($so)...\n";
+                                $stop = 1;
                             }
-                        }
+                        } 
+                        close(EXPAND);
+
+#                        foreach my $n2 (keys %to_build) {
+#                            my @subs = @{$to_build{$n2}->{subpacks}};
+#                            if (! grep($_ eq $n2, @done)) {
+#                                foreach my $sub (@subs) {
+#                                    my $so = source_of($sub, %to_build);
+#                                    $dep =~ m/([^\s]+).*/;
+#                                    if ( $sub eq $1 && ! grep($_ eq $so, @skipped) ) {
+#                                        $stop = 1;
+#                                    }
+#                                }
+#                            }
+#                        }
 
                     }