]> git.donarmstrong.com Git - wannabuild.git/blobdiff - bin/wanna-build
wanna-build --list: Format BD-Problem like Failed reasons
[wannabuild.git] / bin / wanna-build
index 693528e58e93d5c21e053b6fc8d3a342c5ed9d11..277273cab3f46dd3068c0a647f8d433bfc22ddb7 100755 (executable)
@@ -53,7 +53,7 @@ our ($verbose, $mail_logs, $list_order, $list_state,
     $lock_for_pid, $transactional);
 
 # global vars
-$ENV{'PATH'} = "/bin:/usr/bin:/usr/local/bin";
+$ENV{'PATH'} = "/bin:/usr/bin:/usr/local/bin:/org/wanna-build/bin/";
 $verbose = 0;
 $mail_logs = "";
 @curr_time = gmtime;
@@ -445,8 +445,8 @@ sub process {
                        @ARGV = ( $ARGS[1] );
                        parse_quinn_diff(0);
                        @ARGV = ( $ARGS[2] );
-                       my $build_deps = parse_sources(1);
-                       call_edos_depcheck( $ARGS[0], $ARGS[2] );
+                       my $srcs = parse_sources(1);
+                       call_edos_depcheck( $ARGS[0], $srcs );
                        clean_db();
                        last SWITCH;
                };
@@ -968,23 +968,31 @@ sub add_one_needsbuild {
        }
        $state = $pkg->{'State'};
 
-       if ($state eq "Dep-Wait") {
+       if ($state eq "BD-Uninstallable") {
                if ($opt_override) {
-                       print "$name: Forcing source dependency list to be cleared\n";
+                       print "$name: Forcing uninstallability mark to be removed. This is not permanent and might be reset with the next trigger run\n";
+
+                       change_state( \$pkg, 'Needs-Build' );
+                       delete $pkg->{'Builder'};
+                       delete $pkg->{'Depends'};
+                       log_ta( $pkg, "--give-back" );
+                       $db{$name} = $pkg;
+                       print "$name: given back\n" if $verbose;
+                       return;
                }
                else {
-                       print "$name: waiting for source dependencies. Skipping\n",
+                       print "$name: has uninstallable build-dependencies. Skipping\n",
                                  "  (use --override to clear dependency list and ",
                                  "give back anyway)\n";
                        return;
                }
        }
-       if ($state eq "BD-Uninstallable") {
+       elsif ($state eq "Dep-Wait") {
                if ($opt_override) {
-                       print "$name: Forcing uninstallability mark to be removed\n";
+                       print "$name: Forcing source dependency list to be cleared\n";
                }
                else {
-                       print "$name: has uninstallable build-dependencies. Skipping\n",
+                       print "$name: waiting for source dependencies. Skipping\n",
                                  "  (use --override to clear dependency list and ",
                                  "give back anyway)\n";
                        return;
@@ -1011,7 +1019,8 @@ sub add_one_needsbuild {
                          "Skipping.\n";
                return;
        }
-       change_state( \$pkg, 'Needs-Build' );
+       change_state( \$pkg, 'BD-Uninstallable' );
+       $pkg->{'BD-Problem'} = "Installability of build dependencies not tested yet";
        delete $pkg->{'Builder'};
        delete $pkg->{'Depends'};
        log_ta( $pkg, "--give-back" );
@@ -1075,7 +1084,8 @@ sub set_one_binnmu {
                return;
        }
 
-       change_state( \$pkg, 'Needs-Build' );
+       change_state( \$pkg, 'BD-Uninstallable' );
+       $pkg->{'BD-Problem'} = "Installability of build dependencies not tested yet";
        delete $pkg->{'Builder'};
        delete $pkg->{'Depends'};
        $pkg->{'Binary-NMU-Version'} = $binNMUver;
@@ -1222,6 +1232,8 @@ sub parse_sources {
 
                $pkgs{$name}{'ver'} = $version;
                $pkgs{$name}{'bin'} = $binaries;
+               $pkgs{$name}{'dep'} = $builddep;
+               $pkgs{$name}{'conf'} = $buildconf;
                my $pkg = $db{$name};
 
                if (defined $pkg) {
@@ -1250,11 +1262,13 @@ sub parse_sources {
                        $pkg->{'Section'} = $section, $change++
                                if defined $section and (not defined($pkg->{'Section'}) or $pkg->{'Section'} ne $section);
 
-                       # Store Build-Deps and Build-Conflicts for edos-debcheck later
-                       $pkg->{'Build-Depends'} = $builddep, $change++
-                               if ($pkg->{'Build-Depends'} ne $builddep);
-                       $pkg->{'Build-Conflicts'} = $builddep, $change++
-                               if ($pkg->{'Build-Conflicts'} ne $buildconf);
+                       # Remove field from previous wanna-build versions
+                       for (qw/Reason Build-Depends Build-Conflicts/) {
+                               if (exists $pkg->{$_}) {
+                                       delete $pkg->{$_};
+                                       $change++;
+                               }
+                       }
 
                        $db{$name} = $pkg if $change;
                }
@@ -1869,7 +1883,8 @@ sub list_packages {
                        if $pkg->{'State'} =~ /^Failed/;
                print "  Dependencies: $pkg->{'Depends'}\n"
                        if $pkg->{'State'} eq "Dep-Wait";
-               print "  Reason: $pkg->{'Reason'}\n"
+               print "  Reasons for BD-Uninstallable:\n    ",
+                         join("\n    ",split("\n",$pkg->{'BD-Problem'})), "\n"
                        if $pkg->{'State'} eq "BD-Uninstallable";
                print "  Previous state was $pkg->{'Previous-State'} until ",
                          "$pkg->{'State-Change'}\n"
@@ -2210,7 +2225,7 @@ sub write_db {
                                my $val = $ui->{$key};
                                 $val =~ s/\n*$//;
                                $val =~ s/^/ /mg;
-                               $val =~ s/^ $/ ./mg;
+                               $val =~ s/^ +$/ ./mg;
                                print F "$key: $val\n";
                            }
                            print F "\n";
@@ -2221,7 +2236,7 @@ sub write_db {
                                my $val = $pkg->{$key};
                                 $val =~ s/\n*$//;
                                $val =~ s/^/ /mg;
-                               $val =~ s/^ $/ ./mg;
+                               $val =~ s/^ +$/ ./mg;
                                print F "$key: $val\n";
                        }
                        print F "\n";
@@ -2260,7 +2275,7 @@ sub change_state {
                delete $pkg->{'Failed-Category'};
        }
        if (defined($$state) and $$state eq 'BD-Uninstallable') {
-               delete $pkg->{'Reason'};
+               delete $pkg->{'BD-Problem'};
        }
        $$state = $newstate;
 }
@@ -2561,7 +2576,7 @@ sub get_unsatisfied_dep {
 
 sub call_edos_depcheck {
     my $packagesfile = shift;
-    my $sourcesfile = shift;
+    my $srcs = shift;
     my $key;
     
     return if defined ($conf::distributions{$distribution}{noadw});
@@ -2581,7 +2596,27 @@ sub call_edos_depcheck {
     #print "I would look at these sources with edos-depcheck:\n";
     #print join " ", keys %interesting_packages,"\n";
 
-    if (open(EDOS,"-|","wb-edos-builddebcheck", "-a", $arch, $packagesfile, $sourcesfile)) {
+    my $tmpfile_pattern = "/tmp/wanna-build-interesting-sources-$distribution.$$-";
+    my ($tmpfile, $i);
+    for( $i = 0;; ++$i ) {
+           $tmpfile = $tmpfile_pattern . $i;
+           last if ! -e $tmpfile;
+    }
+
+    open SOURCES, '>', $tmpfile or die "Could not open temporary file $tmpfile\n";
+    for my $key (keys %interesting_packages) {
+       my $pkg = $db{$key};
+       print SOURCES "Package: $key\n";
+       print SOURCES "Version: $pkg->{'Version'}\n";
+       print SOURCES "Build-Depends: $srcs->{$key}{'dep'}\n" if $srcs->{$key}{'dep'};
+       print SOURCES "Build-Conflicts: $srcs->{$key}{'conf'}\n" if $srcs->{$key}{'conf'};
+       print SOURCES "Architecture: all\n";
+       print SOURCES "\n";
+    }
+    close SOURCES;
+
+    if (open(EDOS,"-|","wb-edos-builddebcheck", "-a", $arch, $packagesfile, $tmpfile))
+    {
        local($/) = ""; # read in paragraph mode
        while( <EDOS> ) {
                my( $key, $reason ) ;
@@ -2602,23 +2637,35 @@ sub call_edos_depcheck {
        print "ERROR: Could not run wb-edos-builddebcheck. I am continuing, assuming\n" .
              "all packages have installable build-dependencies."
     }
+    
+    unlink( $tmpfile );
 
     for my $key (keys %interesting_packages) {
        my $pkg = $db{$key};
        my $change = 
            (defined $interesting_packages{$key} and $pkg->{'State'} eq 'Needs-Build') ||
            (not defined $interesting_packages{$key} and $pkg->{'State'} eq 'BD-Uninstallable');
+       my $problemchange = $interesting_packages{$key} ne $pkg->{'BD-Problem'};
        if ($change) {
            if (defined $interesting_packages{$key}) {
                    change_state( \$pkg, 'BD-Uninstallable' );
-                   $pkg->{'Reason'} = $interesting_packages{$key};
+                   $pkg->{'BD-Problem'} = $interesting_packages{$key};
            } else {
                    change_state( \$pkg, 'Needs-Build' );
            }
+       }
+       if ($problemchange) {
+           if (defined $interesting_packages{$key}) {
+                   $pkg->{'BD-Problem'} = $interesting_packages{$key};
+           }   
+       }
+       if ($change) {
            log_ta( $pkg, "--merge-all" );
-           $db{$key} = $pkg;
            print "edos-builddebchange changed state of ${key}_$pkg->{'Version'} to $pkg->{'State'}\n" if $verbose;
        }
+       if ($change || $problemchange) {
+           $db{$key} = $pkg;
+       }
     }
 }
 
@@ -2644,7 +2691,10 @@ Options:
          a new version number (source-version + "+b<num>")
     --give-back: Mark a package as ready to build that is in state Building,
         Built or Build-Attempted. To give back a package in state Failed, use
-        --override
+        --override. This command will actually put the package in state
+        BD-Uninstallable, until the installability of its Build-Dependencies
+        were verified. This happens at each call of --merge-all, usually
+        every 15 minutes.
     --merge-quinn: Merge quinn-diff output into database.
     --merge-packages: Merge Packages files into database.
     --pretend-avail: Pretend that given packages are available now and give
@@ -2666,7 +2716,7 @@ Options:
     --export FILE: Export database to a ASCII file FILE
     --lock-for PID: Locks the database for the process with this pid
     --unlock-for PID: Unlocks the database for the process with this pid
-    --act-on-behalf-of PID: Ignores the log (if it is held by this pid)
+    --act-on-behalf-of PID: Ignores the lock (if it is held by this pid)
     --start-transaction: Creates a copy of the state of the database, for
        use with --transactional. This overrides any previous uncommited
        transaction. Should only be used after --lock-for