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";
25 $dbbase ||= "build-db";
26 $transactlog ||= "transactions.log";
27 $mailprog ||= "/usr/sbin/sendmail";
28 require "/org/wanna-build/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 lib '/org/wanna-build/bin';
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, $opt_create_db,
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);
55 $ENV{'PATH'} = "/bin:/usr/bin:/usr/local/bin:/org/wanna-build/bin/";
59 $curr_date = strftime("%Y %b %d %H:%M:%S",@curr_time);
60 $short_date = strftime("%m/%d/%y",@curr_time);
63 # map program invocation names to operation modes
64 my %prognames = ( "uploaded-build" => "set-uploaded",
65 "failed-build" => "set-failed",
66 "no-build" => "set-not-for-us",
67 "give-back-build" => "set-needs-build",
68 "dep-wait-build" => "set-dep-wait",
69 "forget-build" => "forget",
70 "merge-quinn" => "merge-quinn",
71 "merge-packages" => "merge-packages",
72 "merge-sources" => "merge-sources",
73 "build-info" => "info" );
75 %short_category = ( u => "uploaded-fixed-pkg",
82 c => "compiler-error",
86 ($progname = $0) =~ s,.*/,,;
87 if ($prognames{$progname}) {
88 $op_mode = $prognames{$progname};
90 elsif ($progname =~ /^list-(.*)$/) {
92 $list_state = ($1 eq "all") ? "" : $1;
97 verbose => { short => "v", flag => \$verbose },
98 override => { short => "o", flag => \$opt_override },
99 "create-db" => { flag => \$opt_create_db },
100 "correct-compare" => { flag => \$WannaBuild::opt_correct_version_cmp },
101 # TODO: remove after buildds no longer pass to wanna-build
102 "no-propagation" => { short => "N" },
103 "no-down-propagation" => { short => "D" },
105 take => { mode => "set-building" },
106 failed => { short => "f", mode => "set-failed" },
107 uploaded => { short => "u", mode => "set-uploaded" },
108 "no-build" => { short => "n", mode => "set-not-for-us" },
109 built => { mode => "set-built" },
110 attempted => { mode => "set-attempted" },
111 "give-back" => { mode => "set-needs-build" },
112 "dep-wait" => { mode => "set-dep-wait" },
113 forget => { mode => "forget" },
114 'forget-user' => { mode => 'forget-user' },
115 "merge-quinn" => { mode => "merge-quinn" },
116 "merge-partial-quinn" => { mode => "merge-partial-quinn" },
117 "merge-packages" => { mode => "merge-packages" },
118 "merge-sources" => { mode => "merge-sources" },
119 "pretend-avail" => { short => "p", mode => "pretend-avail" },
120 "merge-all" => { mode => "merge-all" },
121 info => { short => "i", mode => "info" },
122 'binNMU' => { mode => 'set-binary-nmu', arg => \$binNMUver,
123 code => sub { die "Invalid binNMU version: $binNMUver\n"
124 if $binNMUver !~ /^([\d]*)$/ and $1 >= 0; } },
125 'perm-build-priority' => { mode => "set-permanent-build-priority", arg => \$build_priority,
126 code => sub { die "Invalid build priority: $build_priority\n"
127 if $build_priority !~ /^-?[\d]+$/; } },
128 'build-priority' => { mode => "set-build-priority", arg => \$build_priority,
129 code => sub { die "Invalid build priority: $build_priority\n"
130 if $build_priority !~ /^-?[\d]+$/; } },
132 { short => "l", mode => "list", arg => \$list_state,
134 die "Unknown state to list: $list_state\n"
135 if !isin( $list_state, qw(needs-build building uploaded
136 built build-attempted failed installed dep-wait
137 not-for-us all failed-removed
138 install-wait reupload-wait bd-uninstallable));} },
141 { short => "d", arg => \$distribution,
143 if ($distribution eq "a" || $distribution eq "all") {
148 $distribution = "oldstable" if $distribution eq "o";
149 $distribution = "stable" if $distribution eq "s";
150 $distribution = "testing" if $distribution eq "t";
151 $distribution = "unstable" if $distribution eq "u";
155 { short => "O", arg => \$list_order,
157 die "Bad ordering character\n"
158 if $list_order !~ /^[PSpsncb]+$/;
160 message => { short => "m", arg => \$fail_reason },
161 # database is deprecated, use arch instead.
162 database => { short => "b", arg => \$conf::dbbase },
163 arch => { short => "A", arg => \$arch },
164 user => { short => "U", arg => \$user },
165 category => { short => "c", arg => \$category,
167 $category = $short_category{$category}
168 if exists $short_category{$category};
169 die "Unknown category: $category\n"
170 if !isin( $category, values %short_category );
172 "min-age" => { short => "a", arg => \$list_min_age,
174 die "Argument of --min-age must be a non-zero number\n"
175 if $list_min_age == 0;
177 "max-age" => { arg => \$list_min_age,
179 die "Argument of --max-age must be a non-zero number\n"
180 if $list_min_age == 0;
184 import => { arg => \$import_from, mode => "import" },
185 "manual-edit" => { mode => "manual-edit" },
188 while( @ARGV && $ARGV[0] =~ /^-/ ) {
191 my($opt, $optname, $arg);
192 if (/^--([^=]+)(=|$)/) {
194 $opt = $options{$optname};
195 $arg = $1 if /^--\Q$optname\E=((.|\n)*)$/;
198 $optname = substr( $_, 1, 1 );
199 $opt = (grep { defined($_->{short}) ? $_->{short} eq $optname : 0} values %options)[0];
200 $arg = $1 if /^-$optname(.+)$/;
203 warn "Unknown option: --$1\n";
208 die "$optname option missing argument\n" if !@ARGV;
211 ${$opt->{arg}} = $arg;
213 elsif (defined $arg) {
214 die "Option $optname takes no argument\n";
218 die "Conflicting operation modes\n" if $op_mode;
219 $op_mode = $opt->{mode};
229 $op_mode = $category ? "set-failed" : "set-building"
230 if !$op_mode; # default operation
231 $list_order = $list_state eq "failed" ? 'fPcpsn' : 'PScpsn'
232 if !$list_order and $list_state;
233 $distribution ||= "unstable";
234 die "Bad distribution '$distribution'\n"
235 if !isin($distribution, keys %conf::distributions);
237 # If they didn't specify an arch, try to get it from database name which
238 # is in the form of $arch/build-db
239 # This is for backwards compatibity with older versions that didn't
240 # specify the arch yet.
241 $conf::dbbase =~ m#^([^/]+)#;
244 # TODO: Check that it's an known arch (for that dist), and give
248 my $version = '$Revision: db181a534e9d $ $Date: 2008/03/26 06:20:22 $ $Author: rmurray $';
249 $version =~ s/(^\$| \$ .*$)//g;
250 print "wanna-build $version for $distribution on $arch\n";
253 if (!@ARGV && !isin( $op_mode, qw(list merge-quinn merge-partial-quinn import
254 merge-packages manual-edit
256 warn "No packages given.\n";
260 $real_user = (getpwuid($<))[0];
261 die "Can't determine your user name\n"
262 if $op_mode ne "list" && !$user &&
263 !($user = $real_user);
266 if ($op_mode eq "set-failed" && !$category) {
267 print "Enter reason for failing (end with '.' alone on ".
272 last if $line eq ".\n";
273 $fail_reason .= $line;
275 chomp( $fail_reason );
276 } elsif ($op_mode eq "set-dep-wait") {
277 print "Enter dependencies (one line):\n";
279 while( !$line && !eof(STDIN) ) {
280 chomp( $line = <STDIN> );
282 die "No dependencies given\n" if !$line;
283 $fail_reason = $line;
284 } elsif ($op_mode eq "set-binary-nmu" and $binNMUver > 0) {
285 print "Enter changelog entry (one line):\n";
287 while( !$line && !eof(STDIN) ) {
288 chomp( $line = <STDIN> );
290 die "No changelog entry given\n" if !$line;
291 $fail_reason = $line;
300 $dbh->disconnect or warn $dbh->errstr;
304 my $schema_suffix = '';
305 if (isin( $op_mode, qw(list info)) && $distribution !~ /security/ && !(not -t and $user =~ /-/)) {
306 $dbh = DBI->connect("DBI:Pg:service=wanna-build") ||
307 die "FATAL: Cannot open database: $DBI::errstr\n";
308 $schema_suffix = '_public';
312 $dbh = DBI->connect("DBI:Pg:service=wanna-build-privileged") ||
313 die "FATAL: Cannot open database: $DBI::errstr\n";
316 # TODO: This shouldn't be needed, file a bug.
317 $dbh->{pg_server_prepare} = 0;
319 $dbh->begin_work or die $dbh->errstr;
326 if ($mail_logs && $conf::log_mail) {
327 send_mail( $conf::log_mail,
328 "wanna-build $distribution state changes $curr_date",
329 "State changes at $curr_date for distribution ".
330 "$distribution:\n\n$mail_logs\n" );
338 SWITCH: foreach ($op_mode) {
340 add_packages( $1, @ARGV );
344 list_packages( $list_state );
348 info_packages( @ARGV );
351 /^forget-user/ && do {
352 die "This operation is restricted to admin users\n"
353 if (defined @conf::admin_users and
354 !isin( $real_user, @conf::admin_users));
355 forget_users( @ARGV );
359 forget_packages( @ARGV );
362 /^merge-partial-quinn/ && do {
363 die "This operation is restricted to admin users\n"
364 if (defined @conf::admin_users and
365 !isin( $real_user, @conf::admin_users));
369 /^merge-quinn/ && do {
370 die "This operation is restricted to admin users\n"
371 if (defined @conf::admin_users and
372 !isin( $real_user, @conf::admin_users));
376 /^merge-packages/ && do {
377 die "This operation is restricted to admin users\n"
378 if (defined @conf::admin_users and
379 !isin( $real_user, @conf::admin_users));
383 /^merge-sources/ && do {
384 die "This operation is restricted to admin users\n"
385 if (defined @conf::admin_users and
386 !isin( $real_user, @conf::admin_users));
390 /^pretend-avail/ && do {
391 pretend_avail( @ARGV );
395 die "This operation is restricted to admin users\n"
396 if (defined @conf::admin_users and
397 !isin( $real_user, @conf::admin_users));
399 @ARGV = ( $ARGS[0] );
400 my $pkgs = parse_packages();
401 @ARGV = ( $ARGS[1] );
403 @ARGV = ( $ARGS[2] );
404 my $srcs = parse_sources(1);
405 call_edos_depcheck( $ARGS[0], $srcs );
409 die "This operation is restricted to admin users\n"
410 if (defined @conf::admin_users and
411 !isin( $real_user, @conf::admin_users));
412 $dbh->do("DELETE from " . table_name() .
413 " WHERE distribution = ?", undef,
417 read_db( $import_from );
421 die "Unexpected operation mode $op_mode\n";
423 if (not -t and $user =~ /-/) {
424 my $userinfo = get_user_info($user);
425 if (!defined $userinfo)
427 add_user_info($user);
431 update_user_info($user);
437 my $newstate = shift;
438 my( $package, $name, $version, $ok, $reason );
440 foreach $package (@_) {
441 $package =~ s,^.*/,,; # strip path
442 $package =~ s/\.(dsc|diff\.gz|tar\.gz|deb)$//; # strip extension
443 $package =~ s/_[a-zA-Z\d-]+\.changes$//; # strip extension
444 if ($package =~ /^([\w\d.+-]+)_([\w\d:.+~-]+)/) {
445 ($name,$version) = ($1,$2);
448 warn "$package: can't extract package name and version ".
453 if ($op_mode eq "set-building") {
454 add_one_building( $name, $version );
456 elsif ($op_mode eq "set-built") {
457 add_one_built( $name, $version );
459 elsif ($op_mode eq "set-attempted") {
460 add_one_attempted( $name, $version );
462 elsif ($op_mode eq "set-uploaded") {
463 add_one_uploaded( $name, $version );
465 elsif ($op_mode eq "set-failed") {
466 add_one_failed( $name, $version );
468 elsif ($op_mode eq "set-not-for-us") {
469 add_one_notforus( $name, $version );
471 elsif ($op_mode eq "set-needs-build") {
472 add_one_needsbuild( $name, $version );
474 elsif ($op_mode eq "set-dep-wait") {
475 add_one_depwait( $name, $version );
477 elsif ($op_mode eq "set-build-priority") {
478 set_one_buildpri( $name, $version, 'buildpri' );
480 elsif ($op_mode eq "set-permanent-build-priority") {
481 set_one_buildpri( $name, $version, 'permbuildpri' );
483 elsif ($op_mode eq "set-binary-nmu") {
484 set_one_binnmu( $name, $version );
489 sub add_one_building {
495 my $pkg = get_source_info($name);
497 if ($pkg->{'state'} eq "Not-For-Us") {
499 $reason = "not suitable for this architecture";
501 elsif ($pkg->{'state'} =~ /^Dep-Wait/) {
503 $reason = "not all source dependencies available yet";
505 elsif ($pkg->{'state'} =~ /^BD-Uninstallable/) {
507 $reason = "source dependencies are not installable";
509 elsif ($pkg->{'state'} eq "Uploaded" &&
510 (version_lesseq($version, $pkg->{'version'}))) {
512 $reason = "already uploaded by $pkg->{'builder'}";
513 $reason .= " (in newer version $pkg->{'version'})"
514 if !version_eq($pkg, $version);
516 elsif ($pkg->{'state'} eq "Installed" &&
517 version_less($version,$pkg->{'version'})) {
519 print "$name: Warning: newer version $pkg->{'version'} ".
520 "already installed, but overridden.\n";
524 $reason = "newer version $pkg->{'version'} already in ".
525 "archive; doesn't need rebuilding";
526 print "$name: Note: If the following is due to an epoch ",
527 " change, use --override\n";
530 elsif ($pkg->{'state'} eq "Installed" &&
531 pkg_version_eq($pkg,$version)) {
533 $reason = "is up-to-date in the archive; doesn't need rebuilding";
535 elsif ($pkg->{'state'} eq "Needs-Build" &&
536 version_less($version,$pkg->{'version'})) {
538 print "$name: Warning: newer version $pkg->{'version'} ".
539 "needs building, but overridden.";
543 $reason = "newer version $pkg->{'version'} needs building, ".
547 elsif (isin($pkg->{'state'},qw(Building Built Build-Attempted))) {
548 if (version_less($pkg->{'version'},$version)) {
549 print "$name: Warning: Older version $pkg->{'version'} ",
550 "is being built by $pkg->{'builder'}\n";
551 if ($pkg->{'builder'} ne $user) {
552 send_mail( $pkg->{'builder'},
553 "package takeover in newer version",
554 "You are building package '$name' in ".
555 "version $version\n".
556 "(as far as I'm informed).\n".
557 "$user now has taken the newer ".
558 "version $version for building.".
559 "You can abort the build if you like.\n" );
564 print "User $pkg->{'builder'} had already ",
565 "taken the following package,\n",
566 "but overriding this as you request:\n";
567 send_mail( $pkg->{'builder'}, "package takeover",
568 "The package '$name' (version $version) that ".
569 "was taken by you\n".
570 "has been taken over by $user\n" );
572 elsif ($pkg->{'builder'} eq $user) {
573 print "$name: Note: already taken by you.\n";
574 print "$name: ok\n" if $verbose;
579 $reason = "already taken by $pkg->{'builder'}";
580 $reason .= " (in newer version $pkg->{'version'})"
581 if !version_eq($pkg->{'version'}, $version);
585 elsif ($pkg->{'state'} =~ /^Failed/ &&
586 pkg_version_eq($pkg, $version)) {
588 print "The following package previously failed ",
589 "(by $pkg->{'builder'})\n",
590 "but overriding this as you request:\n";
591 send_mail( $pkg->{'builder'}, "failed package takeover",
592 "The package '$name' (version $version) that ".
594 "and has failed previously has been taken over ".
596 if $pkg->{'builder'} ne $user;
600 $reason = "build of $version failed previously:\n ";
601 $reason .= join( "\n ", split( "\n", $pkg->{'failed'} ));
602 $reason .= "\nalso the package doesn't need builing"
603 if $pkg->{'state'} eq 'Failed-Removed';
609 if ($pkg->{'binary_nmu_version'}) {
610 print "$name: Warning: needs binary NMU $pkg->{'binary_nmu_version'}\n" .
611 "$pkg->{'binary_nmu_changelog'}\n";
614 print "$name: Warning: Previous version failed!\n"
615 if $pkg->{'previous_state'} =~ /^Failed/ ||
616 $pkg->{'state'} =~ /^Failed/;
618 change_state( \$pkg, 'Building' );
619 $pkg->{'package'} = $name;
620 $pkg->{'version'} = $version;
621 $pkg->{'builder'} = $user;
622 log_ta( $pkg, "--take" );
623 update_source_info($pkg);
624 print "$name: $ok\n" if $verbose;
627 print "$name: NOT OK!\n $reason\n";
631 sub add_one_attempted {
634 my $pkg = get_source_info($name);
636 if (!defined($pkg)) {
637 print "$name: not registered yet.\n";
641 if ($pkg->{'state'} ne "Building" ) {
642 print "$name: not taken for building (state is $pkg->{'state'}). ",
646 if ($pkg->{'builder'} ne $user) {
647 print "$name: not taken by you, but by $pkg->{'builder'}. Skipping.\n";
650 elsif ( !pkg_version_eq($pkg, $version) ) {
651 print "$name: version mismatch ".
652 "$(pkg->{'version'} ".
653 "by $pkg->{'builder'})\n";
657 change_state( \$pkg, 'Build-Attempted' );
658 log_ta( $pkg, "--attempted" );
659 update_source_info($pkg);
660 print "$name: registered as uploaded\n" if $verbose;
666 my $pkg = get_source_info($name);
668 if (!defined($pkg)) {
669 print "$name: not registered yet.\n";
673 if ($pkg->{'state'} ne "Building" ) {
674 print "$name: not taken for building (state is $pkg->{'state'}). ",
678 if ($pkg->{'builder'} ne $user) {
679 print "$name: not taken by you, but by $pkg->{'builder'}. Skipping.\n";
682 elsif ( !pkg_version_eq($pkg, $version) ) {
683 print "$name: version mismatch ".
684 "$(pkg->{'version'} ".
685 "by $pkg->{'builder'})\n";
688 change_state( \$pkg, 'Built' );
689 log_ta( $pkg, "--built" );
690 update_source_info($pkg);
691 print "$name: registered as built\n" if $verbose;
694 sub add_one_uploaded {
697 my $pkg = get_source_info($name);
699 if (!defined($pkg)) {
700 print "$name: not registered yet.\n";
704 if ($pkg->{'state'} eq "Uploaded" &&
705 pkg_version_eq($pkg,$version)) {
706 print "$name: already uploaded\n";
709 if (!isin( $pkg->{'state'}, qw(Building Built Build-Attempted))) {
710 print "$name: not taken for building (state is $pkg->{'state'}). ",
714 if ($pkg->{'builder'} ne $user) {
715 print "$name: not taken by you, but by $pkg->{'builder'}. Skipping.\n";
718 # strip epoch -- buildd-uploader used to go based on the filename.
719 # (to remove at some point)
721 ($pkgver = $pkg->{'version'}) =~ s/^\d+://;
722 $version =~ s/^\d+://; # for command line use
723 if ($pkg->{'binary_nmu_version'} ) {
724 my $nmuver = binNMU_version($pkgver, $pkg->{'binary_nmu_version'});
725 if (!version_eq( $nmuver, $version )) {
726 print "$name: version mismatch ($nmuver registered). ",
730 } elsif (!version_eq($pkgver, $version)) {
731 print "$name: version mismatch ($pkg->{'version'} registered). ",
736 change_state( \$pkg, 'Uploaded' );
737 log_ta( $pkg, "--uploaded" );
738 update_source_info($pkg);
739 print "$name: registered as uploaded\n" if $verbose;
746 my $pkg = get_source_info($name);
748 if (!defined($pkg)) {
749 print "$name: not registered yet.\n";
752 $state = $pkg->{'state'};
754 if ($state eq "Not-For-Us") {
755 print "$name: not suitable for this architecture anyway. Skipping.\n";
758 elsif ($state eq "Failed-Removed") {
759 print "$name: failed previously and doesn't need building. Skipping.\n";
762 elsif ($state eq "Installed") {
763 print "$name: Is already installed in archive. Skipping.\n";
766 elsif ($pkg->{'builder'} &&
767 (($user ne $pkg->{'builder'}) &&
768 !($pkg->{'builder'} =~ /^(\w+)-\w+/ && $1 eq $user))) {
769 print "$name: not taken by you, but by ".
770 "$pkg->{'builder'}. Skipping.\n";
773 elsif ( !pkg_version_eq($pkg, $version) ) {
774 print "$name: version mismatch ".
775 "$(pkg->{'version'} ".
776 "by $pkg->{'builder'})\n";
781 if (!$cat && $fail_reason =~ /^\[([^\]]+)\]/) {
783 $cat = $short_category{$cat} if exists $short_category{$cat};
784 if (!isin( $cat, values %short_category )) {
785 print "$name: Warning: unknown category $cat; discarded\n";
788 $fail_reason =~ s/^\[[^\]]+\][ \t]*\n*//;
791 if ($state eq "Needs-Build") {
792 print "$name: Warning: not registered for building previously, ".
793 "but processing anyway.\n";
795 elsif ($state eq "Uploaded") {
796 print "$name: Warning: marked as uploaded previously, ".
797 "but processing anyway.\n";
799 elsif ($state eq "Dep-Wait") {
800 print "$name: Warning: marked as waiting for dependencies, ".
801 "but processing anyway.\n";
803 elsif ($state eq "BD-Uninstallable") {
804 print "$name: Warning: marked as having uninstallable build-dependencies, ".
805 "but processing anyway.\n";
807 elsif ($state eq "Failed") {
808 print "$name: already registered as failed; will append new message\n"
810 print "$name: already registered as failed; changing category\n"
814 if (($cat eq "reminder-sent" || $cat eq "nmu-offered") &&
815 defined $pkg->{'failed_category'} &&
816 $pkg->{'failed_category'} ne $cat) {
817 (my $action = $cat) =~ s/-/ /;
818 $fail_reason .= "\n$short_date: $action";
821 change_state( \$pkg, 'Failed' );
822 $pkg->{'builder'} = $user;
823 $pkg->{'failed'} .= "\n" if $pkg->{'failed'};
824 $pkg->{'failed'} .= $fail_reason;
825 $pkg->{'failed_category'} = $cat if $cat;
826 if (defined $pkg->{'permbuildpri'}) {
827 $pkg->{'buildpri'} = $pkg->{'permbuildpri'};
829 delete $pkg->{'buildpri'};
831 log_ta( $pkg, "--failed" );
832 update_source_info($pkg);
833 print "$name: registered as failed\n" if $verbose;
836 sub add_one_notforus {
839 my $pkg = get_source_info($name);
841 if ($pkg->{'state'} eq 'Not-For-Us') {
842 # reset Not-For-Us state in case it's called twice; this is
843 # the only way to get a package out of this state...
844 # There is no really good state in which such packages should
845 # be put :-( So use Failed for now.
846 change_state( \$pkg, 'Failed' );
847 $pkg->{'package'} = $name;
848 $pkg->{'failed'} = "Was Not-For-Us previously";
849 delete $pkg->{'builder'};
850 delete $pkg->{'depends'};
851 log_ta( $pkg, "--no-build(rev)" );
852 print "$name: now not unsuitable anymore\n";
854 send_mail( $conf::notforus_maint,
855 "$name moved out of Not-For-Us state",
856 "The package '$name' has been moved out of the Not-For-Us ".
858 "It should probably also be removed from ".
859 "Packages-arch-specific or\n".
860 "the action was wrong.\n" )
861 if $conf::notforus_maint;
864 change_state( \$pkg, 'Not-For-Us' );
865 $pkg->{'package'} = $name;
866 delete $pkg->{'builder'};
867 delete $pkg->{'depends'};
868 delete $pkg->{'buildpri'};
869 delete $pkg->{'binary_nmu_version'};
870 delete $pkg->{'binary_nmu_changelog'};
871 log_ta( $pkg, "--no-build" );
872 print "$name: registered as unsuitable\n" if $verbose;
874 send_mail( $conf::notforus_maint,
875 "$name set to Not-For-Us",
876 "The package '$name' has been set to state Not-For-Us ".
878 "It should probably also be added to ".
879 "Packages-arch-specific or\n".
880 "the Not-For-Us state is wrong.\n" )
881 if $conf::notforus_maint;
883 update_source_info($pkg);
886 sub add_one_needsbuild {
890 my $pkg = get_source_info($name);
892 if (!defined($pkg)) {
893 print "$name: not registered; can't give back.\n";
896 $state = $pkg->{'state'};
898 if ($state eq "BD-Uninstallable") {
900 print "$name: Forcing uninstallability mark to be removed. This is not permanent and might be reset with the next trigger run\n";
902 change_state( \$pkg, 'Needs-Build' );
903 delete $pkg->{'builder'};
904 delete $pkg->{'depends'};
905 log_ta( $pkg, "--give-back" );
906 update_source_info($pkg);
907 print "$name: given back\n" if $verbose;
911 print "$name: has uninstallable build-dependencies. Skipping\n",
912 " (use --override to clear dependency list and ",
913 "give back anyway)\n";
917 elsif ($state eq "Dep-Wait") {
919 print "$name: Forcing source dependency list to be cleared\n";
922 print "$name: waiting for source dependencies. Skipping\n",
923 " (use --override to clear dependency list and ",
924 "give back anyway)\n";
928 elsif (!isin( $state, qw(Building Built Build-Attempted))) {
929 print "$name: not taken for building (state is $state).";
931 print "\n$name: Forcing give-back\n";
934 print " Skipping.\n";
938 if (defined ($pkg->{'builder'}) && $user ne $pkg->{'builder'} &&
939 !($pkg->{'builder'} =~ /^(\w+)-\w+/ && $1 eq $user) &&
941 print "$name: not taken by you, but by ".
942 "$pkg->{'builder'}. Skipping.\n";
945 if (!pkg_version_eq($pkg, $version)) {
946 print "$name: version mismatch ($pkg->{'version'} registered). ",
950 if ($distribution eq "unstable") {
951 change_state( \$pkg, 'BD-Uninstallable' );
952 $pkg->{'bd_problem'} = "Installability of build dependencies not tested yet";
954 change_state( \$pkg, 'Needs-Build' );
956 $pkg->{'builder'} = undef;
957 $pkg->{'depends'} = undef;
958 log_ta( $pkg, "--give-back" );
959 update_source_info($pkg);
960 print "$name: given back\n" if $verbose;
966 my $pkg = get_source_info($name);
969 if (!defined($pkg)) {
970 print "$name: not registered; can't register for binNMU.\n";
973 my $db_ver = $pkg->{'version'};
975 if (!version_eq($db_ver, $version)) {
976 print "$name: version mismatch ($db_ver registered). ",
980 $state = $pkg->{'state'};
982 if (defined $pkg->{'binary_nmu_version'}) {
983 if ($binNMUver == 0) {
984 change_state( \$pkg, 'Installed' );
985 delete $pkg->{'builder'};
986 delete $pkg->{'depends'};
987 delete $pkg->{'binary_nmu_version'};
988 delete $pkg->{'binary_nmu_changelog'};
989 } elsif ($binNMUver <= $pkg->{'binary_nmu_version'}) {
990 print "$name: already building binNMU $pkg->{'binary_nmu_version'}\n";
993 $pkg->{'binary_nmu_version'} = $binNMUver;
994 $pkg->{'binary_nmu_changelog'} = $fail_reason;
995 $pkg->{'notes'} = 'out-of-date';
996 $pkg->{'buildpri'} = $pkg->{'permbuildpri'}
997 if (defined $pkg->{'permbuildpri'});
999 log_ta( $pkg, "--binNMU" );
1000 update_source_info($pkg);
1002 } elsif ($binNMUver == 0) {
1003 print "${name}_$version: no scheduled binNMU to cancel.\n";
1007 if ($state ne 'Installed') {
1008 print "${name}_$version: not installed; can't register for binNMU.\n";
1012 my $fullver = binNMU_version($version,$binNMUver);
1013 if ( version_lesseq( $fullver, $pkg->{'installed_version'} ) )
1015 print "$name: binNMU $fullver is not newer than current version $pkg->{'installed_version'}\n";
1019 change_state( \$pkg, 'BD-Uninstallable' );
1020 $pkg->{'bd_problem'} = "Installability of build dependencies not tested yet";
1021 delete $pkg->{'builder'};
1022 delete $pkg->{'depends'};
1023 $pkg->{'binary_nmu_version'} = $binNMUver;
1024 $pkg->{'binary_nmu_changelog'} = $fail_reason;
1025 $pkg->{'notes'} = 'out-of-date';
1026 log_ta( $pkg, "--binNMU" );
1027 update_source_info($pkg);
1028 print "${name}: registered for binNMU $fullver\n" if $verbose;
1031 sub set_one_buildpri {
1033 my $version = shift;
1035 my $pkg = get_source_info($name);
1038 if (!defined($pkg)) {
1039 print "$name: not registered; can't set priority.\n";
1042 $state = $pkg->{'state'};
1044 if ($state eq "Not-For-Us") {
1045 print "$name: not suitable for this architecture. Skipping.\n";
1047 } elsif ($state eq "Failed-Removed") {
1048 print "$name: failed previously and doesn't need building. Skipping.\n";
1051 if (!pkg_version_eq($pkg, $version)) {
1052 print "$name: version mismatch ($pkg->{'version'} registered). ",
1056 if ( $build_priority == 0 ) {
1057 delete $pkg->{'buildpri'}
1058 if $key eq 'permbuildpri' and defined $pkg->{'buildpri'}
1059 and $pkg->{'buildpri'} == $pkg->{$key};
1060 delete $pkg->{$key};
1062 $pkg->{'buildpri'} = $build_priority
1063 if $key eq 'permbuildpri';
1064 $pkg->{$key} = $build_priority;
1066 update_source_info($pkg);
1067 print "$name: set to build priority $build_priority\n" if $verbose;
1070 sub add_one_depwait {
1072 my $version = shift;
1074 my $pkg = get_source_info($name);
1076 if (!defined($pkg)) {
1077 print "$name: not registered yet.\n";
1080 $state = $pkg->{'state'};
1082 if ($state eq "Dep-Wait") {
1083 print "$name: merging with previously registered dependencies\n";
1086 if (isin( $state, qw(Needs-Build Failed BD-Uninstallable))) {
1087 print "$name: Warning: not registered for building previously, ".
1088 "but processing anyway.\n";
1090 elsif ($state eq "Not-For-Us") {
1091 print "$name: not suitable for this architecture anyway. Skipping.\n";
1094 elsif ($state eq "Failed-Removed") {
1095 print "$name: failed previously and doesn't need building. Skipping.\n";
1098 elsif ($state eq "Installed") {
1099 print "$name: Is already installed in archive. Skipping.\n";
1102 elsif ($state eq "Uploaded") {
1103 print "$name: Is already uploaded. Skipping.\n";
1106 elsif ($pkg->{'builder'} &&
1107 $user ne $pkg->{'builder'}) {
1108 print "$name: not taken by you, but by ".
1109 "$pkg->{'builder'}. Skipping.\n";
1112 elsif ( !pkg_version_eq($pkg,$version)) {
1113 print "$name: version mismatch ".
1114 "($pkg->{'version'} ".
1115 "by $pkg->{'builder'})\n";
1118 elsif ($fail_reason =~ /^\s*$/ ||
1119 !parse_deplist( $fail_reason, 1 )) {
1120 print "$name: Bad dependency list\n";
1123 change_state( \$pkg, 'Dep-Wait' );
1124 $pkg->{'builder'} = $user;
1125 if (defined $pkg->{'permbuildpri'}) {
1126 $pkg->{'buildpri'} = $pkg->{'permbuildpri'};
1128 delete $pkg->{'buildpri'};
1130 my $deplist = parse_deplist( $pkg->{'depends'} );
1131 my $new_deplist = parse_deplist( $fail_reason );
1132 # add new dependencies, maybe overwriting old entries
1133 foreach (keys %$new_deplist) {
1134 $deplist->{$_} = $new_deplist->{$_};
1136 $pkg->{'depends'} = build_deplist($deplist);
1137 log_ta( $pkg, "--dep-wait" );
1138 update_source_info($pkg);
1139 print "$name: registered as waiting for dependencies\n" if $verbose;
1149 local($/) = ""; # read in paragraph mode
1151 my( $version, $arch, $section, $priority, $builddep, $buildconf, $binaries );
1153 /^Package:\s*(\S+)$/mi and $name = $1;
1154 /^Version:\s*(\S+)$/mi and $version = $1;
1155 /^Architecture:\s*(\S+)$/mi and $arch = $1;
1156 /^Section:\s*(\S+)$/mi and $section = $1;
1157 /^Priority:\s*(\S+)$/mi and $priority = $1;
1158 /^Build-Depends:\s*(.*)$/mi and $builddep = $1;
1159 /^Build-Conflicts:\s*(.*)$/mi and $buildconf = $1;
1160 /^Binary:\s*(.*)$/mi and $binaries = $1;
1162 next if (defined $srcver{$name} and version_less( $version, $srcver{$name} ));
1163 $srcver{$name} = $version;
1165 $pkgs{$name}{'ver'} = $version;
1166 $pkgs{$name}{'bin'} = $binaries;
1167 $pkgs{$name}{'dep'} = $builddep;
1168 $pkgs{$name}{'conf'} = $buildconf;
1169 my $pkg = get_source_info($name);
1174 if ($arch eq "all" && !version_less( $version, $pkg->{'version'} )) {
1175 # package is now Arch: all, delete it from db
1176 change_state( \$pkg, 'deleted' );
1177 log_ta( $pkg, "--merge-sources" );
1178 print "$name ($pkg->{'version'}): deleted ".
1179 "from database, because now Arch: all\n"
1181 del_source_info($name);
1185 # The "Version" should always be the source version --
1186 # not a possible binNMU version number.
1187 $pkg->{'version'} = $version, $change++
1188 if ($pkg->{'state'} eq 'Installed' and
1189 !version_eq( $pkg->{'version'}, $version));
1190 # Always update priority and section, if available
1191 $pkg->{'priority'} = $priority, $change++
1192 if defined $priority and (not defined($pkg->{'priority'}) or $pkg->{'priority'} ne $priority);
1194 $pkg->{'section'} = $section, $change++
1195 if defined $section and (not defined($pkg->{'section'}) or $pkg->{'section'} ne $section);
1197 update_source_info($pkg) if $change;
1200 # Now that we only have the latest source version, build the list
1201 # of binary packages from the Sources point of view
1202 foreach $name (keys %pkgs) {
1203 foreach my $bin (split( /\s*,\s*/, $pkgs{$name}{'bin'} ) ) {
1204 $merge_binsrc{$bin} = $name;
1207 # remove installed packages that no longer have source available
1208 # or binaries installed
1209 my $db = get_all_source_info();
1210 foreach $name (keys %$db) {
1211 next if $name =~ /^_/;
1212 my $pkg = $db->{$name};
1213 if (not defined($pkgs{$name})) {
1214 change_state( \$pkg, 'deleted' );
1215 log_ta( $pkg, "--merge-sources" );
1216 print "$name ($pkg->{'version'}): ".
1217 "deleted from database, because ".
1218 "not in Sources anymore\n"
1220 del_source_info($name);
1222 next if !isin( $pkg->{'state'}, qw(Installed) );
1223 if ($full && not defined $merge_srcvers{$name}) {
1224 change_state( \$pkg, 'deleted' );
1225 log_ta( $pkg, "--merge-sources" );
1226 print "$name ($pkg->{'version'}): ".
1227 "deleted from database, because ".
1228 "binaries don't exist anymore\n"
1230 del_source_info($name);
1231 } elsif ($full && version_less( $merge_srcvers{$name}, $pkg->{'version'})) {
1232 print "$name ($pkg->{'version'}): ".
1233 "package is Installed but binaries are from ".
1234 $merge_srcvers{$name}. "\n"
1242 # This function looks through a Packages file and sets the state of
1243 # packages to 'Installed'
1244 sub parse_packages {
1247 local($/) = ""; # read in paragraph mode
1249 my( $name, $version, $depends, $source, $sourcev, $architecture, $provides, $binaryv, $binnmu );
1251 /^Package:\s*(\S+)$/mi and $name = $1;
1252 /^Version:\s*(\S+)$/mi and $version = $1;
1253 /^Depends:\s*(.*)$/mi and $depends = $1;
1254 /^Source:\s*(\S+)(\s*\((\S+)\))?$/mi and ($source,$sourcev) = ($1, $3);
1255 /^Architecture:\s*(\S+)$/mi and $architecture = $1;
1256 /^Provides:\s*(.*)$/mi and $provides = $1;
1257 next if !$name || !$version;
1258 next if ($arch ne $architecture and $architecture ne "all");
1259 next if (defined ($installed->{$name}) and $installed->{$name}{'version'} ne "" and
1260 version_lesseq( $version, $installed->{$name}{'version'} ));
1261 $installed->{$name}{'version'} = $version;
1262 $installed->{$name}{'depends'} = $depends;
1263 $installed->{$name}{'all'} = 1 if $architecture eq "all";
1264 undef $installed->{$name}{'Provider'};
1265 $installed->{$name}{'Source'} = $source ? $source : $name;
1267 foreach (split( /\s*,\s*/, $provides )) {
1268 if (not defined ($installed->{$_})) {
1269 $installed->{$_}{'version'} = "";
1270 $installed->{$_}{'Provider'} = $name;
1274 if ( $version =~ /\+b(\d+)$/ ) {
1277 $version = $sourcev if $sourcev;
1278 $binaryv = $version;
1279 $binaryv =~ s/\+b\d+$//;
1280 $installed->{$name}{'Sourcev'} = $sourcev ? $sourcev : $binaryv;
1281 $binaryv .= "+b$binnmu" if defined($binnmu);
1283 next if $architecture ne $arch;
1284 $name = $source if $source;
1285 next if defined($merge_srcvers{$name}) and $merge_srcvers{$name} eq $version;
1286 $merge_srcvers{$name} = $version;
1288 my $pkg = get_source_info($name);
1291 if (isin( $pkg->{'state'}, qw(Not-For-Us)) ||
1292 (isin($pkg->{'state'}, qw(Installed)) &&
1293 version_lesseq($binaryv, $pkg->{'installed_version'}))) {
1294 print "Skipping $name because State == $pkg->{'state'}\n"
1298 if ($pkg->{'binary_nmu_version'} ) {
1299 my $nmuver = binNMU_version($pkg->{'version'}, $pkg->{'binary_nmu_version'});
1300 if (version_less( $binaryv, $nmuver )) {
1301 print "Skipping $name ($version) because have newer ".
1302 "version ($nmuver) in db.\n"
1306 } elsif (version_less($version, $pkg->{'version'})) {
1307 print "Skipping $name ($version) because have newer ".
1308 "version ($pkg->{'version'}) in db.\n"
1313 if (!pkg_version_eq($pkg, $version) &&
1314 $pkg->{'state'} ne "Installed") {
1315 warn "Warning: $name: newer version than expected appeared ".
1316 "in archive ($version vs. $pkg->{'version'})\n";
1317 delete $pkg->{'builder'};
1320 if (!isin( $pkg->{'state'}, qw(Uploaded) )) {
1321 warn "Warning: Package $name was not in uploaded state ".
1322 "before (but in '$pkg->{'state'}').\n";
1323 delete $pkg->{'builder'};
1324 delete $pkg->{'depends'};
1328 $pkg->{'version'} = $version;
1331 change_state( \$pkg, 'Installed' );
1332 $pkg->{'package'} = $name;
1333 $pkg->{'installed_version'} = $binaryv;
1334 if (defined $pkg->{'permbuildpri'}) {
1335 $pkg->{'buildpri'} = $pkg->{'permbuildpri'};
1337 delete $pkg->{'buildpri'};
1339 $pkg->{'version'} = $version
1340 if version_less( $pkg->{'version'}, $version);
1341 delete $pkg->{'binary_nmu_version'};
1342 delete $pkg->{'binary_nmu_changelog'};
1343 log_ta( $pkg, "--merge-packages" );
1344 update_source_info($pkg);
1345 print "$name ($version) is up-to-date now.\n" if $verbose;
1348 check_dep_wait( "--merge-packages", $installed );
1353 my ($package, $name, $version, $installed);
1355 foreach $package (@_) {
1356 $package =~ s,^.*/,,; # strip path
1357 $package =~ s/\.(dsc|diff\.gz|tar\.gz|deb)$//; # strip extension
1358 $package =~ s/_[\w\d]+\.changes$//; # strip extension
1359 if ($package =~ /^([\w\d.+-]+)_([\w\d:.+~-]+)/) {
1360 ($name,$version) = ($1,$2);
1363 warn "$package: can't extract package name and version ".
1367 $installed->{$name}{'version'} = $version;
1370 check_dep_wait( "--pretend-avail", $installed );
1373 sub check_dep_wait {
1375 my $installed = shift;
1377 # check all packages in state Dep-Wait if dependencies are all
1380 my $db = get_all_source_info();
1381 foreach $name (keys %$db) {
1382 next if $name =~ /^_/;
1383 my $pkg = $db->{$name};
1384 next if $pkg->{'state'} ne "Dep-Wait";
1385 my $deps = $pkg->{'depends'};
1387 print "$name: was in state Dep-Wait, but with empty ",
1389 goto make_needs_build;
1391 my $deplist = parse_deplist($deps);
1395 foreach (keys %$deplist) {
1396 if (!exists $installed->{$_} ||
1397 ($deplist->{$_}->{'rel'} && $deplist->{$_}->{'version'} &&
1398 !version_compare( $installed->{$_}{'version'},
1399 $deplist->{$_}->{'rel'},
1400 $deplist->{$_}->{'version'}))) {
1402 $new_deplist->{$_} = $deplist->{$_};
1405 push( @removed_deps, $_ );
1410 change_state( \$pkg, 'Needs-Build' );
1411 log_ta( $pkg, $action );
1412 delete $pkg->{'builder'};
1413 delete $pkg->{'depends'};
1414 print "$name ($pkg->{'version'}) has all ",
1415 "dependencies available now\n" if $verbose;
1417 update_source_info($pkg);
1419 elsif (@removed_deps) {
1420 $pkg->{'depends'} = build_deplist( $new_deplist );
1421 print "$name ($pkg->{'version'}): some dependencies ",
1422 "(@removed_deps) available now, but not all yet\n"
1424 update_source_info($pkg);
1429 # This function accepts quinn-diff output (either from a file named on
1430 # the command line, or on stdin) and sets the packages named there to
1431 # state 'Needs-Build'.
1432 sub parse_quinn_diff {
1433 my $partial = shift;
1439 next if !m,^([-\w\d/]*)/ # section
1440 ([-\w\d.+]+)_ # package name
1441 ([\w\d:.~+-]+)\.dsc\s* # version
1442 \[([^:]*): # priority
1443 ([^]]+)\]\s*$,x; # rest of notes
1444 my($section,$name,$version,$priority,$notes) = ($1, $2, $3, $4, $5);
1445 $quinn_pkgs{$name}++;
1446 $section ||= "unknown";
1447 $priority ||= "unknown";
1448 $priority = "unknown" if $priority eq "-";
1449 $priority = "standard" if ($name eq "debian-installer");
1451 my $pkg = get_source_info($name);
1453 # Always update section and priority.
1454 if (defined($pkg)) {
1456 $pkg->{'section'} = $section, $change++ if not defined
1457 $pkg->{'section'} or $section ne "unknown";
1458 $pkg->{'priority'} = $priority, $change++ if not defined
1459 $pkg->{'priority'} or $priority ne "unknown";
1462 if (defined($pkg) &&
1463 $pkg->{'state'} =~ /^Dep-Wait/ &&
1464 version_less( $pkg->{'version'}, $version )) {
1465 change_state( \$pkg, 'Dep-Wait' );
1466 $pkg->{'version'} = $version;
1467 delete $pkg->{'binary_nmu_version'};
1468 delete $pkg->{'binary_nmu_changelog'};
1469 log_ta( $pkg, "--merge-quinn" );
1471 print "$name ($version) still waiting for dependencies.\n"
1474 elsif (defined($pkg) &&
1475 $pkg->{'state'} =~ /-Removed$/ &&
1476 version_eq($pkg->{'version'}, $version)) {
1477 # reinstantiate a package that has been removed earlier
1478 # (probably due to a quinn-diff malfunction...)
1479 my $newstate = $pkg->{'state'};
1480 $newstate =~ s/-Removed$//;
1481 change_state( \$pkg, $newstate );
1482 $pkg->{'version'} = $version;
1483 $pkg->{'notes'} = $notes;
1484 log_ta( $pkg, "--merge-quinn" );
1486 print "$name ($version) reinstantiated to $newstate.\n"
1489 elsif (defined($pkg) &&
1490 $pkg->{'state'} eq "Not-For-Us" &&
1491 version_less( $pkg->{'version'}, $version )) {
1492 # for Not-For-Us packages just update the version etc., but
1494 change_state( \$pkg, "Not-For-Us" );
1495 $pkg->{'package'} = $name;
1496 $pkg->{'version'} = $version;
1497 $pkg->{'notes'} = $notes;
1498 delete $pkg->{'builder'};
1499 log_ta( $pkg, "--merge-quinn" );
1501 print "$name ($version) still Not-For-Us.\n" if $verbose;
1503 elsif (!defined($pkg) ||
1504 $pkg->{'state'} ne "Not-For-Us" &&
1505 (version_less( $pkg->{'version'}, $version ) ||
1506 ($pkg->{'state'} eq "Installed" && version_less($pkg->{'installed_version'}, $version)))) {
1508 if (defined( $pkg->{'state'} ) && isin( $pkg->{'state'}, qw(Building Built Build-Attempted))) {
1509 send_mail( $pkg->{'builder'},
1510 "new version of $name (dist=$distribution)",
1511 "As far as I'm informed, you're currently ".
1512 "building the package $name\n".
1513 "in version $pkg->{'version'}.\n\n".
1514 "Now there's a new source version $version. ".
1515 "If you haven't finished\n".
1516 "compiling $name yet, you can stop it to ".
1517 "save some work.\n".
1518 "Just to inform you...\n".
1519 "(This is an automated message)\n" );
1520 print "$name: new version ($version) while building ".
1521 "$pkg->{'version'} -- sending mail ".
1522 "to builder ($pkg->{'builder'})\n"
1525 change_state( \$pkg, 'Needs-Build' );
1526 $pkg->{'package'} = $name;
1527 $pkg->{'version'} = $version;
1528 $pkg->{'section'} = $section;
1529 $pkg->{'priority'} = $priority;
1530 $pkg->{'notes'} = $notes;
1531 delete $pkg->{'builder'};
1532 delete $pkg->{'binary_nmu_version'};
1533 delete $pkg->{'binary_nmu_changelog'};
1534 log_ta( $pkg, "--merge-quinn" );
1537 print "$name ($version) needs rebuilding now.\n" if $verbose;
1539 elsif (defined($pkg) &&
1540 !version_eq( $pkg->{'version'}, $version ) &&
1541 isin( $pkg->{'state'}, qw(Installed Not-For-Us) )) {
1542 print "$name: skipping because version in db ".
1543 "($pkg->{'version'}) is >> than ".
1544 "what quinn-diff says ($version) ".
1545 "(state is $pkg->{'state'})\n"
1547 $dubious .= "$pkg->{'state'}: ".
1548 "db ${name}_$pkg->{'version'} >> ".
1549 "quinn $version\n" if !$partial;
1551 elsif ($verbose >= 2) {
1552 if ($pkg->{'state'} eq "Not-For-Us") {
1553 print "Skipping $name because State == ".
1554 "$pkg->{'state'}\n";
1556 elsif (!version_less($pkg->{'version'}, $version)) {
1557 print "Skipping $name because version in db ".
1558 "($pkg->{'version'}) is >= than ".
1559 "what quinn-diff says ($version)\n";
1562 update_source_info($pkg) if $change;
1566 send_mail( $conf::db_maint,
1567 "Dubious versions in " . table_name() . " "
1568 . $distribution . " table",
1569 "The following packages have a newer version in the ".
1570 "wanna-build database\n".
1571 "than what quinn-diff says, and this is strange for ".
1573 "It could be caused by a lame mirror, or the version ".
1574 "in the database\n".
1579 # Now re-check the DB for packages in states Needs-Build, Failed,
1580 # Dep-Wait or BD-Uninstallable and remove them if they're not listed
1581 # anymore by quinn-diff.
1584 my $db = get_all_source_info();
1585 foreach $name (keys %$db) {
1586 next if $name =~ /^_/;
1587 my $pkg = $db->{$name};
1588 next if defined $pkg->{'binary_nmu_version'};
1589 next if !isin( $pkg->{'state'},
1590 qw(Needs-Build Building Built Build-Attempted Uploaded Failed Dep-Wait BD-Uninstallable) );
1591 my $virtual_delete = $pkg->{'state'} eq 'Failed';
1593 if (!$quinn_pkgs{$name}) {
1594 change_state( \$pkg, $virtual_delete ?
1595 $pkg->{'state'}."-Removed" :
1597 log_ta( $pkg, "--merge-quinn" );
1598 print "$name ($pkg->{'version'}): ".
1599 ($virtual_delete ? "(virtually) " : "") . "deleted ".
1600 "from database, because not in quinn-diff anymore\n"
1602 if ($virtual_delete) {
1603 update_source_info($pkg);
1605 del_source_info($name);
1613 # for sorting priorities and sections
1615 %prioval = ( required => -5,
1623 'debian-installer' => -199,
1644 localizations => -178,
1645 interpreters => -177,
1670 electronics => -152,
1676 foreach my $i (keys %sectval) {
1677 $sectval{"contrib/$i"} = $sectval{$i}+40;
1678 $sectval{"non-free/$i"} = $sectval{$i}+80;
1680 $sectval{'unknown'} = -165;
1682 %catval = ( "none" => -20,
1683 "uploaded-fixed-pkg" => -19,
1684 "fix-expected" => -18,
1685 "reminder-sent" => -17,
1686 "nmu-offered" => -16,
1690 "compiler-error" => -12 );
1693 sub sort_list_func {
1694 my( $letter, $x, $ax, $bx );
1696 foreach $letter (split( "", $list_order )) {
1697 SWITCH: foreach ($letter) {
1699 $x = $b->{'buildpri'} <=> $a->{'buildpri'};
1700 return $x if $x != 0;
1704 $x = $prioval{$a->{'priority'}} <=> $prioval{$b->{'priority'}};
1705 return $x if $x != 0;
1709 $x = $sectval{$a->{'section'}} <=> $sectval{$b->{'section'}};
1710 return $x if $x != 0;
1714 $x = $a->{'package'} cmp $b->{'package'};
1715 return $x if $x != 0;
1719 $x = $a->{'builder'} cmp $b->{'builder'};
1720 return $x if $x != 0;
1724 $ax = ($a->{'notes'} =~ /^(out-of-date|partial)/) ? 0 :
1725 ($a->{'notes'} =~ /^uncompiled/) ? 2 : 1;
1726 $bx = ($b->{'notes'} =~ /^(out-of-date|partial)/) ? 0 :
1727 ($b->{'notes'} =~ /^uncompiled/) ? 2 : 1;
1729 return $x if $x != 0;
1733 my $ca = defined $a->{'failed_category'} ?
1734 $a->{'failed_category'} : "none";
1735 my $cb = defined $b->{'failed_category'} ?
1736 $b->{'failed_category'} : "none";
1737 $x = $catval{$ca} <=> $catval{$cb};
1738 return $x if $x != 0;
1742 my $pa = $prioval{$a->{'priority'}} >
1743 $prioval{'standard'};
1744 my $pb = $prioval{$b->{'priority'}} >
1745 $prioval{'standard'};
1747 return $x if $x != 0;
1757 my( $name, $pkg, @list );
1762 my $db = get_all_source_info(state => $state, user => $user, category => $category, list_min_age => $list_min_age);
1763 foreach $name (keys %$db) {
1764 next if $name =~ /^_/;
1765 push @list, $db->{$name};
1768 foreach $pkg (sort sort_list_func @list) {
1769 print "$pkg->{'section'}/$pkg->{'package'}_$pkg->{'version'}";
1770 print ": $pkg->{'state'}"
1772 print " by $pkg->{'builder'}"
1773 if $pkg->{'state'} ne "Needs-Build" && $pkg->{'builder'};
1774 print " [$pkg->{'priority'}:$pkg->{'notes'}";
1775 print ":PREV-FAILED"
1776 if $pkg->{'previous_state'} =~ /^Failed/;
1777 print ":bp{" . $pkg->{'buildpri'} . "}"
1778 if defined $pkg->{'buildpri'};
1779 print ":binNMU{" . $pkg->{'binary_nmu_version'} . "}"
1780 if defined $pkg->{'binary_nmu_version'};
1782 print " Reasons for failing:\n",
1784 defined $pkg->{'failed_category'} ? $pkg->{'failed_category'} : "none",
1786 join("\n ",split("\n",$pkg->{'failed'})), "\n"
1787 if $pkg->{'state'} =~ /^Failed/;
1788 print " Dependencies: $pkg->{'depends'}\n"
1789 if $pkg->{'state'} eq "Dep-Wait";
1790 print " Reasons for BD-Uninstallable:\n ",
1791 join("\n ",split("\n",$pkg->{'bd_problem'})), "\n"
1792 if $pkg->{'state'} eq "BD-Uninstallable";
1793 print " Previous state was $pkg->{'previous_state'} until ",
1794 "$pkg->{'state_change'}\n"
1795 if $verbose && $pkg->{'previous_state'};
1796 print " No previous state recorded\n"
1797 if $verbose && !$pkg->{'previous_state'};
1798 print " Previous failing reasons:\n ",
1799 join("\n ",split("\n",$pkg->{'old_failed'})), "\n"
1800 if $verbose && $pkg->{'old_failed'};
1802 $scnt{$pkg->{'state'}}++ if $state eq "all";
1804 if ($state eq "all") {
1805 foreach (sort keys %scnt) {
1806 print "Total $scnt{$_} package(s) in state $_.\n";
1809 print "Total $cnt package(s)\n";
1814 my( $name, $pkg, $key, $dist );
1815 my @firstkeys = qw(package version builder state section priority
1816 installed_version previous_state state_change);
1817 my @dists = $info_all_dists ? keys %conf::distributions : ($distribution);
1819 foreach $name (@_) {
1820 $name =~ s/_.*$//; # strip version
1821 foreach $dist (@dists) {
1822 my $pname = "$name" . ($info_all_dists ? "($dist)" : "");
1824 $pkg = get_readonly_source_info($name);
1825 if (!defined( $pkg )) {
1826 print "$pname: not registered\n";
1831 foreach $key (@firstkeys) {
1832 next if !defined $pkg->{$key};
1833 my $val = $pkg->{$key};
1835 $val = "\n$val" if isin( $key, qw(Failed Old-Failed));
1837 my $print_key = $key;
1838 $print_key = 'Package' if ($key eq 'package');
1839 $print_key = 'Version' if ($key eq 'version');
1840 $print_key = 'Builder' if ($key eq 'builder');
1841 $print_key = 'State' if ($key eq 'state');
1842 $print_key = 'Section' if ($key eq 'section');
1843 $print_key = 'Priority' if ($key eq 'priority');
1844 $print_key = 'Installed-Version' if ($key eq 'installed_version');
1845 $print_key = 'Previous-State' if ($key eq 'previous_state');
1846 $print_key = 'State-Change' if ($key eq 'state_change');
1847 printf " %-20s: %s\n", $print_key, $val;
1849 foreach $key (sort keys %$pkg) {
1850 next if isin( $key, @firstkeys );
1851 my $val = $pkg->{$key};
1852 next if !defined($val);
1854 $val = "\n$val" if isin( $key, qw(Failed Old-Failed));
1856 my $print_key = $key;
1857 $print_key = 'BD-Problem' if ($key eq 'bd_problem');
1858 $print_key = 'Binary-NMU-Changelog' if ($key eq 'binary_nmu_changelog');
1859 $print_key = 'Binary-NMU-Version' if ($key eq 'binary_nmu_version');
1860 $print_key = 'BuildPri' if ($key eq 'buildpri');
1861 $print_key = 'Depends' if ($key eq 'depends');
1862 $print_key = 'Failed' if ($key eq 'failed');
1863 $print_key = 'Failed-Category' if ($key eq 'failed_category');
1864 $print_key = 'Notes' if ($key eq 'notes');
1865 $print_key = 'Distribution' if ($key eq 'distribution');
1866 $print_key = 'Old-Failed' if ($key eq 'old_failed');
1867 $print_key = 'PermBuildPri' if ($key eq 'permbuildpri');
1868 $print_key = 'Rel' if ($key eq 'rel');
1869 printf " %-20s: %s\n", $print_key, $val;
1875 sub forget_packages {
1876 my( $name, $pkg, $key, $data );
1878 foreach $name (@_) {
1879 $name =~ s/_.*$//; # strip version
1880 $pkg = get_source_info($name);
1881 if (!defined( $pkg )) {
1882 print "$name: not registered\n";
1887 foreach $key (sort keys %$pkg) {
1888 my $val = $pkg->{$key};
1891 $data .= sprintf " %-20s: %s\n", $key, $val;
1893 send_mail( $conf::db_maint,
1894 "$name deleted from DB " . table_name() . " " . $distribution,
1895 "The package '$name' has been deleted from the database ".
1897 "Data registered about the deleted package:\n".
1898 "$data\n" ) if $conf::db_maint;
1899 change_state( \$pkg, 'deleted' );
1900 log_ta( $pkg, "--forget" );
1901 del_source_info($name);
1902 print "$name: deleted from database\n" if $verbose;
1907 $dbh->do("DELETE from " . user_table_name() .
1908 " WHERE distribution = ?", undef, $distribution) or die $dbh->errstr;
1914 print "Reading ASCII database from $file..." if $verbose >= 1;
1915 open( F, "<$file" ) or
1916 die "Can't open database $file: $!\n";
1918 local($/) = ""; # read in paragraph mode
1920 my( %thispkg, $name );
1922 s/\n[ \t]+/\376\377/g; # fix continuation lines
1923 s/\376\377\s*\376\377/\376\377/og;
1925 while( /^(\S+):[ \t]*(.*)[ \t]*$/mg ) {
1926 my ($key, $val) = ($1, $2);
1928 $key =~ tr/A-Z/a-z/;
1929 $val =~ s/\376\377/\n/g;
1930 $thispkg{$key} = $val;
1932 check_entry( \%thispkg );
1934 if (exists($thispkg{'package'})) {
1935 update_source_info(\%thispkg);
1937 elsif(exists($thispkg{'user'})) {
1938 # user in import, username in database.
1939 $dbh->do('INSERT INTO ' . user_table_name() .
1940 ' (username, distribution, last_seen)' .
1941 ' values (?, ?, ?)',
1942 undef, $thispkg{'user'}, $distribution,
1943 $thispkg{'last_seen'})
1944 or die $dbh->errstr;
1948 print "done\n" if $verbose >= 1;
1955 return if $op_mode eq "manual-edit"; # no checks then
1957 # check for required fields
1958 if (exists $pkg->{'user'}) {
1961 if (!exists $pkg->{'package'}) {
1962 print STDERR "Bad entry: ",
1963 join( "\n", map { "$_: $pkg->{$_}" } keys %$pkg ), "\n";
1964 die "Database entry lacks package or username field\n";
1966 # if no State: field, generate one (for old db compat)
1967 if (!exists($pkg->{'state'})) {
1969 exists $pkg->{'failed'} ? 'Failed' : 'Building';
1971 if (!exists $pkg->{'version'} and $pkg->{'state'} ne 'Not-For-Us') {
1972 die "Database entry for $pkg->{'package'} lacks Version: field\n";
1975 die "Bad state $pkg->{'state'} of package $pkg->{Package}\n"
1976 if !isin( $pkg->{'state'},
1977 qw(Needs-Build Building Built Build-Attempted Uploaded Installed Dep-Wait Dep-Wait-Removed
1978 Failed Failed-Removed Not-For-Us BD-Uninstallable
1985 my $newstate = shift;
1986 my $state = \$pkg->{'state'};
1988 return if defined($$state) and $$state eq $newstate;
1989 $pkg->{'previous_state'} = $$state if defined($$state);
1990 $pkg->{'state_change'} = $curr_date;
1992 if (defined($$state) and $$state eq 'Failed') {
1993 $pkg->{'old_failed'} =
1994 "-"x20 . " $pkg->{'version'} " . "-"x20 . "\n" .
1995 $pkg->{'failed'} . "\n" .
1996 $pkg->{'old_failed'};
1997 delete $pkg->{'failed'};
1998 delete $pkg->{'failed_category'};
2000 if (defined($$state) and $$state eq 'BD-Uninstallable') {
2001 delete $pkg->{'bd_problem'};
2003 $$state = $newstate;
2009 my $dist = $distribution;
2013 $prevstate = $pkg->{'previous_state'};
2014 $str = "$action($dist): $pkg->{'package'}_$pkg->{'version'} ".
2015 "changed from $prevstate to $pkg->{'state'} ".
2016 "by $real_user as $user";
2018 my $transactlog = db_transactlog();
2019 if (!open( LOG, ">>$transactlog" )) {
2020 warn "Can't open log file $transactlog: $!\n";
2023 print LOG "$curr_date: $str\n";
2026 if (!($prevstate eq 'Failed' && $pkg->{'state'} eq 'Failed')) {
2027 $str .= " (with --override)"
2029 $mail_logs .= "$str\n";
2036 my $subject = shift;
2039 my $from = $conf::db_maint;
2040 my $domain = $conf::buildd_domain;
2042 $from .= "\@$domain" if $from !~ /\@/;
2044 $to .= '@' . $domain if $to !~ /\@/;
2045 $text =~ s/^\.$/../mg;
2046 local $SIG{'PIPE'} = 'IGNORE';
2047 open( PIPE, "| $conf::mailprog -oem $to" )
2048 or die "Can't open pipe to $conf::mailprog: $!\n";
2050 print PIPE "From: $from\n";
2051 print PIPE "Subject: $subject\n\n";
2052 print PIPE "$text\n";
2056 sub db_transactlog {
2057 return "$conf::basedir/$arch/$conf::transactlog";
2060 # for parsing input to dep-wait
2066 foreach (split( /\s*,\s*/, $deps )) {
2068 # verification requires > starting prompts, no | crap
2069 if (!/^(\S+)\s*(\(\s*(>(?:[>=])?)\s*(\S+)\s*\))?\s*$/) {
2074 my @alts = split( /\s*\|\s*/, $_ );
2075 # Anything with an | is ignored, as it can be configured on a
2076 # per-buildd basis what will be installed
2077 next if $#alts != 0;
2080 if (!/^(\S+)\s*(\(\s*(>=|=|==|>|>>|<<|<=)\s*(\S+)\s*\))?\s*$/) {
2081 warn( "parse_deplist: bad dependency $_\n" );
2084 my($dep, $rel, $relv) = ($1, $3, $4);
2085 $rel = ">>" if defined($rel) and $rel eq ">";
2086 $result{$dep}->{'package'} = $dep;
2087 if ($rel && $relv) {
2088 $result{$dep}->{'rel'} = $rel;
2089 $result{$dep}->{'version'} = $relv;
2092 return 1 if $verify;
2096 # for parsing Build-Depends from Sources
2097 sub parse_srcdeplist {
2104 foreach $dep (split( /\s*,\s*/, $deps )) {
2105 my @alts = split( /\s*\|\s*/, $dep );
2106 # Anything with an | is ignored, as it can be configured on a
2107 # per-buildd basis what will be installed
2108 next if $#alts != 0;
2110 if (!/^([^\s([]+)\s*(\(\s*([<=>]+)\s*(\S+)\s*\))?(\s*\[([^]]+)\])?/) {
2111 warn( "parse_srcdeplist: bad dependency $_\n" );
2114 my($dep, $rel, $relv, $archlist) = ($1, $3, $4, $6);
2116 $archlist =~ s/^\s*(.*)\s*$/$1/;
2117 my @archs = split( /\s+/, $archlist );
2118 my ($use_it, $ignore_it, $include) = (0, 0, 0);
2121 $ignore_it = 1 if substr($_, 1) eq $arch;
2123 $use_it = 1 if $_ eq $arch;
2127 warn "Warning: inconsistent arch restriction on ",
2128 "$pkg: $dep depedency\n"
2129 if $ignore_it && $use_it;
2130 next if $ignore_it || ($include && !$use_it);
2138 $result->{'package'} = $dep;
2139 $result->{'Neg'} = $neg;
2140 if ($rel && $relv) {
2141 $result->{'rel'} = $rel;
2142 $result->{'version'} = $relv;
2144 push @results, $result;
2153 foreach $key (keys %$list) {
2154 $result .= ", " if $result;
2156 $result .= " ($list->{$key}->{'rel'} $list->{$key}->{'version'})"
2157 if $list->{$key}->{'rel'} && $list->{$key}->{'version'};
2162 sub get_unsatisfied_dep {
2166 my $savedep = shift;
2168 my $pkgname = $dep->{'package'};
2170 if (defined $pkgs->{$pkgname}{'Provider'}) {
2171 # provides. leave them for buildd/sbuild.
2176 return $pkgs->{$pkgname}{'Unsatisfied'} if $savedep and defined($pkgs->{$pkgname}{'Unsatisfied'});
2178 # Return unsatisfied deps to a higher caller to process
2179 if ((!defined($pkgs->{$pkgname})) or
2180 (defined($dep->{'rel'}) and !version_compare( $pkgs->{$pkgname}{'version'}, $dep->{'rel'}, $dep->{'Version'} ) ) ) {
2182 $deplist{$pkgname} = $dep;
2183 my $deps = build_deplist(\%deplist);
2184 $pkgs->{$pkgname}{'Unsatisfied'} = $deps if $savedep;
2188 # set cache to "" to avoid infinite recursion
2189 $pkgs->{$pkgname}{'Unsatisfied'} = "" if $savedep;
2191 if (defined $pkgs->{$dep->{'package'}}{'depends'}) {
2192 my $deps = parse_deplist( $pkgs->{$dep->{'package'}}{'depends'} );
2193 foreach (keys %$deps) {
2196 my $ret = get_unsatisfied_dep($bd,$pkgs,$dep,1);
2198 my $retdep = parse_deplist( $ret );
2199 foreach (keys %$retdep) {
2200 $dep = $$retdep{$_};
2202 $dep->{'rel'} = '>=' if defined($dep->{'rel'}) and $dep->{'rel'} =~ '^=';
2204 if (defined($dep->{'rel'}) and $dep->{'rel'} =~ '^>' and defined ($pkgs->{$dep->{'package'}}) and
2205 version_compare($bd->{$pkgs->{$dep->{'package'}}{'Source'}}{'ver'},'>>',$pkgs->{$dep->{'package'}}{'Sourcev'})) {
2206 if (not defined($merge_binsrc{$dep->{'package'}})) {
2207 # the uninstallable package doesn't exist in the new source; look for something else that does.
2208 delete $$retdep{$dep->{'package'}};
2209 foreach (sort (split( /\s*,\s*/, $bd->{$pkgs->{$dep->{'package'}}{'Source'}}{'bin'}))) {
2210 next if ($pkgs->{$_}{'all'} or not defined $pkgs->{$_}{'version'});
2211 $dep->{'package'} = $_;
2212 $dep->{'rel'} = '>>';
2213 $dep->{'version'} = $pkgs->{$_}{'Version'};
2214 $$retdep{$_} = $dep;
2219 # sanity check to make sure the depending binary still exists, and the depended binary exists and dep-wait on a new version of it
2220 if ( defined($merge_binsrc{$pkgname}) and defined($pkgs->{$dep->{'package'}}{'version'}) ) {
2221 delete $$retdep{$dep->{'package'}};
2222 $dep->{'package'} = $pkgname;
2223 $dep->{'rel'} = '>>';
2224 $dep->{'version'} = $pkgs->{$pkgname}{'Version'};
2225 $$retdep{$pkgname} = $dep;
2227 delete $$retdep{$dep->{'package'}} if (defined ($dep->{'rel'}) and $dep->{'rel'} =~ '^>');
2230 $ret = build_deplist($retdep);
2231 $pkgs->{$pkgname}{'Unsatisfied'} = $ret if $savedep;
2239 sub call_edos_depcheck {
2240 my $packagesfile = shift;
2244 return if defined ($conf::distributions{$distribution}{noadw});
2246 # We need to check all of needs-build, as any new upload could make
2247 # something in needs-build have uninstallable deps
2248 # We also check everything in bd-uninstallable, as any new upload could
2249 # make that work again
2250 my %interesting_packages;
2251 my $db = get_all_source_info();
2252 foreach $key (keys %$db) {
2253 my $pkg = $db->{$key};
2254 if (defined $pkg and isin($pkg->{'state'}, qw/Needs-Build BD-Uninstallable/)) {
2255 $interesting_packages{$key} = undef;
2259 #print "I would look at these sources with edos-depcheck:\n";
2260 #print join " ", keys %interesting_packages,"\n";
2262 my $tmpfile_pattern = "/tmp/wanna-build-interesting-sources-$distribution.$$-";
2264 for( $i = 0;; ++$i ) {
2265 $tmpfile = $tmpfile_pattern . $i;
2266 last if ! -e $tmpfile;
2269 open SOURCES, '>', $tmpfile or die "Could not open temporary file $tmpfile\n";
2270 for my $key (keys %interesting_packages) {
2271 my $pkg = get_source_info($key);
2272 print SOURCES "Package: $key\n";
2273 print SOURCES "Version: $pkg->{'version'}\n";
2274 print SOURCES "Build-Depends: $srcs->{$key}{'dep'}\n" if $srcs->{$key}{'dep'};
2275 print SOURCES "Build-Conflicts: $srcs->{$key}{'conf'}\n" if $srcs->{$key}{'conf'};
2276 print SOURCES "Architecture: all\n";
2281 if (open(EDOS,"-|","wb-edos-builddebcheck", "-a", $arch, $packagesfile, $tmpfile))
2283 local($/) = ""; # read in paragraph mode
2285 my( $key, $reason ) ;
2287 /^Package:\s*(\S+)$/mi and $key = $1;
2288 /^Failed-Why:(([^\n]|\n ([^\n]|\.))*)$/msi and $reason = $1;
2289 $reason =~ s/^\s*//mg;
2290 $reason ||= 'No reason given by edos-debcheck';
2292 if (exists $interesting_packages{$key}) {
2293 $interesting_packages{$key} = $reason;
2295 #print "TODO: edos reported a package we do not care about now\n" if $verbose;
2300 print "ERROR: Could not run wb-edos-builddebcheck. I am continuing, assuming\n" .
2301 "all packages have installable build-dependencies."
2306 for my $key (keys %interesting_packages) {
2307 my $pkg = get_source_info($key);
2309 (defined $interesting_packages{$key} and $pkg->{'state'} eq 'Needs-Build') ||
2310 (not defined $interesting_packages{$key} and $pkg->{'state'} eq 'BD-Uninstallable');
2311 my $problemchange = $interesting_packages{$key} ne $pkg->{'bd_problem'};
2313 if (defined $interesting_packages{$key}) {
2314 change_state( \$pkg, 'BD-Uninstallable' );
2315 $pkg->{'bd_problem'} = $interesting_packages{$key};
2317 change_state( \$pkg, 'Needs-Build' );
2320 if ($problemchange) {
2321 if (defined $interesting_packages{$key}) {
2322 $pkg->{'bd_problem'} = $interesting_packages{$key};
2326 log_ta( $pkg, "--merge-all" );
2327 print "edos-builddebchange changed state of ${key}_$pkg->{'version'} to $pkg->{'state'}\n" if $verbose;
2329 if ($change || $problemchange) {
2330 update_source_info($pkg);
2337 ($prgname = $0) =~ s,^.*/,,;
2339 Usage: $prgname <options...> <package_version...>
2341 -v, --verbose: Verbose execution.
2342 -A arch: Architecture this operation is for.
2343 --take: Take package for building [default operation]
2344 -f, --failed: Record in database that a build failed due to
2345 deficiencies in the package (that aren't fixable without a new
2347 -u, --uploaded: Record in the database that the packages build
2348 correctly and were uploaded.
2349 -n, --no-build: Record in the database that the packages aren't
2350 desired for this architecture and shouldn't appear in listings even
2351 if they're out of date.
2352 --dep-wait: Record in the database that the packages are waiting
2353 for some source dependencies to become available
2354 --binNMU num: Schedule a re-build of the package with unchanged source, but
2355 a new version number (source-version + "+b<num>")
2356 --give-back: Mark a package as ready to build that is in state Building,
2357 Built or Build-Attempted. To give back a package in state Failed, use
2358 --override. This command will actually put the package in state
2359 BD-Uninstallable, until the installability of its Build-Dependencies
2360 were verified. This happens at each call of --merge-all, usually
2362 --merge-quinn: Merge quinn-diff output into database.
2363 --merge-packages: Merge Packages files into database.
2364 --pretend-avail: Pretend that given packages are available now and give
2365 free packages waiting for them
2366 -i SRC_PKG, --info SRC_PKG: Show information for source package
2367 -l STATE, --list=STATE: List all packages in state STATE; can be
2368 combined with -U to restrict to a specific user; STATE can
2370 -m MESSAGE, --message=MESSAGE: Give reason why package failed or
2371 source dependency list
2372 (used with -f, --dep-wait, and --binNMU)
2373 -o, --override: Override another user's lock on a package, i.e.
2374 take it over; a notice mail will be sent to the other user
2375 -U USER, --user=USER: select user name for which listings should
2376 apply, if not given all users are listed.
2377 if -l is missing, set user name to be entered in db; usually
2378 automatically choosen
2379 --import FILE: Import database from a ASCII file FILE
2381 The remaining arguments (depending on operation) usually start with
2382 "name_version", the trailer is ignored. This allows to pass the names
2383 of .dsc files, for which file name completion can be used.
2384 --merge-packages and --merge-quinn take Package/quin--diff file names
2385 on the command line or read stdin. --list needs nothing more on the
2386 command line. --info takes source package names (without version).
2391 sub pkg_version_eq {
2393 my $version = shift;
2396 if (defined $pkg->{'binary_nmu_version'}) and
2397 version_compare(binNMU_version($pkg->{'version'},
2398 $pkg->{'binary_nmu_version'}),'=', $version);
2399 return version_compare( $pkg->{'version'}, "=", $version );
2403 return '"' . $arch . $schema_suffix . '".packages';
2406 sub user_table_name {
2407 return '"' . $arch . $schema_suffix . '".users';
2410 sub get_readonly_source_info {
2412 my $pkg = $dbh->selectrow_hashref('SELECT * FROM ' .
2413 table_name() . ' WHERE package = ? AND distribution = ?',
2414 undef, $name, $distribution);
2418 sub get_source_info {
2420 my $pkg = $dbh->selectrow_hashref('SELECT * FROM ' .
2421 table_name() . ' WHERE package = ? AND distribution = ?' .
2423 undef, $name, $distribution);
2427 sub get_all_source_info {
2430 my $q = 'SELECT * FROM ' . table_name()
2431 . ' WHERE distribution = ? ';
2432 my @args = ($distribution);
2433 if (uc($options{state}) ne "ALL") {
2434 $q .= ' AND upper(state) = ? ';
2435 push @args, uc($options{state});
2438 if ($options{user}) {
2439 #this basically means "this user, or no user at all":
2440 $q .= ' AND (builder = ? OR upper(state) = ?)';
2441 push @args, $options{user};
2442 push @args, "NEEDS-BUILD";
2445 if ($options{category}) {
2446 $q .= ' AND failed_category <> ? AND upper(state) = ? ';
2447 push @args, $options{category};
2448 push @args, "FAILED";
2451 if ($options{list_min_age} > 0) {
2452 $q .= ' AND age(state_change::timestamp) > ? ';
2453 push @args, $options{list_min_age} . " days";
2456 if ($options{list_min_age} < 0) {
2457 $q .= ' AND age(state_change::timestamp) < ? days ';
2458 push @args, -$options{list_min_age} . " days";
2461 my $db = $dbh->selectall_hashref($q, 'package', undef, @args);
2465 sub update_source_info {
2468 my $pkg2 = get_source_info($pkg->{'package'});
2469 if (! defined $pkg2)
2471 add_source_info($pkg);
2474 $dbh->do('UPDATE ' . table_name() . ' SET ' .
2479 'installed_version = ?, ' .
2480 'previous_state = ?, ' .
2481 'state_change = ?, ' .
2485 'old_failed = ?, ' .
2486 'binary_nmu_version = ?, ' .
2487 'binary_nmu_changelog = ?, ' .
2488 'failed_category = ?, ' .
2489 'permbuildpri = ?, ' .
2494 'WHERE package = ? AND distribution = ?',
2500 $pkg->{'installed_version'},
2501 $pkg->{'previous_state'},
2502 $pkg->{'state_change'},
2506 $pkg->{'old_failed'},
2507 $pkg->{'binary_nmu_version'},
2508 $pkg->{'binary_nmu_changelog'},
2509 $pkg->{'failed_category'},
2510 $pkg->{'permbuildpri'},
2514 $pkg->{'bd_problem'},
2516 $distribution) or die $dbh->errstr;
2519 sub add_source_info {
2521 $dbh->do('INSERT INTO ' . table_name() .
2522 ' (package, distribution) values (?, ?)',
2523 undef, $pkg->{'package'}, $distribution) or die $dbh->errstr;
2526 sub del_source_info {
2528 $dbh->do('DELETE FROM ' . table_name() .
2529 ' WHERE package = ? AND distribution = ?',
2530 undef, $name, $distribution) or die $dbh->errstr;
2535 my $user = $dbh->selectrow_hashref('SELECT * FROM ' .
2536 user_table_name() . ' WHERE username = ? AND distribution = ?',
2537 undef, $name, $distribution);
2541 sub update_user_info {
2543 $dbh->do('UPDATE ' . user_table_name() .
2544 ' SET last_seen = now() WHERE username = ?' .
2545 ' AND distribution = ?',
2546 undef, $user, $distribution)
2547 or die $dbh->errstr;
2553 $dbh->do('INSERT INTO ' . user_table_name() .
2554 ' (username, distribution, last_seen)' .
2555 ' values (?, ?, now())',
2556 undef, $user, $distribution)
2557 or die $dbh->errstr;