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;
42 use MLDBM qw(GDBM_File Storable);
45 our ($verbose, $mail_logs, $list_order, $list_state,
46 $curr_date, $op_mode, $user, $real_user, $distribution,
47 $fail_reason, $opt_override, $import_from, $export_to, $opt_create_db,
48 $transactlog, %db, %otherdb, %otherdb_lock, %prioval, %sectval,
49 $info_all_dists, $arch,
50 $category, %catval, %short_category,
51 $short_date, $list_min_age, $dbbase, @curr_time,
52 $build_priority, %new_vers, $binNMUver, %merge_srcvers, %merge_binsrc,
53 $lock_for_pid, $transactional);
56 $ENV{'PATH'} = "/bin:/usr/bin:/usr/local/bin";
60 $curr_date = strftime("%Y %b %d %H:%M:%S",@curr_time);
61 $short_date = strftime("%m/%d/%y",@curr_time);
63 $lock_for_pid = -1; # -1 means normal procedure
64 $transactional = 0; # 0 means: work on main copy
66 # map program invocation names to operation modes
67 my %prognames = ( "uploaded-build" => "set-uploaded",
68 "failed-build" => "set-failed",
69 "no-build" => "set-not-for-us",
70 "give-back-build" => "set-needs-build",
71 "dep-wait-build" => "set-dep-wait",
72 "forget-build" => "forget",
73 "merge-quinn" => "merge-quinn",
74 "merge-packages" => "merge-packages",
75 "merge-sources" => "merge-sources",
76 "build-info" => "info" );
78 %short_category = ( u => "uploaded-fixed-pkg",
85 c => "compiler-error",
89 ($progname = $0) =~ s,.*/,,;
90 if ($prognames{$progname}) {
91 $op_mode = $prognames{$progname};
93 elsif ($progname =~ /^list-(.*)$/) {
95 $list_state = ($1 eq "all") ? "" : $1;
100 verbose => { short => "v", flag => \$verbose },
101 override => { short => "o", flag => \$opt_override },
102 "create-db" => { flag => \$opt_create_db },
103 "correct-compare" => { flag => \$WannaBuild::opt_correct_version_cmp },
104 # TODO: remove after buildds no longer pass to wanna-build
105 "no-propagation" => { short => "N" },
106 "no-down-propagation" => { short => "D" },
108 take => { mode => "set-building" },
109 failed => { short => "f", mode => "set-failed" },
110 uploaded => { short => "u", mode => "set-uploaded" },
111 "no-build" => { short => "n", mode => "set-not-for-us" },
112 built => { mode => "set-built" },
113 attempted => { mode => "set-attempted" },
114 "give-back" => { mode => "set-needs-build" },
115 "dep-wait" => { mode => "set-dep-wait" },
116 forget => { mode => "forget" },
117 'forget-user' => { mode => 'forget-user' },
118 "merge-quinn" => { mode => "merge-quinn" },
119 "merge-partial-quinn" => { mode => "merge-partial-quinn" },
120 "merge-packages" => { mode => "merge-packages" },
121 "merge-sources" => { mode => "merge-sources" },
122 "pretend-avail" => { short => "p", mode => "pretend-avail" },
123 "merge-all" => { mode => "merge-all" },
124 info => { short => "i", mode => "info" },
125 'binNMU' => { mode => 'set-binary-nmu', arg => \$binNMUver,
126 code => sub { die "Invalid binNMU version: $binNMUver\n"
127 if $binNMUver !~ /^([\d]*)$/ and $1 >= 0; } },
128 'perm-build-priority' => { mode => "set-permanent-build-priority", arg => \$build_priority,
129 code => sub { die "Invalid build priority: $build_priority\n"
130 if $build_priority !~ /^-?[\d]+$/; } },
131 'build-priority' => { mode => "set-build-priority", arg => \$build_priority,
132 code => sub { die "Invalid build priority: $build_priority\n"
133 if $build_priority !~ /^-?[\d]+$/; } },
135 { short => "l", mode => "list", arg => \$list_state,
137 die "Unknown state to list: $list_state\n"
138 if !isin( $list_state, qw(needs-build building uploaded
139 built build-attempted failed installed dep-wait
140 not-for-us all failed-removed
141 install-wait reupload-wait));} },
144 { short => "d", arg => \$distribution,
146 if ($distribution eq "a" || $distribution eq "all") {
151 $distribution = "oldstable" if $distribution eq "o";
152 $distribution = "stable" if $distribution eq "s";
153 $distribution = "testing" if $distribution eq "t";
154 $distribution = "unstable" if $distribution eq "u";
158 { short => "O", arg => \$list_order,
160 die "Bad ordering character\n"
161 if $list_order !~ /^[PSpsncb]+$/;
163 message => { short => "m", arg => \$fail_reason },
164 database => { short => "b", arg => \$conf::dbbase },
165 arch => { short => "A", arg => \$arch },
166 user => { short => "U", arg => \$user },
167 category => { short => "c", arg => \$category,
169 $category = $short_category{$category}
170 if exists $short_category{$category};
171 die "Unknown category: $category\n"
172 if !isin( $category, values %short_category );
174 "min-age" => { short => "a", arg => \$list_min_age,
176 die "Argument of --min-age must be a non-zero number\n"
177 if $list_min_age == 0;
178 $list_min_age *= 24*60*60;
180 "max-age" => { arg => \$list_min_age,
182 die "Argument of --max-age must be a non-zero number\n"
183 if $list_min_age == 0;
184 $list_min_age *= -24*60*60;
187 import => { arg => \$import_from, mode => "import" },
188 export => { arg => \$export_to, mode => "export" },
189 "lock-for" => { arg => \$lock_for_pid, mode => "lock-for" },
190 "unlock-for" => { arg => \$lock_for_pid, mode => "unlock-for" },
191 "act-on-behalve-of" => { arg => \$lock_for_pid },
192 "start-transaction" => { mode => "start-transaction" },
193 "commit-transaction" => { mode => "commit-transaction" },
194 "transactional" => { flag => \$transactional },
195 "manual-edit" => { mode => "manual-edit" },
196 "create-maintenance-lock" => { mode => "maintlock-create" },
197 "remove-maintenance-lock" => { mode => "maintlock-remove" },
198 "clean-db" => { mode => "clean-db" },
201 while( @ARGV && $ARGV[0] =~ /^-/ ) {
204 my($opt, $optname, $arg);
205 if (/^--([^=]+)(=|$)/) {
207 $opt = $options{$optname};
208 $arg = $1 if /^--\Q$optname\E=((.|\n)*)$/;
211 $optname = substr( $_, 1, 1 );
212 $opt = (grep { defined($_->{short}) ? $_->{short} eq $optname : 0} values %options)[0];
213 $arg = $1 if /^-$optname(.+)$/;
216 warn "Unknown option: --$1\n";
221 die "$optname option missing argument\n" if !@ARGV;
224 ${$opt->{arg}} = $arg;
226 elsif (defined $arg) {
227 die "Option $optname takes no argument\n";
231 die "Conflicting operation modes\n" if $op_mode;
232 $op_mode = $opt->{mode};
242 $op_mode = $category ? "set-failed" : "set-building"
243 if !$op_mode; # default operation
244 $list_order = $list_state eq "failed" ? 'fPcpsn' : 'PScpsn'
245 if !$list_order and $list_state;
246 $distribution ||= "unstable";
247 die "Bad distribution '$distribution'\n"
248 if !isin($distribution, keys %conf::distributions);
249 $conf::dbbase =~ m#^([^/]+/)#;
250 $transactlog = "$conf::basedir/$1$conf::transactlog";
253 my $version = '$Revision: db181a534e9d $ $Date: 2008/03/26 06:20:22 $ $Author: rmurray $';
254 $version =~ s/(^\$| \$ .*$)//g;
255 print "wanna-build $version for $distribution on $conf::dbbase\n";
258 if (!@ARGV && !isin( $op_mode, qw(list merge-quinn merge-partial-quinn import export
259 merge-packages manual-edit maintlock-create lock-for unlock-for
260 start-transaction commit-transaction
261 merge-sources maintlock-remove clean-db))) {
262 warn "No packages given.\n";
266 $real_user = (getpwuid($<))[0];
267 die "Can't determine your user name\n"
268 if $op_mode ne "list" && !$user &&
269 !($user = $real_user);
272 if ($op_mode eq "set-failed" && !$category) {
273 print "Enter reason for failing (end with '.' alone on ".
278 last if $line eq ".\n";
279 $line = ".\n" if $line eq "\n";
280 $fail_reason .= $line;
282 chomp( $fail_reason );
283 } elsif ($op_mode eq "set-dep-wait") {
284 print "Enter dependencies (one line):\n";
286 while( !$line && !eof(STDIN) ) {
287 chomp( $line = <STDIN> );
289 die "No dependencies given\n" if !$line;
290 $fail_reason = $line;
291 } elsif ($op_mode eq "set-binary-nmu" and $binNMUver > 0) {
292 print "Enter changelog entry (one line):\n";
294 while( !$line && !eof(STDIN) ) {
295 chomp( $line = <STDIN> );
297 die "No changelog entry given\n" if !$line;
298 $fail_reason = $line;
301 if ($op_mode eq "maintlock-create") {
305 if ($op_mode eq "maintlock-remove") {
309 waitfor_maintlock() if $op_mode !~ /^(?:merge-|clean-db$)/;
311 if (!-f db_filename( $distribution ) && !$opt_create_db) {
312 if ($transactional) {
313 die "No running transaction for $distribution\n";
315 die "Database for $distribution doesn't exist\n";
319 # Locking for another process means that a longer running process (most likely
320 # wb) wants to do several steps at once, and manages the locks.
321 if ($op_mode eq "lock-for") {
322 lock_db( $distribution );
325 if ($op_mode eq "unlock-for") {
326 unlock_db( $distribution );
330 lock_db( $distribution );
332 if ($op_mode eq "start-transaction") {
333 copy ( db_filename_master( $distribution ), db_filename_transaction( $distribution ))
334 or die "Copy failed: $!";
338 if ($op_mode eq "commit-transaction") {
339 move ( db_filename_transaction( $distribution ), db_filename_master( $distribution ))
340 or die "Copy failed: $!";
346 if ($lock_for_pid == -1) {
347 unlock_db( $distribution );
349 foreach (keys %conf::distributions) {
350 untie %{$otherdb{$_}} if tied(%{$otherdb{$_}});
351 unlock_db( $_ ) if $otherdb_lock{$_};
355 tie %db, 'MLDBM', db_filename( $distribution ), GDBM_WRCREAT, 0664
356 or die "FATAL: Cannot open database\n";
360 if ($mail_logs && $conf::log_mail) {
361 send_mail( $conf::log_mail,
362 "wanna-build $distribution state changes $curr_date",
363 "State changes at $curr_date for distribution ".
364 "$distribution:\n\n$mail_logs\n" );
372 SWITCH: foreach ($op_mode) {
374 add_packages( $1, @ARGV );
378 list_packages( $list_state );
382 info_packages( @ARGV );
385 /^forget-user/ && do {
386 die "This operation is restricted to admin users\n"
387 if (defined @conf::admin_users and
388 !isin( $real_user, @conf::admin_users));
389 forget_users( @ARGV );
393 forget_packages( @ARGV );
396 /^merge-partial-quinn/ && do {
397 die "This operation is restricted to admin users\n"
398 if (defined @conf::admin_users and
399 !isin( $real_user, @conf::admin_users));
403 /^merge-quinn/ && do {
404 die "This operation is restricted to admin users\n"
405 if (defined @conf::admin_users and
406 !isin( $real_user, @conf::admin_users));
410 /^merge-packages/ && do {
411 die "This operation is restricted to admin users\n"
412 if (defined @conf::admin_users and
413 !isin( $real_user, @conf::admin_users));
417 /^merge-sources/ && do {
418 die "This operation is restricted to admin users\n"
419 if (defined @conf::admin_users and
420 !isin( $real_user, @conf::admin_users));
424 /^pretend-avail/ && do {
425 pretend_avail( @ARGV );
429 die "This operation is restricted to admin users\n"
430 if (defined @conf::admin_users and
431 !isin( $real_user, @conf::admin_users));
433 @ARGV = ( $ARGS[0] );
434 my $pkgs = parse_packages();
435 @ARGV = ( $ARGS[1] );
437 @ARGV = ( $ARGS[2] );
438 my $build_deps = parse_sources(1);
439 auto_dep_wait( $build_deps, $pkgs );
444 die "This operation is restricted to admin users\n"
445 if (defined @conf::admin_users and
446 !isin( $real_user, @conf::admin_users));
447 %db = (); # clear all current contents
448 read_db( $import_from );
452 write_db( $export_to );
455 /^manual-edit/ && do {
456 die "This operation is restricted to admin users\n"
457 if (defined @conf::admin_users and
458 !isin( $real_user, @conf::admin_users));
459 my $tmpfile_pattern = "/tmp/wanna-build-$distribution.$$-";
461 for( $i = 0;; ++$i ) {
462 $tmpfile = $tmpfile_pattern . $i;
463 last if ! -e $tmpfile;
465 write_db( $tmpfile );
466 my $editor = $ENV{'VISUAL'} ||
467 "/usr/bin/sensible-editor";
468 system "$editor $tmpfile";
469 %db = (); # clear all current contents
475 die "This operation is restricted to admin users\n"
476 if (defined @conf::admin_users and
477 !isin( $real_user, @conf::admin_users));
482 die "Unexpected operation mode $op_mode\n";
484 if (not -t and $user =~ /-/) {
485 my $userinfo = $db{'_userinfo'};
486 $userinfo = {} if (!defined($userinfo));
488 my $ui = $userinfo->{$user};
489 $ui = {} if (!defined($ui));
491 $ui->{'Last-Seen'} = $curr_date;
492 $ui->{'User'} = $user;
494 $userinfo->{$user} = $ui;
495 $db{'_userinfo'} = $userinfo;
500 my $newstate = shift;
501 my( $package, $name, $version, $ok, $reason );
503 foreach $package (@_) {
504 $package =~ s,^.*/,,; # strip path
505 $package =~ s/\.(dsc|diff\.gz|tar\.gz|deb)$//; # strip extension
506 $package =~ s/_[a-zA-Z\d-]+\.changes$//; # strip extension
507 if ($package =~ /^([\w\d.+-]+)_([\w\d:.+~-]+)/) {
508 ($name,$version) = ($1,$2);
511 warn "$package: can't extract package name and version ".
516 if ($op_mode eq "set-building") {
517 add_one_building( $name, $version );
519 elsif ($op_mode eq "set-built") {
520 add_one_built( $name, $version );
522 elsif ($op_mode eq "set-attempted") {
523 add_one_attempted( $name, $version );
525 elsif ($op_mode eq "set-uploaded") {
526 add_one_uploaded( $name, $version );
528 elsif ($op_mode eq "set-failed") {
529 add_one_failed( $name, $version );
531 elsif ($op_mode eq "set-not-for-us") {
532 add_one_notforus( $name, $version );
534 elsif ($op_mode eq "set-needs-build") {
535 add_one_needsbuild( $name, $version );
537 elsif ($op_mode eq "set-dep-wait") {
538 add_one_depwait( $name, $version );
540 elsif ($op_mode eq "set-build-priority") {
541 set_one_buildpri( $name, $version, 'BuildPri' );
543 elsif ($op_mode eq "set-permanent-build-priority") {
544 set_one_buildpri( $name, $version, 'PermBuildPri' );
546 elsif ($op_mode eq "set-binary-nmu") {
547 set_one_binnmu( $name, $version );
552 sub add_one_building {
558 my $pkg = $db{$name};
560 if ($pkg->{'State'} eq "Not-For-Us") {
562 $reason = "not suitable for this architecture";
564 elsif ($pkg->{'State'} =~ /^Dep-Wait/) {
566 $reason = "not all source dependencies available yet";
568 elsif ($pkg->{'State'} eq "Uploaded" &&
569 (version_lesseq($version, $pkg->{'Version'}))) {
571 $reason = "already uploaded by $pkg->{'Builder'}";
572 $reason .= " (in newer version $pkg->{'Version'})"
573 if !version_eq($pkg, $version);
575 elsif ($pkg->{'State'} eq "Installed" &&
576 version_less($version,$pkg->{'Version'})) {
578 print "$name: Warning: newer version $pkg->{'Version'} ".
579 "already installed, but overridden.\n";
583 $reason = "newer version $pkg->{'Version'} already in ".
584 "archive; doesn't need rebuilding";
585 print "$name: Note: If the following is due to an epoch ",
586 " change, use --override\n";
589 elsif ($pkg->{'State'} eq "Installed" &&
590 pkg_version_eq($pkg,$version)) {
592 $reason = "is up-to-date in the archive; doesn't need rebuilding";
594 elsif ($pkg->{'State'} eq "Needs-Build" &&
595 version_less($version,$pkg->{'Version'})) {
597 print "$name: Warning: newer version $pkg->{'Version'} ".
598 "needs building, but overridden.";
602 $reason = "newer version $pkg->{'Version'} needs building, ".
606 elsif (isin($pkg->{'State'},qw(Building Built Build-Attempted))) {
607 if (version_less($pkg->{'Version'},$version)) {
608 print "$name: Warning: Older version $pkg->{'Version'} ",
609 "is being built by $pkg->{'Builder'}\n";
610 if ($pkg->{'Builder'} ne $user) {
611 send_mail( $pkg->{'Builder'},
612 "package takeover in newer version",
613 "You are building package '$name' in ".
614 "version $version\n".
615 "(as far as I'm informed).\n".
616 "$user now has taken the newer ".
617 "version $version for building.".
618 "You can abort the build if you like.\n" );
623 print "User $pkg->{'Builder'} had already ",
624 "taken the following package,\n",
625 "but overriding this as you request:\n";
626 send_mail( $pkg->{'Builder'}, "package takeover",
627 "The package '$name' (version $version) that ".
628 "was locked by you\n".
629 "has been taken over by $user\n" );
631 elsif ($pkg->{'Builder'} eq $user) {
632 print "$name: Note: already taken by you.\n";
633 print "$name: ok\n" if $verbose;
638 $reason = "already taken by $pkg->{'Builder'}";
639 $reason .= " (in newer version $pkg->{'Version'})"
640 if !version_eq($pkg->{'Version'}, $version);
644 elsif ($pkg->{'State'} =~ /^Failed/ &&
645 pkg_version_eq($pkg, $version)) {
647 print "The following package previously failed ",
648 "(by $pkg->{'Builder'})\n",
649 "but overriding this as you request:\n";
650 send_mail( $pkg->{'Builder'}, "failed package takeover",
651 "The package '$name' (version $version) that ".
652 "is locked by you\n".
653 "and has failed previously has been taken over ".
655 if $pkg->{'Builder'} ne $user;
659 $reason = "build of $version failed previously:\n ";
660 $reason .= join( "\n ", split( "\n", $pkg->{'Failed'} ));
661 $reason .= "\nalso the package doesn't need builing"
662 if $pkg->{'State'} eq 'Failed-Removed';
668 if ($pkg->{'Binary-NMU-Version'}) {
669 print "$name: Warning: needs binary NMU $pkg->{'Binary-NMU-Version'}\n" .
670 "$pkg->{'Binary-NMU-Changelog'}\n";
673 print "$name: Warning: Previous version failed!\n"
674 if $pkg->{'Previous-State'} =~ /^Failed/ ||
675 $pkg->{'State'} =~ /^Failed/;
677 change_state( \$pkg, 'Building' );
678 $pkg->{'Package'} = $name;
679 $pkg->{'Version'} = $version;
680 $pkg->{'Builder'} = $user;
681 log_ta( $pkg, "--take" );
683 print "$name: $ok\n" if $verbose;
686 print "$name: NOT OK!\n $reason\n";
690 sub add_one_attempted {
693 my $pkg = $db{$name};
695 if (!defined($pkg)) {
696 print "$name: not registered yet.\n";
700 if ($pkg->{'State'} ne "Building" ) {
701 print "$name: not taken for building (state is $pkg->{'State'}). ",
705 if ($pkg->{'Builder'} ne $user) {
706 print "$name: not taken by you, but by $pkg->{'Builder'}. Skipping.\n";
709 elsif ( !pkg_version_eq($pkg, $version) ) {
710 print "$name: version mismatch ".
711 "$(pkg->{'Version'} ".
712 "by $pkg->{'Builder'})\n";
716 change_state( \$pkg, 'Build-Attempted' );
717 log_ta( $pkg, "--attempted" );
719 print "$name: registered as uploaded\n" if $verbose;
725 my $pkg = $db{$name};
727 if (!defined($pkg)) {
728 print "$name: not registered yet.\n";
732 if ($pkg->{'State'} ne "Building" ) {
733 print "$name: not taken for building (state is $pkg->{'State'}). ",
737 if ($pkg->{'Builder'} ne $user) {
738 print "$name: not taken by you, but by $pkg->{'Builder'}. Skipping.\n";
741 elsif ( !pkg_version_eq($pkg, $version) ) {
742 print "$name: version mismatch ".
743 "$(pkg->{'Version'} ".
744 "by $pkg->{'Builder'})\n";
747 change_state( \$pkg, 'Built' );
748 log_ta( $pkg, "--built" );
750 print "$name: registered as built\n" if $verbose;
753 sub add_one_uploaded {
756 my $pkg = $db{$name};
758 if (!defined($pkg)) {
759 print "$name: not registered yet.\n";
763 if ($pkg->{'State'} eq "Uploaded" &&
764 pkg_version_eq($pkg,$version)) {
765 print "$name: already uploaded\n";
768 if (!isin( $pkg->{'State'}, qw(Building Built Build-Attempted))) {
769 print "$name: not taken for building (state is $pkg->{'State'}). ",
773 if ($pkg->{'Builder'} ne $user) {
774 print "$name: not taken by you, but by $pkg->{'Builder'}. Skipping.\n";
777 # strip epoch -- buildd-uploader used to go based on the filename.
778 # (to remove at some point)
780 ($pkgver = $pkg->{'Version'}) =~ s/^\d+://;
781 $version =~ s/^\d+://; # for command line use
782 if ($pkg->{'Binary-NMU-Version'} ) {
783 my $nmuver = binNMU_version($pkgver, $pkg->{'Binary-NMU-Version'});
784 if (!version_eq( $nmuver, $version )) {
785 print "$name: version mismatch ($nmuver registered). ",
789 } elsif (!version_eq($pkgver, $version)) {
790 print "$name: version mismatch ($pkg->{'Version'} registered). ",
795 change_state( \$pkg, 'Uploaded' );
796 log_ta( $pkg, "--uploaded" );
798 print "$name: registered as uploaded\n" if $verbose;
805 my $pkg = $db{$name};
807 if (!defined($pkg)) {
808 print "$name: not registered yet.\n";
811 $state = $pkg->{'State'};
813 if ($state eq "Not-For-Us") {
814 print "$name: not suitable for this architecture anyway. Skipping.\n";
817 elsif ($state eq "Failed-Removed") {
818 print "$name: failed previously and doesn't need building. Skipping.\n";
821 elsif ($state eq "Installed") {
822 print "$name: Is already installed in archive. Skipping.\n";
825 elsif ($pkg->{'Builder'} &&
826 (($user ne $pkg->{'Builder'}) &&
827 !($pkg->{'Builder'} =~ /^(\w+)-\w+/ && $1 eq $user))) {
828 print "$name: not taken by you, but by ".
829 "$pkg->{'Builder'}. Skipping.\n";
832 elsif ( !pkg_version_eq($pkg, $version) ) {
833 print "$name: version mismatch ".
834 "$(pkg->{'Version'} ".
835 "by $pkg->{'Builder'})\n";
840 if (!$cat && $fail_reason =~ /^\[([^\]]+)\]/) {
842 $cat = $short_category{$cat} if exists $short_category{$cat};
843 if (!isin( $cat, values %short_category )) {
844 print "$name: Warning: unknown category $cat; discarded\n";
847 $fail_reason =~ s/^\[[^\]]+\][ \t]*\n*//;
850 if ($state eq "Needs-Build") {
851 print "$name: Warning: not registered for building previously, ".
852 "but processing anyway.\n";
854 elsif ($state eq "Uploaded") {
855 print "$name: Warning: marked as uploaded previously, ".
856 "but processing anyway.\n";
858 elsif ($state eq "Dep-Wait") {
859 print "$name: Warning: marked as waiting for dependencies, ".
860 "but processing anyway.\n";
862 elsif ($state eq "Failed") {
863 print "$name: already registered as failed; will append new message\n"
865 print "$name: already registered as failed; changing category\n"
869 if (($cat eq "reminder-sent" || $cat eq "nmu-offered") &&
870 exists $pkg->{'Failed-Category'} &&
871 $pkg->{'Failed-Category'} ne $cat) {
872 (my $action = $cat) =~ s/-/ /;
873 $fail_reason .= "\n$short_date: $action";
876 change_state( \$pkg, 'Failed' );
877 $pkg->{'Builder'} = $user;
878 $pkg->{'Failed'} .= "\n" if $pkg->{'Failed'};
879 $pkg->{'Failed'} .= $fail_reason;
880 $pkg->{'Failed-Category'} = $cat if $cat;
881 if (defined $pkg->{'PermBuildPri'}) {
882 $pkg->{'BuildPri'} = $pkg->{'PermBuildPri'};
884 delete $pkg->{'BuildPri'};
886 log_ta( $pkg, "--failed" );
888 print "$name: registered as failed\n" if $verbose;
891 sub add_one_notforus {
894 my $pkg = $db{$name};
896 if ($pkg->{'State'} eq 'Not-For-Us') {
897 # reset Not-For-Us state in case it's called twice; this is
898 # the only way to get a package out of this state...
899 # There is no really good state in which such packages should
900 # be put :-( So use Failed for now.
901 change_state( \$pkg, 'Failed' );
902 $pkg->{'Package'} = $name;
903 $pkg->{'Failed'} = "Was Not-For-Us previously";
904 delete $pkg->{'Builder'};
905 delete $pkg->{'Depends'};
906 log_ta( $pkg, "--no-build(rev)" );
907 print "$name: now not unsuitable anymore\n";
909 send_mail( $conf::notforus_maint,
910 "$name moved out of Not-For-Us state",
911 "The package '$name' has been moved out of the Not-For-Us ".
913 "It should probably also be removed from ".
914 "Packages-arch-specific or\n".
915 "the action was wrong.\n" )
916 if $conf::notforus_maint;
919 change_state( \$pkg, 'Not-For-Us' );
920 $pkg->{'Package'} = $name;
921 delete $pkg->{'Builder'};
922 delete $pkg->{'Depends'};
923 delete $pkg->{'BuildPri'};
924 delete $pkg->{'Binary-NMU-Version'};
925 delete $pkg->{'Binary-NMU-Changelog'};
926 log_ta( $pkg, "--no-build" );
927 print "$name: registered as unsuitable\n" if $verbose;
929 send_mail( $conf::notforus_maint,
930 "$name set to Not-For-Us",
931 "The package '$name' has been set to state Not-For-Us ".
933 "It should probably also be added to ".
934 "Packages-arch-specific or\n".
935 "the Not-For-Us state is wrong.\n" )
936 if $conf::notforus_maint;
941 sub add_one_needsbuild {
945 my $pkg = $db{$name};
947 if (!defined($pkg)) {
948 print "$name: not registered; can't give back.\n";
951 $state = $pkg->{'State'};
953 if ($state eq "Dep-Wait") {
955 print "$name: Forcing source dependency list to be cleared\n";
958 print "$name: waiting for source dependencies. Skipping\n",
959 " (use --override to clear dependency list and ",
960 "give back anyway)\n";
964 elsif (!isin( $state, qw(Building Built Build-Attempted))) {
965 print "$name: not taken for building (state is $state).";
967 print "\n$name: Forcing give-back\n";
970 print " Skipping.\n";
974 if (defined ($pkg->{'Builder'}) && $user ne $pkg->{'Builder'} &&
975 !($pkg->{'Builder'} =~ /^(\w+)-\w+/ && $1 eq $user)) {
976 print "$name: not taken by you, but by ".
977 "$pkg->{'Builder'}. Skipping.\n";
980 if (!pkg_version_eq($pkg, $version)) {
981 print "$name: version mismatch ($pkg->{'Version'} registered). ",
985 change_state( \$pkg, 'Needs-Build' );
986 delete $pkg->{'Builder'};
987 delete $pkg->{'Depends'};
988 log_ta( $pkg, "--give-back" );
990 print "$name: given back\n" if $verbose;
996 my $pkg = $db{$name};
999 if (!defined($pkg)) {
1000 print "$name: not registered; can't register for binNMU.\n";
1003 my $db_ver = $pkg->{'Version'};
1005 if (!version_eq($db_ver, $version)) {
1006 print "$name: version mismatch ($db_ver registered). ",
1010 $state = $pkg->{'State'};
1012 if (defined $pkg->{'Binary-NMU-Version'}) {
1013 if ($binNMUver == 0) {
1014 change_state( \$pkg, 'Installed' );
1015 delete $pkg->{'Builder'};
1016 delete $pkg->{'Depends'};
1017 delete $pkg->{'Binary-NMU-Version'};
1018 delete $pkg->{'Binary-NMU-Changelog'};
1019 } elsif ($binNMUver <= $pkg->{'Binary-NMU-Version'}) {
1020 print "$name: already building binNMU $pkg->{'Binary-NMU-Version'}\n";
1023 $pkg->{'Binary-NMU-Version'} = $binNMUver;
1024 $pkg->{'Binary-NMU-Changelog'} = $fail_reason;
1025 $pkg->{'Notes'} = 'out-of-date';
1026 $pkg->{'BuildPri'} = $pkg->{'PermBuildPri'}
1027 if (defined $pkg->{'PermBuildPri'});
1029 log_ta( $pkg, "--binNMU" );
1032 } elsif ($binNMUver == 0) {
1033 print "${name}_$version: no scheduled binNMU to cancel.\n";
1037 if ($state ne 'Installed') {
1038 print "${name}_$version: not installed; can't register for binNMU.\n";
1042 my $fullver = binNMU_version($version,$binNMUver);
1043 if ( version_lesseq( $fullver, $pkg->{'Installed-Version'} ) )
1045 print "$name: binNMU $fullver is not newer than current version $pkg->{'Installed-Version'}\n";
1049 change_state( \$pkg, 'Needs-Build' );
1050 delete $pkg->{'Builder'};
1051 delete $pkg->{'Depends'};
1052 $pkg->{'Binary-NMU-Version'} = $binNMUver;
1053 $pkg->{'Binary-NMU-Changelog'} = $fail_reason;
1054 $pkg->{'Notes'} = 'out-of-date';
1055 log_ta( $pkg, "--binNMU" );
1057 print "${name}: registered for binNMU $fullver\n" if $verbose;
1060 sub set_one_buildpri {
1062 my $version = shift;
1064 my $pkg = $db{$name};
1067 if (!defined($pkg)) {
1068 print "$name: not registered; can't set priority.\n";
1071 $state = $pkg->{'State'};
1073 if ($state eq "Not-For-Us") {
1074 print "$name: not suitable for this architecture. Skipping.\n";
1076 } elsif ($state eq "Failed-Removed") {
1077 print "$name: failed previously and doesn't need building. Skipping.\n";
1080 if (!pkg_version_eq($pkg, $version)) {
1081 print "$name: version mismatch ($pkg->{'Version'} registered). ",
1085 if ( $build_priority == 0 ) {
1086 delete $pkg->{'BuildPri'}
1087 if $key eq 'PermBuildPri' and defined $pkg->{'BuildPri'}
1088 and $pkg->{'BuildPri'} == $pkg->{$key};
1089 delete $pkg->{$key};
1091 $pkg->{'BuildPri'} = $build_priority
1092 if $key eq 'PermBuildPri';
1093 $pkg->{$key} = $build_priority;
1096 print "$name: set to build priority $build_priority\n" if $verbose;
1099 sub add_one_depwait {
1101 my $version = shift;
1103 my $pkg = $db{$name};
1105 if (!defined($pkg)) {
1106 print "$name: not registered yet.\n";
1109 $state = $pkg->{'State'};
1111 if ($state eq "Dep-Wait") {
1112 print "$name: merging with previously registered dependencies\n";
1115 if (isin( $state, qw(Needs-Build Failed))) {
1116 print "$name: Warning: not registered for building previously, ".
1117 "but processing anyway.\n";
1119 elsif ($state eq "Not-For-Us") {
1120 print "$name: not suitable for this architecture anyway. Skipping.\n";
1123 elsif ($state eq "Failed-Removed") {
1124 print "$name: failed previously and doesn't need building. Skipping.\n";
1127 elsif ($state eq "Installed") {
1128 print "$name: Is already installed in archive. Skipping.\n";
1131 elsif ($state eq "Uploaded") {
1132 print "$name: Is already uploaded. Skipping.\n";
1135 elsif ($pkg->{'Builder'} &&
1136 $user ne $pkg->{'Builder'}) {
1137 print "$name: not taken by you, but by ".
1138 "$pkg->{'Builder'}. Skipping.\n";
1141 elsif ( !pkg_version_eq($pkg,$version)) {
1142 print "$name: version mismatch ".
1143 "($pkg->{'Version'} ".
1144 "by $pkg->{'Builder'})\n";
1147 elsif ($fail_reason =~ /^\s*$/ ||
1148 !parse_deplist( $fail_reason, 1 )) {
1149 print "$name: Bad dependency list\n";
1152 change_state( \$pkg, 'Dep-Wait' );
1153 $pkg->{'Builder'} = $user;
1154 if (defined $pkg->{'PermBuildPri'}) {
1155 $pkg->{'BuildPri'} = $pkg->{'PermBuildPri'};
1157 delete $pkg->{'BuildPri'};
1159 my $deplist = parse_deplist( $pkg->{'Depends'} );
1160 my $new_deplist = parse_deplist( $fail_reason );
1161 # add new dependencies, maybe overwriting old entries
1162 foreach (keys %$new_deplist) {
1163 $deplist->{$_} = $new_deplist->{$_};
1165 $pkg->{'Depends'} = build_deplist($deplist);
1166 log_ta( $pkg, "--dep-wait" );
1168 print "$name: registered as waiting for dependencies\n" if $verbose;
1178 local($/) = ""; # read in paragraph mode
1180 my( $version, $arch, $section, $priority, $builddep, $buildconf, $binaries );
1182 /^Package:\s*(\S+)$/mi and $name = $1;
1183 /^Version:\s*(\S+)$/mi and $version = $1;
1184 /^Architecture:\s*(\S+)$/mi and $arch = $1;
1185 /^Section:\s*(\S+)$/mi and $section = $1;
1186 /^Priority:\s*(\S+)$/mi and $priority = $1;
1187 /^Build-Depends:\s*(.*)$/mi and $builddep = $1;
1188 /^Build-Conflicts:\s*(.*)$/mi and $buildconf = $1;
1189 /^Binary:\s*(.*)$/mi and $binaries = $1;
1191 next if (defined $srcver{$name} and version_less( $version, $srcver{$name} ));
1192 $srcver{$name} = $version;
1194 $buildconf = join( ", ", map { "!$_" } split( /\s*,\s*/, $buildconf ));
1196 $builddep .= "," . $buildconf;
1198 $builddep = $buildconf;
1202 $pkgs{$name}{'dep'} = defined $builddep ? $builddep : "";
1203 $pkgs{$name}{'ver'} = $version;
1204 $pkgs{$name}{'bin'} = $binaries;
1205 my $pkg = $db{$name};
1210 if ($arch eq "all" && !version_less( $version, $pkg->{'Version'} )) {
1211 # package is now Arch: all, delete it from db
1212 change_state( \$pkg, 'deleted' );
1213 log_ta( $pkg, "--merge-sources" );
1214 print "$name ($pkg->{'Version'}): deleted ".
1215 "from database, because now Arch: all\n"
1221 # The "Version" should always be the source version --
1222 # not a possible binNMU version number.
1223 $pkg->{'Version'} = $version, $change++
1224 if ($pkg->{'State'} eq 'Installed' and
1225 !version_eq( $pkg->{'Version'}, $version));
1226 # Always update priority and section, if available
1227 $pkg->{'Priority'} = $priority, $change++
1228 if defined $priority and (not defined($pkg->{'Priority'}) or $pkg->{'Priority'} ne $priority);
1230 $pkg->{'Section'} = $section, $change++
1231 if defined $section and (not defined($pkg->{'Section'}) or $pkg->{'Section'} ne $section);
1232 $db{$name} = $pkg if $change;
1235 # Now that we only have the latest source version, build the list
1236 # of binary packages from the Sources point of view
1237 foreach $name (keys %pkgs) {
1238 foreach my $bin (split( /\s*,\s*/, $pkgs{$name}{'bin'} ) ) {
1239 $merge_binsrc{$bin} = $name;
1242 # remove installed packages that no longer have source available
1243 # or binaries installed
1244 foreach $name (keys %db) {
1245 next if $name =~ /^_/;
1246 my $pkg = $db{$name};
1247 if (not defined($pkgs{$name})) {
1248 change_state( \$pkg, 'deleted' );
1249 log_ta( $pkg, "--merge-sources" );
1250 print "$name ($pkg->{'Version'}): ".
1251 "deleted from database, because ".
1252 "not in Sources anymore\n"
1256 next if !isin( $pkg->{'State'}, qw(Installed) );
1257 if ($full && not defined $merge_srcvers{$name}) {
1258 change_state( \$pkg, 'deleted' );
1259 log_ta( $pkg, "--merge-sources" );
1260 print "$name ($pkg->{'Version'}): ".
1261 "deleted from database, because ".
1262 "binaries don't exist anymore\n"
1265 } elsif ($full && version_less( $merge_srcvers{$name}, $pkg->{'Version'})) {
1266 print "$name ($pkg->{'Version'}): ".
1267 "package is Installed but binaries are from ".
1268 $merge_srcvers{$name}. "\n"
1276 # This function looks through a Packages file and sets the state of
1277 # packages to 'Installed'
1278 sub parse_packages {
1281 local($/) = ""; # read in paragraph mode
1283 my( $name, $version, $depends, $source, $sourcev, $architecture, $provides, $binaryv, $binnmu );
1285 /^Package:\s*(\S+)$/mi and $name = $1;
1286 /^Version:\s*(\S+)$/mi and $version = $1;
1287 /^Depends:\s*(.*)$/mi and $depends = $1;
1288 /^Source:\s*(\S+)(\s*\((\S+)\))?$/mi and ($source,$sourcev) = ($1, $3);
1289 /^Architecture:\s*(\S+)$/mi and $architecture = $1;
1290 /^Provides:\s*(.*)$/mi and $provides = $1;
1291 next if !$name || !$version;
1292 next if ($arch ne $architecture and $architecture ne "all");
1293 next if (defined ($installed->{$name}) and $installed->{$name}{'Version'} ne "" and
1294 version_lesseq( $version, $installed->{$name}{'Version'} ));
1295 $installed->{$name}{'Version'} = $version;
1296 $installed->{$name}{'Depends'} = $depends;
1297 $installed->{$name}{'all'} = 1 if $architecture eq "all";
1298 undef $installed->{$name}{'Provider'};
1299 $installed->{$name}{'Source'} = $source ? $source : $name;
1301 foreach (split( /\s*,\s*/, $provides )) {
1302 if (not defined ($installed->{$_})) {
1303 $installed->{$_}{'Version'} = "";
1304 $installed->{$_}{'Provider'} = $name;
1308 if ( $version =~ /\+b(\d+)$/ ) {
1311 $version = $sourcev if $sourcev;
1312 $binaryv = $version;
1313 $binaryv =~ s/\+b\d+$//;
1314 $installed->{$name}{'Sourcev'} = $sourcev ? $sourcev : $binaryv;
1315 $binaryv .= "+b$binnmu" if defined($binnmu);
1317 next if $architecture ne $arch;
1318 $name = $source if $source;
1319 next if defined($merge_srcvers{$name}) and $merge_srcvers{$name} eq $version;
1320 $merge_srcvers{$name} = $version;
1322 my $pkg = $db{$name};
1325 if (isin( $pkg->{'State'}, qw(Not-For-Us)) ||
1326 (isin($pkg->{'State'}, qw(Installed)) &&
1327 version_lesseq($binaryv, $pkg->{'Installed-Version'}))) {
1328 print "Skipping $name because State == $pkg->{'State'}\n"
1332 if ($pkg->{'Binary-NMU-Version'} ) {
1333 my $nmuver = binNMU_version($pkg->{'Version'}, $pkg->{'Binary-NMU-Version'});
1334 if (version_less( $binaryv, $nmuver )) {
1335 print "Skipping $name ($version) because have newer ".
1336 "version ($nmuver) in db.\n"
1340 } elsif (version_less($version, $pkg->{'Version'})) {
1341 print "Skipping $name ($version) because have newer ".
1342 "version ($pkg->{'Version'}) in db.\n"
1347 if (!pkg_version_eq($pkg, $version) &&
1348 $pkg->{'State'} ne "Installed") {
1349 warn "Warning: $name: newer version than expected appeared ".
1350 "in archive ($version vs. $pkg->{'Version'})\n";
1351 delete $pkg->{'Builder'};
1354 if (!isin( $pkg->{'State'}, qw(Uploaded) )) {
1355 warn "Warning: Package $name was not in uploaded state ".
1356 "before (but in '$pkg->{'State'}').\n";
1357 delete $pkg->{'Builder'};
1358 delete $pkg->{'Depends'};
1362 $pkg->{'Version'} = $version;
1365 change_state( \$pkg, 'Installed' );
1366 $pkg->{'Package'} = $name;
1367 $pkg->{'Installed-Version'} = $binaryv;
1368 if (defined $pkg->{'PermBuildPri'}) {
1369 $pkg->{'BuildPri'} = $pkg->{'PermBuildPri'};
1371 delete $pkg->{'BuildPri'};
1373 $pkg->{'Version'} = $version
1374 if version_less( $pkg->{'Version'}, $version);
1375 delete $pkg->{'Binary-NMU-Version'};
1376 delete $pkg->{'Binary-NMU-Changelog'};
1377 log_ta( $pkg, "--merge-packages" );
1379 print "$name ($version) is up-to-date now.\n" if $verbose;
1382 check_dep_wait( "--merge-packages", $installed );
1387 my ($package, $name, $version, $installed);
1389 foreach $package (@_) {
1390 $package =~ s,^.*/,,; # strip path
1391 $package =~ s/\.(dsc|diff\.gz|tar\.gz|deb)$//; # strip extension
1392 $package =~ s/_[\w\d]+\.changes$//; # strip extension
1393 if ($package =~ /^([\w\d.+-]+)_([\w\d:.+~-]+)/) {
1394 ($name,$version) = ($1,$2);
1397 warn "$package: can't extract package name and version ".
1401 $installed->{$name}{'Version'} = $version;
1404 check_dep_wait( "--pretend-avail", $installed );
1407 sub check_dep_wait {
1409 my $installed = shift;
1411 # check all packages in state Dep-Wait if dependencies are all
1414 foreach $name (keys %db) {
1415 next if $name =~ /^_/;
1416 my $pkg = $db{$name};
1417 next if $pkg->{'State'} ne "Dep-Wait";
1418 my $deps = $pkg->{'Depends'};
1420 print "$name: was in state Dep-Wait, but with empty ",
1422 goto make_needs_build;
1424 my $deplist = parse_deplist($deps);
1428 foreach (keys %$deplist) {
1429 if (!exists $installed->{$_} ||
1430 ($deplist->{$_}->{'Rel'} && $deplist->{$_}->{'Version'} &&
1431 !version_compare( $installed->{$_}{'Version'},
1432 $deplist->{$_}->{'Rel'},
1433 $deplist->{$_}->{'Version'}))) {
1435 $new_deplist->{$_} = $deplist->{$_};
1438 push( @removed_deps, $_ );
1443 change_state( \$pkg, 'Needs-Build' );
1444 log_ta( $pkg, $action );
1445 delete $pkg->{'Builder'};
1446 delete $pkg->{'Depends'};
1447 print "$name ($pkg->{'Version'}) has all ",
1448 "dependencies available now\n" if $verbose;
1452 elsif (@removed_deps) {
1453 $pkg->{'Depends'} = build_deplist( $new_deplist );
1454 print "$name ($pkg->{'Version'}): some dependencies ",
1455 "(@removed_deps) available now, but not all yet\n"
1462 # This function accepts quinn-diff output (either from a file named on
1463 # the command line, or on stdin) and sets the packages named there to
1464 # state 'Needs-Build'.
1465 sub parse_quinn_diff {
1466 my $partial = shift;
1472 next if !m,^([-\w\d/]*)/ # section
1473 ([-\w\d.+]+)_ # package name
1474 ([\w\d:.~+-]+)\.dsc\s* # version
1475 \[([^:]*): # priority
1476 ([^]]+)\]\s*$,x; # rest of notes
1477 my($section,$name,$version,$priority,$notes) = ($1, $2, $3, $4, $5);
1478 $quinn_pkgs{$name}++;
1479 $section ||= "unknown";
1480 $priority ||= "unknown";
1481 $priority = "unknown" if $priority eq "-";
1482 $priority = "standard" if ($name eq "debian-installer");
1484 my $pkg = $db{$name};
1486 # Always update section and priority.
1487 if (defined($pkg)) {
1489 $pkg->{'Section'} = $section, $change++ if not defined
1490 $pkg->{'Section'} or $section ne "unknown";
1491 $pkg->{'Priority'} = $priority, $change++ if not defined
1492 $pkg->{'Priority'} or $priority ne "unknown";
1495 if (defined($pkg) &&
1496 $pkg->{'State'} =~ /^Dep-Wait/ &&
1497 version_less( $pkg->{'Version'}, $version )) {
1498 change_state( \$pkg, 'Dep-Wait' );
1499 $pkg->{'Version'} = $version;
1500 delete $pkg->{'Binary-NMU-Version'};
1501 delete $pkg->{'Binary-NMU-Changelog'};
1502 log_ta( $pkg, "--merge-quinn" );
1504 print "$name ($version) still waiting for dependencies.\n"
1507 elsif (defined($pkg) &&
1508 $pkg->{'State'} =~ /-Removed$/ &&
1509 version_eq($pkg->{'Version'}, $version)) {
1510 # reinstantiate a package that has been removed earlier
1511 # (probably due to a quinn-diff malfunction...)
1512 my $newstate = $pkg->{'State'};
1513 $newstate =~ s/-Removed$//;
1514 change_state( \$pkg, $newstate );
1515 $pkg->{'Version'} = $version;
1516 $pkg->{'Notes'} = $notes;
1517 log_ta( $pkg, "--merge-quinn" );
1519 print "$name ($version) reinstantiated to $newstate.\n"
1522 elsif (defined($pkg) &&
1523 $pkg->{'State'} eq "Not-For-Us" &&
1524 version_less( $pkg->{'Version'}, $version )) {
1525 # for Not-For-Us packages just update the version etc., but
1527 change_state( \$pkg, "Not-For-Us" );
1528 $pkg->{'Package'} = $name;
1529 $pkg->{'Version'} = $version;
1530 $pkg->{'Notes'} = $notes;
1531 delete $pkg->{'Builder'};
1532 log_ta( $pkg, "--merge-quinn" );
1534 print "$name ($version) still Not-For-Us.\n" if $verbose;
1536 elsif (!defined($pkg) ||
1537 $pkg->{'State'} ne "Not-For-Us" &&
1538 (version_less( $pkg->{'Version'}, $version ) ||
1539 ($pkg->{'State'} eq "Installed" && version_less($pkg->{'Installed-Version'}, $version)))) {
1541 if (defined( $pkg->{'State'} ) && isin( $pkg->{'State'}, qw(Building Built Build-Attempted))) {
1542 send_mail( $pkg->{'Builder'},
1543 "new version of $name (dist=$distribution)",
1544 "As far as I'm informed, you're currently ".
1545 "building the package $name\n".
1546 "in version $pkg->{'Version'}.\n\n".
1547 "Now there's a new source version $version. ".
1548 "If you haven't finished\n".
1549 "compiling $name yet, you can stop it to ".
1550 "save some work.\n".
1551 "Just to inform you...\n".
1552 "(This is an automated message)\n" );
1553 print "$name: new version ($version) while building ".
1554 "$pkg->{'Version'} -- sending mail ".
1555 "to builder ($pkg->{'Builder'})\n"
1558 change_state( \$pkg, 'Needs-Build' );
1559 $pkg->{'Package'} = $name;
1560 $pkg->{'Version'} = $version;
1561 $pkg->{'Section'} = $section;
1562 $pkg->{'Priority'} = $priority;
1563 $pkg->{'Notes'} = $notes;
1564 delete $pkg->{'Builder'};
1565 delete $pkg->{'Binary-NMU-Version'};
1566 delete $pkg->{'Binary-NMU-Changelog'};
1567 log_ta( $pkg, "--merge-quinn" );
1570 print "$name ($version) needs rebuilding now.\n" if $verbose;
1572 elsif (defined($pkg) &&
1573 !version_eq( $pkg->{'Version'}, $version ) &&
1574 isin( $pkg->{'State'}, qw(Installed Not-For-Us) )) {
1575 print "$name: skipping because version in db ".
1576 "($pkg->{'Version'}) is >> than ".
1577 "what quinn-diff says ($version) ".
1578 "(state is $pkg->{'State'})\n"
1580 $dubious .= "$pkg->{'State'}: ".
1581 "db ${name}_$pkg->{'Version'} >> ".
1582 "quinn $version\n" if !$partial;
1584 elsif ($verbose >= 2) {
1585 if ($pkg->{'State'} eq "Not-For-Us") {
1586 print "Skipping $name because State == ".
1587 "$pkg->{'State'}\n";
1589 elsif (!version_less($pkg->{'Version'}, $version)) {
1590 print "Skipping $name because version in db ".
1591 "($pkg->{'Version'}) is >= than ".
1592 "what quinn-diff says ($version)\n";
1595 $db{$name} = $pkg if $change;
1599 send_mail( $conf::db_maint,
1600 "Dubious versions in $distribution $conf::dbbase database",
1601 "The following packages have a newer version in the ".
1602 "wanna-build database\n".
1603 "than what quinn-diff says, and this is strange for ".
1605 "It could be caused by a lame mirror, or the version ".
1606 "in the database\n".
1611 # Now re-check the DB for packages in states Needs-Build, Failed,
1612 # or Dep-Wait and remove them if they're not listed anymore by quinn-diff.
1615 foreach $name (keys %db) {
1616 next if $name =~ /^_/;
1617 my $pkg = $db{$name};
1618 next if defined $pkg->{'Binary-NMU-Version'};
1619 next if !isin( $pkg->{'State'},
1620 qw(Needs-Build Building Built Build-Attempted Uploaded Failed Dep-Wait) );
1621 my $virtual_delete = $pkg->{'State'} eq 'Failed';
1623 if (!$quinn_pkgs{$name}) {
1624 change_state( \$pkg, $virtual_delete ?
1625 $pkg->{'State'}."-Removed" :
1627 log_ta( $pkg, "--merge-quinn" );
1628 print "$name ($pkg->{'Version'}): ".
1629 ($virtual_delete ? "(virtually) " : "") . "deleted ".
1630 "from database, because not in quinn-diff anymore\n"
1632 if ($virtual_delete) {
1642 sub send_reupload_mail {
1645 my $version = shift;
1647 my $other_dist = shift;
1650 "Please reupload ${pkg}_${'Version'} for $dist",
1651 "You have recently built (or are currently building)\n".
1652 "${pkg}_${'Version'} for $other_dist.\n".
1653 "This version is now also needed in the $dist distribution.\n".
1654 "Please reupload the files now present in the Debian archive\n".
1655 "(best with buildd-reupload).\n" );
1659 # for sorting priorities and sections
1661 %prioval = ( required => -5,
1669 'debian-installer' => -199,
1690 localizations => -178,
1691 interpreters => -177,
1716 electronics => -152,
1722 foreach my $i (keys %sectval) {
1723 $sectval{"contrib/$i"} = $sectval{$i}+40;
1724 $sectval{"non-free/$i"} = $sectval{$i}+80;
1726 $sectval{'unknown'} = -165;
1728 %catval = ( "none" => -20,
1729 "uploaded-fixed-pkg" => -19,
1730 "fix-expected" => -18,
1731 "reminder-sent" => -17,
1732 "nmu-offered" => -16,
1736 "compiler-error" => -12 );
1739 sub sort_list_func {
1740 my( $letter, $x, $ax, $bx );
1742 foreach $letter (split( "", $list_order )) {
1743 SWITCH: foreach ($letter) {
1745 $x = $b->{'BuildPri'} <=> $a->{'BuildPri'};
1746 return $x if $x != 0;
1750 $x = $prioval{$a->{'Priority'}} <=> $prioval{$b->{'Priority'}};
1751 return $x if $x != 0;
1755 $x = $sectval{$a->{'Section'}} <=> $sectval{$b->{'Section'}};
1756 return $x if $x != 0;
1760 $x = $a->{'Package'} cmp $b->{'Package'};
1761 return $x if $x != 0;
1765 $x = $a->{'Builder'} cmp $b->{'Builder'};
1766 return $x if $x != 0;
1770 $ax = ($a->{'Notes'} =~ /^(out-of-date|partial)/) ? 0 :
1771 ($a->{'Notes'} =~ /^uncompiled/) ? 2 : 1;
1772 $bx = ($b->{'Notes'} =~ /^(out-of-date|partial)/) ? 0 :
1773 ($b->{'Notes'} =~ /^uncompiled/) ? 2 : 1;
1775 return $x if $x != 0;
1779 my $ca = exists $a->{'Failed-Category'} ?
1780 $a->{'Failed-Category'} : "none";
1781 my $cb = exists $b->{'Failed-Category'} ?
1782 $b->{'Failed-Category'} : "none";
1783 $x = $catval{$ca} <=> $catval{$cb};
1784 return $x if $x != 0;
1788 my $pa = $prioval{$a->{'Priority'}} >
1789 $prioval{'standard'};
1790 my $pb = $prioval{$b->{'Priority'}} >
1791 $prioval{'standard'};
1793 return $x if $x != 0;
1803 my( $name, $pkg, @list );
1808 foreach $name (keys %db) {
1809 next if $name =~ /^_/;
1811 next if $state ne "all" && $pkg->{'State'} !~ /^\Q$state\E$/i;
1812 next if $user && (lc($state) ne 'needs-build' and $pkg->{'Builder'} ne $user);
1813 next if $category && $pkg->{'State'} eq "Failed" &&
1814 $pkg->{'Failed-Category'} ne $category;
1815 next if ($list_min_age > 0 &&
1816 ($ctime-parse_date($pkg->{'State-Change'})) < $list_min_age)||
1817 ($list_min_age < 0 &&
1818 ($ctime-parse_date($pkg->{'State-Change'})) > -$list_min_age);
1819 push( @list, $pkg );
1822 foreach $pkg (sort sort_list_func @list) {
1823 print "$pkg->{'Section'}/$pkg->{'Package'}_$pkg->{'Version'}";
1824 print ": $pkg->{'State'}"
1826 print " by $pkg->{'Builder'}"
1827 if $pkg->{'State'} ne "Needs-Build" && $pkg->{'Builder'};
1828 print " [$pkg->{'Priority'}:$pkg->{'Notes'}";
1829 print ":PREV-FAILED"
1830 if $pkg->{'Previous-State'} =~ /^Failed/;
1831 print ":bp{" . $pkg->{'BuildPri'} . "}"
1832 if exists $pkg->{'BuildPri'};
1833 print ":binNMU{" . $pkg->{'Binary-NMU-Version'} . "}"
1834 if exists $pkg->{'Binary-NMU-Version'};
1836 print " Reasons for failing:\n",
1838 exists $pkg->{'Failed-Category'} ? $pkg->{'Failed-Category'} : "none",
1840 join("\n ",split("\n",$pkg->{'Failed'})), "\n"
1841 if $pkg->{'State'} =~ /^Failed/;
1842 print " Dependencies: $pkg->{'Depends'}\n"
1843 if $pkg->{'State'} eq "Dep-Wait";
1844 print " Previous state was $pkg->{'Previous-State'} until ",
1845 "$pkg->{'State-Change'}\n"
1846 if $verbose && $pkg->{'Previous-State'};
1847 print " Previous failing reasons:\n ",
1848 join("\n ",split("\n",$pkg->{'Old-Failed'})), "\n"
1849 if $verbose && $pkg->{'Old-Failed'};
1851 $scnt{$pkg->{'State'}}++ if $state eq "all";
1853 if ($state eq "all") {
1854 foreach (sort keys %scnt) {
1855 print "Total $scnt{$_} package(s) in state $_.\n";
1858 print "Total $cnt package(s)\n";
1863 my( $name, $pkg, $key, $dist );
1864 my @firstkeys = qw(Package Version Builder State Section Priority
1865 Installed-Version Previous-State State-Change);
1866 my @dists = $info_all_dists ? keys %conf::distributions : ($distribution);
1868 foreach $dist (@dists) {
1869 if ($dist ne $distribution) {
1870 if (!-f db_filename( $dist ) || !open_other_db( $dist )) {
1871 warn "Cannot open database for $dist!\n";
1872 @dists = grep { $_ ne $dist } @dists;
1877 foreach $name (@_) {
1878 $name =~ s/_.*$//; # strip version
1879 foreach $dist (@dists) {
1880 my $db = $dist ne $distribution ? $otherdb{$dist} : \%db;
1881 my $pname = "$name" . ($info_all_dists ? "($dist)" : "");
1883 $pkg = $db->{$name};
1884 if (!defined( $pkg )) {
1885 print "$pname: not registered\n";
1890 foreach $key (@firstkeys) {
1891 next if !exists $pkg->{$key};
1892 my $val = $pkg->{$key};
1894 $val = "\n$val" if isin( $key, qw(Failed Old-Failed));
1896 printf " %-20s: %s\n", $key, $val;
1898 foreach $key (sort keys %$pkg) {
1899 next if isin( $key, @firstkeys );
1900 my $val = $pkg->{$key};
1902 $val = "\n$val" if isin( $key, qw(Failed Old-Failed));
1904 printf " %-20s: %s\n", $key, $val;
1910 sub forget_packages {
1911 my( $name, $pkg, $key, $data );
1913 foreach $name (@_) {
1914 $name =~ s/_.*$//; # strip version
1916 if (!defined( $pkg )) {
1917 print "$name: not registered\n";
1922 foreach $key (sort keys %$pkg) {
1923 my $val = $pkg->{$key};
1926 $data .= sprintf " %-20s: %s\n", $key, $val;
1928 send_mail( $conf::db_maint,
1929 "$name deleted from DB $conf::dbbase",
1930 "The package '$name' has been deleted from the database ".
1932 "Data registered about the deleted package:\n".
1933 "$data\n" ) if $conf::db_maint;
1934 change_state( \$pkg, 'deleted' );
1935 log_ta( $pkg, "--forget" );
1937 print "$name: deleted from database\n" if $verbose;
1945 $ui = $db{'_userinfo'};
1946 foreach $name (@_) {
1947 if (!defined( $ui->{$name} )) {
1948 print "$name: not registered\n";
1952 delete $ui->{$name};
1954 print "$name: deleted from database\n" if $verbose;
1956 $db{'_userinfo'} = $ui if $change;
1962 my $lockfile = db_filename($dist) . ".lock";
1965 print "Locking $dist database\n" if $verbose >= 2;
1967 if (!sysopen( F, $lockfile, O_WRONLY|O_CREAT|O_TRUNC|O_EXCL, 0644 )){
1969 # lock file exists, wait
1970 goto repeat if !open( F, "<$lockfile" );
1973 if ($line !~ /^(\d+)\s+([\w\d.-]+)$/) {
1974 warn "Bad lock file contents -- still trying\n";
1977 my($pid, $usr) = ($1, $2);
1978 if (kill( 0, $pid ) == 0 && $! == ESRCH) {
1979 # process doesn't exist anymore, remove stale lock
1980 print "Removing stale lock file (pid $pid, user $usr)\n";
1981 unlink( $lockfile );
1984 if ($pid == $lock_for_pid) {
1985 # We are allowed to use this lock.
1988 warn "Database locked by $usr -- please wait\n" if $try == 0;
1991 # avoid the END routine removes the lock
1992 $main::keep_lock{$dist} = 1;
1993 die "Lock still present after 200 * 5 seconds.\n";
1998 die "Can't create lock file $lockfile: $!\n";
2000 my $pid = $lock_for_pid == -1 ? $$ : $lock_for_pid;
2001 F->print("$pid $real_user\n");
2007 my $lockfile = db_filename($dist) . ".lock";
2009 if (!$main::keep_lock{$dist}) {
2010 print "Unlocking $dist database\n" if $verbose >= 2;
2015 sub create_maintlock {
2016 my $lockfile = db_filename("maintenance") . ".lock";
2020 print "Creating maintenance lock\n" if $verbose >= 2;
2022 if (!sysopen( F, $lockfile, O_WRONLY|O_CREAT|O_TRUNC|O_EXCL, 0644 )){
2024 # lock file exists, wait
2025 goto repeat if !open( F, "<$lockfile" );
2028 if ($line !~ /^(\d+)\s+([\w\d.-]+)$/) {
2029 warn "Bad maintenance lock file contents -- still trying\n";
2032 my($pid, $usr) = ($1, $2);
2033 if (kill( 0, $pid ) == 0 && $! == ESRCH) {
2034 # process doesn't exist anymore, remove stale lock
2035 print "Removing stale lock file (pid $pid, user $usr)\n";
2036 unlink( $lockfile );
2039 warn "Maintenance lock already exists by $usr -- ".
2040 "please wait\n" if $try == 0;
2043 die "Lock still present after 120 * 60 seconds.\n";
2048 die "Can't create maintenance lock $lockfile: $!\n";
2050 F->print(getppid(), " $real_user\n");
2054 sub remove_maintlock {
2055 my $lockfile = db_filename("maintenance") . ".lock";
2057 print "Removing maintenance lock\n" if $verbose >= 2;
2061 sub waitfor_maintlock {
2062 my $lockfile = db_filename("maintenance") . ".lock";
2066 print "Checking for maintenance lock\n" if $verbose >= 2;
2068 if (open( F, "<$lockfile" )) {
2071 if ($line !~ /^(\d+)\s+([\w\d.-]+)$/) {
2072 warn "Bad maintenance lock file contents -- still trying\n";
2075 my($pid, $usr) = ($1, $2);
2076 if (kill( 0, $pid ) == 0 && $! == ESRCH) {
2077 # process doesn't exist anymore, remove stale lock
2078 print "Removing stale maintenance lock (pid $pid, user $usr)\n";
2079 unlink( $lockfile );
2082 warn "Databases locked for general maintenance by $usr -- ".
2083 "please wait\n" if $try == 0;
2086 die "Lock still present after 120 * 60 seconds.\n";
2097 print "Reading ASCII database from $file..." if $verbose >= 1;
2098 open( F, "<$file" ) or
2099 die "Can't open database $file: $!\n";
2101 local($/) = ""; # read in paragraph mode
2103 my( %thispkg, $name );
2105 s/\n[ \t]+/\376\377/g; # fix continuation lines
2106 s/\376\377\s*\376\377/\376\377/og;
2108 while( /^(\S+):[ \t]*(.*)[ \t]*$/mg ) {
2109 my ($key, $val) = ($1, $2);
2110 $val =~ s/\376\377/\n/g;
2111 $thispkg{$key} = $val;
2113 check_entry( \%thispkg );
2115 if (exists($thispkg{'Package'})) {
2116 $name = $thispkg{'Package'};
2117 $db{$name} = \%thispkg;
2119 elsif(exists($thispkg{'User'})) {
2120 my $userinfo = $db{'_userinfo'};
2121 $userinfo = {} if (!defined($userinfo));
2123 $name = $thispkg{'User'};
2124 $userinfo->{$name} = \%thispkg;
2126 $db{'_userinfo'} = $userinfo;
2130 print "done\n" if $verbose >= 1;
2137 return if $op_mode eq "manual-edit"; # no checks then
2139 # check for required fields
2140 if (exists $pkg->{'User'}) {
2143 if (!exists $pkg->{'Package'}) {
2144 print STDERR "Bad entry: ",
2145 join( "\n", map { "$_: $pkg->{$_}" } keys %$pkg ), "\n";
2146 die "Database entry lacks Package or User: field\n";
2148 if (!exists $pkg->{'Version'}) {
2149 die "Database entry for $pkg->{'Package'} lacks Version: field\n";
2151 # if no State: field, generate one (for old db compat)
2152 if (!exists($pkg->{'State'})) {
2154 exists $pkg->{'Failed'} ? 'Failed' : 'Building';
2157 die "Bad state $pkg->{'State'} of package $pkg->{Package}\n"
2158 if !isin( $pkg->{'State'},
2159 qw(Needs-Build Building Built Build-Attempted Uploaded Installed Dep-Wait
2160 Failed Failed-Removed Not-For-Us
2166 my($name,$pkg,$key);
2168 print "Writing ASCII database to $file..." if $verbose >= 1;
2169 open( F, ">$file" ) or
2170 die "Can't open database $file: $!\n";
2172 foreach $name (sort keys %db) {
2173 my $pkg = $db{$name};
2174 if ($name eq '_userinfo') {
2175 foreach $user (sort keys %{$pkg}) {
2176 my $ui = $pkg->{$user};
2177 print F "User: $user\n"
2178 if (!defined($ui->{'User'}));
2179 foreach $key (keys %{$ui}) {
2180 my $val = $ui->{$key};
2183 print F "$key: $val\n";
2189 foreach $key (keys %{$pkg}) {
2190 my $val = $pkg->{$key};
2193 print F "$key: $val\n";
2199 print "done\n" if $verbose >= 1;
2205 my $newstate = shift;
2206 my $for_dist = shift;
2209 return if !open_other_db( $for_dist );
2210 $db = $otherdb{$for_dist};
2211 $pkg = \$db{$pkg->{'Package'}};
2216 my $state = \$pkg->{'State'};
2218 return if defined($$state) and $$state eq $newstate;
2219 $pkg->{'Previous-State'} = $$state if defined($$state);
2220 $pkg->{'State-Change'} = $curr_date;
2222 if (defined($$state) and $$state eq 'Failed') {
2223 $pkg->{'Old-Failed'} =
2224 "-"x20 . " $pkg->{'Version'} " . "-"x20 . "\n" .
2225 $pkg->{'Failed'} . "\n" .
2226 $pkg->{'Old-Failed'};
2227 delete $pkg->{'Failed'};
2228 delete $pkg->{'Failed-Category'};
2230 $$state = $newstate;
2236 if (!tied(%{$otherdb{$dist}})) {
2238 $otherdb_lock{$dist} = 1;
2239 if (!(tie %{$otherdb{$dist}}, 'MLDBM', db_filename($dist), 0, 0664)){
2240 warn "Serious warning: Cannot open database for $dist\n";
2242 $otherdb_lock{$dist} = 0;
2253 my $dist = $distribution;
2257 $prevstate = $pkg->{'Previous-State'};
2258 $str = "$action($dist): $pkg->{'Package'}_$pkg->{'Version'} ".
2259 "changed from $prevstate to $pkg->{'State'} ".
2260 "by $real_user as $user";
2262 if (!open( LOG, ">>$transactlog" )) {
2263 warn "Can't open log file $transactlog: $!\n";
2266 print LOG "$curr_date: $str\n";
2269 if (!($prevstate eq 'Failed' && $pkg->{'State'} eq 'Failed')) {
2270 $str .= " (with --override)"
2272 $mail_logs .= "$str\n";
2279 my $subject = shift;
2282 my $from = $conf::db_maint;
2283 my $domain = $conf::buildd_domain;
2285 $from .= "\@$domain" if $from !~ /\@/;
2287 $to .= '@' . $domain if $to !~ /\@/;
2288 $text =~ s/^\.$/../mg;
2289 local $SIG{'PIPE'} = 'IGNORE';
2290 open( PIPE, "| $conf::mailprog -oem $to" )
2291 or die "Can't open pipe to $conf::mailprog: $!\n";
2293 print PIPE "From: $from\n";
2294 print PIPE "Subject: $subject\n\n";
2295 print PIPE "$text\n";
2301 return $transactional ? db_filename_transaction($dist) : db_filename_master($dist);
2304 sub db_filename_master {
2306 return "$conf::basedir/$conf::dbbase-$dist";
2308 sub db_filename_transaction {
2310 return "$conf::basedir/$conf::dbbase-$dist-transaction";
2313 # for parsing input to dep-wait
2319 foreach (split( /\s*,\s*/, $deps )) {
2321 # verification requires > starting prompts, no | crap
2322 if (!/^(\S+)\s*(\(\s*(>(?:[>=])?)\s*(\S+)\s*\))?\s*$/) {
2327 my @alts = split( /\s*\|\s*/, $_ );
2328 # Anything with an | is ignored, as it can be configured on a
2329 # per-buildd basis what will be installed
2330 next if $#alts != 0;
2333 if (!/^(\S+)\s*(\(\s*(>=|=|==|>|>>|<<|<=)\s*(\S+)\s*\))?\s*$/) {
2334 warn( "parse_deplist: bad dependency $_\n" );
2337 my($dep, $rel, $relv) = ($1, $3, $4);
2338 $rel = ">>" if defined($rel) and $rel eq ">";
2339 $result{$dep}->{'Package'} = $dep;
2340 if ($rel && $relv) {
2341 $result{$dep}->{'Rel'} = $rel;
2342 $result{$dep}->{'Version'} = $relv;
2345 return 1 if $verify;
2349 # for parsing Build-Depends from Sources
2350 sub parse_srcdeplist {
2357 foreach $dep (split( /\s*,\s*/, $deps )) {
2358 my @alts = split( /\s*\|\s*/, $dep );
2359 # Anything with an | is ignored, as it can be configured on a
2360 # per-buildd basis what will be installed
2361 next if $#alts != 0;
2363 if (!/^([^\s([]+)\s*(\(\s*([<=>]+)\s*(\S+)\s*\))?(\s*\[([^]]+)\])?/) {
2364 warn( "parse_srcdeplist: bad dependency $_\n" );
2367 my($dep, $rel, $relv, $archlist) = ($1, $3, $4, $6);
2369 $archlist =~ s/^\s*(.*)\s*$/$1/;
2370 my @archs = split( /\s+/, $archlist );
2371 my ($use_it, $ignore_it, $include) = (0, 0, 0);
2374 $ignore_it = 1 if substr($_, 1) eq $arch;
2376 $use_it = 1 if $_ eq $arch;
2380 warn "Warning: inconsistent arch restriction on ",
2381 "$pkg: $dep depedency\n"
2382 if $ignore_it && $use_it;
2383 next if $ignore_it || ($include && !$use_it);
2391 $result->{'Package'} = $dep;
2392 $result->{'Neg'} = $neg;
2393 if ($rel && $relv) {
2394 $result->{'Rel'} = $rel;
2395 $result->{'Version'} = $relv;
2397 push @results, $result;
2406 foreach $key (keys %$list) {
2407 $result .= ", " if $result;
2409 $result .= " ($list->{$key}->{'Rel'} $list->{$key}->{'Version'})"
2410 if $list->{$key}->{'Rel'} && $list->{$key}->{'Version'};
2417 tie %new_db, 'MLDBM', db_filename( $distribution ) . ".new", GDBM_WRCREAT, 0664
2418 or die "FATAL: Cannot create new database\n";
2420 untie %db or die "FATAL: Cannot untie old database\n";
2421 system ("cp " . db_filename( $distribution ) . ".new " .
2422 db_filename( $distribution ) ) == 0
2423 or die "FATAL: Cannot overwrite old database";
2424 unlink db_filename( $distribution ) . ".new";
2429 sub get_unsatisfied_dep {
2433 my $savedep = shift;
2435 my $pkgname = $dep->{'Package'};
2437 if (defined $pkgs->{$pkgname}{'Provider'}) {
2438 # provides. leave them for buildd/sbuild.
2443 return $pkgs->{$pkgname}{'Unsatisfied'} if $savedep and defined($pkgs->{$pkgname}{'Unsatisfied'});
2445 # Return unsatisfied deps to a higher caller to process
2446 if ((!defined($pkgs->{$pkgname})) or
2447 (defined($dep->{'Rel'}) and !version_compare( $pkgs->{$pkgname}{'Version'}, $dep->{'Rel'}, $dep->{'Version'} ) ) ) {
2449 $deplist{$pkgname} = $dep;
2450 my $deps = build_deplist(\%deplist);
2451 $pkgs->{$pkgname}{'Unsatisfied'} = $deps if $savedep;
2455 # set cache to "" to avoid infinite recursion
2456 $pkgs->{$pkgname}{'Unsatisfied'} = "" if $savedep;
2458 if (defined $pkgs->{$dep->{'Package'}}{'Depends'}) {
2459 my $deps = parse_deplist( $pkgs->{$dep->{'Package'}}{'Depends'} );
2460 foreach (keys %$deps) {
2463 my $ret = get_unsatisfied_dep($bd,$pkgs,$dep,1);
2465 my $retdep = parse_deplist( $ret );
2466 foreach (keys %$retdep) {
2467 $dep = $$retdep{$_};
2469 $dep->{'Rel'} = '>=' if defined($dep->{'Rel'}) and $dep->{'Rel'} =~ '^=';
2471 if (defined($dep->{'Rel'}) and $dep->{'Rel'} =~ '^>' and defined ($pkgs->{$dep->{'Package'}}) and
2472 version_compare($bd->{$pkgs->{$dep->{'Package'}}{'Source'}}{'ver'},'>>',$pkgs->{$dep->{'Package'}}{'Sourcev'})) {
2473 if (not defined($merge_binsrc{$dep->{'Package'}})) {
2474 # the uninstallable package doesn't exist in the new source; look for something else that does.
2475 delete $$retdep{$dep->{'Package'}};
2476 foreach (sort (split( /\s*,\s*/, $bd->{$pkgs->{$dep->{'Package'}}{'Source'}}{'bin'}))) {
2477 next if ($pkgs->{$_}{'all'} or not defined $pkgs->{$_}{'Version'});
2478 $dep->{'Package'} = $_;
2479 $dep->{'Rel'} = '>>';
2480 $dep->{'Version'} = $pkgs->{$_}{'Version'};
2481 $$retdep{$_} = $dep;
2486 # sanity check to make sure the depending binary still exists, and the depended binary exists and dep-wait on a new version of it
2487 if ( defined($merge_binsrc{$pkgname}) and defined($pkgs->{$dep->{'Package'}}{'Version'}) ) {
2488 delete $$retdep{$dep->{'Package'}};
2489 $dep->{'Package'} = $pkgname;
2490 $dep->{'Rel'} = '>>';
2491 $dep->{'Version'} = $pkgs->{$pkgname}{'Version'};
2492 $$retdep{$pkgname} = $dep;
2494 delete $$retdep{$dep->{'Package'}} if (defined ($dep->{'Rel'}) and $dep->{'Rel'} =~ '^>');
2497 $ret = build_deplist($retdep);
2498 $pkgs->{$pkgname}{'Unsatisfied'} = $ret if $savedep;
2511 return if defined ($conf::distributions{$distribution}{noadw});
2513 # We need to walk all of needs-build, as any new upload could make
2514 # something in needs-build have uninstallable deps
2515 foreach $key (keys %db) {
2516 my $pkg = $db{$key};
2518 if not defined $pkg or $pkg->{'State'} ne "Needs-Build";
2519 my $srcdeps = parse_srcdeplist($key,$bd->{$key}{'dep'},$arch);
2520 foreach my $srcdep (@$srcdeps) {
2521 next if $srcdep->{'Neg'} != 0; # we ignore conflicts atm
2522 my $rc = get_unsatisfied_dep($bd,$pkgs,$srcdep,0);
2525 my $deplist = parse_deplist( $pkg->{'Depends'} );
2526 my $newdeps = parse_deplist( $rc );
2528 foreach (%$newdeps) {
2529 my $dep = $$newdeps{$_};
2530 # ensure we're not waiting on ourselves, or a package that has been removed
2531 next if (not defined($merge_binsrc{$dep->{'Package'}})) or ($merge_binsrc{$dep->{'Package'}} eq $key);
2532 if ($dep->{'Rel'} =~ '^>') {
2533 $deplist->{$dep->{'Package'}} = $dep;
2538 $pkg->{'Depends'} = build_deplist($deplist);
2539 change_state( \$pkg, 'Dep-Wait' );
2540 log_ta( $pkg, "--merge-all" );
2542 print "Auto-Dep-Waiting ${key}_$pkg->{'Version'} to $pkg->{'Depends'}\n" if $verbose;
2552 ($prgname = $0) =~ s,^.*/,,;
2554 Usage: $prgname <options...> <package_version...>
2556 -v, --verbose: Verbose execution.
2557 --take: Take package for building [default operation]
2558 -f, --failed: Record in database that a build failed due to
2559 deficiencies in the package (that aren't fixable without a new
2561 -u, --uploaded: Record in the database that the packages build
2562 correctly and were uploaded.
2563 -n, --no-build: Record in the database that the packages aren't
2564 desired for this architecture and shouldn't appear in listings even
2565 if they're out of date.
2566 --dep-wait: Record in the database that the packages are waiting
2567 for some source dependencies to become available
2568 --binNMU num: Schedule a re-build of the package with unchanged source, but
2569 a new version number (source-version + "+b<num>")
2570 --merge-quinn: Merge quinn-diff output into database.
2571 --merge-packages: Merge Packages files into database.
2572 --pretend-avail: Pretend that given packages are available now and give
2573 free packages waiting for them
2574 -i SRC_PKG, --info SRC_PKG: Show information for source package
2575 -l STATE, --list=STATE: List all packages in state STATE; can be
2576 combined with -U to restrict to a specific user; STATE can
2578 -m MESSAGE, --message=MESSAGE: Give reason why package failed or
2579 source dependency list
2580 (used with -f, --dep-wait, and --binNMU)
2581 -o, --override: Override another user's lock on a package, i.e.
2582 take it over; a notice mail will be sent to the other user
2583 -U USER, --user=USER: select user name for which listings should
2584 apply, if not given all users are listed.
2585 if -l is missing, set user name to be entered in db; usually
2586 automatically choosen
2587 --import FILE: Import database from a ASCII file FILE
2588 --export FILE: Export database to a ASCII file FILE
2589 --lock-for PID: Locks the database for the process with this pid
2590 --unlock-for PID: Unlocks the database for the process with this pid
2591 --act-on-behalve-of PID: Ignores the log (if it is held by this pid)
2592 --start-transaction: Creates a copy of the state of the database, for
2593 use with --transactional. This overrides any previous uncommited
2594 transaction. Should only be used after --lock-for
2595 --commit-transaction: Atomically moves the copy back to the main, thus
2596 commiting the changes
2597 --transactional: Flag to indicate that we want to work on the copy
2599 The remaining arguments (depending on operation) usually start with
2600 "name_version", the trailer is ignored. This allows to pass the names
2601 of .dsc files, for which file name completion can be used.
2602 --merge-packages and --merge-quinn take Package/quin--diff file names
2603 on the command line or read stdin. --list needs nothing more on the
2604 command line. --info takes source package names (without version).
2609 sub pkg_version_eq {
2611 my $version = shift;
2614 if (defined $pkg->{'Binary-NMU-Version'}) and
2615 version_compare(binNMU_version($pkg->{'Version'},
2616 $pkg->{'Binary-NMU-Version'}),'=', $version);
2617 return version_compare( $pkg->{'Version'}, "=", $version );