3 # wanna-build: coordination script for Debian buildds
4 # Copyright (C) 1998 Roman Hodek <Roman.Hodek@informatik.uni-erlangen.de>
5 # Copyright (C) 2005-2008 Ryan Murray <rmurray@debian.org>
7 # This program is free software; you can redistribute it and/or
8 # modify it under the terms of the GNU General Public License as
9 # published by the Free Software Foundation; either version 2 of the
10 # License, or (at your option) any later version.
12 # This program is distributed in the hope that it will be useful, but
13 # WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 # General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program; if not, write to the Free Software
19 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24 $basedir = "/var/lib/debbuild";
26 $transactlog = "transactions.log";
27 $mailprog = "/usr/sbin/sendmail";
28 require "/etc/wanna-build.conf";
29 die "$conf::basedir is not a directory\n" if ! -d $conf::basedir;
30 die "dbbase is empty\n" if ! $dbbase;
31 die "transactlog is empty\n" if ! $transactlog;
32 die "mailprog binary $conf::mailprog does not exist or isn't executable\n"
33 if !-x $conf::mailprog;
34 die "no distributions defined\n" if ! %distributions;
41 use MLDBM qw(GDBM_File Storable);
44 our ($verbose, $mail_logs, $list_order, $list_state,
45 $curr_date, $op_mode, $user, $real_user, $distribution,
46 $fail_reason, $opt_override, $import_from, $export_to, $opt_create_db,
47 $transactlog, %db, %otherdb, %otherdb_lock, %prioval, %sectval,
48 $info_all_dists, $arch,
49 $category, %catval, %short_category,
50 $short_date, $list_min_age, $dbbase, @curr_time,
51 $build_priority, %new_vers, $binNMUver, %merge_srcvers, %merge_binsrc,
55 $ENV{'PATH'} = "/bin:/usr/bin:/usr/local/bin";
59 $curr_date = strftime("%Y %b %d %H:%M:%S",@curr_time);
60 $short_date = strftime("%m/%d/%y",@curr_time);
62 $lock_for_pid = -1; # -1 means normal procedure
64 # map program invocation names to operation modes
65 my %prognames = ( "uploaded-build" => "set-uploaded",
66 "failed-build" => "set-failed",
67 "no-build" => "set-not-for-us",
68 "give-back-build" => "set-needs-build",
69 "dep-wait-build" => "set-dep-wait",
70 "forget-build" => "forget",
71 "merge-quinn" => "merge-quinn",
72 "merge-packages" => "merge-packages",
73 "merge-sources" => "merge-sources",
74 "build-info" => "info" );
76 %short_category = ( u => "uploaded-fixed-pkg",
83 c => "compiler-error",
87 ($progname = $0) =~ s,.*/,,;
88 if ($prognames{$progname}) {
89 $op_mode = $prognames{$progname};
91 elsif ($progname =~ /^list-(.*)$/) {
93 $list_state = ($1 eq "all") ? "" : $1;
98 verbose => { short => "v", flag => \$verbose },
99 override => { short => "o", flag => \$opt_override },
100 "create-db" => { flag => \$opt_create_db },
101 "correct-compare" => { flag => \$WannaBuild::opt_correct_version_cmp },
102 # TODO: remove after buildds no longer pass to wanna-build
103 "no-propagation" => { short => "N" },
104 "no-down-propagation" => { short => "D" },
106 take => { mode => "set-building" },
107 failed => { short => "f", mode => "set-failed" },
108 uploaded => { short => "u", mode => "set-uploaded" },
109 "no-build" => { short => "n", mode => "set-not-for-us" },
110 built => { mode => "set-built" },
111 attempted => { mode => "set-attempted" },
112 "give-back" => { mode => "set-needs-build" },
113 "dep-wait" => { mode => "set-dep-wait" },
114 forget => { mode => "forget" },
115 'forget-user' => { mode => 'forget-user' },
116 "merge-quinn" => { mode => "merge-quinn" },
117 "merge-partial-quinn" => { mode => "merge-partial-quinn" },
118 "merge-packages" => { mode => "merge-packages" },
119 "merge-sources" => { mode => "merge-sources" },
120 "pretend-avail" => { short => "p", mode => "pretend-avail" },
121 "merge-all" => { mode => "merge-all" },
122 info => { short => "i", mode => "info" },
123 'binNMU' => { mode => 'set-binary-nmu', arg => \$binNMUver,
124 code => sub { die "Invalid binNMU version: $binNMUver\n"
125 if $binNMUver !~ /^([\d]*)$/ and $1 >= 0; } },
126 'perm-build-priority' => { mode => "set-permanent-build-priority", arg => \$build_priority,
127 code => sub { die "Invalid build priority: $build_priority\n"
128 if $build_priority !~ /^-?[\d]+$/; } },
129 'build-priority' => { mode => "set-build-priority", arg => \$build_priority,
130 code => sub { die "Invalid build priority: $build_priority\n"
131 if $build_priority !~ /^-?[\d]+$/; } },
133 { short => "l", mode => "list", arg => \$list_state,
135 die "Unknown state to list: $list_state\n"
136 if !isin( $list_state, qw(needs-build building uploaded
137 built build-attempted failed installed dep-wait
138 not-for-us all failed-removed
139 install-wait reupload-wait));} },
142 { short => "d", arg => \$distribution,
144 if ($distribution eq "a" || $distribution eq "all") {
149 $distribution = "oldstable" if $distribution eq "o";
150 $distribution = "stable" if $distribution eq "s";
151 $distribution = "testing" if $distribution eq "t";
152 $distribution = "unstable" if $distribution eq "u";
156 { short => "O", arg => \$list_order,
158 die "Bad ordering character\n"
159 if $list_order !~ /^[PSpsncb]+$/;
161 message => { short => "m", arg => \$fail_reason },
162 database => { short => "b", arg => \$conf::dbbase },
163 arch => { short => "A", arg => \$arch },
164 user => { short => "U", arg => \$user },
165 category => { short => "c", arg => \$category,
167 $category = $short_category{$category}
168 if exists $short_category{$category};
169 die "Unknown category: $category\n"
170 if !isin( $category, values %short_category );
172 "min-age" => { short => "a", arg => \$list_min_age,
174 die "Argument of --min-age must be a non-zero number\n"
175 if $list_min_age == 0;
176 $list_min_age *= 24*60*60;
178 "max-age" => { arg => \$list_min_age,
180 die "Argument of --max-age must be a non-zero number\n"
181 if $list_min_age == 0;
182 $list_min_age *= -24*60*60;
185 import => { arg => \$import_from, mode => "import" },
186 export => { arg => \$export_to, mode => "export" },
187 "lock-for" => { arg => \$lock_for_pid, mode => "lock-for" },
188 "unlock-for" => { arg => \$lock_for_pid, mode => "unlock-for" },
189 "act-on-behalve-of" => { arg => \$lock_for_pid },
190 "manual-edit" => { mode => "manual-edit" },
191 "create-maintenance-lock" => { mode => "maintlock-create" },
192 "remove-maintenance-lock" => { mode => "maintlock-remove" },
193 "clean-db" => { mode => "clean-db" },
196 while( @ARGV && $ARGV[0] =~ /^-/ ) {
199 my($opt, $optname, $arg);
200 if (/^--([^=]+)(=|$)/) {
202 $opt = $options{$optname};
203 $arg = $1 if /^--\Q$optname\E=((.|\n)*)$/;
206 $optname = substr( $_, 1, 1 );
207 $opt = (grep { defined($_->{short}) ? $_->{short} eq $optname : 0} values %options)[0];
208 $arg = $1 if /^-$optname(.+)$/;
211 warn "Unknown option: --$1\n";
216 die "$optname option missing argument\n" if !@ARGV;
219 ${$opt->{arg}} = $arg;
221 elsif (defined $arg) {
222 die "Option $optname takes no argument\n";
226 die "Conflicting operation modes\n" if $op_mode;
227 $op_mode = $opt->{mode};
237 $op_mode = $category ? "set-failed" : "set-building"
238 if !$op_mode; # default operation
239 $list_order = $list_state eq "failed" ? 'fPcpsn' : 'PScpsn'
240 if !$list_order and $list_state;
241 $distribution ||= "unstable";
242 die "Bad distribution '$distribution'\n"
243 if !isin($distribution, keys %conf::distributions);
244 $conf::dbbase =~ m#^([^/]+/)#;
245 $transactlog = "$conf::basedir/$1$conf::transactlog";
248 my $version = '$Revision: db181a534e9d $ $Date: 2008/03/26 06:20:22 $ $Author: rmurray $';
249 $version =~ s/(^\$| \$ .*$)//g;
250 print "wanna-build $version for $distribution on $conf::dbbase\n";
253 if (!@ARGV && !isin( $op_mode, qw(list merge-quinn merge-partial-quinn import export
254 merge-packages manual-edit maintlock-create lock-for unlock-for
255 merge-sources maintlock-remove clean-db))) {
256 warn "No packages given.\n";
260 $real_user = (getpwuid($<))[0];
261 die "Can't determine your user name\n"
262 if $op_mode ne "list" && !$user &&
263 !($user = $real_user);
266 if ($op_mode eq "set-failed" && !$category) {
267 print "Enter reason for failing (end with '.' alone on ".
272 last if $line eq ".\n";
273 $line = ".\n" if $line eq "\n";
274 $fail_reason .= $line;
276 chomp( $fail_reason );
277 } elsif ($op_mode eq "set-dep-wait") {
278 print "Enter dependencies (one line):\n";
280 while( !$line && !eof(STDIN) ) {
281 chomp( $line = <STDIN> );
283 die "No dependencies given\n" if !$line;
284 $fail_reason = $line;
285 } elsif ($op_mode eq "set-binary-nmu" and $binNMUver > 0) {
286 print "Enter changelog entry (one line):\n";
288 while( !$line && !eof(STDIN) ) {
289 chomp( $line = <STDIN> );
291 die "No changelog entry given\n" if !$line;
292 $fail_reason = $line;
295 if ($op_mode eq "maintlock-create") {
299 if ($op_mode eq "maintlock-remove") {
303 waitfor_maintlock() if $op_mode !~ /^(?:merge-|clean-db$)/;
305 if (!-f db_filename( $distribution ) && !$opt_create_db) {
306 die "Database for $distribution doesn't exist\n";
309 # Locking for another process means that a longer running process (most likely
310 # wb) wants to do several steps at once, and manages the locks.
311 if ($op_mode eq "lock-for") {
312 lock_db( $distribution );
315 if ($op_mode eq "unlock-for") {
316 unlock_db( $distribution );
320 lock_db( $distribution );
323 if ($lock_for_pid == -1) {
324 unlock_db( $distribution );
326 foreach (keys %conf::distributions) {
327 untie %{$otherdb{$_}} if tied(%{$otherdb{$_}});
328 unlock_db( $_ ) if $otherdb_lock{$_};
332 tie %db, 'MLDBM', db_filename( $distribution ), GDBM_WRCREAT, 0664
333 or die "FATAL: Cannot open database\n";
337 if ($mail_logs && $conf::log_mail) {
338 send_mail( $conf::log_mail,
339 "wanna-build $distribution state changes $curr_date",
340 "State changes at $curr_date for distribution ".
341 "$distribution:\n\n$mail_logs\n" );
349 SWITCH: foreach ($op_mode) {
351 add_packages( $1, @ARGV );
355 list_packages( $list_state );
359 info_packages( @ARGV );
362 /^forget-user/ && do {
363 die "This operation is restricted to admin users\n"
364 if (defined @conf::admin_users and
365 !isin( $real_user, @conf::admin_users));
366 forget_users( @ARGV );
370 forget_packages( @ARGV );
373 /^merge-partial-quinn/ && do {
374 die "This operation is restricted to admin users\n"
375 if (defined @conf::admin_users and
376 !isin( $real_user, @conf::admin_users));
380 /^merge-quinn/ && do {
381 die "This operation is restricted to admin users\n"
382 if (defined @conf::admin_users and
383 !isin( $real_user, @conf::admin_users));
387 /^merge-packages/ && do {
388 die "This operation is restricted to admin users\n"
389 if (defined @conf::admin_users and
390 !isin( $real_user, @conf::admin_users));
394 /^merge-sources/ && do {
395 die "This operation is restricted to admin users\n"
396 if (defined @conf::admin_users and
397 !isin( $real_user, @conf::admin_users));
401 /^pretend-avail/ && do {
402 pretend_avail( @ARGV );
406 die "This operation is restricted to admin users\n"
407 if (defined @conf::admin_users and
408 !isin( $real_user, @conf::admin_users));
410 @ARGV = ( $ARGS[0] );
411 my $pkgs = parse_packages();
412 @ARGV = ( $ARGS[1] );
414 @ARGV = ( $ARGS[2] );
415 my $build_deps = parse_sources(1);
416 auto_dep_wait( $build_deps, $pkgs );
421 die "This operation is restricted to admin users\n"
422 if (defined @conf::admin_users and
423 !isin( $real_user, @conf::admin_users));
424 %db = (); # clear all current contents
425 read_db( $import_from );
429 write_db( $export_to );
432 /^manual-edit/ && do {
433 die "This operation is restricted to admin users\n"
434 if (defined @conf::admin_users and
435 !isin( $real_user, @conf::admin_users));
436 my $tmpfile_pattern = "/tmp/wanna-build-$distribution.$$-";
438 for( $i = 0;; ++$i ) {
439 $tmpfile = $tmpfile_pattern . $i;
440 last if ! -e $tmpfile;
442 write_db( $tmpfile );
443 my $editor = $ENV{'VISUAL'} ||
444 "/usr/bin/sensible-editor";
445 system "$editor $tmpfile";
446 %db = (); # clear all current contents
452 die "This operation is restricted to admin users\n"
453 if (defined @conf::admin_users and
454 !isin( $real_user, @conf::admin_users));
459 die "Unexpected operation mode $op_mode\n";
461 if (not -t and $user =~ /-/) {
462 my $userinfo = $db{'_userinfo'};
463 $userinfo = {} if (!defined($userinfo));
465 my $ui = $userinfo->{$user};
466 $ui = {} if (!defined($ui));
468 $ui->{'Last-Seen'} = $curr_date;
469 $ui->{'User'} = $user;
471 $userinfo->{$user} = $ui;
472 $db{'_userinfo'} = $userinfo;
477 my $newstate = shift;
478 my( $package, $name, $version, $ok, $reason );
480 foreach $package (@_) {
481 $package =~ s,^.*/,,; # strip path
482 $package =~ s/\.(dsc|diff\.gz|tar\.gz|deb)$//; # strip extension
483 $package =~ s/_[a-zA-Z\d-]+\.changes$//; # strip extension
484 if ($package =~ /^([\w\d.+-]+)_([\w\d:.+~-]+)/) {
485 ($name,$version) = ($1,$2);
488 warn "$package: can't extract package name and version ".
493 if ($op_mode eq "set-building") {
494 add_one_building( $name, $version );
496 elsif ($op_mode eq "set-built") {
497 add_one_built( $name, $version );
499 elsif ($op_mode eq "set-attempted") {
500 add_one_attempted( $name, $version );
502 elsif ($op_mode eq "set-uploaded") {
503 add_one_uploaded( $name, $version );
505 elsif ($op_mode eq "set-failed") {
506 add_one_failed( $name, $version );
508 elsif ($op_mode eq "set-not-for-us") {
509 add_one_notforus( $name, $version );
511 elsif ($op_mode eq "set-needs-build") {
512 add_one_needsbuild( $name, $version );
514 elsif ($op_mode eq "set-dep-wait") {
515 add_one_depwait( $name, $version );
517 elsif ($op_mode eq "set-build-priority") {
518 set_one_buildpri( $name, $version, 'BuildPri' );
520 elsif ($op_mode eq "set-permanent-build-priority") {
521 set_one_buildpri( $name, $version, 'PermBuildPri' );
523 elsif ($op_mode eq "set-binary-nmu") {
524 set_one_binnmu( $name, $version );
529 sub add_one_building {
535 my $pkg = $db{$name};
537 if ($pkg->{'State'} eq "Not-For-Us") {
539 $reason = "not suitable for this architecture";
541 elsif ($pkg->{'State'} =~ /^Dep-Wait/) {
543 $reason = "not all source dependencies available yet";
545 elsif ($pkg->{'State'} eq "Uploaded" &&
546 (version_lesseq($version, $pkg->{'Version'}))) {
548 $reason = "already uploaded by $pkg->{'Builder'}";
549 $reason .= " (in newer version $pkg->{'Version'})"
550 if !version_eq($pkg, $version);
552 elsif ($pkg->{'State'} eq "Installed" &&
553 version_less($version,$pkg->{'Version'})) {
555 print "$name: Warning: newer version $pkg->{'Version'} ".
556 "already installed, but overridden.\n";
560 $reason = "newer version $pkg->{'Version'} already in ".
561 "archive; doesn't need rebuilding";
562 print "$name: Note: If the following is due to an epoch ",
563 " change, use --override\n";
566 elsif ($pkg->{'State'} eq "Installed" &&
567 pkg_version_eq($pkg,$version)) {
569 $reason = "is up-to-date in the archive; doesn't need rebuilding";
571 elsif ($pkg->{'State'} eq "Needs-Build" &&
572 version_less($version,$pkg->{'Version'})) {
574 print "$name: Warning: newer version $pkg->{'Version'} ".
575 "needs building, but overridden.";
579 $reason = "newer version $pkg->{'Version'} needs building, ".
583 elsif (isin($pkg->{'State'},qw(Building Built Build-Attempted))) {
584 if (version_less($pkg->{'Version'},$version)) {
585 print "$name: Warning: Older version $pkg->{'Version'} ",
586 "is being built by $pkg->{'Builder'}\n";
587 if ($pkg->{'Builder'} ne $user) {
588 send_mail( $pkg->{'Builder'},
589 "package takeover in newer version",
590 "You are building package '$name' in ".
591 "version $version\n".
592 "(as far as I'm informed).\n".
593 "$user now has taken the newer ".
594 "version $version for building.".
595 "You can abort the build if you like.\n" );
600 print "User $pkg->{'Builder'} had already ",
601 "taken the following package,\n",
602 "but overriding this as you request:\n";
603 send_mail( $pkg->{'Builder'}, "package takeover",
604 "The package '$name' (version $version) that ".
605 "was locked by you\n".
606 "has been taken over by $user\n" );
608 elsif ($pkg->{'Builder'} eq $user) {
609 print "$name: Note: already taken by you.\n";
610 print "$name: ok\n" if $verbose;
615 $reason = "already taken by $pkg->{'Builder'}";
616 $reason .= " (in newer version $pkg->{'Version'})"
617 if !version_eq($pkg->{'Version'}, $version);
621 elsif ($pkg->{'State'} =~ /^Failed/ &&
622 pkg_version_eq($pkg, $version)) {
624 print "The following package previously failed ",
625 "(by $pkg->{'Builder'})\n",
626 "but overriding this as you request:\n";
627 send_mail( $pkg->{'Builder'}, "failed package takeover",
628 "The package '$name' (version $version) that ".
629 "is locked by you\n".
630 "and has failed previously has been taken over ".
632 if $pkg->{'Builder'} ne $user;
636 $reason = "build of $version failed previously:\n ";
637 $reason .= join( "\n ", split( "\n", $pkg->{'Failed'} ));
638 $reason .= "\nalso the package doesn't need builing"
639 if $pkg->{'State'} eq 'Failed-Removed';
645 if ($pkg->{'Binary-NMU-Version'}) {
646 print "$name: Warning: needs binary NMU $pkg->{'Binary-NMU-Version'}\n" .
647 "$pkg->{'Binary-NMU-Changelog'}\n";
650 print "$name: Warning: Previous version failed!\n"
651 if $pkg->{'Previous-State'} =~ /^Failed/ ||
652 $pkg->{'State'} =~ /^Failed/;
654 change_state( \$pkg, 'Building' );
655 $pkg->{'Package'} = $name;
656 $pkg->{'Version'} = $version;
657 $pkg->{'Builder'} = $user;
658 log_ta( $pkg, "--take" );
660 print "$name: $ok\n" if $verbose;
663 print "$name: NOT OK!\n $reason\n";
667 sub add_one_attempted {
670 my $pkg = $db{$name};
672 if (!defined($pkg)) {
673 print "$name: not registered yet.\n";
677 if ($pkg->{'State'} ne "Building" ) {
678 print "$name: not taken for building (state is $pkg->{'State'}). ",
682 if ($pkg->{'Builder'} ne $user) {
683 print "$name: not taken by you, but by $pkg->{'Builder'}. Skipping.\n";
686 elsif ( !pkg_version_eq($pkg, $version) ) {
687 print "$name: version mismatch ".
688 "$(pkg->{'Version'} ".
689 "by $pkg->{'Builder'})\n";
693 change_state( \$pkg, 'Build-Attempted' );
694 log_ta( $pkg, "--attempted" );
696 print "$name: registered as uploaded\n" if $verbose;
702 my $pkg = $db{$name};
704 if (!defined($pkg)) {
705 print "$name: not registered yet.\n";
709 if ($pkg->{'State'} ne "Building" ) {
710 print "$name: not taken for building (state is $pkg->{'State'}). ",
714 if ($pkg->{'Builder'} ne $user) {
715 print "$name: not taken by you, but by $pkg->{'Builder'}. Skipping.\n";
718 elsif ( !pkg_version_eq($pkg, $version) ) {
719 print "$name: version mismatch ".
720 "$(pkg->{'Version'} ".
721 "by $pkg->{'Builder'})\n";
724 change_state( \$pkg, 'Built' );
725 log_ta( $pkg, "--built" );
727 print "$name: registered as built\n" if $verbose;
730 sub add_one_uploaded {
733 my $pkg = $db{$name};
735 if (!defined($pkg)) {
736 print "$name: not registered yet.\n";
740 if ($pkg->{'State'} eq "Uploaded" &&
741 pkg_version_eq($pkg,$version)) {
742 print "$name: already uploaded\n";
745 if (!isin( $pkg->{'State'}, qw(Building Built Build-Attempted))) {
746 print "$name: not taken for building (state is $pkg->{'State'}). ",
750 if ($pkg->{'Builder'} ne $user) {
751 print "$name: not taken by you, but by $pkg->{'Builder'}. Skipping.\n";
754 # strip epoch -- buildd-uploader used to go based on the filename.
755 # (to remove at some point)
757 ($pkgver = $pkg->{'Version'}) =~ s/^\d+://;
758 $version =~ s/^\d+://; # for command line use
759 if ($pkg->{'Binary-NMU-Version'} ) {
760 my $nmuver = binNMU_version($pkgver, $pkg->{'Binary-NMU-Version'});
761 if (!version_eq( $nmuver, $version )) {
762 print "$name: version mismatch ($nmuver registered). ",
766 } elsif (!version_eq($pkgver, $version)) {
767 print "$name: version mismatch ($pkg->{'Version'} registered). ",
772 change_state( \$pkg, 'Uploaded' );
773 log_ta( $pkg, "--uploaded" );
775 print "$name: registered as uploaded\n" if $verbose;
782 my $pkg = $db{$name};
784 if (!defined($pkg)) {
785 print "$name: not registered yet.\n";
788 $state = $pkg->{'State'};
790 if ($state eq "Not-For-Us") {
791 print "$name: not suitable for this architecture anyway. Skipping.\n";
794 elsif ($state eq "Failed-Removed") {
795 print "$name: failed previously and doesn't need building. Skipping.\n";
798 elsif ($state eq "Installed") {
799 print "$name: Is already installed in archive. Skipping.\n";
802 elsif ($pkg->{'Builder'} &&
803 (($user ne $pkg->{'Builder'}) &&
804 !($pkg->{'Builder'} =~ /^(\w+)-\w+/ && $1 eq $user))) {
805 print "$name: not taken by you, but by ".
806 "$pkg->{'Builder'}. Skipping.\n";
809 elsif ( !pkg_version_eq($pkg, $version) ) {
810 print "$name: version mismatch ".
811 "$(pkg->{'Version'} ".
812 "by $pkg->{'Builder'})\n";
817 if (!$cat && $fail_reason =~ /^\[([^\]]+)\]/) {
819 $cat = $short_category{$cat} if exists $short_category{$cat};
820 if (!isin( $cat, values %short_category )) {
821 print "$name: Warning: unknown category $cat; discarded\n";
824 $fail_reason =~ s/^\[[^\]]+\][ \t]*\n*//;
827 if ($state eq "Needs-Build") {
828 print "$name: Warning: not registered for building previously, ".
829 "but processing anyway.\n";
831 elsif ($state eq "Uploaded") {
832 print "$name: Warning: marked as uploaded previously, ".
833 "but processing anyway.\n";
835 elsif ($state eq "Dep-Wait") {
836 print "$name: Warning: marked as waiting for dependencies, ".
837 "but processing anyway.\n";
839 elsif ($state eq "Failed") {
840 print "$name: already registered as failed; will append new message\n"
842 print "$name: already registered as failed; changing category\n"
846 if (($cat eq "reminder-sent" || $cat eq "nmu-offered") &&
847 exists $pkg->{'Failed-Category'} &&
848 $pkg->{'Failed-Category'} ne $cat) {
849 (my $action = $cat) =~ s/-/ /;
850 $fail_reason .= "\n$short_date: $action";
853 change_state( \$pkg, 'Failed' );
854 $pkg->{'Builder'} = $user;
855 $pkg->{'Failed'} .= "\n" if $pkg->{'Failed'};
856 $pkg->{'Failed'} .= $fail_reason;
857 $pkg->{'Failed-Category'} = $cat if $cat;
858 if (defined $pkg->{'PermBuildPri'}) {
859 $pkg->{'BuildPri'} = $pkg->{'PermBuildPri'};
861 delete $pkg->{'BuildPri'};
863 log_ta( $pkg, "--failed" );
865 print "$name: registered as failed\n" if $verbose;
868 sub add_one_notforus {
871 my $pkg = $db{$name};
873 if ($pkg->{'State'} eq 'Not-For-Us') {
874 # reset Not-For-Us state in case it's called twice; this is
875 # the only way to get a package out of this state...
876 # There is no really good state in which such packages should
877 # be put :-( So use Failed for now.
878 change_state( \$pkg, 'Failed' );
879 $pkg->{'Package'} = $name;
880 $pkg->{'Failed'} = "Was Not-For-Us previously";
881 delete $pkg->{'Builder'};
882 delete $pkg->{'Depends'};
883 log_ta( $pkg, "--no-build(rev)" );
884 print "$name: now not unsuitable anymore\n";
886 send_mail( $conf::notforus_maint,
887 "$name moved out of Not-For-Us state",
888 "The package '$name' has been moved out of the Not-For-Us ".
890 "It should probably also be removed from ".
891 "Packages-arch-specific or\n".
892 "the action was wrong.\n" )
893 if $conf::notforus_maint;
896 change_state( \$pkg, 'Not-For-Us' );
897 $pkg->{'Package'} = $name;
898 delete $pkg->{'Builder'};
899 delete $pkg->{'Depends'};
900 delete $pkg->{'BuildPri'};
901 delete $pkg->{'Binary-NMU-Version'};
902 delete $pkg->{'Binary-NMU-Changelog'};
903 log_ta( $pkg, "--no-build" );
904 print "$name: registered as unsuitable\n" if $verbose;
906 send_mail( $conf::notforus_maint,
907 "$name set to Not-For-Us",
908 "The package '$name' has been set to state Not-For-Us ".
910 "It should probably also be added to ".
911 "Packages-arch-specific or\n".
912 "the Not-For-Us state is wrong.\n" )
913 if $conf::notforus_maint;
918 sub add_one_needsbuild {
922 my $pkg = $db{$name};
924 if (!defined($pkg)) {
925 print "$name: not registered; can't give back.\n";
928 $state = $pkg->{'State'};
930 if ($state eq "Dep-Wait") {
932 print "$name: Forcing source dependency list to be cleared\n";
935 print "$name: waiting for source dependencies. Skipping\n",
936 " (use --override to clear dependency list and ",
937 "give back anyway)\n";
941 elsif (!isin( $state, qw(Building Built Build-Attempted))) {
942 print "$name: not taken for building (state is $state).";
944 print "\n$name: Forcing give-back\n";
947 print " Skipping.\n";
951 if (defined ($pkg->{'Builder'}) && $user ne $pkg->{'Builder'} &&
952 !($pkg->{'Builder'} =~ /^(\w+)-\w+/ && $1 eq $user)) {
953 print "$name: not taken by you, but by ".
954 "$pkg->{'Builder'}. Skipping.\n";
957 if (!pkg_version_eq($pkg, $version)) {
958 print "$name: version mismatch ($pkg->{'Version'} registered). ",
962 change_state( \$pkg, 'Needs-Build' );
963 delete $pkg->{'Builder'};
964 delete $pkg->{'Depends'};
965 log_ta( $pkg, "--give-back" );
967 print "$name: given back\n" if $verbose;
973 my $pkg = $db{$name};
976 if (!defined($pkg)) {
977 print "$name: not registered; can't register for binNMU.\n";
980 my $db_ver = $pkg->{'Version'};
982 if (!version_eq($db_ver, $version)) {
983 print "$name: version mismatch ($db_ver registered). ",
987 $state = $pkg->{'State'};
989 if (defined $pkg->{'Binary-NMU-Version'}) {
990 if ($binNMUver == 0) {
991 change_state( \$pkg, 'Installed' );
992 delete $pkg->{'Builder'};
993 delete $pkg->{'Depends'};
994 delete $pkg->{'Binary-NMU-Version'};
995 delete $pkg->{'Binary-NMU-Changelog'};
996 } elsif ($binNMUver <= $pkg->{'Binary-NMU-Version'}) {
997 print "$name: already building binNMU $pkg->{'Binary-NMU-Version'}\n";
1000 $pkg->{'Binary-NMU-Version'} = $binNMUver;
1001 $pkg->{'Binary-NMU-Changelog'} = $fail_reason;
1002 $pkg->{'Notes'} = 'out-of-date';
1003 $pkg->{'BuildPri'} = $pkg->{'PermBuildPri'}
1004 if (defined $pkg->{'PermBuildPri'});
1006 log_ta( $pkg, "--binNMU" );
1009 } elsif ($binNMUver == 0) {
1010 print "${name}_$version: no scheduled binNMU to cancel.\n";
1014 if ($state ne 'Installed') {
1015 print "${name}_$version: not installed; can't register for binNMU.\n";
1019 my $fullver = binNMU_version($version,$binNMUver);
1020 if ( version_lesseq( $fullver, $pkg->{'Installed-Version'} ) )
1022 print "$name: binNMU $fullver is not newer than current version $pkg->{'Installed-Version'}\n";
1026 change_state( \$pkg, 'Needs-Build' );
1027 delete $pkg->{'Builder'};
1028 delete $pkg->{'Depends'};
1029 $pkg->{'Binary-NMU-Version'} = $binNMUver;
1030 $pkg->{'Binary-NMU-Changelog'} = $fail_reason;
1031 $pkg->{'Notes'} = 'out-of-date';
1032 log_ta( $pkg, "--binNMU" );
1034 print "${name}: registered for binNMU $fullver\n" if $verbose;
1037 sub set_one_buildpri {
1039 my $version = shift;
1041 my $pkg = $db{$name};
1044 if (!defined($pkg)) {
1045 print "$name: not registered; can't set priority.\n";
1048 $state = $pkg->{'State'};
1050 if ($state eq "Not-For-Us") {
1051 print "$name: not suitable for this architecture. Skipping.\n";
1053 } elsif ($state eq "Failed-Removed") {
1054 print "$name: failed previously and doesn't need building. Skipping.\n";
1057 if (!pkg_version_eq($pkg, $version)) {
1058 print "$name: version mismatch ($pkg->{'Version'} registered). ",
1062 if ( $build_priority == 0 ) {
1063 delete $pkg->{'BuildPri'}
1064 if $key eq 'PermBuildPri' and defined $pkg->{'BuildPri'}
1065 and $pkg->{'BuildPri'} == $pkg->{$key};
1066 delete $pkg->{$key};
1068 $pkg->{'BuildPri'} = $build_priority
1069 if $key eq 'PermBuildPri';
1070 $pkg->{$key} = $build_priority;
1073 print "$name: set to build priority $build_priority\n" if $verbose;
1076 sub add_one_depwait {
1078 my $version = shift;
1080 my $pkg = $db{$name};
1082 if (!defined($pkg)) {
1083 print "$name: not registered yet.\n";
1086 $state = $pkg->{'State'};
1088 if ($state eq "Dep-Wait") {
1089 print "$name: merging with previously registered dependencies\n";
1092 if (isin( $state, qw(Needs-Build Failed))) {
1093 print "$name: Warning: not registered for building previously, ".
1094 "but processing anyway.\n";
1096 elsif ($state eq "Not-For-Us") {
1097 print "$name: not suitable for this architecture anyway. Skipping.\n";
1100 elsif ($state eq "Failed-Removed") {
1101 print "$name: failed previously and doesn't need building. Skipping.\n";
1104 elsif ($state eq "Installed") {
1105 print "$name: Is already installed in archive. Skipping.\n";
1108 elsif ($state eq "Uploaded") {
1109 print "$name: Is already uploaded. Skipping.\n";
1112 elsif ($pkg->{'Builder'} &&
1113 $user ne $pkg->{'Builder'}) {
1114 print "$name: not taken by you, but by ".
1115 "$pkg->{'Builder'}. Skipping.\n";
1118 elsif ( !pkg_version_eq($pkg,$version)) {
1119 print "$name: version mismatch ".
1120 "($pkg->{'Version'} ".
1121 "by $pkg->{'Builder'})\n";
1124 elsif ($fail_reason =~ /^\s*$/ ||
1125 !parse_deplist( $fail_reason, 1 )) {
1126 print "$name: Bad dependency list\n";
1129 change_state( \$pkg, 'Dep-Wait' );
1130 $pkg->{'Builder'} = $user;
1131 if (defined $pkg->{'PermBuildPri'}) {
1132 $pkg->{'BuildPri'} = $pkg->{'PermBuildPri'};
1134 delete $pkg->{'BuildPri'};
1136 my $deplist = parse_deplist( $pkg->{'Depends'} );
1137 my $new_deplist = parse_deplist( $fail_reason );
1138 # add new dependencies, maybe overwriting old entries
1139 foreach (keys %$new_deplist) {
1140 $deplist->{$_} = $new_deplist->{$_};
1142 $pkg->{'Depends'} = build_deplist($deplist);
1143 log_ta( $pkg, "--dep-wait" );
1145 print "$name: registered as waiting for dependencies\n" if $verbose;
1155 local($/) = ""; # read in paragraph mode
1157 my( $version, $arch, $section, $priority, $builddep, $buildconf, $binaries );
1159 /^Package:\s*(\S+)$/mi and $name = $1;
1160 /^Version:\s*(\S+)$/mi and $version = $1;
1161 /^Architecture:\s*(\S+)$/mi and $arch = $1;
1162 /^Section:\s*(\S+)$/mi and $section = $1;
1163 /^Priority:\s*(\S+)$/mi and $priority = $1;
1164 /^Build-Depends:\s*(.*)$/mi and $builddep = $1;
1165 /^Build-Conflicts:\s*(.*)$/mi and $buildconf = $1;
1166 /^Binary:\s*(.*)$/mi and $binaries = $1;
1168 next if (defined $srcver{$name} and version_less( $version, $srcver{$name} ));
1169 $srcver{$name} = $version;
1171 $buildconf = join( ", ", map { "!$_" } split( /\s*,\s*/, $buildconf ));
1173 $builddep .= "," . $buildconf;
1175 $builddep = $buildconf;
1179 $pkgs{$name}{'dep'} = defined $builddep ? $builddep : "";
1180 $pkgs{$name}{'ver'} = $version;
1181 $pkgs{$name}{'bin'} = $binaries;
1182 my $pkg = $db{$name};
1187 if ($arch eq "all" && !version_less( $version, $pkg->{'Version'} )) {
1188 # package is now Arch: all, delete it from db
1189 change_state( \$pkg, 'deleted' );
1190 log_ta( $pkg, "--merge-sources" );
1191 print "$name ($pkg->{'Version'}): deleted ".
1192 "from database, because now Arch: all\n"
1198 # The "Version" should always be the source version --
1199 # not a possible binNMU version number.
1200 $pkg->{'Version'} = $version, $change++
1201 if ($pkg->{'State'} eq 'Installed' and
1202 !version_eq( $pkg->{'Version'}, $version));
1203 # Always update priority and section, if available
1204 $pkg->{'Priority'} = $priority, $change++
1205 if defined $priority and (not defined($pkg->{'Priority'}) or $pkg->{'Priority'} ne $priority);
1207 $pkg->{'Section'} = $section, $change++
1208 if defined $section and (not defined($pkg->{'Section'}) or $pkg->{'Section'} ne $section);
1209 $db{$name} = $pkg if $change;
1212 # Now that we only have the latest source version, build the list
1213 # of binary packages from the Sources point of view
1214 foreach $name (keys %pkgs) {
1215 foreach my $bin (split( /\s*,\s*/, $pkgs{$name}{'bin'} ) ) {
1216 $merge_binsrc{$bin} = $name;
1219 # remove installed packages that no longer have source available
1220 # or binaries installed
1221 foreach $name (keys %db) {
1222 next if $name =~ /^_/;
1223 my $pkg = $db{$name};
1224 if (not defined($pkgs{$name})) {
1225 change_state( \$pkg, 'deleted' );
1226 log_ta( $pkg, "--merge-sources" );
1227 print "$name ($pkg->{'Version'}): ".
1228 "deleted from database, because ".
1229 "not in Sources anymore\n"
1233 next if !isin( $pkg->{'State'}, qw(Installed) );
1234 if ($full && not defined $merge_srcvers{$name}) {
1235 change_state( \$pkg, 'deleted' );
1236 log_ta( $pkg, "--merge-sources" );
1237 print "$name ($pkg->{'Version'}): ".
1238 "deleted from database, because ".
1239 "binaries don't exist anymore\n"
1242 } elsif ($full && version_less( $merge_srcvers{$name}, $pkg->{'Version'})) {
1243 print "$name ($pkg->{'Version'}): ".
1244 "package is Installed but binaries are from ".
1245 $merge_srcvers{$name}. "\n"
1253 # This function looks through a Packages file and sets the state of
1254 # packages to 'Installed'
1255 sub parse_packages {
1258 local($/) = ""; # read in paragraph mode
1260 my( $name, $version, $depends, $source, $sourcev, $architecture, $provides, $binaryv, $binnmu );
1262 /^Package:\s*(\S+)$/mi and $name = $1;
1263 /^Version:\s*(\S+)$/mi and $version = $1;
1264 /^Depends:\s*(.*)$/mi and $depends = $1;
1265 /^Source:\s*(\S+)(\s*\((\S+)\))?$/mi and ($source,$sourcev) = ($1, $3);
1266 /^Architecture:\s*(\S+)$/mi and $architecture = $1;
1267 /^Provides:\s*(.*)$/mi and $provides = $1;
1268 next if !$name || !$version;
1269 next if ($arch ne $architecture and $architecture ne "all");
1270 next if (defined ($installed->{$name}) and $installed->{$name}{'Version'} ne "" and
1271 version_lesseq( $version, $installed->{$name}{'Version'} ));
1272 $installed->{$name}{'Version'} = $version;
1273 $installed->{$name}{'Depends'} = $depends;
1274 $installed->{$name}{'all'} = 1 if $architecture eq "all";
1275 undef $installed->{$name}{'Provider'};
1276 $installed->{$name}{'Source'} = $source ? $source : $name;
1278 foreach (split( /\s*,\s*/, $provides )) {
1279 if (not defined ($installed->{$_})) {
1280 $installed->{$_}{'Version'} = "";
1281 $installed->{$_}{'Provider'} = $name;
1285 if ( $version =~ /\+b(\d+)$/ ) {
1288 $version = $sourcev if $sourcev;
1289 $binaryv = $version;
1290 $binaryv =~ s/\+b\d+$//;
1291 $installed->{$name}{'Sourcev'} = $sourcev ? $sourcev : $binaryv;
1292 $binaryv .= "+b$binnmu" if defined($binnmu);
1294 next if $architecture ne $arch;
1295 $name = $source if $source;
1296 next if defined($merge_srcvers{$name}) and $merge_srcvers{$name} eq $version;
1297 $merge_srcvers{$name} = $version;
1299 my $pkg = $db{$name};
1302 if (isin( $pkg->{'State'}, qw(Not-For-Us)) ||
1303 (isin($pkg->{'State'}, qw(Installed)) &&
1304 version_lesseq($binaryv, $pkg->{'Installed-Version'}))) {
1305 print "Skipping $name because State == $pkg->{'State'}\n"
1309 if ($pkg->{'Binary-NMU-Version'} ) {
1310 my $nmuver = binNMU_version($pkg->{'Version'}, $pkg->{'Binary-NMU-Version'});
1311 if (version_less( $binaryv, $nmuver )) {
1312 print "Skipping $name ($version) because have newer ".
1313 "version ($nmuver) in db.\n"
1317 } elsif (version_less($version, $pkg->{'Version'})) {
1318 print "Skipping $name ($version) because have newer ".
1319 "version ($pkg->{'Version'}) in db.\n"
1324 if (!pkg_version_eq($pkg, $version) &&
1325 $pkg->{'State'} ne "Installed") {
1326 warn "Warning: $name: newer version than expected appeared ".
1327 "in archive ($version vs. $pkg->{'Version'})\n";
1328 delete $pkg->{'Builder'};
1331 if (!isin( $pkg->{'State'}, qw(Uploaded) )) {
1332 warn "Warning: Package $name was not in uploaded state ".
1333 "before (but in '$pkg->{'State'}').\n";
1334 delete $pkg->{'Builder'};
1335 delete $pkg->{'Depends'};
1339 $pkg->{'Version'} = $version;
1342 change_state( \$pkg, 'Installed' );
1343 $pkg->{'Package'} = $name;
1344 $pkg->{'Installed-Version'} = $binaryv;
1345 if (defined $pkg->{'PermBuildPri'}) {
1346 $pkg->{'BuildPri'} = $pkg->{'PermBuildPri'};
1348 delete $pkg->{'BuildPri'};
1350 $pkg->{'Version'} = $version
1351 if version_less( $pkg->{'Version'}, $version);
1352 delete $pkg->{'Binary-NMU-Version'};
1353 delete $pkg->{'Binary-NMU-Changelog'};
1354 log_ta( $pkg, "--merge-packages" );
1356 print "$name ($version) is up-to-date now.\n" if $verbose;
1359 check_dep_wait( "--merge-packages", $installed );
1364 my ($package, $name, $version, $installed);
1366 foreach $package (@_) {
1367 $package =~ s,^.*/,,; # strip path
1368 $package =~ s/\.(dsc|diff\.gz|tar\.gz|deb)$//; # strip extension
1369 $package =~ s/_[\w\d]+\.changes$//; # strip extension
1370 if ($package =~ /^([\w\d.+-]+)_([\w\d:.+~-]+)/) {
1371 ($name,$version) = ($1,$2);
1374 warn "$package: can't extract package name and version ".
1378 $installed->{$name}{'Version'} = $version;
1381 check_dep_wait( "--pretend-avail", $installed );
1384 sub check_dep_wait {
1386 my $installed = shift;
1388 # check all packages in state Dep-Wait if dependencies are all
1391 foreach $name (keys %db) {
1392 next if $name =~ /^_/;
1393 my $pkg = $db{$name};
1394 next if $pkg->{'State'} ne "Dep-Wait";
1395 my $deps = $pkg->{'Depends'};
1397 print "$name: was in state Dep-Wait, but with empty ",
1399 goto make_needs_build;
1401 my $deplist = parse_deplist($deps);
1405 foreach (keys %$deplist) {
1406 if (!exists $installed->{$_} ||
1407 ($deplist->{$_}->{'Rel'} && $deplist->{$_}->{'Version'} &&
1408 !version_compare( $installed->{$_}{'Version'},
1409 $deplist->{$_}->{'Rel'},
1410 $deplist->{$_}->{'Version'}))) {
1412 $new_deplist->{$_} = $deplist->{$_};
1415 push( @removed_deps, $_ );
1420 change_state( \$pkg, 'Needs-Build' );
1421 log_ta( $pkg, $action );
1422 delete $pkg->{'Builder'};
1423 delete $pkg->{'Depends'};
1424 print "$name ($pkg->{'Version'}) has all ",
1425 "dependencies available now\n" if $verbose;
1429 elsif (@removed_deps) {
1430 $pkg->{'Depends'} = build_deplist( $new_deplist );
1431 print "$name ($pkg->{'Version'}): some dependencies ",
1432 "(@removed_deps) available now, but not all yet\n"
1439 # This function accepts quinn-diff output (either from a file named on
1440 # the command line, or on stdin) and sets the packages named there to
1441 # state 'Needs-Build'.
1442 sub parse_quinn_diff {
1443 my $partial = shift;
1449 next if !m,^([-\w\d/]*)/ # section
1450 ([-\w\d.+]+)_ # package name
1451 ([\w\d:.~+-]+)\.dsc\s* # version
1452 \[([^:]*): # priority
1453 ([^]]+)\]\s*$,x; # rest of notes
1454 my($section,$name,$version,$priority,$notes) = ($1, $2, $3, $4, $5);
1455 $quinn_pkgs{$name}++;
1456 $section ||= "unknown";
1457 $priority ||= "unknown";
1458 $priority = "unknown" if $priority eq "-";
1459 $priority = "standard" if ($name eq "debian-installer");
1461 my $pkg = $db{$name};
1463 # Always update section and priority.
1464 if (defined($pkg)) {
1466 $pkg->{'Section'} = $section, $change++ if not defined
1467 $pkg->{'Section'} or $section ne "unknown";
1468 $pkg->{'Priority'} = $priority, $change++ if not defined
1469 $pkg->{'Priority'} or $priority ne "unknown";
1472 if (defined($pkg) &&
1473 $pkg->{'State'} =~ /^Dep-Wait/ &&
1474 version_less( $pkg->{'Version'}, $version )) {
1475 change_state( \$pkg, 'Dep-Wait' );
1476 $pkg->{'Version'} = $version;
1477 delete $pkg->{'Binary-NMU-Version'};
1478 delete $pkg->{'Binary-NMU-Changelog'};
1479 log_ta( $pkg, "--merge-quinn" );
1481 print "$name ($version) still waiting for dependencies.\n"
1484 elsif (defined($pkg) &&
1485 $pkg->{'State'} =~ /-Removed$/ &&
1486 version_eq($pkg->{'Version'}, $version)) {
1487 # reinstantiate a package that has been removed earlier
1488 # (probably due to a quinn-diff malfunction...)
1489 my $newstate = $pkg->{'State'};
1490 $newstate =~ s/-Removed$//;
1491 change_state( \$pkg, $newstate );
1492 $pkg->{'Version'} = $version;
1493 $pkg->{'Notes'} = $notes;
1494 log_ta( $pkg, "--merge-quinn" );
1496 print "$name ($version) reinstantiated to $newstate.\n"
1499 elsif (defined($pkg) &&
1500 $pkg->{'State'} eq "Not-For-Us" &&
1501 version_less( $pkg->{'Version'}, $version )) {
1502 # for Not-For-Us packages just update the version etc., but
1504 change_state( \$pkg, "Not-For-Us" );
1505 $pkg->{'Package'} = $name;
1506 $pkg->{'Version'} = $version;
1507 $pkg->{'Notes'} = $notes;
1508 delete $pkg->{'Builder'};
1509 log_ta( $pkg, "--merge-quinn" );
1511 print "$name ($version) still Not-For-Us.\n" if $verbose;
1513 elsif (!defined($pkg) ||
1514 $pkg->{'State'} ne "Not-For-Us" &&
1515 (version_less( $pkg->{'Version'}, $version ) ||
1516 ($pkg->{'State'} eq "Installed" && version_less($pkg->{'Installed-Version'}, $version)))) {
1518 if (defined( $pkg->{'State'} ) && isin( $pkg->{'State'}, qw(Building Built Build-Attempted))) {
1519 send_mail( $pkg->{'Builder'},
1520 "new version of $name (dist=$distribution)",
1521 "As far as I'm informed, you're currently ".
1522 "building the package $name\n".
1523 "in version $pkg->{'Version'}.\n\n".
1524 "Now there's a new source version $version. ".
1525 "If you haven't finished\n".
1526 "compiling $name yet, you can stop it to ".
1527 "save some work.\n".
1528 "Just to inform you...\n".
1529 "(This is an automated message)\n" );
1530 print "$name: new version ($version) while building ".
1531 "$pkg->{'Version'} -- sending mail ".
1532 "to builder ($pkg->{'Builder'})\n"
1535 change_state( \$pkg, 'Needs-Build' );
1536 $pkg->{'Package'} = $name;
1537 $pkg->{'Version'} = $version;
1538 $pkg->{'Section'} = $section;
1539 $pkg->{'Priority'} = $priority;
1540 $pkg->{'Notes'} = $notes;
1541 delete $pkg->{'Builder'};
1542 delete $pkg->{'Binary-NMU-Version'};
1543 delete $pkg->{'Binary-NMU-Changelog'};
1544 log_ta( $pkg, "--merge-quinn" );
1547 print "$name ($version) needs rebuilding now.\n" if $verbose;
1549 elsif (defined($pkg) &&
1550 !version_eq( $pkg->{'Version'}, $version ) &&
1551 isin( $pkg->{'State'}, qw(Installed Not-For-Us) )) {
1552 print "$name: skipping because version in db ".
1553 "($pkg->{'Version'}) is >> than ".
1554 "what quinn-diff says ($version) ".
1555 "(state is $pkg->{'State'})\n"
1557 $dubious .= "$pkg->{'State'}: ".
1558 "db ${name}_$pkg->{'Version'} >> ".
1559 "quinn $version\n" if !$partial;
1561 elsif ($verbose >= 2) {
1562 if ($pkg->{'State'} eq "Not-For-Us") {
1563 print "Skipping $name because State == ".
1564 "$pkg->{'State'}\n";
1566 elsif (!version_less($pkg->{'Version'}, $version)) {
1567 print "Skipping $name because version in db ".
1568 "($pkg->{'Version'}) is >= than ".
1569 "what quinn-diff says ($version)\n";
1572 $db{$name} = $pkg if $change;
1576 send_mail( $conf::db_maint,
1577 "Dubious versions in $distribution $conf::dbbase database",
1578 "The following packages have a newer version in the ".
1579 "wanna-build database\n".
1580 "than what quinn-diff says, and this is strange for ".
1582 "It could be caused by a lame mirror, or the version ".
1583 "in the database\n".
1588 # Now re-check the DB for packages in states Needs-Build, Failed,
1589 # or Dep-Wait and remove them if they're not listed anymore by quinn-diff.
1592 foreach $name (keys %db) {
1593 next if $name =~ /^_/;
1594 my $pkg = $db{$name};
1595 next if defined $pkg->{'Binary-NMU-Version'};
1596 next if !isin( $pkg->{'State'},
1597 qw(Needs-Build Building Built Build-Attempted Uploaded Failed Dep-Wait) );
1598 my $virtual_delete = $pkg->{'State'} eq 'Failed';
1600 if (!$quinn_pkgs{$name}) {
1601 change_state( \$pkg, $virtual_delete ?
1602 $pkg->{'State'}."-Removed" :
1604 log_ta( $pkg, "--merge-quinn" );
1605 print "$name ($pkg->{'Version'}): ".
1606 ($virtual_delete ? "(virtually) " : "") . "deleted ".
1607 "from database, because not in quinn-diff anymore\n"
1609 if ($virtual_delete) {
1619 sub send_reupload_mail {
1622 my $version = shift;
1624 my $other_dist = shift;
1627 "Please reupload ${pkg}_${'Version'} for $dist",
1628 "You have recently built (or are currently building)\n".
1629 "${pkg}_${'Version'} for $other_dist.\n".
1630 "This version is now also needed in the $dist distribution.\n".
1631 "Please reupload the files now present in the Debian archive\n".
1632 "(best with buildd-reupload).\n" );
1636 # for sorting priorities and sections
1638 %prioval = ( required => -5,
1646 'debian-installer' => -199,
1667 localizations => -178,
1668 interpreters => -177,
1693 electronics => -152,
1699 foreach my $i (keys %sectval) {
1700 $sectval{"contrib/$i"} = $sectval{$i}+40;
1701 $sectval{"non-free/$i"} = $sectval{$i}+80;
1703 $sectval{'unknown'} = -165;
1705 %catval = ( "none" => -20,
1706 "uploaded-fixed-pkg" => -19,
1707 "fix-expected" => -18,
1708 "reminder-sent" => -17,
1709 "nmu-offered" => -16,
1713 "compiler-error" => -12 );
1716 sub sort_list_func {
1717 my( $letter, $x, $ax, $bx );
1719 foreach $letter (split( "", $list_order )) {
1720 SWITCH: foreach ($letter) {
1722 $x = $b->{'BuildPri'} <=> $a->{'BuildPri'};
1723 return $x if $x != 0;
1727 $x = $prioval{$a->{'Priority'}} <=> $prioval{$b->{'Priority'}};
1728 return $x if $x != 0;
1732 $x = $sectval{$a->{'Section'}} <=> $sectval{$b->{'Section'}};
1733 return $x if $x != 0;
1737 $x = $a->{'Package'} cmp $b->{'Package'};
1738 return $x if $x != 0;
1742 $x = $a->{'Builder'} cmp $b->{'Builder'};
1743 return $x if $x != 0;
1747 $ax = ($a->{'Notes'} =~ /^(out-of-date|partial)/) ? 0 :
1748 ($a->{'Notes'} =~ /^uncompiled/) ? 2 : 1;
1749 $bx = ($b->{'Notes'} =~ /^(out-of-date|partial)/) ? 0 :
1750 ($b->{'Notes'} =~ /^uncompiled/) ? 2 : 1;
1752 return $x if $x != 0;
1756 my $ca = exists $a->{'Failed-Category'} ?
1757 $a->{'Failed-Category'} : "none";
1758 my $cb = exists $b->{'Failed-Category'} ?
1759 $b->{'Failed-Category'} : "none";
1760 $x = $catval{$ca} <=> $catval{$cb};
1761 return $x if $x != 0;
1765 my $pa = $prioval{$a->{'Priority'}} >
1766 $prioval{'standard'};
1767 my $pb = $prioval{$b->{'Priority'}} >
1768 $prioval{'standard'};
1770 return $x if $x != 0;
1780 my( $name, $pkg, @list );
1785 foreach $name (keys %db) {
1786 next if $name =~ /^_/;
1788 next if $state ne "all" && $pkg->{'State'} !~ /^\Q$state\E$/i;
1789 next if $user && (lc($state) ne 'needs-build' and $pkg->{'Builder'} ne $user);
1790 next if $category && $pkg->{'State'} eq "Failed" &&
1791 $pkg->{'Failed-Category'} ne $category;
1792 next if ($list_min_age > 0 &&
1793 ($ctime-parse_date($pkg->{'State-Change'})) < $list_min_age)||
1794 ($list_min_age < 0 &&
1795 ($ctime-parse_date($pkg->{'State-Change'})) > -$list_min_age);
1796 push( @list, $pkg );
1799 foreach $pkg (sort sort_list_func @list) {
1800 print "$pkg->{'Section'}/$pkg->{'Package'}_$pkg->{'Version'}";
1801 print ": $pkg->{'State'}"
1803 print " by $pkg->{'Builder'}"
1804 if $pkg->{'State'} ne "Needs-Build" && $pkg->{'Builder'};
1805 print " [$pkg->{'Priority'}:$pkg->{'Notes'}";
1806 print ":PREV-FAILED"
1807 if $pkg->{'Previous-State'} =~ /^Failed/;
1808 print ":bp{" . $pkg->{'BuildPri'} . "}"
1809 if exists $pkg->{'BuildPri'};
1810 print ":binNMU{" . $pkg->{'Binary-NMU-Version'} . "}"
1811 if exists $pkg->{'Binary-NMU-Version'};
1813 print " Reasons for failing:\n",
1815 exists $pkg->{'Failed-Category'} ? $pkg->{'Failed-Category'} : "none",
1817 join("\n ",split("\n",$pkg->{'Failed'})), "\n"
1818 if $pkg->{'State'} =~ /^Failed/;
1819 print " Dependencies: $pkg->{'Depends'}\n"
1820 if $pkg->{'State'} eq "Dep-Wait";
1821 print " Previous state was $pkg->{'Previous-State'} until ",
1822 "$pkg->{'State-Change'}\n"
1823 if $verbose && $pkg->{'Previous-State'};
1824 print " Previous failing reasons:\n ",
1825 join("\n ",split("\n",$pkg->{'Old-Failed'})), "\n"
1826 if $verbose && $pkg->{'Old-Failed'};
1828 $scnt{$pkg->{'State'}}++ if $state eq "all";
1830 if ($state eq "all") {
1831 foreach (sort keys %scnt) {
1832 print "Total $scnt{$_} package(s) in state $_.\n";
1835 print "Total $cnt package(s)\n";
1840 my( $name, $pkg, $key, $dist );
1841 my @firstkeys = qw(Package Version Builder State Section Priority
1842 Installed-Version Previous-State State-Change);
1843 my @dists = $info_all_dists ? keys %conf::distributions : ($distribution);
1845 foreach $dist (@dists) {
1846 if ($dist ne $distribution) {
1847 if (!-f db_filename( $dist ) || !open_other_db( $dist )) {
1848 warn "Cannot open database for $dist!\n";
1849 @dists = grep { $_ ne $dist } @dists;
1854 foreach $name (@_) {
1855 $name =~ s/_.*$//; # strip version
1856 foreach $dist (@dists) {
1857 my $db = $dist ne $distribution ? $otherdb{$dist} : \%db;
1858 my $pname = "$name" . ($info_all_dists ? "($dist)" : "");
1860 $pkg = $db->{$name};
1861 if (!defined( $pkg )) {
1862 print "$pname: not registered\n";
1867 foreach $key (@firstkeys) {
1868 next if !exists $pkg->{$key};
1869 my $val = $pkg->{$key};
1871 $val = "\n$val" if isin( $key, qw(Failed Old-Failed));
1873 printf " %-20s: %s\n", $key, $val;
1875 foreach $key (sort keys %$pkg) {
1876 next if isin( $key, @firstkeys );
1877 my $val = $pkg->{$key};
1879 $val = "\n$val" if isin( $key, qw(Failed Old-Failed));
1881 printf " %-20s: %s\n", $key, $val;
1887 sub forget_packages {
1888 my( $name, $pkg, $key, $data );
1890 foreach $name (@_) {
1891 $name =~ s/_.*$//; # strip version
1893 if (!defined( $pkg )) {
1894 print "$name: not registered\n";
1899 foreach $key (sort keys %$pkg) {
1900 my $val = $pkg->{$key};
1903 $data .= sprintf " %-20s: %s\n", $key, $val;
1905 send_mail( $conf::db_maint,
1906 "$name deleted from DB $conf::dbbase",
1907 "The package '$name' has been deleted from the database ".
1909 "Data registered about the deleted package:\n".
1910 "$data\n" ) if $conf::db_maint;
1911 change_state( \$pkg, 'deleted' );
1912 log_ta( $pkg, "--forget" );
1914 print "$name: deleted from database\n" if $verbose;
1922 $ui = $db{'_userinfo'};
1923 foreach $name (@_) {
1924 if (!defined( $ui->{$name} )) {
1925 print "$name: not registered\n";
1929 delete $ui->{$name};
1931 print "$name: deleted from database\n" if $verbose;
1933 $db{'_userinfo'} = $ui if $change;
1939 my $lockfile = db_filename($dist) . ".lock";
1942 print "Locking $dist database\n" if $verbose >= 2;
1944 if (!sysopen( F, $lockfile, O_WRONLY|O_CREAT|O_TRUNC|O_EXCL, 0644 )){
1946 # lock file exists, wait
1947 goto repeat if !open( F, "<$lockfile" );
1950 if ($line !~ /^(\d+)\s+([\w\d.-]+)$/) {
1951 warn "Bad lock file contents -- still trying\n";
1954 my($pid, $usr) = ($1, $2);
1955 if (kill( 0, $pid ) == 0 && $! == ESRCH) {
1956 # process doesn't exist anymore, remove stale lock
1957 print "Removing stale lock file (pid $pid, user $usr)\n";
1958 unlink( $lockfile );
1961 if ($pid == $lock_for_pid) {
1962 # We are allowed to use this lock.
1965 warn "Database locked by $usr -- please wait\n" if $try == 0;
1968 # avoid the END routine removes the lock
1969 $main::keep_lock{$dist} = 1;
1970 die "Lock still present after 200 * 5 seconds.\n";
1975 die "Can't create lock file $lockfile: $!\n";
1977 my $pid = $lock_for_pid == -1 ? $$ : $lock_for_pid;
1978 F->print("$pid $real_user\n");
1984 my $lockfile = db_filename($dist) . ".lock";
1986 if (!$main::keep_lock{$dist}) {
1987 print "Unlocking $dist database\n" if $verbose >= 2;
1992 sub create_maintlock {
1993 my $lockfile = db_filename("maintenance") . ".lock";
1997 print "Creating maintenance lock\n" if $verbose >= 2;
1999 if (!sysopen( F, $lockfile, O_WRONLY|O_CREAT|O_TRUNC|O_EXCL, 0644 )){
2001 # lock file exists, wait
2002 goto repeat if !open( F, "<$lockfile" );
2005 if ($line !~ /^(\d+)\s+([\w\d.-]+)$/) {
2006 warn "Bad maintenance lock file contents -- still trying\n";
2009 my($pid, $usr) = ($1, $2);
2010 if (kill( 0, $pid ) == 0 && $! == ESRCH) {
2011 # process doesn't exist anymore, remove stale lock
2012 print "Removing stale lock file (pid $pid, user $usr)\n";
2013 unlink( $lockfile );
2016 warn "Maintenance lock already exists by $usr -- ".
2017 "please wait\n" if $try == 0;
2020 die "Lock still present after 120 * 60 seconds.\n";
2025 die "Can't create maintenance lock $lockfile: $!\n";
2027 F->print(getppid(), " $real_user\n");
2031 sub remove_maintlock {
2032 my $lockfile = db_filename("maintenance") . ".lock";
2034 print "Removing maintenance lock\n" if $verbose >= 2;
2038 sub waitfor_maintlock {
2039 my $lockfile = db_filename("maintenance") . ".lock";
2043 print "Checking for maintenance lock\n" if $verbose >= 2;
2045 if (open( F, "<$lockfile" )) {
2048 if ($line !~ /^(\d+)\s+([\w\d.-]+)$/) {
2049 warn "Bad maintenance lock file contents -- still trying\n";
2052 my($pid, $usr) = ($1, $2);
2053 if (kill( 0, $pid ) == 0 && $! == ESRCH) {
2054 # process doesn't exist anymore, remove stale lock
2055 print "Removing stale maintenance lock (pid $pid, user $usr)\n";
2056 unlink( $lockfile );
2059 warn "Databases locked for general maintenance by $usr -- ".
2060 "please wait\n" if $try == 0;
2063 die "Lock still present after 120 * 60 seconds.\n";
2074 print "Reading ASCII database from $file..." if $verbose >= 1;
2075 open( F, "<$file" ) or
2076 die "Can't open database $file: $!\n";
2078 local($/) = ""; # read in paragraph mode
2080 my( %thispkg, $name );
2082 s/\n[ \t]+/\376\377/g; # fix continuation lines
2083 s/\376\377\s*\376\377/\376\377/og;
2085 while( /^(\S+):[ \t]*(.*)[ \t]*$/mg ) {
2086 my ($key, $val) = ($1, $2);
2087 $val =~ s/\376\377/\n/g;
2088 $thispkg{$key} = $val;
2090 check_entry( \%thispkg );
2092 if (exists($thispkg{'Package'})) {
2093 $name = $thispkg{'Package'};
2094 $db{$name} = \%thispkg;
2096 elsif(exists($thispkg{'User'})) {
2097 my $userinfo = $db{'_userinfo'};
2098 $userinfo = {} if (!defined($userinfo));
2100 $name = $thispkg{'User'};
2101 $userinfo->{$name} = \%thispkg;
2103 $db{'_userinfo'} = $userinfo;
2107 print "done\n" if $verbose >= 1;
2114 return if $op_mode eq "manual-edit"; # no checks then
2116 # check for required fields
2117 if (exists $pkg->{'User'}) {
2120 if (!exists $pkg->{'Package'}) {
2121 print STDERR "Bad entry: ",
2122 join( "\n", map { "$_: $pkg->{$_}" } keys %$pkg ), "\n";
2123 die "Database entry lacks Package or User: field\n";
2125 if (!exists $pkg->{'Version'}) {
2126 die "Database entry for $pkg->{'Package'} lacks Version: field\n";
2128 # if no State: field, generate one (for old db compat)
2129 if (!exists($pkg->{'State'})) {
2131 exists $pkg->{'Failed'} ? 'Failed' : 'Building';
2134 die "Bad state $pkg->{'State'} of package $pkg->{Package}\n"
2135 if !isin( $pkg->{'State'},
2136 qw(Needs-Build Building Built Build-Attempted Uploaded Installed Dep-Wait
2137 Failed Failed-Removed Not-For-Us
2143 my($name,$pkg,$key);
2145 print "Writing ASCII database to $file..." if $verbose >= 1;
2146 open( F, ">$file" ) or
2147 die "Can't open database $file: $!\n";
2149 foreach $name (sort keys %db) {
2150 my $pkg = $db{$name};
2151 if ($name eq '_userinfo') {
2152 foreach $user (sort keys %{$pkg}) {
2153 my $ui = $pkg->{$user};
2154 print F "User: $user\n"
2155 if (!defined($ui->{'User'}));
2156 foreach $key (keys %{$ui}) {
2157 my $val = $ui->{$key};
2160 print F "$key: $val\n";
2166 foreach $key (keys %{$pkg}) {
2167 my $val = $pkg->{$key};
2170 print F "$key: $val\n";
2176 print "done\n" if $verbose >= 1;
2182 my $newstate = shift;
2183 my $for_dist = shift;
2186 return if !open_other_db( $for_dist );
2187 $db = $otherdb{$for_dist};
2188 $pkg = \$db{$pkg->{'Package'}};
2193 my $state = \$pkg->{'State'};
2195 return if defined($$state) and $$state eq $newstate;
2196 $pkg->{'Previous-State'} = $$state if defined($$state);
2197 $pkg->{'State-Change'} = $curr_date;
2199 if (defined($$state) and $$state eq 'Failed') {
2200 $pkg->{'Old-Failed'} =
2201 "-"x20 . " $pkg->{'Version'} " . "-"x20 . "\n" .
2202 $pkg->{'Failed'} . "\n" .
2203 $pkg->{'Old-Failed'};
2204 delete $pkg->{'Failed'};
2205 delete $pkg->{'Failed-Category'};
2207 $$state = $newstate;
2213 if (!tied(%{$otherdb{$dist}})) {
2215 $otherdb_lock{$dist} = 1;
2216 if (!(tie %{$otherdb{$dist}}, 'MLDBM', db_filename($dist), 0, 0664)){
2217 warn "Serious warning: Cannot open database for $dist\n";
2219 $otherdb_lock{$dist} = 0;
2230 my $dist = $distribution;
2234 $prevstate = $pkg->{'Previous-State'};
2235 $str = "$action($dist): $pkg->{'Package'}_$pkg->{'Version'} ".
2236 "changed from $prevstate to $pkg->{'State'} ".
2237 "by $real_user as $user";
2239 if (!open( LOG, ">>$transactlog" )) {
2240 warn "Can't open log file $transactlog: $!\n";
2243 print LOG "$curr_date: $str\n";
2246 if (!($prevstate eq 'Failed' && $pkg->{'State'} eq 'Failed')) {
2247 $str .= " (with --override)"
2249 $mail_logs .= "$str\n";
2256 my $subject = shift;
2259 my $from = $conf::db_maint;
2260 my $domain = $conf::buildd_domain;
2262 $from .= "\@$domain" if $from !~ /\@/;
2264 $to .= '@' . $domain if $to !~ /\@/;
2265 $text =~ s/^\.$/../mg;
2266 local $SIG{'PIPE'} = 'IGNORE';
2267 open( PIPE, "| $conf::mailprog -oem $to" )
2268 or die "Can't open pipe to $conf::mailprog: $!\n";
2270 print PIPE "From: $from\n";
2271 print PIPE "Subject: $subject\n\n";
2272 print PIPE "$text\n";
2278 return "$conf::basedir/$conf::dbbase-$dist";
2281 # for parsing input to dep-wait
2287 foreach (split( /\s*,\s*/, $deps )) {
2289 # verification requires > starting prompts, no | crap
2290 if (!/^(\S+)\s*(\(\s*(>(?:[>=])?)\s*(\S+)\s*\))?\s*$/) {
2295 my @alts = split( /\s*\|\s*/, $_ );
2296 # Anything with an | is ignored, as it can be configured on a
2297 # per-buildd basis what will be installed
2298 next if $#alts != 0;
2301 if (!/^(\S+)\s*(\(\s*(>=|=|==|>|>>|<<|<=)\s*(\S+)\s*\))?\s*$/) {
2302 warn( "parse_deplist: bad dependency $_\n" );
2305 my($dep, $rel, $relv) = ($1, $3, $4);
2306 $rel = ">>" if defined($rel) and $rel eq ">";
2307 $result{$dep}->{'Package'} = $dep;
2308 if ($rel && $relv) {
2309 $result{$dep}->{'Rel'} = $rel;
2310 $result{$dep}->{'Version'} = $relv;
2313 return 1 if $verify;
2317 # for parsing Build-Depends from Sources
2318 sub parse_srcdeplist {
2325 foreach $dep (split( /\s*,\s*/, $deps )) {
2326 my @alts = split( /\s*\|\s*/, $dep );
2327 # Anything with an | is ignored, as it can be configured on a
2328 # per-buildd basis what will be installed
2329 next if $#alts != 0;
2331 if (!/^([^\s([]+)\s*(\(\s*([<=>]+)\s*(\S+)\s*\))?(\s*\[([^]]+)\])?/) {
2332 warn( "parse_srcdeplist: bad dependency $_\n" );
2335 my($dep, $rel, $relv, $archlist) = ($1, $3, $4, $6);
2337 $archlist =~ s/^\s*(.*)\s*$/$1/;
2338 my @archs = split( /\s+/, $archlist );
2339 my ($use_it, $ignore_it, $include) = (0, 0, 0);
2342 $ignore_it = 1 if substr($_, 1) eq $arch;
2344 $use_it = 1 if $_ eq $arch;
2348 warn "Warning: inconsistent arch restriction on ",
2349 "$pkg: $dep depedency\n"
2350 if $ignore_it && $use_it;
2351 next if $ignore_it || ($include && !$use_it);
2359 $result->{'Package'} = $dep;
2360 $result->{'Neg'} = $neg;
2361 if ($rel && $relv) {
2362 $result->{'Rel'} = $rel;
2363 $result->{'Version'} = $relv;
2365 push @results, $result;
2374 foreach $key (keys %$list) {
2375 $result .= ", " if $result;
2377 $result .= " ($list->{$key}->{'Rel'} $list->{$key}->{'Version'})"
2378 if $list->{$key}->{'Rel'} && $list->{$key}->{'Version'};
2385 tie %new_db, 'MLDBM', db_filename( $distribution ) . ".new", GDBM_WRCREAT, 0664
2386 or die "FATAL: Cannot create new database\n";
2388 untie %db or die "FATAL: Cannot untie old database\n";
2389 system ("cp " . db_filename( $distribution ) . ".new " .
2390 db_filename( $distribution ) ) == 0
2391 or die "FATAL: Cannot overwrite old database";
2392 unlink db_filename( $distribution ) . ".new";
2397 sub get_unsatisfied_dep {
2401 my $savedep = shift;
2403 my $pkgname = $dep->{'Package'};
2405 if (defined $pkgs->{$pkgname}{'Provider'}) {
2406 # provides. leave them for buildd/sbuild.
2411 return $pkgs->{$pkgname}{'Unsatisfied'} if $savedep and defined($pkgs->{$pkgname}{'Unsatisfied'});
2413 # Return unsatisfied deps to a higher caller to process
2414 if ((!defined($pkgs->{$pkgname})) or
2415 (defined($dep->{'Rel'}) and !version_compare( $pkgs->{$pkgname}{'Version'}, $dep->{'Rel'}, $dep->{'Version'} ) ) ) {
2417 $deplist{$pkgname} = $dep;
2418 my $deps = build_deplist(\%deplist);
2419 $pkgs->{$pkgname}{'Unsatisfied'} = $deps if $savedep;
2423 # set cache to "" to avoid infinite recursion
2424 $pkgs->{$pkgname}{'Unsatisfied'} = "" if $savedep;
2426 if (defined $pkgs->{$dep->{'Package'}}{'Depends'}) {
2427 my $deps = parse_deplist( $pkgs->{$dep->{'Package'}}{'Depends'} );
2428 foreach (keys %$deps) {
2431 my $ret = get_unsatisfied_dep($bd,$pkgs,$dep,1);
2433 my $retdep = parse_deplist( $ret );
2434 foreach (keys %$retdep) {
2435 $dep = $$retdep{$_};
2437 $dep->{'Rel'} = '>=' if defined($dep->{'Rel'}) and $dep->{'Rel'} =~ '^=';
2439 if (defined($dep->{'Rel'}) and $dep->{'Rel'} =~ '^>' and defined ($pkgs->{$dep->{'Package'}}) and
2440 version_compare($bd->{$pkgs->{$dep->{'Package'}}{'Source'}}{'ver'},'>>',$pkgs->{$dep->{'Package'}}{'Sourcev'})) {
2441 if (not defined($merge_binsrc{$dep->{'Package'}})) {
2442 # the uninstallable package doesn't exist in the new source; look for something else that does.
2443 delete $$retdep{$dep->{'Package'}};
2444 foreach (sort (split( /\s*,\s*/, $bd->{$pkgs->{$dep->{'Package'}}{'Source'}}{'bin'}))) {
2445 next if ($pkgs->{$_}{'all'} or not defined $pkgs->{$_}{'Version'});
2446 $dep->{'Package'} = $_;
2447 $dep->{'Rel'} = '>>';
2448 $dep->{'Version'} = $pkgs->{$_}{'Version'};
2449 $$retdep{$_} = $dep;
2454 # sanity check to make sure the depending binary still exists, and the depended binary exists and dep-wait on a new version of it
2455 if ( defined($merge_binsrc{$pkgname}) and defined($pkgs->{$dep->{'Package'}}{'Version'}) ) {
2456 delete $$retdep{$dep->{'Package'}};
2457 $dep->{'Package'} = $pkgname;
2458 $dep->{'Rel'} = '>>';
2459 $dep->{'Version'} = $pkgs->{$pkgname}{'Version'};
2460 $$retdep{$pkgname} = $dep;
2462 delete $$retdep{$dep->{'Package'}} if (defined ($dep->{'Rel'}) and $dep->{'Rel'} =~ '^>');
2465 $ret = build_deplist($retdep);
2466 $pkgs->{$pkgname}{'Unsatisfied'} = $ret if $savedep;
2479 return if defined ($conf::distributions{$distribution}{noadw});
2481 # We need to walk all of needs-build, as any new upload could make
2482 # something in needs-build have uninstallable deps
2483 foreach $key (keys %db) {
2484 my $pkg = $db{$key};
2486 if not defined $pkg or $pkg->{'State'} ne "Needs-Build";
2487 my $srcdeps = parse_srcdeplist($key,$bd->{$key}{'dep'},$arch);
2488 foreach my $srcdep (@$srcdeps) {
2489 next if $srcdep->{'Neg'} != 0; # we ignore conflicts atm
2490 my $rc = get_unsatisfied_dep($bd,$pkgs,$srcdep,0);
2493 my $deplist = parse_deplist( $pkg->{'Depends'} );
2494 my $newdeps = parse_deplist( $rc );
2496 foreach (%$newdeps) {
2497 my $dep = $$newdeps{$_};
2498 # ensure we're not waiting on ourselves, or a package that has been removed
2499 next if (not defined($merge_binsrc{$dep->{'Package'}})) or ($merge_binsrc{$dep->{'Package'}} eq $key);
2500 if ($dep->{'Rel'} =~ '^>') {
2501 $deplist->{$dep->{'Package'}} = $dep;
2506 $pkg->{'Depends'} = build_deplist($deplist);
2507 change_state( \$pkg, 'Dep-Wait' );
2508 log_ta( $pkg, "--merge-all" );
2510 print "Auto-Dep-Waiting ${key}_$pkg->{'Version'} to $pkg->{'Depends'}\n" if $verbose;
2520 ($prgname = $0) =~ s,^.*/,,;
2522 Usage: $prgname <options...> <package_version...>
2524 -v, --verbose: Verbose execution.
2525 --take: Take package for building [default operation]
2526 -f, --failed: Record in database that a build failed due to
2527 deficiencies in the package (that aren't fixable without a new
2529 -u, --uploaded: Record in the database that the packages build
2530 correctly and were uploaded.
2531 -n, --no-build: Record in the database that the packages aren't
2532 desired for this architecture and shouldn't appear in listings even
2533 if they're out of date.
2534 --dep-wait: Record in the database that the packages are waiting
2535 for some source dependencies to become available
2536 --merge-quinn: Merge quinn-diff output into database.
2537 --merge-packages: Merge Packages files into database.
2538 --pretend-avail: Pretend that given packages are available now and give
2539 free packages waiting for them
2540 -i SRC_PKG, --info SRC_PKG: Show information for source package
2541 -l STATE, --list=STATE: List all packages in state STATE; can be
2542 combined with -U to restrict to a specific user; STATE can
2544 -m MESSAGE, --message=MESSAGE: Give reason why package failed or
2545 source dependency list
2546 (used with -f, --dep-wait, and --binNMU)
2547 -o, --override: Override another user's lock on a package, i.e.
2548 take it over; a notice mail will be sent to the other user
2549 -U USER, --user=USER: select user name for which listings should
2550 apply, if not given all users are listed.
2551 if -l is missing, set user name to be entered in db; usually
2552 automatically choosen
2553 --import FILE: Import database from a ASCII file FILE
2554 --export FILE: Export database to a ASCII file FILE
2555 --lock-for PID: Locks the database for the process with this pid
2556 --unlock-for PID: Unlocks the database for the process with this pid
2557 --act-on-behalve-of PID: Ignores the log (if it is held by this pid)
2558 The remaining arguments (depending on operation) usually start with
2559 "name_version", the trailer is ignored. This allows to pass the names
2560 of .dsc files, for which file name completion can be used.
2561 --merge-packages and --merge-quinn take Package/quin--diff file names
2562 on the command line or read stdin. --list needs nothing more on the
2563 command line. --info takes source package names (without version).
2568 sub pkg_version_eq {
2570 my $version = shift;
2573 if (defined $pkg->{'Binary-NMU-Version'}) and
2574 version_compare(binNMU_version($pkg->{'Version'},
2575 $pkg->{'Binary-NMU-Version'}),'=', $version);
2576 return version_compare( $pkg->{'Version'}, "=", $version );