]> git.donarmstrong.com Git - wannabuild.git/blobdiff - bin/wanna-build
Store the time in the graph data.
[wannabuild.git] / bin / wanna-build
index c1c0a3191632abf5e8785056c35a134d2ef80fd6..028242745c7286742ef858b523c13c8511780a64 100755 (executable)
@@ -50,7 +50,7 @@ our ($verbose, $mail_logs, $list_order, $list_state,
     $category, %catval, %short_category,
     $short_date, $list_min_age, $dbbase, @curr_time,
     $build_priority, %new_vers, $binNMUver, %merge_srcvers, %merge_binsrc,
-    $lock_for_pid, $transactional);
+    $lock_for_pid, $transactional, $read_only);
 
 # global vars
 $ENV{'PATH'} = "/bin:/usr/bin:/usr/local/bin:/org/wanna-build/bin/";
@@ -62,6 +62,7 @@ $short_date = strftime("%m/%d/%y",@curr_time);
 $| = 1;
 $lock_for_pid = -1; # -1 means normal procedure
 $transactional = 0; # 0 means: work on main copy
+$read_only = 0; # 1 means: do not set or check lock, do never write
 
 # map program invocation names to operation modes
 my %prognames = ( "uploaded-build"  => "set-uploaded",
@@ -192,6 +193,7 @@ my %options =
         "start-transaction" => { mode => "start-transaction" },
         "commit-transaction" => { mode => "commit-transaction" },
         "transactional" => { flag => \$transactional },
+        "read-only" => { flag => \$read_only },
         "manual-edit"  => { mode => "manual-edit" },
         "create-maintenance-lock" => { mode => "maintlock-create" },
         "remove-maintenance-lock" => { mode => "maintlock-remove" },
@@ -253,6 +255,11 @@ if ($verbose) {
        print "wanna-build $version for $distribution on $conf::dbbase\n";
 }
 
+if ($read_only && !isin( $op_mode, qw(list export info))) {
+       warn "Invalid operation with --read-only. You can only use --list, --export or --info.\n";
+       exit 1;
+}
+
 if (!@ARGV && !isin( $op_mode, qw(list merge-quinn merge-partial-quinn import export
                                  merge-packages manual-edit maintlock-create lock-for unlock-for
                                  start-transaction commit-transaction
@@ -324,7 +331,9 @@ if ($op_mode eq "unlock-for") {
        exit 0;
 }
 
-lock_db( $distribution );
+if (!$read_only) {
+       lock_db( $distribution );
+}
 
 if ($op_mode eq "start-transaction") {
        copy ( db_filename_master( $distribution ), db_filename_transaction( $distribution ))
@@ -352,17 +361,19 @@ if ($op_mode eq "commit-transaction") {
 }
 
 END {
-       untie %db;
-       if ($lock_for_pid == -1) {
-               unlock_db( $distribution );
-       }
-       foreach (keys %conf::distributions) {
-               untie %{$otherdb{$_}} if tied(%{$otherdb{$_}});
-               unlock_db( $_ ) if $otherdb_lock{$_};
+       if (!$read_only) {
+               untie %db;
+               if ($lock_for_pid == -1) {
+                       unlock_db( $distribution );
+               }
+               foreach (keys %conf::distributions) {
+                       untie %{$otherdb{$_}} if tied(%{$otherdb{$_}});
+                       unlock_db( $_ ) if $otherdb_lock{$_};
+               }
        }
 }
 
-tie %db, 'MLDBM', db_filename( $distribution ), GDBM_WRCREAT, 0664
+tie %db, 'MLDBM', db_filename( $distribution ), $read_only ? GDBM_READER : GDBM_WRCREAT, 0664
        or die "FATAL: Cannot open database\n";
 
 process();
@@ -978,6 +989,7 @@ sub add_one_needsbuild {
                        log_ta( $pkg, "--give-back" );
                        $db{$name} = $pkg;
                        print "$name: given back\n" if $verbose;
+                       return;
                }
                else {
                        print "$name: has uninstallable build-dependencies. Skipping\n",
@@ -1018,8 +1030,12 @@ sub add_one_needsbuild {
                          "Skipping.\n";
                return;
        }
-       change_state( \$pkg, 'BD-Uninstallable' );
-       $pkg->{'BD-Problem'} = "Installability of build dependencies not tested yet";
+       if ($distribution eq "unstable") {
+               change_state( \$pkg, 'BD-Uninstallable' );
+               $pkg->{'BD-Problem'} = "Installability of build dependencies not tested yet";
+       } else {
+               change_state( \$pkg, 'Needs-Build' );
+       }
        delete $pkg->{'Builder'};
        delete $pkg->{'Depends'};
        log_ta( $pkg, "--give-back" );
@@ -1882,11 +1898,14 @@ sub list_packages {
                        if $pkg->{'State'} =~ /^Failed/;
                print "  Dependencies: $pkg->{'Depends'}\n"
                        if $pkg->{'State'} eq "Dep-Wait";
-               print "  Reason: $pkg->{'BD-Problem'}\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"
                        if $verbose && $pkg->{'Previous-State'};
+               print "  No previous state recorded\n"
+                       if $verbose && !$pkg->{'Previous-State'};
                print "  Previous failing reasons:\n    ",
                      join("\n    ",split("\n",$pkg->{'Old-Failed'})), "\n"
                        if $verbose && $pkg->{'Old-Failed'};
@@ -2223,7 +2242,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";
@@ -2234,7 +2253,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";