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);
54 $ENV{'PATH'} = "/bin:/usr/bin:/usr/local/bin";
58 $curr_date = strftime("%Y %b %d %H:%M:%S",@curr_time);
59 $short_date = strftime("%m/%d/%y",@curr_time);
62 # map program invocation names to operation modes
63 my %prognames = ( "uploaded-build" => "set-uploaded",
64 "failed-build" => "set-failed",
65 "no-build" => "set-not-for-us",
66 "give-back-build" => "set-needs-build",
67 "dep-wait-build" => "set-dep-wait",
68 "forget-build" => "forget",
69 "merge-quinn" => "merge-quinn",
70 "merge-packages" => "merge-packages",
71 "merge-sources" => "merge-sources",
72 "build-info" => "info" );
74 %short_category = ( u => "uploaded-fixed-pkg",
81 c => "compiler-error",
85 ($progname = $0) =~ s,.*/,,;
86 if ($prognames{$progname}) {
87 $op_mode = $prognames{$progname};
89 elsif ($progname =~ /^list-(.*)$/) {
91 $list_state = ($1 eq "all") ? "" : $1;
96 verbose => { short => "v", flag => \$verbose },
97 override => { short => "o", flag => \$opt_override },
98 "create-db" => { flag => \$opt_create_db },
99 "correct-compare" => { flag => \$WannaBuild::opt_correct_version_cmp },
100 # TODO: remove after buildds no longer pass to wanna-build
101 "no-propagation" => { short => "N" },
102 "no-down-propagation" => { short => "D" },
104 take => { mode => "set-building" },
105 failed => { short => "f", mode => "set-failed" },
106 uploaded => { short => "u", mode => "set-uploaded" },
107 "no-build" => { short => "n", mode => "set-not-for-us" },
108 built => { mode => "set-built" },
109 attempted => { mode => "set-attempted" },
110 "give-back" => { mode => "set-needs-build" },
111 "dep-wait" => { mode => "set-dep-wait" },
112 forget => { mode => "forget" },
113 'forget-user' => { mode => 'forget-user' },
114 "merge-quinn" => { mode => "merge-quinn" },
115 "merge-partial-quinn" => { mode => "merge-partial-quinn" },
116 "merge-packages" => { mode => "merge-packages" },
117 "merge-sources" => { mode => "merge-sources" },
118 "pretend-avail" => { short => "p", mode => "pretend-avail" },
119 "merge-all" => { mode => "merge-all" },
120 info => { short => "i", mode => "info" },
121 'binNMU' => { mode => 'set-binary-nmu', arg => \$binNMUver,
122 code => sub { die "Invalid binNMU version: $binNMUver\n"
123 if $binNMUver !~ /^([\d]*)$/ and $1 >= 0; } },
124 'perm-build-priority' => { mode => "set-permanent-build-priority", arg => \$build_priority,
125 code => sub { die "Invalid build priority: $build_priority\n"
126 if $build_priority !~ /^-?[\d]+$/; } },
127 'build-priority' => { mode => "set-build-priority", arg => \$build_priority,
128 code => sub { die "Invalid build priority: $build_priority\n"
129 if $build_priority !~ /^-?[\d]+$/; } },
131 { short => "l", mode => "list", arg => \$list_state,
133 die "Unknown state to list: $list_state\n"
134 if !isin( $list_state, qw(needs-build building uploaded
135 built build-attempted failed installed dep-wait
136 not-for-us all failed-removed
137 install-wait reupload-wait));} },
140 { short => "d", arg => \$distribution,
142 if ($distribution eq "a" || $distribution eq "all") {
147 $distribution = "oldstable" if $distribution eq "o";
148 $distribution = "stable" if $distribution eq "s";
149 $distribution = "testing" if $distribution eq "t";
150 $distribution = "unstable" if $distribution eq "u";
154 { short => "O", arg => \$list_order,
156 die "Bad ordering character\n"
157 if $list_order !~ /^[PSpsncb]+$/;
159 message => { short => "m", arg => \$fail_reason },
160 database => { short => "b", arg => \$conf::dbbase },
161 arch => { short => "A", arg => \$arch },
162 user => { short => "U", arg => \$user },
163 category => { short => "c", arg => \$category,
165 $category = $short_category{$category}
166 if exists $short_category{$category};
167 die "Unknown category: $category\n"
168 if !isin( $category, values %short_category );
170 "min-age" => { short => "a", arg => \$list_min_age,
172 die "Argument of --min-age must be a non-zero number\n"
173 if $list_min_age == 0;
174 $list_min_age *= 24*60*60;
176 "max-age" => { arg => \$list_min_age,
178 die "Argument of --max-age must be a non-zero number\n"
179 if $list_min_age == 0;
180 $list_min_age *= -24*60*60;
183 import => { arg => \$import_from, mode => "import" },
184 export => { arg => \$export_to, mode => "export" },
185 "manual-edit" => { mode => "manual-edit" },
186 "create-maintenance-lock" => { mode => "maintlock-create" },
187 "remove-maintenance-lock" => { mode => "maintlock-remove" },
188 "clean-db" => { mode => "clean-db" },
191 while( @ARGV && $ARGV[0] =~ /^-/ ) {
194 my($opt, $optname, $arg);
195 if (/^--([^=]+)(=|$)/) {
197 $opt = $options{$optname};
198 $arg = $1 if /^--\Q$optname\E=((.|\n)*)$/;
201 $optname = substr( $_, 1, 1 );
202 $opt = (grep { defined($_->{short}) ? $_->{short} eq $optname : 0} values %options)[0];
203 $arg = $1 if /^-$optname(.+)$/;
206 warn "Unknown option: --$1\n";
211 die "$optname option missing argument\n" if !@ARGV;
214 ${$opt->{arg}} = $arg;
216 elsif (defined $arg) {
217 die "Option $optname takes no argument\n";
221 die "Conflicting operation modes\n" if $op_mode;
222 $op_mode = $opt->{mode};
232 $op_mode = $category ? "set-failed" : "set-building"
233 if !$op_mode; # default operation
234 $list_order = $list_state eq "failed" ? 'fPcpsn' : 'PScpsn'
235 if !$list_order and $list_state;
236 $distribution ||= "unstable";
237 die "Bad distribution '$distribution'\n"
238 if !isin($distribution, keys %conf::distributions);
239 $conf::dbbase =~ m#^([^/]+/)#;
240 $transactlog = "$conf::basedir/$1$conf::transactlog";
243 my $version = '$Revision: db181a534e9d $ $Date: 2008/03/26 06:20:22 $ $Author: rmurray $';
244 $version =~ s/(^\$| \$ .*$)//g;
245 print "wanna-build $version for $distribution on $conf::dbbase\n";
248 if (!@ARGV && !isin( $op_mode, qw(list merge-quinn merge-partial-quinn import export
249 merge-packages manual-edit maintlock-create
250 merge-sources maintlock-remove clean-db))) {
251 warn "No packages given.\n";
255 $real_user = (getpwuid($<))[0];
256 die "Can't determine your user name\n"
257 if $op_mode ne "list" && !$user &&
258 !($user = $real_user);
261 if ($op_mode eq "set-failed" && !$category) {
262 print "Enter reason for failing (end with '.' alone on ".
267 last if $line eq ".\n";
268 $line = ".\n" if $line eq "\n";
269 $fail_reason .= $line;
271 chomp( $fail_reason );
272 } elsif ($op_mode eq "set-dep-wait") {
273 print "Enter dependencies (one line):\n";
275 while( !$line && !eof(STDIN) ) {
276 chomp( $line = <STDIN> );
278 die "No dependencies given\n" if !$line;
279 $fail_reason = $line;
280 } elsif ($op_mode eq "set-binary-nmu" and $binNMUver > 0) {
281 print "Enter changelog entry (one line):\n";
283 while( !$line && !eof(STDIN) ) {
284 chomp( $line = <STDIN> );
286 die "No changelog entry given\n" if !$line;
287 $fail_reason = $line;
290 if ($op_mode eq "maintlock-create") {
294 if ($op_mode eq "maintlock-remove") {
298 waitfor_maintlock() if $op_mode !~ /^(?:merge-|clean-db$)/;
300 if (!-f db_filename( $distribution ) && !$opt_create_db) {
301 die "Database for $distribution doesn't exist\n";
303 lock_db( $distribution );
306 unlock_db( $distribution );
307 foreach (keys %conf::distributions) {
308 untie %{$otherdb{$_}} if tied(%{$otherdb{$_}});
309 unlock_db( $_ ) if $otherdb_lock{$_};
313 tie %db, 'MLDBM', db_filename( $distribution ), GDBM_WRCREAT, 0664
314 or die "FATAL: Cannot open database\n";
318 if ($mail_logs && $conf::log_mail) {
319 send_mail( $conf::log_mail,
320 "wanna-build $distribution state changes $curr_date",
321 "State changes at $curr_date for distribution ".
322 "$distribution:\n\n$mail_logs\n" );
330 SWITCH: foreach ($op_mode) {
332 add_packages( $1, @ARGV );
336 list_packages( $list_state );
340 info_packages( @ARGV );
343 /^forget-user/ && do {
344 die "This operation is restricted to admin users\n"
345 if (defined @conf::admin_users and
346 !isin( $real_user, @conf::admin_users));
347 forget_users( @ARGV );
351 forget_packages( @ARGV );
354 /^merge-partial-quinn/ && do {
355 die "This operation is restricted to admin users\n"
356 if (defined @conf::admin_users and
357 !isin( $real_user, @conf::admin_users));
361 /^merge-quinn/ && do {
362 die "This operation is restricted to admin users\n"
363 if (defined @conf::admin_users and
364 !isin( $real_user, @conf::admin_users));
368 /^merge-packages/ && do {
369 die "This operation is restricted to admin users\n"
370 if (defined @conf::admin_users and
371 !isin( $real_user, @conf::admin_users));
375 /^merge-sources/ && do {
376 die "This operation is restricted to admin users\n"
377 if (defined @conf::admin_users and
378 !isin( $real_user, @conf::admin_users));
382 /^pretend-avail/ && do {
383 pretend_avail( @ARGV );
387 die "This operation is restricted to admin users\n"
388 if (defined @conf::admin_users and
389 !isin( $real_user, @conf::admin_users));
391 @ARGV = ( $ARGS[0] );
392 my $pkgs = parse_packages();
393 @ARGV = ( $ARGS[1] );
395 @ARGV = ( $ARGS[2] );
396 my $build_deps = parse_sources(1);
397 auto_dep_wait( $build_deps, $pkgs );
402 die "This operation is restricted to admin users\n"
403 if (defined @conf::admin_users and
404 !isin( $real_user, @conf::admin_users));
405 %db = (); # clear all current contents
406 read_db( $import_from );
410 write_db( $export_to );
413 /^manual-edit/ && do {
414 die "This operation is restricted to admin users\n"
415 if (defined @conf::admin_users and
416 !isin( $real_user, @conf::admin_users));
417 my $tmpfile_pattern = "/tmp/wanna-build-$distribution.$$-";
419 for( $i = 0;; ++$i ) {
420 $tmpfile = $tmpfile_pattern . $i;
421 last if ! -e $tmpfile;
423 write_db( $tmpfile );
424 my $editor = $ENV{'VISUAL'} ||
425 "/usr/bin/sensible-editor";
426 system "$editor $tmpfile";
427 %db = (); # clear all current contents
433 die "This operation is restricted to admin users\n"
434 if (defined @conf::admin_users and
435 !isin( $real_user, @conf::admin_users));
440 die "Unexpected operation mode $op_mode\n";
442 if (not -t and $user =~ /-/) {
443 my $userinfo = $db{'_userinfo'};
444 $userinfo = {} if (!defined($userinfo));
446 my $ui = $userinfo->{$user};
447 $ui = {} if (!defined($ui));
449 $ui->{'Last-Seen'} = $curr_date;
450 $ui->{'User'} = $user;
452 $userinfo->{$user} = $ui;
453 $db{'_userinfo'} = $userinfo;
458 my $newstate = shift;
459 my( $package, $name, $version, $ok, $reason );
461 foreach $package (@_) {
462 $package =~ s,^.*/,,; # strip path
463 $package =~ s/\.(dsc|diff\.gz|tar\.gz|deb)$//; # strip extension
464 $package =~ s/_[a-zA-Z\d-]+\.changes$//; # strip extension
465 if ($package =~ /^([\w\d.+-]+)_([\w\d:.+~-]+)/) {
466 ($name,$version) = ($1,$2);
469 warn "$package: can't extract package name and version ".
474 if ($op_mode eq "set-building") {
475 add_one_building( $name, $version );
477 elsif ($op_mode eq "set-built") {
478 add_one_built( $name, $version );
480 elsif ($op_mode eq "set-attempted") {
481 add_one_attempted( $name, $version );
483 elsif ($op_mode eq "set-uploaded") {
484 add_one_uploaded( $name, $version );
486 elsif ($op_mode eq "set-failed") {
487 add_one_failed( $name, $version );
489 elsif ($op_mode eq "set-not-for-us") {
490 add_one_notforus( $name, $version );
492 elsif ($op_mode eq "set-needs-build") {
493 add_one_needsbuild( $name, $version );
495 elsif ($op_mode eq "set-dep-wait") {
496 add_one_depwait( $name, $version );
498 elsif ($op_mode eq "set-build-priority") {
499 set_one_buildpri( $name, $version, 'BuildPri' );
501 elsif ($op_mode eq "set-permanent-build-priority") {
502 set_one_buildpri( $name, $version, 'PermBuildPri' );
504 elsif ($op_mode eq "set-binary-nmu") {
505 set_one_binnmu( $name, $version );
510 sub add_one_building {
516 my $pkg = $db{$name};
518 if ($pkg->{'State'} eq "Not-For-Us") {
520 $reason = "not suitable for this architecture";
522 elsif ($pkg->{'State'} =~ /^Dep-Wait/) {
524 $reason = "not all source dependencies available yet";
526 elsif ($pkg->{'State'} eq "Uploaded" &&
527 (version_lesseq($version, $pkg->{'Version'}))) {
529 $reason = "already uploaded by $pkg->{'Builder'}";
530 $reason .= " (in newer version $pkg->{'Version'})"
531 if !version_eq($pkg, $version);
533 elsif ($pkg->{'State'} eq "Installed" &&
534 version_less($version,$pkg->{'Version'})) {
536 print "$name: Warning: newer version $pkg->{'Version'} ".
537 "already installed, but overridden.\n";
541 $reason = "newer version $pkg->{'Version'} already in ".
542 "archive; doesn't need rebuilding";
543 print "$name: Note: If the following is due to an epoch ",
544 " change, use --override\n";
547 elsif ($pkg->{'State'} eq "Installed" &&
548 pkg_version_eq($pkg,$version)) {
550 $reason = "is up-to-date in the archive; doesn't need rebuilding";
552 elsif ($pkg->{'State'} eq "Needs-Build" &&
553 version_less($version,$pkg->{'Version'})) {
555 print "$name: Warning: newer version $pkg->{'Version'} ".
556 "needs building, but overridden.";
560 $reason = "newer version $pkg->{'Version'} needs building, ".
564 elsif (isin($pkg->{'State'},qw(Building Built Build-Attempted))) {
565 if (version_less($pkg->{'Version'},$version)) {
566 print "$name: Warning: Older version $pkg->{'Version'} ",
567 "is being built by $pkg->{'Builder'}\n";
568 if ($pkg->{'Builder'} ne $user) {
569 send_mail( $pkg->{'Builder'},
570 "package takeover in newer version",
571 "You are building package '$name' in ".
572 "version $version\n".
573 "(as far as I'm informed).\n".
574 "$user now has taken the newer ".
575 "version $version for building.".
576 "You can abort the build if you like.\n" );
581 print "User $pkg->{'Builder'} had already ",
582 "taken the following package,\n",
583 "but overriding this as you request:\n";
584 send_mail( $pkg->{'Builder'}, "package takeover",
585 "The package '$name' (version $version) that ".
586 "was locked by you\n".
587 "has been taken over by $user\n" );
589 elsif ($pkg->{'Builder'} eq $user) {
590 print "$name: Note: already taken by you.\n";
591 print "$name: ok\n" if $verbose;
596 $reason = "already taken by $pkg->{'Builder'}";
597 $reason .= " (in newer version $pkg->{'Version'})"
598 if !version_eq($pkg->{'Version'}, $version);
602 elsif ($pkg->{'State'} =~ /^Failed/ &&
603 pkg_version_eq($pkg, $version)) {
605 print "The following package previously failed ",
606 "(by $pkg->{'Builder'})\n",
607 "but overriding this as you request:\n";
608 send_mail( $pkg->{'Builder'}, "failed package takeover",
609 "The package '$name' (version $version) that ".
610 "is locked by you\n".
611 "and has failed previously has been taken over ".
613 if $pkg->{'Builder'} ne $user;
617 $reason = "build of $version failed previously:\n ";
618 $reason .= join( "\n ", split( "\n", $pkg->{'Failed'} ));
619 $reason .= "\nalso the package doesn't need builing"
620 if $pkg->{'State'} eq 'Failed-Removed';
626 if ($pkg->{'Binary-NMU-Version'}) {
627 print "$name: Warning: needs binary NMU $pkg->{'Binary-NMU-Version'}\n" .
628 "$pkg->{'Binary-NMU-Changelog'}\n";
631 print "$name: Warning: Previous version failed!\n"
632 if $pkg->{'Previous-State'} =~ /^Failed/ ||
633 $pkg->{'State'} =~ /^Failed/;
635 change_state( \$pkg, 'Building' );
636 $pkg->{'Package'} = $name;
637 $pkg->{'Version'} = $version;
638 $pkg->{'Builder'} = $user;
639 log_ta( $pkg, "--take" );
641 print "$name: $ok\n" if $verbose;
644 print "$name: NOT OK!\n $reason\n";
648 sub add_one_attempted {
651 my $pkg = $db{$name};
653 if (!defined($pkg)) {
654 print "$name: not registered yet.\n";
658 if ($pkg->{'State'} ne "Building" ) {
659 print "$name: not taken for building (state is $pkg->{'State'}). ",
663 if ($pkg->{'Builder'} ne $user) {
664 print "$name: not taken by you, but by $pkg->{'Builder'}. Skipping.\n";
667 elsif ( !pkg_version_eq($pkg, $version) ) {
668 print "$name: version mismatch ".
669 "$(pkg->{'Version'} ".
670 "by $pkg->{'Builder'})\n";
674 change_state( \$pkg, 'Build-Attempted' );
675 log_ta( $pkg, "--attempted" );
677 print "$name: registered as uploaded\n" if $verbose;
683 my $pkg = $db{$name};
685 if (!defined($pkg)) {
686 print "$name: not registered yet.\n";
690 if ($pkg->{'State'} ne "Building" ) {
691 print "$name: not taken for building (state is $pkg->{'State'}). ",
695 if ($pkg->{'Builder'} ne $user) {
696 print "$name: not taken by you, but by $pkg->{'Builder'}. Skipping.\n";
699 elsif ( !pkg_version_eq($pkg, $version) ) {
700 print "$name: version mismatch ".
701 "$(pkg->{'Version'} ".
702 "by $pkg->{'Builder'})\n";
705 change_state( \$pkg, 'Built' );
706 log_ta( $pkg, "--built" );
708 print "$name: registered as built\n" if $verbose;
711 sub add_one_uploaded {
714 my $pkg = $db{$name};
716 if (!defined($pkg)) {
717 print "$name: not registered yet.\n";
721 if ($pkg->{'State'} eq "Uploaded" &&
722 pkg_version_eq($pkg,$version)) {
723 print "$name: already uploaded\n";
726 if (!isin( $pkg->{'State'}, qw(Building Built Build-Attempted))) {
727 print "$name: not taken for building (state is $pkg->{'State'}). ",
731 if ($pkg->{'Builder'} ne $user) {
732 print "$name: not taken by you, but by $pkg->{'Builder'}. Skipping.\n";
735 # strip epoch -- buildd-uploader used to go based on the filename.
736 # (to remove at some point)
738 ($pkgver = $pkg->{'Version'}) =~ s/^\d+://;
739 $version =~ s/^\d+://; # for command line use
740 if ($pkg->{'Binary-NMU-Version'} ) {
741 my $nmuver = binNMU_version($pkgver, $pkg->{'Binary-NMU-Version'});
742 if (!version_eq( $nmuver, $version )) {
743 print "$name: version mismatch ($nmuver registered). ",
747 } elsif (!version_eq($pkgver, $version)) {
748 print "$name: version mismatch ($pkg->{'Version'} registered). ",
753 change_state( \$pkg, 'Uploaded' );
754 log_ta( $pkg, "--uploaded" );
756 print "$name: registered as uploaded\n" if $verbose;
763 my $pkg = $db{$name};
765 if (!defined($pkg)) {
766 print "$name: not registered yet.\n";
769 $state = $pkg->{'State'};
771 if ($state eq "Not-For-Us") {
772 print "$name: not suitable for this architecture anyway. Skipping.\n";
775 elsif ($state eq "Failed-Removed") {
776 print "$name: failed previously and doesn't need building. Skipping.\n";
779 elsif ($state eq "Installed") {
780 print "$name: Is already installed in archive. Skipping.\n";
783 elsif ($pkg->{'Builder'} &&
784 (($user ne $pkg->{'Builder'}) &&
785 !($pkg->{'Builder'} =~ /^(\w+)-\w+/ && $1 eq $user))) {
786 print "$name: not taken by you, but by ".
787 "$pkg->{'Builder'}. Skipping.\n";
790 elsif ( !pkg_version_eq($pkg, $version) ) {
791 print "$name: version mismatch ".
792 "$(pkg->{'Version'} ".
793 "by $pkg->{'Builder'})\n";
798 if (!$cat && $fail_reason =~ /^\[([^\]]+)\]/) {
800 $cat = $short_category{$cat} if exists $short_category{$cat};
801 if (!isin( $cat, values %short_category )) {
802 print "$name: Warning: unknown category $cat; discarded\n";
805 $fail_reason =~ s/^\[[^\]]+\][ \t]*\n*//;
808 if ($state eq "Needs-Build") {
809 print "$name: Warning: not registered for building previously, ".
810 "but processing anyway.\n";
812 elsif ($state eq "Uploaded") {
813 print "$name: Warning: marked as uploaded previously, ".
814 "but processing anyway.\n";
816 elsif ($state eq "Dep-Wait") {
817 print "$name: Warning: marked as waiting for dependencies, ".
818 "but processing anyway.\n";
820 elsif ($state eq "Failed") {
821 print "$name: already registered as failed; will append new message\n"
823 print "$name: already registered as failed; changing category\n"
827 if (($cat eq "reminder-sent" || $cat eq "nmu-offered") &&
828 exists $pkg->{'Failed-Category'} &&
829 $pkg->{'Failed-Category'} ne $cat) {
830 (my $action = $cat) =~ s/-/ /;
831 $fail_reason .= "\n$short_date: $action";
834 change_state( \$pkg, 'Failed' );
835 $pkg->{'Builder'} = $user;
836 $pkg->{'Failed'} .= "\n" if $pkg->{'Failed'};
837 $pkg->{'Failed'} .= $fail_reason;
838 $pkg->{'Failed-Category'} = $cat if $cat;
839 if (defined $pkg->{'PermBuildPri'}) {
840 $pkg->{'BuildPri'} = $pkg->{'PermBuildPri'};
842 delete $pkg->{'BuildPri'};
844 log_ta( $pkg, "--failed" );
846 print "$name: registered as failed\n" if $verbose;
849 sub add_one_notforus {
852 my $pkg = $db{$name};
854 if ($pkg->{'State'} eq 'Not-For-Us') {
855 # reset Not-For-Us state in case it's called twice; this is
856 # the only way to get a package out of this state...
857 # There is no really good state in which such packages should
858 # be put :-( So use Failed for now.
859 change_state( \$pkg, 'Failed' );
860 $pkg->{'Package'} = $name;
861 $pkg->{'Failed'} = "Was Not-For-Us previously";
862 delete $pkg->{'Builder'};
863 delete $pkg->{'Depends'};
864 log_ta( $pkg, "--no-build(rev)" );
865 print "$name: now not unsuitable anymore\n";
867 send_mail( $conf::notforus_maint,
868 "$name moved out of Not-For-Us state",
869 "The package '$name' has been moved out of the Not-For-Us ".
871 "It should probably also be removed from ".
872 "Packages-arch-specific or\n".
873 "the action was wrong.\n" )
874 if $conf::notforus_maint;
877 change_state( \$pkg, 'Not-For-Us' );
878 $pkg->{'Package'} = $name;
879 delete $pkg->{'Builder'};
880 delete $pkg->{'Depends'};
881 delete $pkg->{'BuildPri'};
882 delete $pkg->{'Binary-NMU-Version'};
883 delete $pkg->{'Binary-NMU-Changelog'};
884 log_ta( $pkg, "--no-build" );
885 print "$name: registered as unsuitable\n" if $verbose;
887 send_mail( $conf::notforus_maint,
888 "$name set to Not-For-Us",
889 "The package '$name' has been set to state Not-For-Us ".
891 "It should probably also be added to ".
892 "Packages-arch-specific or\n".
893 "the Not-For-Us state is wrong.\n" )
894 if $conf::notforus_maint;
899 sub add_one_needsbuild {
903 my $pkg = $db{$name};
905 if (!defined($pkg)) {
906 print "$name: not registered; can't give back.\n";
909 $state = $pkg->{'State'};
911 if ($state eq "Dep-Wait") {
913 print "$name: Forcing source dependency list to be cleared\n";
916 print "$name: waiting for source dependencies. Skipping\n",
917 " (use --override to clear dependency list and ",
918 "give back anyway)\n";
922 elsif (!isin( $state, qw(Building Built Build-Attempted))) {
923 print "$name: not taken for building (state is $state).";
925 print "\n$name: Forcing give-back\n";
928 print " Skipping.\n";
932 if (defined ($pkg->{'Builder'}) && $user ne $pkg->{'Builder'} &&
933 !($pkg->{'Builder'} =~ /^(\w+)-\w+/ && $1 eq $user)) {
934 print "$name: not taken by you, but by ".
935 "$pkg->{'Builder'}. Skipping.\n";
938 if (!pkg_version_eq($pkg, $version)) {
939 print "$name: version mismatch ($pkg->{'Version'} registered). ",
943 change_state( \$pkg, 'Needs-Build' );
944 delete $pkg->{'Builder'};
945 delete $pkg->{'Depends'};
946 log_ta( $pkg, "--give-back" );
948 print "$name: given back\n" if $verbose;
954 my $pkg = $db{$name};
957 if (!defined($pkg)) {
958 print "$name: not registered; can't register for binNMU.\n";
961 my $db_ver = $pkg->{'Version'};
963 if (!version_eq($db_ver, $version)) {
964 print "$name: version mismatch ($db_ver registered). ",
968 $state = $pkg->{'State'};
970 if (defined $pkg->{'Binary-NMU-Version'}) {
971 if ($binNMUver == 0) {
972 change_state( \$pkg, 'Installed' );
973 delete $pkg->{'Builder'};
974 delete $pkg->{'Depends'};
975 delete $pkg->{'Binary-NMU-Version'};
976 delete $pkg->{'Binary-NMU-Changelog'};
977 } elsif ($binNMUver <= $pkg->{'Binary-NMU-Version'}) {
978 print "$name: already building binNMU $pkg->{'Binary-NMU-Version'}\n";
981 $pkg->{'Binary-NMU-Version'} = $binNMUver;
982 $pkg->{'Binary-NMU-Changelog'} = $fail_reason;
983 $pkg->{'Notes'} = 'out-of-date';
984 $pkg->{'BuildPri'} = $pkg->{'PermBuildPri'}
985 if (defined $pkg->{'PermBuildPri'});
987 log_ta( $pkg, "--binNMU" );
990 } elsif ($binNMUver == 0) {
991 print "${name}_$version: no scheduled binNMU to cancel.\n";
995 if ($state ne 'Installed') {
996 print "${name}_$version: not installed; can't register for binNMU.\n";
1000 my $fullver = binNMU_version($version,$binNMUver);
1001 if ( version_lesseq( $fullver, $pkg->{'Installed-Version'} ) )
1003 print "$name: binNMU $fullver is not newer than current version $pkg->{'Installed-Version'}\n";
1007 change_state( \$pkg, 'Needs-Build' );
1008 delete $pkg->{'Builder'};
1009 delete $pkg->{'Depends'};
1010 $pkg->{'Binary-NMU-Version'} = $binNMUver;
1011 $pkg->{'Binary-NMU-Changelog'} = $fail_reason;
1012 $pkg->{'Notes'} = 'out-of-date';
1013 log_ta( $pkg, "--binNMU" );
1015 print "${name}: registered for binNMU $fullver\n" if $verbose;
1018 sub set_one_buildpri {
1020 my $version = shift;
1022 my $pkg = $db{$name};
1025 if (!defined($pkg)) {
1026 print "$name: not registered; can't set priority.\n";
1029 $state = $pkg->{'State'};
1031 if ($state eq "Not-For-Us") {
1032 print "$name: not suitable for this architecture. Skipping.\n";
1034 } elsif ($state eq "Failed-Removed") {
1035 print "$name: failed previously and doesn't need building. Skipping.\n";
1038 if (!pkg_version_eq($pkg, $version)) {
1039 print "$name: version mismatch ($pkg->{'Version'} registered). ",
1043 if ( $build_priority == 0 ) {
1044 delete $pkg->{'BuildPri'}
1045 if $key eq 'PermBuildPri' and defined $pkg->{'BuildPri'}
1046 and $pkg->{'BuildPri'} == $pkg->{$key};
1047 delete $pkg->{$key};
1049 $pkg->{'BuildPri'} = $build_priority
1050 if $key eq 'PermBuildPri';
1051 $pkg->{$key} = $build_priority;
1054 print "$name: set to build priority $build_priority\n" if $verbose;
1057 sub add_one_depwait {
1059 my $version = shift;
1061 my $pkg = $db{$name};
1063 if (!defined($pkg)) {
1064 print "$name: not registered yet.\n";
1067 $state = $pkg->{'State'};
1069 if ($state eq "Dep-Wait") {
1070 print "$name: merging with previously registered dependencies\n";
1073 if (isin( $state, qw(Needs-Build Failed))) {
1074 print "$name: Warning: not registered for building previously, ".
1075 "but processing anyway.\n";
1077 elsif ($state eq "Not-For-Us") {
1078 print "$name: not suitable for this architecture anyway. Skipping.\n";
1081 elsif ($state eq "Failed-Removed") {
1082 print "$name: failed previously and doesn't need building. Skipping.\n";
1085 elsif ($state eq "Installed") {
1086 print "$name: Is already installed in archive. Skipping.\n";
1089 elsif ($state eq "Uploaded") {
1090 print "$name: Is already uploaded. Skipping.\n";
1093 elsif ($pkg->{'Builder'} &&
1094 $user ne $pkg->{'Builder'}) {
1095 print "$name: not taken by you, but by ".
1096 "$pkg->{'Builder'}. Skipping.\n";
1099 elsif ( !pkg_version_eq($pkg,$version)) {
1100 print "$name: version mismatch ".
1101 "($pkg->{'Version'} ".
1102 "by $pkg->{'Builder'})\n";
1105 elsif ($fail_reason =~ /^\s*$/ ||
1106 !parse_deplist( $fail_reason, 1 )) {
1107 print "$name: Bad dependency list\n";
1110 change_state( \$pkg, 'Dep-Wait' );
1111 $pkg->{'Builder'} = $user;
1112 if (defined $pkg->{'PermBuildPri'}) {
1113 $pkg->{'BuildPri'} = $pkg->{'PermBuildPri'};
1115 delete $pkg->{'BuildPri'};
1117 my $deplist = parse_deplist( $pkg->{'Depends'} );
1118 my $new_deplist = parse_deplist( $fail_reason );
1119 # add new dependencies, maybe overwriting old entries
1120 foreach (keys %$new_deplist) {
1121 $deplist->{$_} = $new_deplist->{$_};
1123 $pkg->{'Depends'} = build_deplist($deplist);
1124 log_ta( $pkg, "--dep-wait" );
1126 print "$name: registered as waiting for dependencies\n" if $verbose;
1136 local($/) = ""; # read in paragraph mode
1138 my( $version, $arch, $section, $priority, $builddep, $buildconf, $binaries );
1140 /^Package:\s*(\S+)$/mi and $name = $1;
1141 /^Version:\s*(\S+)$/mi and $version = $1;
1142 /^Architecture:\s*(\S+)$/mi and $arch = $1;
1143 /^Section:\s*(\S+)$/mi and $section = $1;
1144 /^Priority:\s*(\S+)$/mi and $priority = $1;
1145 /^Build-Depends:\s*(.*)$/mi and $builddep = $1;
1146 /^Build-Conflicts:\s*(.*)$/mi and $buildconf = $1;
1147 /^Binary:\s*(.*)$/mi and $binaries = $1;
1149 next if (defined $srcver{$name} and version_less( $version, $srcver{$name} ));
1150 $srcver{$name} = $version;
1152 $buildconf = join( ", ", map { "!$_" } split( /\s*,\s*/, $buildconf ));
1154 $builddep .= "," . $buildconf;
1156 $builddep = $buildconf;
1160 $pkgs{$name}{'dep'} = defined $builddep ? $builddep : "";
1161 $pkgs{$name}{'ver'} = $version;
1162 $pkgs{$name}{'bin'} = $binaries;
1163 my $pkg = $db{$name};
1168 if ($arch eq "all" && !version_less( $version, $pkg->{'Version'} )) {
1169 # package is now Arch: all, delete it from db
1170 change_state( \$pkg, 'deleted' );
1171 log_ta( $pkg, "--merge-sources" );
1172 print "$name ($pkg->{'Version'}): deleted ".
1173 "from database, because now Arch: all\n"
1179 # The "Version" should always be the source version --
1180 # not a possible binNMU version number.
1181 $pkg->{'Version'} = $version, $change++
1182 if ($pkg->{'State'} eq 'Installed' and
1183 !version_eq( $pkg->{'Version'}, $version));
1184 # Always update priority and section, if available
1185 $pkg->{'Priority'} = $priority, $change++
1186 if defined $priority and (not defined($pkg->{'Priority'}) or $pkg->{'Priority'} ne $priority);
1188 $pkg->{'Section'} = $section, $change++
1189 if defined $section and (not defined($pkg->{'Section'}) or $pkg->{'Section'} ne $section);
1190 $db{$name} = $pkg if $change;
1193 # Now that we only have the latest source version, build the list
1194 # of binary packages from the Sources point of view
1195 foreach $name (keys %pkgs) {
1196 foreach my $bin (split( /\s*,\s*/, $pkgs{$name}{'bin'} ) ) {
1197 $merge_binsrc{$bin} = $name;
1200 # remove installed packages that no longer have source available
1201 # or binaries installed
1202 foreach $name (keys %db) {
1203 next if $name =~ /^_/;
1204 my $pkg = $db{$name};
1205 if (not defined($pkgs{$name})) {
1206 change_state( \$pkg, 'deleted' );
1207 log_ta( $pkg, "--merge-sources" );
1208 print "$name ($pkg->{'Version'}): ".
1209 "deleted from database, because ".
1210 "not in Sources anymore\n"
1214 next if !isin( $pkg->{'State'}, qw(Installed) );
1215 if ($full && not defined $merge_srcvers{$name}) {
1216 change_state( \$pkg, 'deleted' );
1217 log_ta( $pkg, "--merge-sources" );
1218 print "$name ($pkg->{'Version'}): ".
1219 "deleted from database, because ".
1220 "binaries don't exist anymore\n"
1223 } elsif ($full && version_less( $merge_srcvers{$name}, $pkg->{'Version'})) {
1224 print "$name ($pkg->{'Version'}): ".
1225 "package is Installed but binaries are from ".
1226 $merge_srcvers{$name}. "\n"
1234 # This function looks through a Packages file and sets the state of
1235 # packages to 'Installed'
1236 sub parse_packages {
1239 local($/) = ""; # read in paragraph mode
1241 my( $name, $version, $depends, $source, $sourcev, $architecture, $provides, $binaryv, $binnmu );
1243 /^Package:\s*(\S+)$/mi and $name = $1;
1244 /^Version:\s*(\S+)$/mi and $version = $1;
1245 /^Depends:\s*(.*)$/mi and $depends = $1;
1246 /^Source:\s*(\S+)(\s*\((\S+)\))?$/mi and ($source,$sourcev) = ($1, $3);
1247 /^Architecture:\s*(\S+)$/mi and $architecture = $1;
1248 /^Provides:\s*(.*)$/mi and $provides = $1;
1249 next if !$name || !$version;
1250 next if ($arch ne $architecture and $architecture ne "all");
1251 next if (defined ($installed->{$name}) and $installed->{$name}{'Version'} ne "" and
1252 version_lesseq( $version, $installed->{$name}{'Version'} ));
1253 $installed->{$name}{'Version'} = $version;
1254 $installed->{$name}{'Depends'} = $depends;
1255 $installed->{$name}{'all'} = 1 if $architecture eq "all";
1256 undef $installed->{$name}{'Provider'};
1257 $installed->{$name}{'Source'} = $source ? $source : $name;
1259 foreach (split( /\s*,\s*/, $provides )) {
1260 if (not defined ($installed->{$_})) {
1261 $installed->{$_}{'Version'} = "";
1262 $installed->{$_}{'Provider'} = $name;
1266 if ( $version =~ /\+b(\d+)$/ ) {
1269 $version = $sourcev if $sourcev;
1270 $binaryv = $version;
1271 $binaryv =~ s/\+b\d+$//;
1272 $installed->{$name}{'Sourcev'} = $sourcev ? $sourcev : $binaryv;
1273 $binaryv .= "+b$binnmu" if defined($binnmu);
1275 next if $architecture ne $arch;
1276 $name = $source if $source;
1277 next if defined($merge_srcvers{$name}) and $merge_srcvers{$name} eq $version;
1278 $merge_srcvers{$name} = $version;
1280 my $pkg = $db{$name};
1283 if (isin( $pkg->{'State'}, qw(Not-For-Us)) ||
1284 (isin($pkg->{'State'}, qw(Installed)) &&
1285 version_lesseq($binaryv, $pkg->{'Installed-Version'}))) {
1286 print "Skipping $name because State == $pkg->{'State'}\n"
1290 if ($pkg->{'Binary-NMU-Version'} ) {
1291 my $nmuver = binNMU_version($pkg->{'Version'}, $pkg->{'Binary-NMU-Version'});
1292 if (version_less( $binaryv, $nmuver )) {
1293 print "Skipping $name ($version) because have newer ".
1294 "version ($nmuver) in db.\n"
1298 } elsif (version_less($version, $pkg->{'Version'})) {
1299 print "Skipping $name ($version) because have newer ".
1300 "version ($pkg->{'Version'}) in db.\n"
1305 if (!pkg_version_eq($pkg, $version) &&
1306 $pkg->{'State'} ne "Installed") {
1307 warn "Warning: $name: newer version than expected appeared ".
1308 "in archive ($version vs. $pkg->{'Version'})\n";
1309 delete $pkg->{'Builder'};
1312 if (!isin( $pkg->{'State'}, qw(Uploaded) )) {
1313 warn "Warning: Package $name was not in uploaded state ".
1314 "before (but in '$pkg->{'State'}').\n";
1315 delete $pkg->{'Builder'};
1316 delete $pkg->{'Depends'};
1320 $pkg->{'Version'} = $version;
1323 change_state( \$pkg, 'Installed' );
1324 $pkg->{'Package'} = $name;
1325 $pkg->{'Installed-Version'} = $binaryv;
1326 if (defined $pkg->{'PermBuildPri'}) {
1327 $pkg->{'BuildPri'} = $pkg->{'PermBuildPri'};
1329 delete $pkg->{'BuildPri'};
1331 $pkg->{'Version'} = $version
1332 if version_less( $pkg->{'Version'}, $version);
1333 delete $pkg->{'Binary-NMU-Version'};
1334 delete $pkg->{'Binary-NMU-Changelog'};
1335 log_ta( $pkg, "--merge-packages" );
1337 print "$name ($version) is up-to-date now.\n" if $verbose;
1340 check_dep_wait( "--merge-packages", $installed );
1345 my ($package, $name, $version, $installed);
1347 foreach $package (@_) {
1348 $package =~ s,^.*/,,; # strip path
1349 $package =~ s/\.(dsc|diff\.gz|tar\.gz|deb)$//; # strip extension
1350 $package =~ s/_[\w\d]+\.changes$//; # strip extension
1351 if ($package =~ /^([\w\d.+-]+)_([\w\d:.+~-]+)/) {
1352 ($name,$version) = ($1,$2);
1355 warn "$package: can't extract package name and version ".
1359 $installed->{$name}{'Version'} = $version;
1362 check_dep_wait( "--pretend-avail", $installed );
1365 sub check_dep_wait {
1367 my $installed = shift;
1369 # check all packages in state Dep-Wait if dependencies are all
1372 foreach $name (keys %db) {
1373 next if $name =~ /^_/;
1374 my $pkg = $db{$name};
1375 next if $pkg->{'State'} ne "Dep-Wait";
1376 my $deps = $pkg->{'Depends'};
1378 print "$name: was in state Dep-Wait, but with empty ",
1380 goto make_needs_build;
1382 my $deplist = parse_deplist($deps);
1386 foreach (keys %$deplist) {
1387 if (!exists $installed->{$_} ||
1388 ($deplist->{$_}->{'Rel'} && $deplist->{$_}->{'Version'} &&
1389 !version_compare( $installed->{$_}{'Version'},
1390 $deplist->{$_}->{'Rel'},
1391 $deplist->{$_}->{'Version'}))) {
1393 $new_deplist->{$_} = $deplist->{$_};
1396 push( @removed_deps, $_ );
1401 change_state( \$pkg, 'Needs-Build' );
1402 log_ta( $pkg, $action );
1403 delete $pkg->{'Builder'};
1404 delete $pkg->{'Depends'};
1405 print "$name ($pkg->{'Version'}) has all ",
1406 "dependencies available now\n" if $verbose;
1410 elsif (@removed_deps) {
1411 $pkg->{'Depends'} = build_deplist( $new_deplist );
1412 print "$name ($pkg->{'Version'}): some dependencies ",
1413 "(@removed_deps) available now, but not all yet\n"
1420 # This function accepts quinn-diff output (either from a file named on
1421 # the command line, or on stdin) and sets the packages named there to
1422 # state 'Needs-Build'.
1423 sub parse_quinn_diff {
1424 my $partial = shift;
1430 next if !m,^([-\w\d/]*)/ # section
1431 ([-\w\d.+]+)_ # package name
1432 ([\w\d:.~+-]+)\.dsc\s* # version
1433 \[([^:]*): # priority
1434 ([^]]+)\]\s*$,x; # rest of notes
1435 my($section,$name,$version,$priority,$notes) = ($1, $2, $3, $4, $5);
1436 $quinn_pkgs{$name}++;
1437 $section ||= "unknown";
1438 $priority ||= "unknown";
1439 $priority = "unknown" if $priority eq "-";
1440 $priority = "standard" if ($name eq "debian-installer");
1442 my $pkg = $db{$name};
1444 # Always update section and priority.
1445 if (defined($pkg)) {
1447 $pkg->{'Section'} = $section, $change++ if not defined
1448 $pkg->{'Section'} or $section ne "unknown";
1449 $pkg->{'Priority'} = $priority, $change++ if not defined
1450 $pkg->{'Priority'} or $priority ne "unknown";
1453 if (defined($pkg) &&
1454 $pkg->{'State'} =~ /^Dep-Wait/ &&
1455 version_less( $pkg->{'Version'}, $version )) {
1456 change_state( \$pkg, 'Dep-Wait' );
1457 $pkg->{'Version'} = $version;
1458 delete $pkg->{'Binary-NMU-Version'};
1459 delete $pkg->{'Binary-NMU-Changelog'};
1460 log_ta( $pkg, "--merge-quinn" );
1462 print "$name ($version) still waiting for dependencies.\n"
1465 elsif (defined($pkg) &&
1466 $pkg->{'State'} =~ /-Removed$/ &&
1467 version_eq($pkg->{'Version'}, $version)) {
1468 # reinstantiate a package that has been removed earlier
1469 # (probably due to a quinn-diff malfunction...)
1470 my $newstate = $pkg->{'State'};
1471 $newstate =~ s/-Removed$//;
1472 change_state( \$pkg, $newstate );
1473 $pkg->{'Version'} = $version;
1474 $pkg->{'Notes'} = $notes;
1475 log_ta( $pkg, "--merge-quinn" );
1477 print "$name ($version) reinstantiated to $newstate.\n"
1480 elsif (defined($pkg) &&
1481 $pkg->{'State'} eq "Not-For-Us" &&
1482 version_less( $pkg->{'Version'}, $version )) {
1483 # for Not-For-Us packages just update the version etc., but
1485 change_state( \$pkg, "Not-For-Us" );
1486 $pkg->{'Package'} = $name;
1487 $pkg->{'Version'} = $version;
1488 $pkg->{'Notes'} = $notes;
1489 delete $pkg->{'Builder'};
1490 log_ta( $pkg, "--merge-quinn" );
1492 print "$name ($version) still Not-For-Us.\n" if $verbose;
1494 elsif (!defined($pkg) ||
1495 $pkg->{'State'} ne "Not-For-Us" &&
1496 (version_less( $pkg->{'Version'}, $version ) ||
1497 ($pkg->{'State'} eq "Installed" && version_less($pkg->{'Installed-Version'}, $version)))) {
1499 if (defined( $pkg->{'State'} ) && isin( $pkg->{'State'}, qw(Building Built Build-Attempted))) {
1500 send_mail( $pkg->{'Builder'},
1501 "new version of $name (dist=$distribution)",
1502 "As far as I'm informed, you're currently ".
1503 "building the package $name\n".
1504 "in version $pkg->{'Version'}.\n\n".
1505 "Now there's a new source version $version. ".
1506 "If you haven't finished\n".
1507 "compiling $name yet, you can stop it to ".
1508 "save some work.\n".
1509 "Just to inform you...\n".
1510 "(This is an automated message)\n" );
1511 print "$name: new version ($version) while building ".
1512 "$pkg->{'Version'} -- sending mail ".
1513 "to builder ($pkg->{'Builder'})\n"
1516 change_state( \$pkg, 'Needs-Build' );
1517 $pkg->{'Package'} = $name;
1518 $pkg->{'Version'} = $version;
1519 $pkg->{'Section'} = $section;
1520 $pkg->{'Priority'} = $priority;
1521 $pkg->{'Notes'} = $notes;
1522 delete $pkg->{'Builder'};
1523 delete $pkg->{'Binary-NMU-Version'};
1524 delete $pkg->{'Binary-NMU-Changelog'};
1525 log_ta( $pkg, "--merge-quinn" );
1528 print "$name ($version) needs rebuilding now.\n" if $verbose;
1530 elsif (defined($pkg) &&
1531 !version_eq( $pkg->{'Version'}, $version ) &&
1532 isin( $pkg->{'State'}, qw(Installed Not-For-Us) )) {
1533 print "$name: skipping because version in db ".
1534 "($pkg->{'Version'}) is >> than ".
1535 "what quinn-diff says ($version) ".
1536 "(state is $pkg->{'State'})\n"
1538 $dubious .= "$pkg->{'State'}: ".
1539 "db ${name}_$pkg->{'Version'} >> ".
1540 "quinn $version\n" if !$partial;
1542 elsif ($verbose >= 2) {
1543 if ($pkg->{'State'} eq "Not-For-Us") {
1544 print "Skipping $name because State == ".
1545 "$pkg->{'State'}\n";
1547 elsif (!version_less($pkg->{'Version'}, $version)) {
1548 print "Skipping $name because version in db ".
1549 "($pkg->{'Version'}) is >= than ".
1550 "what quinn-diff says ($version)\n";
1553 $db{$name} = $pkg if $change;
1557 send_mail( $conf::db_maint,
1558 "Dubious versions in $distribution $conf::dbbase database",
1559 "The following packages have a newer version in the ".
1560 "wanna-build database\n".
1561 "than what quinn-diff says, and this is strange for ".
1563 "It could be caused by a lame mirror, or the version ".
1564 "in the database\n".
1569 # Now re-check the DB for packages in states Needs-Build, Failed,
1570 # or Dep-Wait and remove them if they're not listed anymore by quinn-diff.
1573 foreach $name (keys %db) {
1574 next if $name =~ /^_/;
1575 my $pkg = $db{$name};
1576 next if defined $pkg->{'Binary-NMU-Version'};
1577 next if !isin( $pkg->{'State'},
1578 qw(Needs-Build Building Built Build-Attempted Uploaded Failed Dep-Wait) );
1579 my $virtual_delete = $pkg->{'State'} eq 'Failed';
1581 if (!$quinn_pkgs{$name}) {
1582 change_state( \$pkg, $virtual_delete ?
1583 $pkg->{'State'}."-Removed" :
1585 log_ta( $pkg, "--merge-quinn" );
1586 print "$name ($pkg->{'Version'}): ".
1587 ($virtual_delete ? "(virtually) " : "") . "deleted ".
1588 "from database, because not in quinn-diff anymore\n"
1590 if ($virtual_delete) {
1600 sub send_reupload_mail {
1603 my $version = shift;
1605 my $other_dist = shift;
1608 "Please reupload ${pkg}_${'Version'} for $dist",
1609 "You have recently built (or are currently building)\n".
1610 "${pkg}_${'Version'} for $other_dist.\n".
1611 "This version is now also needed in the $dist distribution.\n".
1612 "Please reupload the files now present in the Debian archive\n".
1613 "(best with buildd-reupload).\n" );
1617 # for sorting priorities and sections
1619 %prioval = ( required => -5,
1627 'debian-installer' => -199,
1648 localizations => -178,
1649 interpreters => -177,
1674 electronics => -152,
1680 foreach my $i (keys %sectval) {
1681 $sectval{"contrib/$i"} = $sectval{$i}+40;
1682 $sectval{"non-free/$i"} = $sectval{$i}+80;
1684 $sectval{'unknown'} = -165;
1686 %catval = ( "none" => -20,
1687 "uploaded-fixed-pkg" => -19,
1688 "fix-expected" => -18,
1689 "reminder-sent" => -17,
1690 "nmu-offered" => -16,
1694 "compiler-error" => -12 );
1697 sub sort_list_func {
1698 my( $letter, $x, $ax, $bx );
1700 foreach $letter (split( "", $list_order )) {
1701 SWITCH: foreach ($letter) {
1703 $x = $b->{'BuildPri'} <=> $a->{'BuildPri'};
1704 return $x if $x != 0;
1708 $x = $prioval{$a->{'Priority'}} <=> $prioval{$b->{'Priority'}};
1709 return $x if $x != 0;
1713 $x = $sectval{$a->{'Section'}} <=> $sectval{$b->{'Section'}};
1714 return $x if $x != 0;
1718 $x = $a->{'Package'} cmp $b->{'Package'};
1719 return $x if $x != 0;
1723 $x = $a->{'Builder'} cmp $b->{'Builder'};
1724 return $x if $x != 0;
1728 $ax = ($a->{'Notes'} =~ /^(out-of-date|partial)/) ? 0 :
1729 ($a->{'Notes'} =~ /^uncompiled/) ? 2 : 1;
1730 $bx = ($b->{'Notes'} =~ /^(out-of-date|partial)/) ? 0 :
1731 ($b->{'Notes'} =~ /^uncompiled/) ? 2 : 1;
1733 return $x if $x != 0;
1737 my $ca = exists $a->{'Failed-Category'} ?
1738 $a->{'Failed-Category'} : "none";
1739 my $cb = exists $b->{'Failed-Category'} ?
1740 $b->{'Failed-Category'} : "none";
1741 $x = $catval{$ca} <=> $catval{$cb};
1742 return $x if $x != 0;
1746 my $pa = $prioval{$a->{'Priority'}} >
1747 $prioval{'standard'};
1748 my $pb = $prioval{$b->{'Priority'}} >
1749 $prioval{'standard'};
1751 return $x if $x != 0;
1761 my( $name, $pkg, @list );
1766 foreach $name (keys %db) {
1767 next if $name =~ /^_/;
1769 next if $state ne "all" && $pkg->{'State'} !~ /^\Q$state\E$/i;
1770 next if $user && (lc($state) ne 'needs-build' and $pkg->{'Builder'} ne $user);
1771 next if $category && $pkg->{'State'} eq "Failed" &&
1772 $pkg->{'Failed-Category'} ne $category;
1773 next if ($list_min_age > 0 &&
1774 ($ctime-parse_date($pkg->{'State-Change'})) < $list_min_age)||
1775 ($list_min_age < 0 &&
1776 ($ctime-parse_date($pkg->{'State-Change'})) > -$list_min_age);
1777 push( @list, $pkg );
1780 foreach $pkg (sort sort_list_func @list) {
1781 print "$pkg->{'Section'}/$pkg->{'Package'}_$pkg->{'Version'}";
1782 print ": $pkg->{'State'}"
1784 print " by $pkg->{'Builder'}"
1785 if $pkg->{'State'} ne "Needs-Build" && $pkg->{'Builder'};
1786 print " [$pkg->{'Priority'}:$pkg->{'Notes'}";
1787 print ":PREV-FAILED"
1788 if $pkg->{'Previous-State'} =~ /^Failed/;
1789 print ":bp{" . $pkg->{'BuildPri'} . "}"
1790 if exists $pkg->{'BuildPri'};
1791 print ":binNMU{" . $pkg->{'Binary-NMU-Version'} . "}"
1792 if exists $pkg->{'Binary-NMU-Version'};
1794 print " Reasons for failing:\n",
1796 exists $pkg->{'Failed-Category'} ? $pkg->{'Failed-Category'} : "none",
1798 join("\n ",split("\n",$pkg->{'Failed'})), "\n"
1799 if $pkg->{'State'} =~ /^Failed/;
1800 print " Dependencies: $pkg->{'Depends'}\n"
1801 if $pkg->{'State'} eq "Dep-Wait";
1802 print " Previous state was $pkg->{'Previous-State'} until ",
1803 "$pkg->{'State-Change'}\n"
1804 if $verbose && $pkg->{'Previous-State'};
1805 print " Previous failing reasons:\n ",
1806 join("\n ",split("\n",$pkg->{'Old-Failed'})), "\n"
1807 if $verbose && $pkg->{'Old-Failed'};
1809 $scnt{$pkg->{'State'}}++ if $state eq "all";
1811 if ($state eq "all") {
1812 foreach (sort keys %scnt) {
1813 print "Total $scnt{$_} package(s) in state $_.\n";
1816 print "Total $cnt package(s)\n";
1821 my( $name, $pkg, $key, $dist );
1822 my @firstkeys = qw(Package Version Builder State Section Priority
1823 Installed-Version Previous-State State-Change);
1824 my @dists = $info_all_dists ? keys %conf::distributions : ($distribution);
1826 foreach $dist (@dists) {
1827 if ($dist ne $distribution) {
1828 if (!-f db_filename( $dist ) || !open_other_db( $dist )) {
1829 warn "Cannot open database for $dist!\n";
1830 @dists = grep { $_ ne $dist } @dists;
1835 foreach $name (@_) {
1836 $name =~ s/_.*$//; # strip version
1837 foreach $dist (@dists) {
1838 my $db = $dist ne $distribution ? $otherdb{$dist} : \%db;
1839 my $pname = "$name" . ($info_all_dists ? "($dist)" : "");
1841 $pkg = $db->{$name};
1842 if (!defined( $pkg )) {
1843 print "$pname: not registered\n";
1848 foreach $key (@firstkeys) {
1849 next if !exists $pkg->{$key};
1850 my $val = $pkg->{$key};
1852 $val = "\n$val" if isin( $key, qw(Failed Old-Failed));
1854 printf " %-20s: %s\n", $key, $val;
1856 foreach $key (sort keys %$pkg) {
1857 next if isin( $key, @firstkeys );
1858 my $val = $pkg->{$key};
1860 $val = "\n$val" if isin( $key, qw(Failed Old-Failed));
1862 printf " %-20s: %s\n", $key, $val;
1868 sub forget_packages {
1869 my( $name, $pkg, $key, $data );
1871 foreach $name (@_) {
1872 $name =~ s/_.*$//; # strip version
1874 if (!defined( $pkg )) {
1875 print "$name: not registered\n";
1880 foreach $key (sort keys %$pkg) {
1881 my $val = $pkg->{$key};
1884 $data .= sprintf " %-20s: %s\n", $key, $val;
1886 send_mail( $conf::db_maint,
1887 "$name deleted from DB $conf::dbbase",
1888 "The package '$name' has been deleted from the database ".
1890 "Data registered about the deleted package:\n".
1891 "$data\n" ) if $conf::db_maint;
1892 change_state( \$pkg, 'deleted' );
1893 log_ta( $pkg, "--forget" );
1895 print "$name: deleted from database\n" if $verbose;
1903 $ui = $db{'_userinfo'};
1904 foreach $name (@_) {
1905 if (!defined( $ui->{$name} )) {
1906 print "$name: not registered\n";
1910 delete $ui->{$name};
1912 print "$name: deleted from database\n" if $verbose;
1914 $db{'_userinfo'} = $ui if $change;
1920 my $lockfile = db_filename($dist) . ".lock";
1923 print "Locking $dist database\n" if $verbose >= 2;
1925 if (!sysopen( F, $lockfile, O_WRONLY|O_CREAT|O_TRUNC|O_EXCL, 0644 )){
1927 # lock file exists, wait
1928 goto repeat if !open( F, "<$lockfile" );
1931 if ($line !~ /^(\d+)\s+([\w\d.-]+)$/) {
1932 warn "Bad lock file contents -- still trying\n";
1935 my($pid, $usr) = ($1, $2);
1936 if (kill( 0, $pid ) == 0 && $! == ESRCH) {
1937 # process doesn't exist anymore, remove stale lock
1938 print "Removing stale lock file (pid $pid, user $usr)\n";
1939 unlink( $lockfile );
1942 warn "Database locked by $usr -- please wait\n" if $try == 0;
1945 # avoid the END routine removes the lock
1946 $main::keep_lock{$dist} = 1;
1947 die "Lock still present after 200 * 5 seconds.\n";
1952 die "Can't create lock file $lockfile: $!\n";
1954 F->print("$$ $real_user\n");
1960 my $lockfile = db_filename($dist) . ".lock";
1962 if (!$main::keep_lock{$dist}) {
1963 print "Unlocking $dist database\n" if $verbose >= 2;
1968 sub create_maintlock {
1969 my $lockfile = db_filename("maintenance") . ".lock";
1973 print "Creating maintenance lock\n" if $verbose >= 2;
1975 if (!sysopen( F, $lockfile, O_WRONLY|O_CREAT|O_TRUNC|O_EXCL, 0644 )){
1977 # lock file exists, wait
1978 goto repeat if !open( F, "<$lockfile" );
1981 if ($line !~ /^(\d+)\s+([\w\d.-]+)$/) {
1982 warn "Bad maintenance lock file contents -- still trying\n";
1985 my($pid, $usr) = ($1, $2);
1986 if (kill( 0, $pid ) == 0 && $! == ESRCH) {
1987 # process doesn't exist anymore, remove stale lock
1988 print "Removing stale lock file (pid $pid, user $usr)\n";
1989 unlink( $lockfile );
1992 warn "Maintenance lock already exists by $usr -- ".
1993 "please wait\n" if $try == 0;
1996 die "Lock still present after 120 * 60 seconds.\n";
2001 die "Can't create maintenance lock $lockfile: $!\n";
2003 F->print(getppid(), " $real_user\n");
2007 sub remove_maintlock {
2008 my $lockfile = db_filename("maintenance") . ".lock";
2010 print "Removing maintenance lock\n" if $verbose >= 2;
2014 sub waitfor_maintlock {
2015 my $lockfile = db_filename("maintenance") . ".lock";
2019 print "Checking for maintenance lock\n" if $verbose >= 2;
2021 if (open( F, "<$lockfile" )) {
2024 if ($line !~ /^(\d+)\s+([\w\d.-]+)$/) {
2025 warn "Bad maintenance lock file contents -- still trying\n";
2028 my($pid, $usr) = ($1, $2);
2029 if (kill( 0, $pid ) == 0 && $! == ESRCH) {
2030 # process doesn't exist anymore, remove stale lock
2031 print "Removing stale maintenance lock (pid $pid, user $usr)\n";
2032 unlink( $lockfile );
2035 warn "Databases locked for general maintenance by $usr -- ".
2036 "please wait\n" if $try == 0;
2039 die "Lock still present after 120 * 60 seconds.\n";
2050 print "Reading ASCII database from $file..." if $verbose >= 1;
2051 open( F, "<$file" ) or
2052 die "Can't open database $file: $!\n";
2054 local($/) = ""; # read in paragraph mode
2056 my( %thispkg, $name );
2058 s/\n[ \t]+/\376\377/g; # fix continuation lines
2059 s/\376\377\s*\376\377/\376\377/og;
2061 while( /^(\S+):[ \t]*(.*)[ \t]*$/mg ) {
2062 my ($key, $val) = ($1, $2);
2063 $val =~ s/\376\377/\n/g;
2064 $thispkg{$key} = $val;
2066 check_entry( \%thispkg );
2068 if (exists($thispkg{'Package'})) {
2069 $name = $thispkg{'Package'};
2070 $db{$name} = \%thispkg;
2072 elsif(exists($thispkg{'User'})) {
2073 my $userinfo = $db{'_userinfo'};
2074 $userinfo = {} if (!defined($userinfo));
2076 $name = $thispkg{'User'};
2077 $userinfo->{$name} = \%thispkg;
2079 $db{'_userinfo'} = $userinfo;
2083 print "done\n" if $verbose >= 1;
2090 return if $op_mode eq "manual-edit"; # no checks then
2092 # check for required fields
2093 if (exists $pkg->{'User'}) {
2096 if (!exists $pkg->{'Package'}) {
2097 print STDERR "Bad entry: ",
2098 join( "\n", map { "$_: $pkg->{$_}" } keys %$pkg ), "\n";
2099 die "Database entry lacks Package or User: field\n";
2101 if (!exists $pkg->{'Version'}) {
2102 die "Database entry for $pkg->{'Package'} lacks Version: field\n";
2104 # if no State: field, generate one (for old db compat)
2105 if (!exists($pkg->{'State'})) {
2107 exists $pkg->{'Failed'} ? 'Failed' : 'Building';
2110 die "Bad state $pkg->{'State'} of package $pkg->{Package}\n"
2111 if !isin( $pkg->{'State'},
2112 qw(Needs-Build Building Built Build-Attempted Uploaded Installed Dep-Wait
2113 Failed Failed-Removed Not-For-Us
2119 my($name,$pkg,$key);
2121 print "Writing ASCII database to $file..." if $verbose >= 1;
2122 open( F, ">$file" ) or
2123 die "Can't open database $file: $!\n";
2125 foreach $name (sort keys %db) {
2126 my $pkg = $db{$name};
2127 if ($name eq '_userinfo') {
2128 foreach $user (sort keys %{$pkg}) {
2129 my $ui = $pkg->{$user};
2130 print F "User: $user\n"
2131 if (!defined($ui->{'User'}));
2132 foreach $key (keys %{$ui}) {
2133 my $val = $ui->{$key};
2136 print F "$key: $val\n";
2142 foreach $key (keys %{$pkg}) {
2143 my $val = $pkg->{$key};
2146 print F "$key: $val\n";
2152 print "done\n" if $verbose >= 1;
2158 my $newstate = shift;
2159 my $for_dist = shift;
2162 return if !open_other_db( $for_dist );
2163 $db = $otherdb{$for_dist};
2164 $pkg = \$db{$pkg->{'Package'}};
2169 my $state = \$pkg->{'State'};
2171 return if defined($$state) and $$state eq $newstate;
2172 $pkg->{'Previous-State'} = $$state if defined($$state);
2173 $pkg->{'State-Change'} = $curr_date;
2175 if (defined($$state) and $$state eq 'Failed') {
2176 $pkg->{'Old-Failed'} =
2177 "-"x20 . " $pkg->{'Version'} " . "-"x20 . "\n" .
2178 $pkg->{'Failed'} . "\n" .
2179 $pkg->{'Old-Failed'};
2180 delete $pkg->{'Failed'};
2181 delete $pkg->{'Failed-Category'};
2183 $$state = $newstate;
2189 if (!tied(%{$otherdb{$dist}})) {
2191 $otherdb_lock{$dist} = 1;
2192 if (!(tie %{$otherdb{$dist}}, 'MLDBM', db_filename($dist), 0, 0664)){
2193 warn "Serious warning: Cannot open database for $dist\n";
2195 $otherdb_lock{$dist} = 0;
2206 my $dist = $distribution;
2210 $prevstate = $pkg->{'Previous-State'};
2211 $str = "$action($dist): $pkg->{'Package'}_$pkg->{'Version'} ".
2212 "changed from $prevstate to $pkg->{'State'} ".
2213 "by $real_user as $user";
2215 if (!open( LOG, ">>$transactlog" )) {
2216 warn "Can't open log file $transactlog: $!\n";
2219 print LOG "$curr_date: $str\n";
2222 if (!($prevstate eq 'Failed' && $pkg->{'State'} eq 'Failed')) {
2223 $str .= " (with --override)"
2225 $mail_logs .= "$str\n";
2232 my $subject = shift;
2235 my $from = $conf::db_maint;
2236 my $domain = $conf::buildd_domain;
2238 $from .= "\@$domain" if $from !~ /\@/;
2240 $to .= '@' . $domain if $to !~ /\@/;
2241 $text =~ s/^\.$/../mg;
2242 local $SIG{'PIPE'} = 'IGNORE';
2243 open( PIPE, "| $conf::mailprog -oem $to" )
2244 or die "Can't open pipe to $conf::mailprog: $!\n";
2246 print PIPE "From: $from\n";
2247 print PIPE "Subject: $subject\n\n";
2248 print PIPE "$text\n";
2254 return "$conf::basedir/$conf::dbbase-$dist";
2257 # for parsing input to dep-wait
2263 foreach (split( /\s*,\s*/, $deps )) {
2265 # verification requires > starting prompts, no | crap
2266 if (!/^(\S+)\s*(\(\s*(>(?:[>=])?)\s*(\S+)\s*\))?\s*$/) {
2271 my @alts = split( /\s*\|\s*/, $_ );
2272 # Anything with an | is ignored, as it can be configured on a
2273 # per-buildd basis what will be installed
2274 next if $#alts != 0;
2277 if (!/^(\S+)\s*(\(\s*(>=|=|==|>|>>|<<|<=)\s*(\S+)\s*\))?\s*$/) {
2278 warn( "parse_deplist: bad dependency $_\n" );
2281 my($dep, $rel, $relv) = ($1, $3, $4);
2282 $rel = ">>" if defined($rel) and $rel eq ">";
2283 $result{$dep}->{'Package'} = $dep;
2284 if ($rel && $relv) {
2285 $result{$dep}->{'Rel'} = $rel;
2286 $result{$dep}->{'Version'} = $relv;
2289 return 1 if $verify;
2293 # for parsing Build-Depends from Sources
2294 sub parse_srcdeplist {
2301 foreach $dep (split( /\s*,\s*/, $deps )) {
2302 my @alts = split( /\s*\|\s*/, $dep );
2303 # Anything with an | is ignored, as it can be configured on a
2304 # per-buildd basis what will be installed
2305 next if $#alts != 0;
2307 if (!/^([^\s([]+)\s*(\(\s*([<=>]+)\s*(\S+)\s*\))?(\s*\[([^]]+)\])?/) {
2308 warn( "parse_srcdeplist: bad dependency $_\n" );
2311 my($dep, $rel, $relv, $archlist) = ($1, $3, $4, $6);
2313 $archlist =~ s/^\s*(.*)\s*$/$1/;
2314 my @archs = split( /\s+/, $archlist );
2315 my ($use_it, $ignore_it, $include) = (0, 0, 0);
2318 $ignore_it = 1 if substr($_, 1) eq $arch;
2320 $use_it = 1 if $_ eq $arch;
2324 warn "Warning: inconsistent arch restriction on ",
2325 "$pkg: $dep depedency\n"
2326 if $ignore_it && $use_it;
2327 next if $ignore_it || ($include && !$use_it);
2335 $result->{'Package'} = $dep;
2336 $result->{'Neg'} = $neg;
2337 if ($rel && $relv) {
2338 $result->{'Rel'} = $rel;
2339 $result->{'Version'} = $relv;
2341 push @results, $result;
2350 foreach $key (keys %$list) {
2351 $result .= ", " if $result;
2353 $result .= " ($list->{$key}->{'Rel'} $list->{$key}->{'Version'})"
2354 if $list->{$key}->{'Rel'} && $list->{$key}->{'Version'};
2361 tie %new_db, 'MLDBM', db_filename( $distribution ) . ".new", GDBM_WRCREAT, 0664
2362 or die "FATAL: Cannot create new database\n";
2364 untie %db or die "FATAL: Cannot untie old database\n";
2365 system ("cp " . db_filename( $distribution ) . ".new " .
2366 db_filename( $distribution ) ) == 0
2367 or die "FATAL: Cannot overwrite old database";
2368 unlink db_filename( $distribution ) . ".new";
2373 sub get_unsatisfied_dep {
2377 my $savedep = shift;
2379 my $pkgname = $dep->{'Package'};
2381 if (defined $pkgs->{$pkgname}{'Provider'}) {
2382 # provides. leave them for buildd/sbuild.
2387 return $pkgs->{$pkgname}{'Unsatisfied'} if $savedep and defined($pkgs->{$pkgname}{'Unsatisfied'});
2389 # Return unsatisfied deps to a higher caller to process
2390 if ((!defined($pkgs->{$pkgname})) or
2391 (defined($dep->{'Rel'}) and !version_compare( $pkgs->{$pkgname}{'Version'}, $dep->{'Rel'}, $dep->{'Version'} ) ) ) {
2393 $deplist{$pkgname} = $dep;
2394 my $deps = build_deplist(\%deplist);
2395 $pkgs->{$pkgname}{'Unsatisfied'} = $deps if $savedep;
2399 # set cache to "" to avoid infinite recursion
2400 $pkgs->{$pkgname}{'Unsatisfied'} = "" if $savedep;
2402 if (defined $pkgs->{$dep->{'Package'}}{'Depends'}) {
2403 my $deps = parse_deplist( $pkgs->{$dep->{'Package'}}{'Depends'} );
2404 foreach (keys %$deps) {
2407 my $ret = get_unsatisfied_dep($bd,$pkgs,$dep,1);
2409 my $retdep = parse_deplist( $ret );
2410 foreach (keys %$retdep) {
2411 $dep = $$retdep{$_};
2413 $dep->{'Rel'} = '>=' if defined($dep->{'Rel'}) and $dep->{'Rel'} =~ '^=';
2415 if (defined($dep->{'Rel'}) and $dep->{'Rel'} =~ '^>' and defined ($pkgs->{$dep->{'Package'}}) and
2416 version_compare($bd->{$pkgs->{$dep->{'Package'}}{'Source'}}{'ver'},'>>',$pkgs->{$dep->{'Package'}}{'Sourcev'})) {
2417 if (not defined($merge_binsrc{$dep->{'Package'}})) {
2418 # the uninstallable package doesn't exist in the new source; look for something else that does.
2419 delete $$retdep{$dep->{'Package'}};
2420 foreach (sort (split( /\s*,\s*/, $bd->{$pkgs->{$dep->{'Package'}}{'Source'}}{'bin'}))) {
2421 next if ($pkgs->{$_}{'all'} or not defined $pkgs->{$_}{'Version'});
2422 $dep->{'Package'} = $_;
2423 $dep->{'Rel'} = '>>';
2424 $dep->{'Version'} = $pkgs->{$_}{'Version'};
2425 $$retdep{$_} = $dep;
2430 # sanity check to make sure the depending binary still exists, and the depended binary exists and dep-wait on a new version of it
2431 if ( defined($merge_binsrc{$pkgname}) and defined($pkgs->{$dep->{'Package'}}{'Version'}) ) {
2432 delete $$retdep{$dep->{'Package'}};
2433 $dep->{'Package'} = $pkgname;
2434 $dep->{'Rel'} = '>>';
2435 $dep->{'Version'} = $pkgs->{$pkgname}{'Version'};
2436 $$retdep{$pkgname} = $dep;
2438 delete $$retdep{$dep->{'Package'}} if (defined ($dep->{'Rel'}) and $dep->{'Rel'} =~ '^>');
2441 $ret = build_deplist($retdep);
2442 $pkgs->{$pkgname}{'Unsatisfied'} = $ret if $savedep;
2455 return if defined ($conf::distributions{$distribution}{noadw});
2457 # We need to walk all of needs-build, as any new upload could make
2458 # something in needs-build have uninstallable deps
2459 foreach $key (keys %db) {
2460 my $pkg = $db{$key};
2462 if not defined $pkg or $pkg->{'State'} ne "Needs-Build";
2463 my $srcdeps = parse_srcdeplist($key,$bd->{$key}{'dep'},$arch);
2464 foreach my $srcdep (@$srcdeps) {
2465 next if $srcdep->{'Neg'} != 0; # we ignore conflicts atm
2466 my $rc = get_unsatisfied_dep($bd,$pkgs,$srcdep,0);
2469 my $deplist = parse_deplist( $pkg->{'Depends'} );
2470 my $newdeps = parse_deplist( $rc );
2472 foreach (%$newdeps) {
2473 my $dep = $$newdeps{$_};
2474 # ensure we're not waiting on ourselves, or a package that has been removed
2475 next if (not defined($merge_binsrc{$dep->{'Package'}})) or ($merge_binsrc{$dep->{'Package'}} eq $key);
2476 if ($dep->{'Rel'} =~ '^>') {
2477 $deplist->{$dep->{'Package'}} = $dep;
2482 $pkg->{'Depends'} = build_deplist($deplist);
2483 change_state( \$pkg, 'Dep-Wait' );
2484 log_ta( $pkg, "--merge-all" );
2486 print "Auto-Dep-Waiting ${key}_$pkg->{'Version'} to $pkg->{'Depends'}\n" if $verbose;
2496 ($prgname = $0) =~ s,^.*/,,;
2498 Usage: $prgname <options...> <package_version...>
2500 -v, --verbose: Verbose execution.
2501 --take: Take package for building [default operation]
2502 -f, --failed: Record in database that a build failed due to
2503 deficiencies in the package (that aren't fixable without a new
2505 -u, --uploaded: Record in the database that the packages build
2506 correctly and were uploaded.
2507 -n, --no-build: Record in the database that the packages aren't
2508 desired for this architecture and shouldn't appear in listings even
2509 if they're out of date.
2510 --dep-wait: Record in the database that the packages are waiting
2511 for some source dependencies to become available
2512 --merge-quinn: Merge quinn-diff output into database.
2513 --merge-packages: Merge Packages files into database.
2514 --pretend-avail: Pretend that given packages are available now and give
2515 free packages waiting for them
2516 -i SRC_PKG, --info SRC_PKG: Show information for source package
2517 -l STATE, --list=STATE: List all packages in state STATE; can be
2518 combined with -U to restrict to a specific user; STATE can
2520 -m MESSAGE, --message=MESSAGE: Give reason why package failed or
2521 source dependency list
2522 (used with -f, --dep-wait, and --binNMU)
2523 -o, --override: Override another user's lock on a package, i.e.
2524 take it over; a notice mail will be sent to the other user
2525 -U USER, --user=USER: select user name for which listings should
2526 apply, if not given all users are listed.
2527 if -l is missing, set user name to be entered in db; usually
2528 automatically choosen
2529 --import FILE: Import database from a ASCII file FILE
2530 --export FILE: Export database to a ASCII file FILE
2531 The remaining arguments (depending on operation) usually start with
2532 "name_version", the trailer is ignored. This allows to pass the names
2533 of .dsc files, for which file name completion can be used.
2534 --merge-packages and --merge-quinn take Package/quin--diff file names
2535 on the command line or read stdin. --list needs nothing more on the
2536 command line. --info takes source package names (without version).
2541 sub pkg_version_eq {
2543 my $version = shift;
2546 if (defined $pkg->{'Binary-NMU-Version'}) and
2547 version_compare(binNMU_version($pkg->{'Version'},
2548 $pkg->{'Binary-NMU-Version'}),'=', $version);
2549 return version_compare( $pkg->{'Version'}, "=", $version );