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 my $ui = $userinfo->{$user};
446 $userinfo->{$user}->{'Last-Seen'} = $curr_date;
447 $db{'_userinfo'} = $userinfo;
452 my $newstate = shift;
453 my( $package, $name, $version, $ok, $reason );
455 foreach $package (@_) {
456 $package =~ s,^.*/,,; # strip path
457 $package =~ s/\.(dsc|diff\.gz|tar\.gz|deb)$//; # strip extension
458 $package =~ s/_[a-zA-Z\d-]+\.changes$//; # strip extension
459 if ($package =~ /^([\w\d.+-]+)_([\w\d:.+~-]+)/) {
460 ($name,$version) = ($1,$2);
463 warn "$package: can't extract package name and version ".
468 if ($op_mode eq "set-building") {
469 add_one_building( $name, $version );
471 elsif ($op_mode eq "set-built") {
472 add_one_built( $name, $version );
474 elsif ($op_mode eq "set-attempted") {
475 add_one_attempted( $name, $version );
477 elsif ($op_mode eq "set-uploaded") {
478 add_one_uploaded( $name, $version );
480 elsif ($op_mode eq "set-failed") {
481 add_one_failed( $name, $version );
483 elsif ($op_mode eq "set-not-for-us") {
484 add_one_notforus( $name, $version );
486 elsif ($op_mode eq "set-needs-build") {
487 add_one_needsbuild( $name, $version );
489 elsif ($op_mode eq "set-dep-wait") {
490 add_one_depwait( $name, $version );
492 elsif ($op_mode eq "set-build-priority") {
493 set_one_buildpri( $name, $version, 'BuildPri' );
495 elsif ($op_mode eq "set-permanent-build-priority") {
496 set_one_buildpri( $name, $version, 'PermBuildPri' );
498 elsif ($op_mode eq "set-binary-nmu") {
499 set_one_binnmu( $name, $version );
504 sub add_one_building {
510 my $pkg = $db{$name};
512 if ($pkg->{'State'} eq "Not-For-Us") {
514 $reason = "not suitable for this architecture";
516 elsif ($pkg->{'State'} =~ /^Dep-Wait/) {
518 $reason = "not all source dependencies available yet";
520 elsif ($pkg->{'State'} eq "Uploaded" &&
521 (version_lesseq($version, $pkg->{'Version'}))) {
523 $reason = "already uploaded by $pkg->{'Builder'}";
524 $reason .= " (in newer version $pkg->{'Version'})"
525 if !version_eq($pkg, $version);
527 elsif ($pkg->{'State'} eq "Installed" &&
528 version_less($version,$pkg->{'Version'})) {
530 print "$name: Warning: newer version $pkg->{'Version'} ".
531 "already installed, but overridden.\n";
535 $reason = "newer version $pkg->{'Version'} already in ".
536 "archive; doesn't need rebuilding";
537 print "$name: Note: If the following is due to an epoch ",
538 " change, use --override\n";
541 elsif ($pkg->{'State'} eq "Installed" &&
542 pkg_version_eq($pkg,$version)) {
544 $reason = "is up-to-date in the archive; doesn't need rebuilding";
546 elsif ($pkg->{'State'} eq "Needs-Build" &&
547 version_less($version,$pkg->{'Version'})) {
549 print "$name: Warning: newer version $pkg->{'Version'} ".
550 "needs building, but overridden.";
554 $reason = "newer version $pkg->{'Version'} needs building, ".
558 elsif (isin($pkg->{'State'},qw(Building Built Build-Attempted))) {
559 if (version_less($pkg->{'Version'},$version)) {
560 print "$name: Warning: Older version $pkg->{'Version'} ",
561 "is being built by $pkg->{'Builder'}\n";
562 if ($pkg->{'Builder'} ne $user) {
563 send_mail( $pkg->{'Builder'},
564 "package takeover in newer version",
565 "You are building package '$name' in ".
566 "version $version\n".
567 "(as far as I'm informed).\n".
568 "$user now has taken the newer ".
569 "version $version for building.".
570 "You can abort the build if you like.\n" );
575 print "User $pkg->{'Builder'} had already ",
576 "taken the following package,\n",
577 "but overriding this as you request:\n";
578 send_mail( $pkg->{'Builder'}, "package takeover",
579 "The package '$name' (version $version) that ".
580 "was locked by you\n".
581 "has been taken over by $user\n" );
583 elsif ($pkg->{'Builder'} eq $user) {
584 print "$name: Note: already taken by you.\n";
585 print "$name: ok\n" if $verbose;
590 $reason = "already taken by $pkg->{'Builder'}";
591 $reason .= " (in newer version $pkg->{'Version'})"
592 if !version_eq($pkg->{'Version'}, $version);
596 elsif ($pkg->{'State'} =~ /^Failed/ &&
597 pkg_version_eq($pkg, $version)) {
599 print "The following package previously failed ",
600 "(by $pkg->{'Builder'})\n",
601 "but overriding this as you request:\n";
602 send_mail( $pkg->{'Builder'}, "failed package takeover",
603 "The package '$name' (version $version) that ".
604 "is locked by you\n".
605 "and has failed previously has been taken over ".
607 if $pkg->{'Builder'} ne $user;
611 $reason = "build of $version failed previously:\n ";
612 $reason .= join( "\n ", split( "\n", $pkg->{'Failed'} ));
613 $reason .= "\nalso the package doesn't need builing"
614 if $pkg->{'State'} eq 'Failed-Removed';
620 if ($pkg->{'Binary-NMU-Version'}) {
621 print "$name: Warning: needs binary NMU $pkg->{'Binary-NMU-Version'}\n" .
622 "$pkg->{'Binary-NMU-Changelog'}\n";
625 print "$name: Warning: Previous version failed!\n"
626 if $pkg->{'Previous-State'} =~ /^Failed/ ||
627 $pkg->{'State'} =~ /^Failed/;
629 change_state( \$pkg, 'Building' );
630 $pkg->{'Package'} = $name;
631 $pkg->{'Version'} = $version;
632 $pkg->{'Builder'} = $user;
633 log_ta( $pkg, "--take" );
635 print "$name: $ok\n" if $verbose;
638 print "$name: NOT OK!\n $reason\n";
642 sub add_one_attempted {
645 my $pkg = $db{$name};
647 if (!defined($pkg)) {
648 print "$name: not registered yet.\n";
652 if ($pkg->{'State'} ne "Building" ) {
653 print "$name: not taken for building (state is $pkg->{'State'}). ",
657 if ($pkg->{'Builder'} ne $user) {
658 print "$name: not taken by you, but by $pkg->{'Builder'}. Skipping.\n";
661 elsif ( !pkg_version_eq($pkg, $version) ) {
662 print "$name: version mismatch ".
663 "$(pkg->{'Version'} ".
664 "by $pkg->{'Builder'})\n";
668 change_state( \$pkg, 'Build-Attempted' );
669 log_ta( $pkg, "--attempted" );
671 print "$name: registered as uploaded\n" if $verbose;
677 my $pkg = $db{$name};
679 if (!defined($pkg)) {
680 print "$name: not registered yet.\n";
684 if ($pkg->{'State'} ne "Building" ) {
685 print "$name: not taken for building (state is $pkg->{'State'}). ",
689 if ($pkg->{'Builder'} ne $user) {
690 print "$name: not taken by you, but by $pkg->{'Builder'}. Skipping.\n";
693 elsif ( !pkg_version_eq($pkg, $version) ) {
694 print "$name: version mismatch ".
695 "$(pkg->{'Version'} ".
696 "by $pkg->{'Builder'})\n";
699 change_state( \$pkg, 'Built' );
700 log_ta( $pkg, "--built" );
702 print "$name: registered as built\n" if $verbose;
705 sub add_one_uploaded {
708 my $pkg = $db{$name};
710 if (!defined($pkg)) {
711 print "$name: not registered yet.\n";
715 if ($pkg->{'State'} eq "Uploaded" &&
716 pkg_version_eq($pkg,$version)) {
717 print "$name: already uploaded\n";
720 if (!isin( $pkg->{'State'}, qw(Building Built Build-Attempted))) {
721 print "$name: not taken for building (state is $pkg->{'State'}). ",
725 if ($pkg->{'Builder'} ne $user) {
726 print "$name: not taken by you, but by $pkg->{'Builder'}. Skipping.\n";
729 # strip epoch -- buildd-uploader used to go based on the filename.
730 # (to remove at some point)
732 ($pkgver = $pkg->{'Version'}) =~ s/^\d+://;
733 $version =~ s/^\d+://; # for command line use
734 if ($pkg->{'Binary-NMU-Version'} ) {
735 my $nmuver = binNMU_version($pkgver, $pkg->{'Binary-NMU-Version'});
736 if (!version_eq( $nmuver, $version )) {
737 print "$name: version mismatch ($nmuver registered). ",
741 } elsif (!version_eq($pkgver, $version)) {
742 print "$name: version mismatch ($pkg->{'Version'} registered). ",
747 change_state( \$pkg, 'Uploaded' );
748 log_ta( $pkg, "--uploaded" );
750 print "$name: registered as uploaded\n" if $verbose;
757 my $pkg = $db{$name};
759 if (!defined($pkg)) {
760 print "$name: not registered yet.\n";
763 $state = $pkg->{'State'};
765 if ($state eq "Not-For-Us") {
766 print "$name: not suitable for this architecture anyway. Skipping.\n";
769 elsif ($state eq "Failed-Removed") {
770 print "$name: failed previously and doesn't need building. Skipping.\n";
773 elsif ($state eq "Installed") {
774 print "$name: Is already installed in archive. Skipping.\n";
777 elsif ($pkg->{'Builder'} &&
778 (($user ne $pkg->{'Builder'}) &&
779 !($pkg->{'Builder'} =~ /^(\w+)-\w+/ && $1 eq $user))) {
780 print "$name: not taken by you, but by ".
781 "$pkg->{'Builder'}. Skipping.\n";
784 elsif ( !pkg_version_eq($pkg, $version) ) {
785 print "$name: version mismatch ".
786 "$(pkg->{'Version'} ".
787 "by $pkg->{'Builder'})\n";
792 if (!$cat && $fail_reason =~ /^\[([^\]]+)\]/) {
794 $cat = $short_category{$cat} if exists $short_category{$cat};
795 if (!isin( $cat, values %short_category )) {
796 print "$name: Warning: unknown category $cat; discarded\n";
799 $fail_reason =~ s/^\[[^\]]+\][ \t]*\n*//;
802 if ($state eq "Needs-Build") {
803 print "$name: Warning: not registered for building previously, ".
804 "but processing anyway.\n";
806 elsif ($state eq "Uploaded") {
807 print "$name: Warning: marked as uploaded previously, ".
808 "but processing anyway.\n";
810 elsif ($state eq "Dep-Wait") {
811 print "$name: Warning: marked as waiting for dependencies, ".
812 "but processing anyway.\n";
814 elsif ($state eq "Failed") {
815 print "$name: already registered as failed; will append new message\n"
817 print "$name: already registered as failed; changing category\n"
821 if (($cat eq "reminder-sent" || $cat eq "nmu-offered") &&
822 exists $pkg->{'Failed-Category'} &&
823 $pkg->{'Failed-Category'} ne $cat) {
824 (my $action = $cat) =~ s/-/ /;
825 $fail_reason .= "\n$short_date: $action";
828 change_state( \$pkg, 'Failed' );
829 $pkg->{'Builder'} = $user;
830 $pkg->{'Failed'} .= "\n" if $pkg->{'Failed'};
831 $pkg->{'Failed'} .= $fail_reason;
832 $pkg->{'Failed-Category'} = $cat if $cat;
833 if (defined $pkg->{'PermBuildPri'}) {
834 $pkg->{'BuildPri'} = $pkg->{'PermBuildPri'};
836 delete $pkg->{'BuildPri'};
838 log_ta( $pkg, "--failed" );
840 print "$name: registered as failed\n" if $verbose;
843 sub add_one_notforus {
846 my $pkg = $db{$name};
848 if ($pkg->{'State'} eq 'Not-For-Us') {
849 # reset Not-For-Us state in case it's called twice; this is
850 # the only way to get a package out of this state...
851 # There is no really good state in which such packages should
852 # be put :-( So use Failed for now.
853 change_state( \$pkg, 'Failed' );
854 $pkg->{'Package'} = $name;
855 $pkg->{'Failed'} = "Was Not-For-Us previously";
856 delete $pkg->{'Builder'};
857 delete $pkg->{'Depends'};
858 log_ta( $pkg, "--no-build(rev)" );
859 print "$name: now not unsuitable anymore\n";
861 send_mail( $conf::notforus_maint,
862 "$name moved out of Not-For-Us state",
863 "The package '$name' has been moved out of the Not-For-Us ".
865 "It should probably also be removed from ".
866 "Packages-arch-specific or\n".
867 "the action was wrong.\n" )
868 if $conf::notforus_maint;
871 change_state( \$pkg, 'Not-For-Us' );
872 $pkg->{'Package'} = $name;
873 delete $pkg->{'Builder'};
874 delete $pkg->{'Depends'};
875 delete $pkg->{'BuildPri'};
876 delete $pkg->{'Binary-NMU-Version'};
877 delete $pkg->{'Binary-NMU-Changelog'};
878 log_ta( $pkg, "--no-build" );
879 print "$name: registered as unsuitable\n" if $verbose;
881 send_mail( $conf::notforus_maint,
882 "$name set to Not-For-Us",
883 "The package '$name' has been set to state Not-For-Us ".
885 "It should probably also be added to ".
886 "Packages-arch-specific or\n".
887 "the Not-For-Us state is wrong.\n" )
888 if $conf::notforus_maint;
893 sub add_one_needsbuild {
897 my $pkg = $db{$name};
899 if (!defined($pkg)) {
900 print "$name: not registered; can't give back.\n";
903 $state = $pkg->{'State'};
905 if ($state eq "Dep-Wait") {
907 print "$name: Forcing source dependency list to be cleared\n";
910 print "$name: waiting for source dependencies. Skipping\n",
911 " (use --override to clear dependency list and ",
912 "give back anyway)\n";
916 elsif (!isin( $state, qw(Building Built Build-Attempted))) {
917 print "$name: not taken for building (state is $state).";
919 print "\n$name: Forcing give-back\n";
922 print " Skipping.\n";
926 if (defined ($pkg->{'Builder'}) && $user ne $pkg->{'Builder'} &&
927 !($pkg->{'Builder'} =~ /^(\w+)-\w+/ && $1 eq $user)) {
928 print "$name: not taken by you, but by ".
929 "$pkg->{'Builder'}. Skipping.\n";
932 if (!pkg_version_eq($pkg, $version)) {
933 print "$name: version mismatch ($pkg->{'Version'} registered). ",
937 change_state( \$pkg, 'Needs-Build' );
938 delete $pkg->{'Builder'};
939 delete $pkg->{'Depends'};
940 log_ta( $pkg, "--give-back" );
942 print "$name: given back\n" if $verbose;
948 my $pkg = $db{$name};
951 if (!defined($pkg)) {
952 print "$name: not registered; can't register for binNMU.\n";
955 my $db_ver = $pkg->{'Version'};
957 if (!version_eq($db_ver, $version)) {
958 print "$name: version mismatch ($db_ver registered). ",
962 $state = $pkg->{'State'};
964 if (defined $pkg->{'Binary-NMU-Version'}) {
965 if ($binNMUver == 0) {
966 change_state( \$pkg, 'Installed' );
967 delete $pkg->{'Builder'};
968 delete $pkg->{'Depends'};
969 delete $pkg->{'Binary-NMU-Version'};
970 delete $pkg->{'Binary-NMU-Changelog'};
971 } elsif ($binNMUver <= $pkg->{'Binary-NMU-Version'}) {
972 print "$name: already building binNMU $pkg->{'Binary-NMU-Version'}\n";
975 $pkg->{'Binary-NMU-Version'} = $binNMUver;
976 $pkg->{'Binary-NMU-Changelog'} = $fail_reason;
977 $pkg->{'Notes'} = 'out-of-date';
978 $pkg->{'BuildPri'} = $pkg->{'PermBuildPri'}
979 if (defined $pkg->{'PermBuildPri'});
981 log_ta( $pkg, "--binNMU" );
984 } elsif ($binNMUver == 0) {
985 print "${name}_$version: no scheduled binNMU to cancel.\n";
989 if ($state ne 'Installed') {
990 print "${name}_$version: not installed; can't register for binNMU.\n";
994 my $fullver = binNMU_version($version,$binNMUver);
995 if ( version_lesseq( $fullver, $pkg->{'Installed-Version'} ) )
997 print "$name: binNMU $fullver is not newer than current version $pkg->{'Installed-Version'}\n";
1001 change_state( \$pkg, 'Needs-Build' );
1002 delete $pkg->{'Builder'};
1003 delete $pkg->{'Depends'};
1004 $pkg->{'Binary-NMU-Version'} = $binNMUver;
1005 $pkg->{'Binary-NMU-Changelog'} = $fail_reason;
1006 $pkg->{'Notes'} = 'out-of-date';
1007 log_ta( $pkg, "--binNMU" );
1009 print "${name}: registered for binNMU $fullver\n" if $verbose;
1012 sub set_one_buildpri {
1014 my $version = shift;
1016 my $pkg = $db{$name};
1019 if (!defined($pkg)) {
1020 print "$name: not registered; can't set priority.\n";
1023 $state = $pkg->{'State'};
1025 if ($state eq "Not-For-Us") {
1026 print "$name: not suitable for this architecture. Skipping.\n";
1028 } elsif ($state eq "Failed-Removed") {
1029 print "$name: failed previously and doesn't need building. Skipping.\n";
1032 if (!pkg_version_eq($pkg, $version)) {
1033 print "$name: version mismatch ($pkg->{'Version'} registered). ",
1037 if ( $build_priority == 0 ) {
1038 delete $pkg->{'BuildPri'}
1039 if $key eq 'PermBuildPri' and defined $pkg->{'BuildPri'}
1040 and $pkg->{'BuildPri'} == $pkg->{$key};
1041 delete $pkg->{$key};
1043 $pkg->{'BuildPri'} = $build_priority
1044 if $key eq 'PermBuildPri';
1045 $pkg->{$key} = $build_priority;
1048 print "$name: set to build priority $build_priority\n" if $verbose;
1051 sub add_one_depwait {
1053 my $version = shift;
1055 my $pkg = $db{$name};
1057 if (!defined($pkg)) {
1058 print "$name: not registered yet.\n";
1061 $state = $pkg->{'State'};
1063 if ($state eq "Dep-Wait") {
1064 print "$name: merging with previously registered dependencies\n";
1067 if (isin( $state, qw(Needs-Build Failed))) {
1068 print "$name: Warning: not registered for building previously, ".
1069 "but processing anyway.\n";
1071 elsif ($state eq "Not-For-Us") {
1072 print "$name: not suitable for this architecture anyway. Skipping.\n";
1075 elsif ($state eq "Failed-Removed") {
1076 print "$name: failed previously and doesn't need building. Skipping.\n";
1079 elsif ($state eq "Installed") {
1080 print "$name: Is already installed in archive. Skipping.\n";
1083 elsif ($state eq "Uploaded") {
1084 print "$name: Is already uploaded. Skipping.\n";
1087 elsif ($pkg->{'Builder'} &&
1088 $user ne $pkg->{'Builder'}) {
1089 print "$name: not taken by you, but by ".
1090 "$pkg->{'Builder'}. Skipping.\n";
1093 elsif ( !pkg_version_eq($pkg,$version)) {
1094 print "$name: version mismatch ".
1095 "($pkg->{'Version'} ".
1096 "by $pkg->{'Builder'})\n";
1099 elsif ($fail_reason =~ /^\s*$/ ||
1100 !parse_deplist( $fail_reason, 1 )) {
1101 print "$name: Bad dependency list\n";
1104 change_state( \$pkg, 'Dep-Wait' );
1105 $pkg->{'Builder'} = $user;
1106 if (defined $pkg->{'PermBuildPri'}) {
1107 $pkg->{'BuildPri'} = $pkg->{'PermBuildPri'};
1109 delete $pkg->{'BuildPri'};
1111 my $deplist = parse_deplist( $pkg->{'Depends'} );
1112 my $new_deplist = parse_deplist( $fail_reason );
1113 # add new dependencies, maybe overwriting old entries
1114 foreach (keys %$new_deplist) {
1115 $deplist->{$_} = $new_deplist->{$_};
1117 $pkg->{'Depends'} = build_deplist($deplist);
1118 log_ta( $pkg, "--dep-wait" );
1120 print "$name: registered as waiting for dependencies\n" if $verbose;
1130 local($/) = ""; # read in paragraph mode
1132 my( $version, $arch, $section, $priority, $builddep, $buildconf, $binaries );
1134 /^Package:\s*(\S+)$/mi and $name = $1;
1135 /^Version:\s*(\S+)$/mi and $version = $1;
1136 /^Architecture:\s*(\S+)$/mi and $arch = $1;
1137 /^Section:\s*(\S+)$/mi and $section = $1;
1138 /^Priority:\s*(\S+)$/mi and $priority = $1;
1139 /^Build-Depends:\s*(.*)$/mi and $builddep = $1;
1140 /^Build-Conflicts:\s*(.*)$/mi and $buildconf = $1;
1141 /^Binary:\s*(.*)$/mi and $binaries = $1;
1143 next if (defined $srcver{$name} and version_less( $version, $srcver{$name} ));
1144 $srcver{$name} = $version;
1146 $buildconf = join( ", ", map { "!$_" } split( /\s*,\s*/, $buildconf ));
1148 $builddep .= "," . $buildconf;
1150 $builddep = $buildconf;
1154 $pkgs{$name}{'dep'} = defined $builddep ? $builddep : "";
1155 $pkgs{$name}{'ver'} = $version;
1156 $pkgs{$name}{'bin'} = $binaries;
1157 my $pkg = $db{$name};
1162 if ($arch eq "all" && !version_less( $version, $pkg->{'Version'} )) {
1163 # package is now Arch: all, delete it from db
1164 change_state( \$pkg, 'deleted' );
1165 log_ta( $pkg, "--merge-sources" );
1166 print "$name ($pkg->{'Version'}): deleted ".
1167 "from database, because now Arch: all\n"
1173 # The "Version" should always be the source version --
1174 # not a possible binNMU version number.
1175 $pkg->{'Version'} = $version, $change++
1176 if ($pkg->{'State'} eq 'Installed' and
1177 !version_eq( $pkg->{'Version'}, $version));
1178 # Always update priority and section, if available
1179 $pkg->{'Priority'} = $priority, $change++
1180 if defined $priority and (not defined($pkg->{'Priority'}) or $pkg->{'Priority'} ne $priority);
1182 $pkg->{'Section'} = $section, $change++
1183 if defined $section and (not defined($pkg->{'Section'}) or $pkg->{'Section'} ne $section);
1184 $db{$name} = $pkg if $change;
1187 # Now that we only have the latest source version, build the list
1188 # of binary packages from the Sources point of view
1189 foreach $name (keys %pkgs) {
1190 foreach my $bin (split( /\s*,\s*/, $pkgs{$name}{'bin'} ) ) {
1191 $merge_binsrc{$bin} = $name;
1194 # remove installed packages that no longer have source available
1195 # or binaries installed
1196 foreach $name (keys %db) {
1197 next if $name =~ /^_/;
1198 my $pkg = $db{$name};
1199 if (not defined($pkgs{$name})) {
1200 change_state( \$pkg, 'deleted' );
1201 log_ta( $pkg, "--merge-sources" );
1202 print "$name ($pkg->{'Version'}): ".
1203 "deleted from database, because ".
1204 "not in Sources anymore\n"
1208 next if !isin( $pkg->{'State'}, qw(Installed) );
1209 if ($full && not defined $merge_srcvers{$name}) {
1210 change_state( \$pkg, 'deleted' );
1211 log_ta( $pkg, "--merge-sources" );
1212 print "$name ($pkg->{'Version'}): ".
1213 "deleted from database, because ".
1214 "binaries don't exist anymore\n"
1217 } elsif ($full && version_less( $merge_srcvers{$name}, $pkg->{'Version'})) {
1218 print "$name ($pkg->{'Version'}): ".
1219 "package is Installed but binaries are from ".
1220 $merge_srcvers{$name}. "\n"
1228 # This function looks through a Packages file and sets the state of
1229 # packages to 'Installed'
1230 sub parse_packages {
1233 local($/) = ""; # read in paragraph mode
1235 my( $name, $version, $depends, $source, $sourcev, $architecture, $provides, $binaryv, $binnmu );
1237 /^Package:\s*(\S+)$/mi and $name = $1;
1238 /^Version:\s*(\S+)$/mi and $version = $1;
1239 /^Depends:\s*(.*)$/mi and $depends = $1;
1240 /^Source:\s*(\S+)(\s*\((\S+)\))?$/mi and ($source,$sourcev) = ($1, $3);
1241 /^Architecture:\s*(\S+)$/mi and $architecture = $1;
1242 /^Provides:\s*(.*)$/mi and $provides = $1;
1243 next if !$name || !$version;
1244 next if ($arch ne $architecture and $architecture ne "all");
1245 next if (defined ($installed->{$name}) and $installed->{$name}{'Version'} ne "" and
1246 version_lesseq( $version, $installed->{$name}{'Version'} ));
1247 $installed->{$name}{'Version'} = $version;
1248 $installed->{$name}{'Depends'} = $depends;
1249 $installed->{$name}{'all'} = 1 if $architecture eq "all";
1250 undef $installed->{$name}{'Provider'};
1251 $installed->{$name}{'Source'} = $source ? $source : $name;
1253 foreach (split( /\s*,\s*/, $provides )) {
1254 if (not defined ($installed->{$_})) {
1255 $installed->{$_}{'Version'} = "";
1256 $installed->{$_}{'Provider'} = $name;
1260 if ( $version =~ /\+b(\d+)$/ ) {
1263 $version = $sourcev if $sourcev;
1264 $binaryv = $version;
1265 $binaryv =~ s/\+b\d+$//;
1266 $installed->{$name}{'Sourcev'} = $sourcev ? $sourcev : $binaryv;
1267 $binaryv .= "+b$binnmu" if defined($binnmu);
1269 next if $architecture ne $arch;
1270 $name = $source if $source;
1271 next if defined($merge_srcvers{$name}) and $merge_srcvers{$name} eq $version;
1272 $merge_srcvers{$name} = $version;
1274 my $pkg = $db{$name};
1277 if (isin( $pkg->{'State'}, qw(Not-For-Us)) ||
1278 (isin($pkg->{'State'}, qw(Installed)) &&
1279 version_lesseq($binaryv, $pkg->{'Installed-Version'}))) {
1280 print "Skipping $name because State == $pkg->{'State'}\n"
1284 if ($pkg->{'Binary-NMU-Version'} ) {
1285 my $nmuver = binNMU_version($pkg->{'Version'}, $pkg->{'Binary-NMU-Version'});
1286 if (version_less( $binaryv, $nmuver )) {
1287 print "Skipping $name ($version) because have newer ".
1288 "version ($nmuver) in db.\n"
1292 } elsif (version_less($version, $pkg->{'Version'})) {
1293 print "Skipping $name ($version) because have newer ".
1294 "version ($pkg->{'Version'}) in db.\n"
1299 if (!pkg_version_eq($pkg, $version) &&
1300 $pkg->{'State'} ne "Installed") {
1301 warn "Warning: $name: newer version than expected appeared ".
1302 "in archive ($version vs. $pkg->{'Version'})\n";
1303 delete $pkg->{'Builder'};
1306 if (!isin( $pkg->{'State'}, qw(Uploaded) )) {
1307 warn "Warning: Package $name was not in uploaded state ".
1308 "before (but in '$pkg->{'State'}').\n";
1309 delete $pkg->{'Builder'};
1310 delete $pkg->{'Depends'};
1314 $pkg->{'Version'} = $version;
1317 change_state( \$pkg, 'Installed' );
1318 $pkg->{'Package'} = $name;
1319 $pkg->{'Installed-Version'} = $binaryv;
1320 if (defined $pkg->{'PermBuildPri'}) {
1321 $pkg->{'BuildPri'} = $pkg->{'PermBuildPri'};
1323 delete $pkg->{'BuildPri'};
1325 $pkg->{'Version'} = $version
1326 if version_less( $pkg->{'Version'}, $version);
1327 delete $pkg->{'Binary-NMU-Version'};
1328 delete $pkg->{'Binary-NMU-Changelog'};
1329 log_ta( $pkg, "--merge-packages" );
1331 print "$name ($version) is up-to-date now.\n" if $verbose;
1334 check_dep_wait( "--merge-packages", $installed );
1339 my ($package, $name, $version, $installed);
1341 foreach $package (@_) {
1342 $package =~ s,^.*/,,; # strip path
1343 $package =~ s/\.(dsc|diff\.gz|tar\.gz|deb)$//; # strip extension
1344 $package =~ s/_[\w\d]+\.changes$//; # strip extension
1345 if ($package =~ /^([\w\d.+-]+)_([\w\d:.+~-]+)/) {
1346 ($name,$version) = ($1,$2);
1349 warn "$package: can't extract package name and version ".
1353 $installed->{$name}{'Version'} = $version;
1356 check_dep_wait( "--pretend-avail", $installed );
1359 sub check_dep_wait {
1361 my $installed = shift;
1363 # check all packages in state Dep-Wait if dependencies are all
1366 foreach $name (keys %db) {
1367 next if $name =~ /^_/;
1368 my $pkg = $db{$name};
1369 next if $pkg->{'State'} ne "Dep-Wait";
1370 my $deps = $pkg->{'Depends'};
1372 print "$name: was in state Dep-Wait, but with empty ",
1374 goto make_needs_build;
1376 my $deplist = parse_deplist($deps);
1380 foreach (keys %$deplist) {
1381 if (!exists $installed->{$_} ||
1382 ($deplist->{$_}->{'Rel'} && $deplist->{$_}->{'Version'} &&
1383 !version_compare( $installed->{$_}{'Version'},
1384 $deplist->{$_}->{'Rel'},
1385 $deplist->{$_}->{'Version'}))) {
1387 $new_deplist->{$_} = $deplist->{$_};
1390 push( @removed_deps, $_ );
1395 change_state( \$pkg, 'Needs-Build' );
1396 log_ta( $pkg, $action );
1397 delete $pkg->{'Builder'};
1398 delete $pkg->{'Depends'};
1399 print "$name ($pkg->{'Version'}) has all ",
1400 "dependencies available now\n" if $verbose;
1404 elsif (@removed_deps) {
1405 $pkg->{'Depends'} = build_deplist( $new_deplist );
1406 print "$name ($pkg->{'Version'}): some dependencies ",
1407 "(@removed_deps) available now, but not all yet\n"
1414 # This function accepts quinn-diff output (either from a file named on
1415 # the command line, or on stdin) and sets the packages named there to
1416 # state 'Needs-Build'.
1417 sub parse_quinn_diff {
1418 my $partial = shift;
1424 next if !m,^([-\w\d/]*)/ # section
1425 ([-\w\d.+]+)_ # package name
1426 ([\w\d:.~+-]+)\.dsc\s* # version
1427 \[([^:]*): # priority
1428 ([^]]+)\]\s*$,x; # rest of notes
1429 my($section,$name,$version,$priority,$notes) = ($1, $2, $3, $4, $5);
1430 $quinn_pkgs{$name}++;
1431 $section ||= "unknown";
1432 $priority ||= "unknown";
1433 $priority = "unknown" if $priority eq "-";
1434 $priority = "standard" if ($name eq "debian-installer");
1436 my $pkg = $db{$name};
1438 # Always update section and priority.
1439 if (defined($pkg)) {
1441 $pkg->{'Section'} = $section, $change++ if not defined
1442 $pkg->{'Section'} or $section ne "unknown";
1443 $pkg->{'Priority'} = $priority, $change++ if not defined
1444 $pkg->{'Priority'} or $priority ne "unknown";
1447 if (defined($pkg) &&
1448 $pkg->{'State'} =~ /^Dep-Wait/ &&
1449 version_less( $pkg->{'Version'}, $version )) {
1450 change_state( \$pkg, 'Dep-Wait' );
1451 $pkg->{'Version'} = $version;
1452 delete $pkg->{'Binary-NMU-Version'};
1453 delete $pkg->{'Binary-NMU-Changelog'};
1454 log_ta( $pkg, "--merge-quinn" );
1456 print "$name ($version) still waiting for dependencies.\n"
1459 elsif (defined($pkg) &&
1460 $pkg->{'State'} =~ /-Removed$/ &&
1461 version_eq($pkg->{'Version'}, $version)) {
1462 # reinstantiate a package that has been removed earlier
1463 # (probably due to a quinn-diff malfunction...)
1464 my $newstate = $pkg->{'State'};
1465 $newstate =~ s/-Removed$//;
1466 change_state( \$pkg, $newstate );
1467 $pkg->{'Version'} = $version;
1468 $pkg->{'Notes'} = $notes;
1469 log_ta( $pkg, "--merge-quinn" );
1471 print "$name ($version) reinstantiated to $newstate.\n"
1474 elsif (defined($pkg) &&
1475 $pkg->{'State'} eq "Not-For-Us" &&
1476 version_less( $pkg->{'Version'}, $version )) {
1477 # for Not-For-Us packages just update the version etc., but
1479 change_state( \$pkg, "Not-For-Us" );
1480 $pkg->{'Package'} = $name;
1481 $pkg->{'Version'} = $version;
1482 $pkg->{'Notes'} = $notes;
1483 delete $pkg->{'Builder'};
1484 log_ta( $pkg, "--merge-quinn" );
1486 print "$name ($version) still Not-For-Us.\n" if $verbose;
1488 elsif (!defined($pkg) ||
1489 $pkg->{'State'} ne "Not-For-Us" &&
1490 (version_less( $pkg->{'Version'}, $version ) ||
1491 ($pkg->{'State'} eq "Installed" && version_less($pkg->{'Installed-Version'}, $version)))) {
1493 if (defined( $pkg->{'State'} ) && isin( $pkg->{'State'}, qw(Building Built Build-Attempted))) {
1494 send_mail( $pkg->{'Builder'},
1495 "new version of $name (dist=$distribution)",
1496 "As far as I'm informed, you're currently ".
1497 "building the package $name\n".
1498 "in version $pkg->{'Version'}.\n\n".
1499 "Now there's a new source version $version. ".
1500 "If you haven't finished\n".
1501 "compiling $name yet, you can stop it to ".
1502 "save some work.\n".
1503 "Just to inform you...\n".
1504 "(This is an automated message)\n" );
1505 print "$name: new version ($version) while building ".
1506 "$pkg->{'Version'} -- sending mail ".
1507 "to builder ($pkg->{'Builder'})\n"
1510 change_state( \$pkg, 'Needs-Build' );
1511 $pkg->{'Package'} = $name;
1512 $pkg->{'Version'} = $version;
1513 $pkg->{'Section'} = $section;
1514 $pkg->{'Priority'} = $priority;
1515 $pkg->{'Notes'} = $notes;
1516 delete $pkg->{'Builder'};
1517 delete $pkg->{'Binary-NMU-Version'};
1518 delete $pkg->{'Binary-NMU-Changelog'};
1519 log_ta( $pkg, "--merge-quinn" );
1522 print "$name ($version) needs rebuilding now.\n" if $verbose;
1524 elsif (defined($pkg) &&
1525 !version_eq( $pkg->{'Version'}, $version ) &&
1526 isin( $pkg->{'State'}, qw(Installed Not-For-Us) )) {
1527 print "$name: skipping because version in db ".
1528 "($pkg->{'Version'}) is >> than ".
1529 "what quinn-diff says ($version) ".
1530 "(state is $pkg->{'State'})\n"
1532 $dubious .= "$pkg->{'State'}: ".
1533 "db ${name}_$pkg->{'Version'} >> ".
1534 "quinn $version\n" if !$partial;
1536 elsif ($verbose >= 2) {
1537 if ($pkg->{'State'} eq "Not-For-Us") {
1538 print "Skipping $name because State == ".
1539 "$pkg->{'State'}\n";
1541 elsif (!version_less($pkg->{'Version'}, $version)) {
1542 print "Skipping $name because version in db ".
1543 "($pkg->{'Version'}) is >= than ".
1544 "what quinn-diff says ($version)\n";
1547 $db{$name} = $pkg if $change;
1551 send_mail( $conf::db_maint,
1552 "Dubious versions in $distribution $conf::dbbase database",
1553 "The following packages have a newer version in the ".
1554 "wanna-build database\n".
1555 "than what quinn-diff says, and this is strange for ".
1557 "It could be caused by a lame mirror, or the version ".
1558 "in the database\n".
1563 # Now re-check the DB for packages in states Needs-Build, Failed,
1564 # or Dep-Wait and remove them if they're not listed anymore by quinn-diff.
1567 foreach $name (keys %db) {
1568 next if $name =~ /^_/;
1569 my $pkg = $db{$name};
1570 next if defined $pkg->{'Binary-NMU-Version'};
1571 next if !isin( $pkg->{'State'},
1572 qw(Needs-Build Building Built Build-Attempted Uploaded Failed Dep-Wait) );
1573 my $virtual_delete = $pkg->{'State'} eq 'Failed';
1575 if (!$quinn_pkgs{$name}) {
1576 change_state( \$pkg, $virtual_delete ?
1577 $pkg->{'State'}."-Removed" :
1579 log_ta( $pkg, "--merge-quinn" );
1580 print "$name ($pkg->{'Version'}): ".
1581 ($virtual_delete ? "(virtually) " : "") . "deleted ".
1582 "from database, because not in quinn-diff anymore\n"
1584 if ($virtual_delete) {
1594 sub send_reupload_mail {
1597 my $version = shift;
1599 my $other_dist = shift;
1602 "Please reupload ${pkg}_${'Version'} for $dist",
1603 "You have recently built (or are currently building)\n".
1604 "${pkg}_${'Version'} for $other_dist.\n".
1605 "This version is now also needed in the $dist distribution.\n".
1606 "Please reupload the files now present in the Debian archive\n".
1607 "(best with buildd-reupload).\n" );
1611 # for sorting priorities and sections
1613 %prioval = ( required => -5,
1621 'debian-installer' => -199,
1639 interpreters => -181,
1651 electronics => -169,
1655 foreach my $i (keys %sectval) {
1656 $sectval{"contrib/$i"} = $sectval{$i}+40;
1657 $sectval{"non-free/$i"} = $sectval{$i}+80;
1659 $sectval{'unknown'} = -165;
1661 %catval = ( "none" => -20,
1662 "uploaded-fixed-pkg" => -19,
1663 "fix-expected" => -18,
1664 "reminder-sent" => -17,
1665 "nmu-offered" => -16,
1669 "compiler-error" => -12 );
1672 sub sort_list_func {
1673 my( $letter, $x, $ax, $bx );
1675 foreach $letter (split( "", $list_order )) {
1676 SWITCH: foreach ($letter) {
1678 $x = $b->{'BuildPri'} <=> $a->{'BuildPri'};
1679 return $x if $x != 0;
1683 $x = $prioval{$a->{'Priority'}} <=> $prioval{$b->{'Priority'}};
1684 return $x if $x != 0;
1688 $x = $sectval{$a->{'Section'}} <=> $sectval{$b->{'Section'}};
1689 return $x if $x != 0;
1693 $x = $a->{'Package'} cmp $b->{'Package'};
1694 return $x if $x != 0;
1698 $x = $a->{'Builder'} cmp $b->{'Builder'};
1699 return $x if $x != 0;
1703 $ax = ($a->{'Notes'} =~ /^(out-of-date|partial)/) ? 0 :
1704 ($a->{'Notes'} =~ /^uncompiled/) ? 2 : 1;
1705 $bx = ($b->{'Notes'} =~ /^(out-of-date|partial)/) ? 0 :
1706 ($b->{'Notes'} =~ /^uncompiled/) ? 2 : 1;
1708 return $x if $x != 0;
1712 my $ca = exists $a->{'Failed-Category'} ?
1713 $a->{'Failed-Category'} : "none";
1714 my $cb = exists $b->{'Failed-Category'} ?
1715 $b->{'Failed-Category'} : "none";
1716 $x = $catval{$ca} <=> $catval{$cb};
1717 return $x if $x != 0;
1721 my $pa = $prioval{$a->{'Priority'}} >
1722 $prioval{'standard'};
1723 my $pb = $prioval{$b->{'Priority'}} >
1724 $prioval{'standard'};
1726 return $x if $x != 0;
1736 my( $name, $pkg, @list );
1741 foreach $name (keys %db) {
1742 next if $name =~ /^_/;
1744 next if $state ne "all" && $pkg->{'State'} !~ /^\Q$state\E$/i;
1745 next if $user && (lc($state) ne 'needs-build' and $pkg->{'Builder'} ne $user);
1746 next if $category && $pkg->{'State'} eq "Failed" &&
1747 $pkg->{'Failed-Category'} ne $category;
1748 next if ($list_min_age > 0 &&
1749 ($ctime-parse_date($pkg->{'State-Change'})) < $list_min_age)||
1750 ($list_min_age < 0 &&
1751 ($ctime-parse_date($pkg->{'State-Change'})) > -$list_min_age);
1752 push( @list, $pkg );
1755 foreach $pkg (sort sort_list_func @list) {
1756 print "$pkg->{'Section'}/$pkg->{'Package'}_$pkg->{'Version'}";
1757 print ": $pkg->{'State'}"
1759 print " by $pkg->{'Builder'}"
1760 if $pkg->{'State'} ne "Needs-Build" && $pkg->{'Builder'};
1761 print " [$pkg->{'Priority'}:$pkg->{'Notes'}";
1762 print ":PREV-FAILED"
1763 if $pkg->{'Previous-State'} =~ /^Failed/;
1764 print ":bp{" . $pkg->{'BuildPri'} . "}"
1765 if exists $pkg->{'BuildPri'};
1766 print ":binNMU{" . $pkg->{'Binary-NMU-Version'} . "}"
1767 if exists $pkg->{'Binary-NMU-Version'};
1769 print " Reasons for failing:\n",
1771 exists $pkg->{'Failed-Category'} ? $pkg->{'Failed-Category'} : "none",
1773 join("\n ",split("\n",$pkg->{'Failed'})), "\n"
1774 if $pkg->{'State'} =~ /^Failed/;
1775 print " Dependencies: $pkg->{'Depends'}\n"
1776 if $pkg->{'State'} eq "Dep-Wait";
1777 print " Previous state was $pkg->{'Previous-State'} until ",
1778 "$pkg->{'State-Change'}\n"
1779 if $verbose && $pkg->{'Previous-State'};
1780 print " Previous failing reasons:\n ",
1781 join("\n ",split("\n",$pkg->{'Old-Failed'})), "\n"
1782 if $verbose && $pkg->{'Old-Failed'};
1784 $scnt{$pkg->{'State'}}++ if $state eq "all";
1786 if ($state eq "all") {
1787 foreach (sort keys %scnt) {
1788 print "Total $scnt{$_} package(s) in state $_.\n";
1791 print "Total $cnt package(s)\n";
1796 my( $name, $pkg, $key, $dist );
1797 my @firstkeys = qw(Package Version Builder State Section Priority
1798 Installed-Version Previous-State State-Change);
1799 my @dists = $info_all_dists ? keys %conf::distributions : ($distribution);
1801 foreach $dist (@dists) {
1802 if ($dist ne $distribution) {
1803 if (!-f db_filename( $dist ) || !open_other_db( $dist )) {
1804 warn "Cannot open database for $dist!\n";
1805 @dists = grep { $_ ne $dist } @dists;
1810 foreach $name (@_) {
1811 $name =~ s/_.*$//; # strip version
1812 foreach $dist (@dists) {
1813 my $db = $dist ne $distribution ? $otherdb{$dist} : \%db;
1814 my $pname = "$name" . ($info_all_dists ? "($dist)" : "");
1816 $pkg = $db->{$name};
1817 if (!defined( $pkg )) {
1818 print "$pname: not registered\n";
1823 foreach $key (@firstkeys) {
1824 next if !exists $pkg->{$key};
1825 my $val = $pkg->{$key};
1827 $val = "\n$val" if isin( $key, qw(Failed Old-Failed));
1829 printf " %-20s: %s\n", $key, $val;
1831 foreach $key (sort keys %$pkg) {
1832 next if isin( $key, @firstkeys );
1833 my $val = $pkg->{$key};
1835 $val = "\n$val" if isin( $key, qw(Failed Old-Failed));
1837 printf " %-20s: %s\n", $key, $val;
1843 sub forget_packages {
1844 my( $name, $pkg, $key, $data );
1846 foreach $name (@_) {
1847 $name =~ s/_.*$//; # strip version
1849 if (!defined( $pkg )) {
1850 print "$name: not registered\n";
1855 foreach $key (sort keys %$pkg) {
1856 my $val = $pkg->{$key};
1859 $data .= sprintf " %-20s: %s\n", $key, $val;
1861 send_mail( $conf::db_maint,
1862 "$name deleted from DB $conf::dbbase",
1863 "The package '$name' has been deleted from the database ".
1865 "Data registered about the deleted package:\n".
1866 "$data\n" ) if $conf::db_maint;
1867 change_state( \$pkg, 'deleted' );
1868 log_ta( $pkg, "--forget" );
1870 print "$name: deleted from database\n" if $verbose;
1878 $ui = $db{'_userinfo'};
1879 foreach $name (@_) {
1880 if (!defined( $ui->{$name} )) {
1881 print "$name: not registered\n";
1885 delete $ui->{$name};
1887 print "$name: deleted from database\n" if $verbose;
1889 $db{'_userinfo'} = $ui if $change;
1895 my $lockfile = db_filename($dist) . ".lock";
1898 print "Locking $dist database\n" if $verbose >= 2;
1900 if (!sysopen( F, $lockfile, O_WRONLY|O_CREAT|O_TRUNC|O_EXCL, 0644 )){
1902 # lock file exists, wait
1903 goto repeat if !open( F, "<$lockfile" );
1906 if ($line !~ /^(\d+)\s+([\w\d.-]+)$/) {
1907 warn "Bad lock file contents -- still trying\n";
1910 my($pid, $usr) = ($1, $2);
1911 if (kill( 0, $pid ) == 0 && $! == ESRCH) {
1912 # process doesn't exist anymore, remove stale lock
1913 print "Removing stale lock file (pid $pid, user $usr)\n";
1914 unlink( $lockfile );
1917 warn "Database locked by $usr -- please wait\n" if $try == 0;
1920 # avoid the END routine removes the lock
1921 $main::keep_lock{$dist} = 1;
1922 die "Lock still present after 200 * 5 seconds.\n";
1927 die "Can't create lock file $lockfile: $!\n";
1929 F->print("$$ $real_user\n");
1935 my $lockfile = db_filename($dist) . ".lock";
1937 if (!$main::keep_lock{$dist}) {
1938 print "Unlocking $dist database\n" if $verbose >= 2;
1943 sub create_maintlock {
1944 my $lockfile = db_filename("maintenance") . ".lock";
1948 print "Creating maintenance lock\n" if $verbose >= 2;
1950 if (!sysopen( F, $lockfile, O_WRONLY|O_CREAT|O_TRUNC|O_EXCL, 0644 )){
1952 # lock file exists, wait
1953 goto repeat if !open( F, "<$lockfile" );
1956 if ($line !~ /^(\d+)\s+([\w\d.-]+)$/) {
1957 warn "Bad maintenance lock file contents -- still trying\n";
1960 my($pid, $usr) = ($1, $2);
1961 if (kill( 0, $pid ) == 0 && $! == ESRCH) {
1962 # process doesn't exist anymore, remove stale lock
1963 print "Removing stale lock file (pid $pid, user $usr)\n";
1964 unlink( $lockfile );
1967 warn "Maintenance lock already exists by $usr -- ".
1968 "please wait\n" if $try == 0;
1971 die "Lock still present after 120 * 60 seconds.\n";
1976 die "Can't create maintenance lock $lockfile: $!\n";
1978 F->print(getppid(), " $real_user\n");
1982 sub remove_maintlock {
1983 my $lockfile = db_filename("maintenance") . ".lock";
1985 print "Removing maintenance lock\n" if $verbose >= 2;
1989 sub waitfor_maintlock {
1990 my $lockfile = db_filename("maintenance") . ".lock";
1994 print "Checking for maintenance lock\n" if $verbose >= 2;
1996 if (open( F, "<$lockfile" )) {
1999 if ($line !~ /^(\d+)\s+([\w\d.-]+)$/) {
2000 warn "Bad maintenance lock file contents -- still trying\n";
2003 my($pid, $usr) = ($1, $2);
2004 if (kill( 0, $pid ) == 0 && $! == ESRCH) {
2005 # process doesn't exist anymore, remove stale lock
2006 print "Removing stale maintenance lock (pid $pid, user $usr)\n";
2007 unlink( $lockfile );
2010 warn "Databases locked for general maintenance by $usr -- ".
2011 "please wait\n" if $try == 0;
2014 die "Lock still present after 120 * 60 seconds.\n";
2025 print "Reading ASCII database from $file..." if $verbose >= 1;
2026 open( F, "<$file" ) or
2027 die "Can't open database $file: $!\n";
2029 local($/) = ""; # read in paragraph mode
2031 my( %thispkg, $name );
2033 s/\n[ \t]+/\376\377/g; # fix continuation lines
2034 s/\376\377\s*\376\377/\376\377/og;
2036 while( /^(\S+):[ \t]*(.*)[ \t]*$/mg ) {
2037 my ($key, $val) = ($1, $2);
2038 $val =~ s/\376\377/\n/g;
2039 $thispkg{$key} = $val;
2041 check_entry( \%thispkg );
2043 $name = $thispkg{'Package'};
2044 $db{$name} = \%thispkg;
2047 print "done\n" if $verbose >= 1;
2054 return if $op_mode eq "manual-edit"; # no checks then
2056 # check for required fields
2057 if (!exists $pkg->{'Package'}) {
2058 print STDERR "Bad entry: ",
2059 join( "\n", map { "$_: $pkg->{$_}" } keys %$pkg ), "\n";
2060 die "Database entry lacks Package: field\n";
2062 if (!exists $pkg->{'Version'}) {
2063 die "Database entry for $pkg->{'Package'} lacks Version: field\n";
2065 # if no State: field, generate one (for old db compat)
2066 if (!exists($pkg->{'State'})) {
2068 exists $pkg->{'Failed'} ? 'Failed' : 'Building';
2071 die "Bad state $pkg->{'State'} of package $pkg->{Package}\n"
2072 if !isin( $pkg->{'State'},
2073 qw(Needs-Build Building Built Build-Attempted Uploaded Installed Dep-Wait
2074 Failed Failed-Removed Not-For-Us
2080 my($name,$pkg,$key);
2082 print "Writing ASCII database to $file..." if $verbose >= 1;
2083 open( F, ">$file" ) or
2084 die "Can't open database $file: $!\n";
2086 foreach $name (sort keys %db) {
2087 my $pkg = $db{$name};
2088 foreach $key (keys %{$pkg}) {
2089 my $val = $pkg->{$key};
2092 print F "$key: $val\n";
2097 print "done\n" if $verbose >= 1;
2103 my $newstate = shift;
2104 my $for_dist = shift;
2107 return if !open_other_db( $for_dist );
2108 $db = $otherdb{$for_dist};
2109 $pkg = \$db{$pkg->{'Package'}};
2114 my $state = \$pkg->{'State'};
2116 return if defined($$state) and $$state eq $newstate;
2117 $pkg->{'Previous-State'} = $$state if defined($$state);
2118 $pkg->{'State-Change'} = $curr_date;
2120 if (defined($$state) and $$state eq 'Failed') {
2121 $pkg->{'Old-Failed'} =
2122 "-"x20 . " $pkg->{'Version'} " . "-"x20 . "\n" .
2123 $pkg->{'Failed'} . "\n" .
2124 $pkg->{'Old-Failed'};
2125 delete $pkg->{'Failed'};
2126 delete $pkg->{'Failed-Category'};
2128 $$state = $newstate;
2134 if (!tied(%{$otherdb{$dist}})) {
2136 $otherdb_lock{$dist} = 1;
2137 if (!(tie %{$otherdb{$dist}}, 'MLDBM', db_filename($dist), 0, 0664)){
2138 warn "Serious warning: Cannot open database for $dist\n";
2140 $otherdb_lock{$dist} = 0;
2151 my $dist = $distribution;
2155 $prevstate = $pkg->{'Previous-State'};
2156 $str = "$action($dist): $pkg->{'Package'}_$pkg->{'Version'} ".
2157 "changed from $prevstate to $pkg->{'State'} ".
2158 "by $real_user as $user";
2160 if (!open( LOG, ">>$transactlog" )) {
2161 warn "Can't open log file $transactlog: $!\n";
2164 print LOG "$curr_date: $str\n";
2167 if (!($prevstate eq 'Failed' && $pkg->{'State'} eq 'Failed')) {
2168 $str .= " (with --override)"
2170 $mail_logs .= "$str\n";
2177 my $subject = shift;
2180 my $from = $conf::db_maint;
2181 my $domain = $conf::buildd_domain;
2183 $from .= "\@$domain" if $from !~ /\@/;
2185 $to .= '@' . $domain if $to !~ /\@/;
2186 $text =~ s/^\.$/../mg;
2187 local $SIG{'PIPE'} = 'IGNORE';
2188 open( PIPE, "| $conf::mailprog -oem $to" )
2189 or die "Can't open pipe to $conf::mailprog: $!\n";
2191 print PIPE "From: $from\n";
2192 print PIPE "Subject: $subject\n\n";
2193 print PIPE "$text\n";
2199 return "$conf::basedir/$conf::dbbase-$dist";
2202 # for parsing input to dep-wait
2208 foreach (split( /\s*,\s*/, $deps )) {
2210 # verification requires > starting prompts, no | crap
2211 if (!/^(\S+)\s*(\(\s*(>(?:[>=])?)\s*(\S+)\s*\))?\s*$/) {
2216 my @alts = split( /\s*\|\s*/, $_ );
2217 # Anything with an | is ignored, as it can be configured on a
2218 # per-buildd basis what will be installed
2219 next if $#alts != 0;
2222 if (!/^(\S+)\s*(\(\s*(>=|=|==|>|>>|<<|<=)\s*(\S+)\s*\))?\s*$/) {
2223 warn( "parse_deplist: bad dependency $_\n" );
2226 my($dep, $rel, $relv) = ($1, $3, $4);
2227 $rel = ">>" if defined($rel) and $rel eq ">";
2228 $result{$dep}->{'Package'} = $dep;
2229 if ($rel && $relv) {
2230 $result{$dep}->{'Rel'} = $rel;
2231 $result{$dep}->{'Version'} = $relv;
2234 return 1 if $verify;
2238 # for parsing Build-Depends from Sources
2239 sub parse_srcdeplist {
2246 foreach $dep (split( /\s*,\s*/, $deps )) {
2247 my @alts = split( /\s*\|\s*/, $dep );
2248 # Anything with an | is ignored, as it can be configured on a
2249 # per-buildd basis what will be installed
2250 next if $#alts != 0;
2252 if (!/^([^\s([]+)\s*(\(\s*([<=>]+)\s*(\S+)\s*\))?(\s*\[([^]]+)\])?/) {
2253 warn( "parse_srcdeplist: bad dependency $_\n" );
2256 my($dep, $rel, $relv, $archlist) = ($1, $3, $4, $6);
2258 $archlist =~ s/^\s*(.*)\s*$/$1/;
2259 my @archs = split( /\s+/, $archlist );
2260 my ($use_it, $ignore_it, $include) = (0, 0, 0);
2263 $ignore_it = 1 if substr($_, 1) eq $arch;
2265 $use_it = 1 if $_ eq $arch;
2269 warn "Warning: inconsistent arch restriction on ",
2270 "$pkg: $dep depedency\n"
2271 if $ignore_it && $use_it;
2272 next if $ignore_it || ($include && !$use_it);
2280 $result->{'Package'} = $dep;
2281 $result->{'Neg'} = $neg;
2282 if ($rel && $relv) {
2283 $result->{'Rel'} = $rel;
2284 $result->{'Version'} = $relv;
2286 push @results, $result;
2295 foreach $key (keys %$list) {
2296 $result .= ", " if $result;
2298 $result .= " ($list->{$key}->{'Rel'} $list->{$key}->{'Version'})"
2299 if $list->{$key}->{'Rel'} && $list->{$key}->{'Version'};
2306 tie %new_db, 'MLDBM', db_filename( $distribution ) . ".new", GDBM_WRCREAT, 0664
2307 or die "FATAL: Cannot create new database\n";
2309 untie %db or die "FATAL: Cannot untie old database\n";
2310 system ("cp " . db_filename( $distribution ) . ".new " .
2311 db_filename( $distribution ) ) == 0
2312 or die "FATAL: Cannot overwrite old database";
2313 unlink db_filename( $distribution ) . ".new";
2318 sub get_unsatisfied_dep {
2322 my $savedep = shift;
2324 my $pkgname = $dep->{'Package'};
2326 if (defined $pkgs->{$pkgname}{'Provider'}) {
2327 # provides. leave them for buildd/sbuild.
2332 return $pkgs->{$pkgname}{'Unsatisfied'} if $savedep and defined($pkgs->{$pkgname}{'Unsatisfied'});
2334 # Return unsatisfied deps to a higher caller to process
2335 if ((!defined($pkgs->{$pkgname})) or
2336 (defined($dep->{'Rel'}) and !version_compare( $pkgs->{$pkgname}{'Version'}, $dep->{'Rel'}, $dep->{'Version'} ) ) ) {
2338 $deplist{$pkgname} = $dep;
2339 my $deps = build_deplist(\%deplist);
2340 $pkgs->{$pkgname}{'Unsatisfied'} = $deps if $savedep;
2344 # set cache to "" to avoid infinite recursion
2345 $pkgs->{$pkgname}{'Unsatisfied'} = "" if $savedep;
2347 if (defined $pkgs->{$dep->{'Package'}}{'Depends'}) {
2348 my $deps = parse_deplist( $pkgs->{$dep->{'Package'}}{'Depends'} );
2349 foreach (keys %$deps) {
2352 my $ret = get_unsatisfied_dep($bd,$pkgs,$dep,1);
2354 my $retdep = parse_deplist( $ret );
2355 foreach (keys %$retdep) {
2356 $dep = $$retdep{$_};
2358 $dep->{'Rel'} = '>=' if defined($dep->{'Rel'}) and $dep->{'Rel'} =~ '^=';
2360 if (defined($dep->{'Rel'}) and $dep->{'Rel'} =~ '^>' and defined ($pkgs->{$dep->{'Package'}}) and
2361 version_compare($bd->{$pkgs->{$dep->{'Package'}}{'Source'}}{'ver'},'>>',$pkgs->{$dep->{'Package'}}{'Sourcev'})) {
2362 if (not defined($merge_binsrc{$dep->{'Package'}})) {
2363 # the uninstallable package doesn't exist in the new source; look for something else that does.
2364 delete $$retdep{$dep->{'Package'}};
2365 foreach (sort (split( /\s*,\s*/, $bd->{$pkgs->{$dep->{'Package'}}{'Source'}}{'bin'}))) {
2366 next if ($pkgs->{$_}{'all'} or not defined $pkgs->{$_}{'Version'});
2367 $dep->{'Package'} = $_;
2368 $dep->{'Rel'} = '>>';
2369 $dep->{'Version'} = $pkgs->{$_}{'Version'};
2370 $$retdep{$_} = $dep;
2375 # sanity check to make sure the depending binary still exists, and the depended binary exists and dep-wait on a new version of it
2376 if ( defined($merge_binsrc{$pkgname}) and defined($pkgs->{$dep->{'Package'}}{'Version'}) ) {
2377 delete $$retdep{$dep->{'Package'}};
2378 $dep->{'Package'} = $pkgname;
2379 $dep->{'Rel'} = '>>';
2380 $dep->{'Version'} = $pkgs->{$pkgname}{'Version'};
2381 $$retdep{$pkgname} = $dep;
2383 delete $$retdep{$dep->{'Package'}} if (defined ($dep->{'Rel'}) and $dep->{'Rel'} =~ '^>');
2386 $ret = build_deplist($retdep);
2387 $pkgs->{$pkgname}{'Unsatisfied'} = $ret if $savedep;
2400 return if defined ($conf::distributions{$distribution}{noadw});
2402 # We need to walk all of needs-build, as any new upload could make
2403 # something in needs-build have uninstallable deps
2404 foreach $key (keys %db) {
2405 my $pkg = $db{$key};
2407 if not defined $pkg or $pkg->{'State'} ne "Needs-Build";
2408 my $srcdeps = parse_srcdeplist($key,$bd->{$key}{'dep'},$arch);
2409 foreach my $srcdep (@$srcdeps) {
2410 next if $srcdep->{'Neg'} != 0; # we ignore conflicts atm
2411 my $rc = get_unsatisfied_dep($bd,$pkgs,$srcdep,0);
2414 my $deplist = parse_deplist( $pkg->{'Depends'} );
2415 my $newdeps = parse_deplist( $rc );
2417 foreach (%$newdeps) {
2418 my $dep = $$newdeps{$_};
2419 # ensure we're not waiting on ourselves, or a package that has been removed
2420 next if (not defined($merge_binsrc{$dep->{'Package'}})) or ($merge_binsrc{$dep->{'Package'}} eq $key);
2421 if ($dep->{'Rel'} =~ '^>') {
2422 $deplist->{$dep->{'Package'}} = $dep;
2427 $pkg->{'Depends'} = build_deplist($deplist);
2428 change_state( \$pkg, 'Dep-Wait' );
2429 log_ta( $pkg, "--merge-all" );
2431 print "Auto-Dep-Waiting ${key}_$pkg->{'Version'} to $pkg->{'Depends'}\n" if $verbose;
2441 ($prgname = $0) =~ s,^.*/,,;
2443 Usage: $prgname <options...> <package_version...>
2445 -v, --verbose: Verbose execution.
2446 --take: Take package for building [default operation]
2447 -f, --failed: Record in database that a build failed due to
2448 deficiencies in the package (that aren't fixable without a new
2450 -u, --uploaded: Record in the database that the packages build
2451 correctly and were uploaded.
2452 -n, --no-build: Record in the database that the packages aren't
2453 desired for this architecture and shouldn't appear in listings even
2454 if they're out of date.
2455 --dep-wait: Record in the database that the packages are waiting
2456 for some source dependencies to become available
2457 --merge-quinn: Merge quinn-diff output into database.
2458 --merge-packages: Merge Packages files into database.
2459 --pretend-avail: Pretend that given packages are available now and give
2460 free packages waiting for them
2461 -i SRC_PKG, --info SRC_PKG: Show information for source package
2462 -l STATE, --list=STATE: List all packages in state STATE; can be
2463 combined with -U to restrict to a specific user; STATE can
2465 -m MESSAGE, --message=MESSAGE: Give reason why package failed or
2466 source dependency list
2467 (used with -f, --dep-wait, and --binNMU)
2468 -o, --override: Override another user's lock on a package, i.e.
2469 take it over; a notice mail will be sent to the other user
2470 -U USER, --user=USER: select user name for which listings should
2471 apply, if not given all users are listed.
2472 if -l is missing, set user name to be entered in db; usually
2473 automatically choosen
2474 --import FILE: Import database from a ASCII file FILE
2475 --export FILE: Export database to a ASCII file FILE
2476 The remaining arguments (depending on operation) usually start with
2477 "name_version", the trailer is ignored. This allows to pass the names
2478 of .dsc files, for which file name completion can be used.
2479 --merge-packages and --merge-quinn take Package/quin--diff file names
2480 on the command line or read stdin. --list needs nothing more on the
2481 command line. --info takes source package names (without version).
2486 sub pkg_version_eq {
2488 my $version = shift;
2491 if (defined $pkg->{'Binary-NMU-Version'}) and
2492 version_compare(binNMU_version($pkg->{'Version'},
2493 $pkg->{'Binary-NMU-Version'}),'=', $version);
2494 return version_compare( $pkg->{'Version'}, "=", $version );