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, $export_to, $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 export => { arg => \$export_to, mode => "export" },
185 import => { arg => \$import_from, mode => "import" },
186 "manual-edit" => { mode => "manual-edit" },
189 while( @ARGV && $ARGV[0] =~ /^-/ ) {
192 my($opt, $optname, $arg);
193 if (/^--([^=]+)(=|$)/) {
195 $opt = $options{$optname};
196 $arg = $1 if /^--\Q$optname\E=((.|\n)*)$/;
199 $optname = substr( $_, 1, 1 );
200 $opt = (grep { defined($_->{short}) ? $_->{short} eq $optname : 0} values %options)[0];
201 $arg = $1 if /^-$optname(.+)$/;
204 warn "Unknown option: --$1\n";
209 die "$optname option missing argument\n" if !@ARGV;
212 ${$opt->{arg}} = $arg;
214 elsif (defined $arg) {
215 die "Option $optname takes no argument\n";
219 die "Conflicting operation modes\n" if $op_mode;
220 $op_mode = $opt->{mode};
230 $op_mode = $category ? "set-failed" : "set-building"
231 if !$op_mode; # default operation
232 $list_order = $list_state eq "failed" ? 'fPcpsn' : 'PScpsn'
233 if !$list_order and $list_state;
234 $distribution ||= "unstable";
235 die "Bad distribution '$distribution'\n"
236 if !isin($distribution, keys %conf::distributions);
238 # If they didn't specify an arch, try to get it from database name which
239 # is in the form of $arch/build-db
240 # This is for backwards compatibity with older versions that didn't
241 # specify the arch yet.
242 $conf::dbbase =~ m#^([^/]+)#;
245 # TODO: Check that it's an known arch (for that dist), and give
249 my $version = '$Revision: db181a534e9d $ $Date: 2008/03/26 06:20:22 $ $Author: rmurray $';
250 $version =~ s/(^\$| \$ .*$)//g;
251 print "wanna-build $version for $distribution on $arch\n";
254 if (!@ARGV && !isin( $op_mode, qw(list merge-quinn merge-partial-quinn import export
255 merge-packages manual-edit
257 warn "No packages given.\n";
261 $real_user = (getpwuid($<))[0];
262 die "Can't determine your user name\n"
263 if $op_mode ne "list" && !$user &&
264 !($user = $real_user);
267 if ($op_mode eq "set-failed" && !$category) {
268 print "Enter reason for failing (end with '.' alone on ".
273 last if $line eq ".\n";
274 $fail_reason .= $line;
276 chomp( $fail_reason );
277 } elsif ($op_mode eq "set-dep-wait") {
278 print "Enter dependencies (one line):\n";
280 while( !$line && !eof(STDIN) ) {
281 chomp( $line = <STDIN> );
283 die "No dependencies given\n" if !$line;
284 $fail_reason = $line;
285 } elsif ($op_mode eq "set-binary-nmu" and $binNMUver > 0) {
286 print "Enter changelog entry (one line):\n";
288 while( !$line && !eof(STDIN) ) {
289 chomp( $line = <STDIN> );
291 die "No changelog entry given\n" if !$line;
292 $fail_reason = $line;
301 $dbh->disconnect or warn $dbh->errstr;
305 my $schema_suffix = '';
306 if (isin( $op_mode, qw(list info)) && $distribution !~ /security/ && !(not -t and $user =~ /-/)) {
307 $dbh = DBI->connect("DBI:Pg:service=wanna-build") ||
308 die "FATAL: Cannot open database: $DBI::errstr\n";
309 $schema_suffix = '_public';
313 $dbh = DBI->connect("DBI:Pg:service=wanna-build-privileged") ||
314 die "FATAL: Cannot open database: $DBI::errstr\n";
317 # TODO: This shouldn't be needed, file a bug.
318 $dbh->{pg_server_prepare} = 0;
320 $dbh->begin_work or die $dbh->errstr;
327 if ($mail_logs && $conf::log_mail) {
328 send_mail( $conf::log_mail,
329 "wanna-build $distribution state changes $curr_date",
330 "State changes at $curr_date for distribution ".
331 "$distribution:\n\n$mail_logs\n" );
339 SWITCH: foreach ($op_mode) {
341 add_packages( $1, @ARGV );
345 list_packages( $list_state );
349 info_packages( @ARGV );
352 /^forget-user/ && do {
353 die "This operation is restricted to admin users\n"
354 if (defined @conf::admin_users and
355 !isin( $real_user, @conf::admin_users));
356 forget_users( @ARGV );
360 forget_packages( @ARGV );
363 /^merge-partial-quinn/ && do {
364 die "This operation is restricted to admin users\n"
365 if (defined @conf::admin_users and
366 !isin( $real_user, @conf::admin_users));
370 /^merge-quinn/ && do {
371 die "This operation is restricted to admin users\n"
372 if (defined @conf::admin_users and
373 !isin( $real_user, @conf::admin_users));
377 /^merge-packages/ && do {
378 die "This operation is restricted to admin users\n"
379 if (defined @conf::admin_users and
380 !isin( $real_user, @conf::admin_users));
384 /^merge-sources/ && do {
385 die "This operation is restricted to admin users\n"
386 if (defined @conf::admin_users and
387 !isin( $real_user, @conf::admin_users));
391 /^pretend-avail/ && do {
392 pretend_avail( @ARGV );
396 die "This operation is restricted to admin users\n"
397 if (defined @conf::admin_users and
398 !isin( $real_user, @conf::admin_users));
400 @ARGV = ( $ARGS[0] );
401 my $pkgs = parse_packages();
402 @ARGV = ( $ARGS[1] );
404 @ARGV = ( $ARGS[2] );
405 my $srcs = parse_sources(1);
406 call_edos_depcheck( $ARGS[0], $srcs );
410 die "This operation is restricted to admin users\n"
411 if (defined @conf::admin_users and
412 !isin( $real_user, @conf::admin_users));
413 $dbh->do("DELETE from " . table_name() .
414 " WHERE distribution = ?", undef,
418 read_db( $import_from );
422 export_db( $export_to );
426 die "Unexpected operation mode $op_mode\n";
428 if (not -t and $user =~ /-/) {
429 my $userinfo = get_user_info($user);
430 if (!defined $userinfo)
432 add_user_info($user);
436 update_user_info($user);
442 my $newstate = shift;
443 my( $package, $name, $version, $ok, $reason );
445 foreach $package (@_) {
446 $package =~ s,^.*/,,; # strip path
447 $package =~ s/\.(dsc|diff\.gz|tar\.gz|deb)$//; # strip extension
448 $package =~ s/_[a-zA-Z\d-]+\.changes$//; # strip extension
449 if ($package =~ /^([\w\d.+-]+)_([\w\d:.+~-]+)/) {
450 ($name,$version) = ($1,$2);
453 warn "$package: can't extract package name and version ".
458 if ($op_mode eq "set-building") {
459 add_one_building( $name, $version );
461 elsif ($op_mode eq "set-built") {
462 add_one_built( $name, $version );
464 elsif ($op_mode eq "set-attempted") {
465 add_one_attempted( $name, $version );
467 elsif ($op_mode eq "set-uploaded") {
468 add_one_uploaded( $name, $version );
470 elsif ($op_mode eq "set-failed") {
471 add_one_failed( $name, $version );
473 elsif ($op_mode eq "set-not-for-us") {
474 add_one_notforus( $name, $version );
476 elsif ($op_mode eq "set-needs-build") {
477 add_one_needsbuild( $name, $version );
479 elsif ($op_mode eq "set-dep-wait") {
480 add_one_depwait( $name, $version );
482 elsif ($op_mode eq "set-build-priority") {
483 set_one_buildpri( $name, $version, 'buildpri' );
485 elsif ($op_mode eq "set-permanent-build-priority") {
486 set_one_buildpri( $name, $version, 'permbuildpri' );
488 elsif ($op_mode eq "set-binary-nmu") {
489 set_one_binnmu( $name, $version );
494 sub add_one_building {
500 my $pkg = get_source_info($name);
502 if ($pkg->{'state'} eq "Not-For-Us") {
504 $reason = "not suitable for this architecture";
506 elsif ($pkg->{'state'} =~ /^Dep-Wait/) {
508 $reason = "not all source dependencies available yet";
510 elsif ($pkg->{'state'} =~ /^BD-Uninstallable/) {
512 $reason = "source dependencies are not installable";
514 elsif ($pkg->{'state'} eq "Uploaded" &&
515 (version_lesseq($version, $pkg->{'version'}))) {
517 $reason = "already uploaded by $pkg->{'builder'}";
518 $reason .= " (in newer version $pkg->{'version'})"
519 if !version_eq($pkg, $version);
521 elsif ($pkg->{'state'} eq "Installed" &&
522 version_less($version,$pkg->{'version'})) {
524 print "$name: Warning: newer version $pkg->{'version'} ".
525 "already installed, but overridden.\n";
529 $reason = "newer version $pkg->{'version'} already in ".
530 "archive; doesn't need rebuilding";
531 print "$name: Note: If the following is due to an epoch ",
532 " change, use --override\n";
535 elsif ($pkg->{'state'} eq "Installed" &&
536 pkg_version_eq($pkg,$version)) {
538 $reason = "is up-to-date in the archive; doesn't need rebuilding";
540 elsif ($pkg->{'state'} eq "Needs-Build" &&
541 version_less($version,$pkg->{'version'})) {
543 print "$name: Warning: newer version $pkg->{'version'} ".
544 "needs building, but overridden.";
548 $reason = "newer version $pkg->{'version'} needs building, ".
552 elsif (isin($pkg->{'state'},qw(Building Built Build-Attempted))) {
553 if (version_less($pkg->{'version'},$version)) {
554 print "$name: Warning: Older version $pkg->{'version'} ",
555 "is being built by $pkg->{'builder'}\n";
556 if ($pkg->{'builder'} ne $user) {
557 send_mail( $pkg->{'builder'},
558 "package takeover in newer version",
559 "You are building package '$name' in ".
560 "version $version\n".
561 "(as far as I'm informed).\n".
562 "$user now has taken the newer ".
563 "version $version for building.".
564 "You can abort the build if you like.\n" );
569 print "User $pkg->{'builder'} had already ",
570 "taken the following package,\n",
571 "but overriding this as you request:\n";
572 send_mail( $pkg->{'builder'}, "package takeover",
573 "The package '$name' (version $version) that ".
574 "was taken by you\n".
575 "has been taken over by $user\n" );
577 elsif ($pkg->{'builder'} eq $user) {
578 print "$name: Note: already taken by you.\n";
579 print "$name: ok\n" if $verbose;
584 $reason = "already taken by $pkg->{'builder'}";
585 $reason .= " (in newer version $pkg->{'version'})"
586 if !version_eq($pkg->{'version'}, $version);
590 elsif ($pkg->{'state'} =~ /^Failed/ &&
591 pkg_version_eq($pkg, $version)) {
593 print "The following package previously failed ",
594 "(by $pkg->{'builder'})\n",
595 "but overriding this as you request:\n";
596 send_mail( $pkg->{'builder'}, "failed package takeover",
597 "The package '$name' (version $version) that ".
599 "and has failed previously has been taken over ".
601 if $pkg->{'builder'} ne $user;
605 $reason = "build of $version failed previously:\n ";
606 $reason .= join( "\n ", split( "\n", $pkg->{'failed'} ));
607 $reason .= "\nalso the package doesn't need builing"
608 if $pkg->{'state'} eq 'Failed-Removed';
614 if ($pkg->{'binary_nmu_version'}) {
615 print "$name: Warning: needs binary NMU $pkg->{'binary_nmu_version'}\n" .
616 "$pkg->{'binary_nmu_changelog'}\n";
619 print "$name: Warning: Previous version failed!\n"
620 if $pkg->{'previous_state'} =~ /^Failed/ ||
621 $pkg->{'state'} =~ /^Failed/;
623 change_state( \$pkg, 'Building' );
624 $pkg->{'package'} = $name;
625 $pkg->{'version'} = $version;
626 $pkg->{'builder'} = $user;
627 log_ta( $pkg, "--take" );
628 update_source_info($pkg);
629 print "$name: $ok\n" if $verbose;
632 print "$name: NOT OK!\n $reason\n";
636 sub add_one_attempted {
639 my $pkg = get_source_info($name);
641 if (!defined($pkg)) {
642 print "$name: not registered yet.\n";
646 if ($pkg->{'state'} ne "Building" ) {
647 print "$name: not taken for building (state is $pkg->{'state'}). ",
651 if ($pkg->{'builder'} ne $user) {
652 print "$name: not taken by you, but by $pkg->{'builder'}. Skipping.\n";
655 elsif ( !pkg_version_eq($pkg, $version) ) {
656 print "$name: version mismatch ".
657 "$(pkg->{'version'} ".
658 "by $pkg->{'builder'})\n";
662 change_state( \$pkg, 'Build-Attempted' );
663 log_ta( $pkg, "--attempted" );
664 update_source_info($pkg);
665 print "$name: registered as uploaded\n" if $verbose;
671 my $pkg = get_source_info($name);
673 if (!defined($pkg)) {
674 print "$name: not registered yet.\n";
678 if ($pkg->{'state'} ne "Building" ) {
679 print "$name: not taken for building (state is $pkg->{'state'}). ",
683 if ($pkg->{'builder'} ne $user) {
684 print "$name: not taken by you, but by $pkg->{'builder'}. Skipping.\n";
687 elsif ( !pkg_version_eq($pkg, $version) ) {
688 print "$name: version mismatch ".
689 "$(pkg->{'version'} ".
690 "by $pkg->{'builder'})\n";
693 change_state( \$pkg, 'Built' );
694 log_ta( $pkg, "--built" );
695 update_source_info($pkg);
696 print "$name: registered as built\n" if $verbose;
699 sub add_one_uploaded {
702 my $pkg = get_source_info($name);
704 if (!defined($pkg)) {
705 print "$name: not registered yet.\n";
709 if ($pkg->{'state'} eq "Uploaded" &&
710 pkg_version_eq($pkg,$version)) {
711 print "$name: already uploaded\n";
714 if (!isin( $pkg->{'state'}, qw(Building Built Build-Attempted))) {
715 print "$name: not taken for building (state is $pkg->{'state'}). ",
719 if ($pkg->{'builder'} ne $user) {
720 print "$name: not taken by you, but by $pkg->{'builder'}. Skipping.\n";
723 # strip epoch -- buildd-uploader used to go based on the filename.
724 # (to remove at some point)
726 ($pkgver = $pkg->{'version'}) =~ s/^\d+://;
727 $version =~ s/^\d+://; # for command line use
728 if ($pkg->{'binary_nmu_version'} ) {
729 my $nmuver = binNMU_version($pkgver, $pkg->{'binary_nmu_version'});
730 if (!version_eq( $nmuver, $version )) {
731 print "$name: version mismatch ($nmuver registered). ",
735 } elsif (!version_eq($pkgver, $version)) {
736 print "$name: version mismatch ($pkg->{'version'} registered). ",
741 change_state( \$pkg, 'Uploaded' );
742 log_ta( $pkg, "--uploaded" );
743 update_source_info($pkg);
744 print "$name: registered as uploaded\n" if $verbose;
751 my $pkg = get_source_info($name);
753 if (!defined($pkg)) {
754 print "$name: not registered yet.\n";
757 $state = $pkg->{'state'};
759 if ($state eq "Not-For-Us") {
760 print "$name: not suitable for this architecture anyway. Skipping.\n";
763 elsif ($state eq "Failed-Removed") {
764 print "$name: failed previously and doesn't need building. Skipping.\n";
767 elsif ($state eq "Installed") {
768 print "$name: Is already installed in archive. Skipping.\n";
771 elsif ($pkg->{'builder'} &&
772 (($user ne $pkg->{'builder'}) &&
773 !($pkg->{'builder'} =~ /^(\w+)-\w+/ && $1 eq $user))) {
774 print "$name: not taken by you, but by ".
775 "$pkg->{'builder'}. Skipping.\n";
778 elsif ( !pkg_version_eq($pkg, $version) ) {
779 print "$name: version mismatch ".
780 "$(pkg->{'version'} ".
781 "by $pkg->{'builder'})\n";
786 if (!$cat && $fail_reason =~ /^\[([^\]]+)\]/) {
788 $cat = $short_category{$cat} if exists $short_category{$cat};
789 if (!isin( $cat, values %short_category )) {
790 print "$name: Warning: unknown category $cat; discarded\n";
793 $fail_reason =~ s/^\[[^\]]+\][ \t]*\n*//;
796 if ($state eq "Needs-Build") {
797 print "$name: Warning: not registered for building previously, ".
798 "but processing anyway.\n";
800 elsif ($state eq "Uploaded") {
801 print "$name: Warning: marked as uploaded previously, ".
802 "but processing anyway.\n";
804 elsif ($state eq "Dep-Wait") {
805 print "$name: Warning: marked as waiting for dependencies, ".
806 "but processing anyway.\n";
808 elsif ($state eq "BD-Uninstallable") {
809 print "$name: Warning: marked as having uninstallable build-dependencies, ".
810 "but processing anyway.\n";
812 elsif ($state eq "Failed") {
813 print "$name: already registered as failed; will append new message\n"
815 print "$name: already registered as failed; changing category\n"
819 if (($cat eq "reminder-sent" || $cat eq "nmu-offered") &&
820 defined $pkg->{'failed_category'} &&
821 $pkg->{'failed_category'} ne $cat) {
822 (my $action = $cat) =~ s/-/ /;
823 $fail_reason .= "\n$short_date: $action";
826 change_state( \$pkg, 'Failed' );
827 $pkg->{'builder'} = $user;
828 $pkg->{'failed'} .= "\n" if $pkg->{'failed'};
829 $pkg->{'failed'} .= $fail_reason;
830 $pkg->{'failed_category'} = $cat if $cat;
831 if (defined $pkg->{'permbuildpri'}) {
832 $pkg->{'buildpri'} = $pkg->{'permbuildpri'};
834 delete $pkg->{'buildpri'};
836 log_ta( $pkg, "--failed" );
837 update_source_info($pkg);
838 print "$name: registered as failed\n" if $verbose;
841 sub add_one_notforus {
844 my $pkg = get_source_info($name);
846 if ($pkg->{'state'} eq 'Not-For-Us') {
847 # reset Not-For-Us state in case it's called twice; this is
848 # the only way to get a package out of this state...
849 # There is no really good state in which such packages should
850 # be put :-( So use Failed for now.
851 change_state( \$pkg, 'Failed' );
852 $pkg->{'package'} = $name;
853 $pkg->{'failed'} = "Was Not-For-Us previously";
854 delete $pkg->{'builder'};
855 delete $pkg->{'depends'};
856 log_ta( $pkg, "--no-build(rev)" );
857 print "$name: now not unsuitable anymore\n";
859 send_mail( $conf::notforus_maint,
860 "$name moved out of Not-For-Us state",
861 "The package '$name' has been moved out of the Not-For-Us ".
863 "It should probably also be removed from ".
864 "Packages-arch-specific or\n".
865 "the action was wrong.\n" )
866 if $conf::notforus_maint;
869 change_state( \$pkg, 'Not-For-Us' );
870 $pkg->{'package'} = $name;
871 delete $pkg->{'builder'};
872 delete $pkg->{'depends'};
873 delete $pkg->{'buildpri'};
874 delete $pkg->{'binary_nmu_version'};
875 delete $pkg->{'binary_nmu_changelog'};
876 log_ta( $pkg, "--no-build" );
877 print "$name: registered as unsuitable\n" if $verbose;
879 send_mail( $conf::notforus_maint,
880 "$name set to Not-For-Us",
881 "The package '$name' has been set to state Not-For-Us ".
883 "It should probably also be added to ".
884 "Packages-arch-specific or\n".
885 "the Not-For-Us state is wrong.\n" )
886 if $conf::notforus_maint;
888 update_source_info($pkg);
891 sub add_one_needsbuild {
895 my $pkg = get_source_info($name);
897 if (!defined($pkg)) {
898 print "$name: not registered; can't give back.\n";
901 $state = $pkg->{'state'};
903 if ($state eq "BD-Uninstallable") {
905 print "$name: Forcing uninstallability mark to be removed. This is not permanent and might be reset with the next trigger run\n";
907 change_state( \$pkg, 'Needs-Build' );
908 delete $pkg->{'builder'};
909 delete $pkg->{'depends'};
910 log_ta( $pkg, "--give-back" );
911 update_source_info($pkg);
912 print "$name: given back\n" if $verbose;
916 print "$name: has uninstallable build-dependencies. Skipping\n",
917 " (use --override to clear dependency list and ",
918 "give back anyway)\n";
922 elsif ($state eq "Dep-Wait") {
924 print "$name: Forcing source dependency list to be cleared\n";
927 print "$name: waiting for source dependencies. Skipping\n",
928 " (use --override to clear dependency list and ",
929 "give back anyway)\n";
933 elsif (!isin( $state, qw(Building Built Build-Attempted))) {
934 print "$name: not taken for building (state is $state).";
936 print "\n$name: Forcing give-back\n";
939 print " Skipping.\n";
943 if (defined ($pkg->{'builder'}) && $user ne $pkg->{'builder'} &&
944 !($pkg->{'builder'} =~ /^(\w+)-\w+/ && $1 eq $user) &&
946 print "$name: not taken by you, but by ".
947 "$pkg->{'builder'}. Skipping.\n";
950 if (!pkg_version_eq($pkg, $version)) {
951 print "$name: version mismatch ($pkg->{'version'} registered). ",
955 if ($distribution eq "unstable") {
956 change_state( \$pkg, 'BD-Uninstallable' );
957 $pkg->{'bd_problem'} = "Installability of build dependencies not tested yet";
959 change_state( \$pkg, 'Needs-Build' );
961 $pkg->{'builder'} = undef;
962 $pkg->{'depends'} = undef;
963 log_ta( $pkg, "--give-back" );
964 update_source_info($pkg);
965 print "$name: given back\n" if $verbose;
971 my $pkg = get_source_info($name);
974 if (!defined($pkg)) {
975 print "$name: not registered; can't register for binNMU.\n";
978 my $db_ver = $pkg->{'version'};
980 if (!version_eq($db_ver, $version)) {
981 print "$name: version mismatch ($db_ver registered). ",
985 $state = $pkg->{'state'};
987 if (defined $pkg->{'binary_nmu_version'}) {
988 if ($binNMUver == 0) {
989 change_state( \$pkg, 'Installed' );
990 delete $pkg->{'builder'};
991 delete $pkg->{'depends'};
992 delete $pkg->{'binary_nmu_version'};
993 delete $pkg->{'binary_nmu_changelog'};
994 } elsif ($binNMUver <= $pkg->{'binary_nmu_version'}) {
995 print "$name: already building binNMU $pkg->{'binary_nmu_version'}\n";
998 $pkg->{'binary_nmu_version'} = $binNMUver;
999 $pkg->{'binary_nmu_changelog'} = $fail_reason;
1000 $pkg->{'notes'} = 'out-of-date';
1001 $pkg->{'buildpri'} = $pkg->{'permbuildpri'}
1002 if (defined $pkg->{'permbuildpri'});
1004 log_ta( $pkg, "--binNMU" );
1005 update_source_info($pkg);
1007 } elsif ($binNMUver == 0) {
1008 print "${name}_$version: no scheduled binNMU to cancel.\n";
1012 if ($state ne 'Installed') {
1013 print "${name}_$version: not installed; can't register for binNMU.\n";
1017 my $fullver = binNMU_version($version,$binNMUver);
1018 if ( version_lesseq( $fullver, $pkg->{'installed_version'} ) )
1020 print "$name: binNMU $fullver is not newer than current version $pkg->{'installed_version'}\n";
1024 change_state( \$pkg, 'BD-Uninstallable' );
1025 $pkg->{'bd_problem'} = "Installability of build dependencies not tested yet";
1026 delete $pkg->{'builder'};
1027 delete $pkg->{'depends'};
1028 $pkg->{'binary_nmu_version'} = $binNMUver;
1029 $pkg->{'binary_nmu_changelog'} = $fail_reason;
1030 $pkg->{'notes'} = 'out-of-date';
1031 log_ta( $pkg, "--binNMU" );
1032 update_source_info($pkg);
1033 print "${name}: registered for binNMU $fullver\n" if $verbose;
1036 sub set_one_buildpri {
1038 my $version = shift;
1040 my $pkg = get_source_info($name);
1043 if (!defined($pkg)) {
1044 print "$name: not registered; can't set priority.\n";
1047 $state = $pkg->{'state'};
1049 if ($state eq "Not-For-Us") {
1050 print "$name: not suitable for this architecture. Skipping.\n";
1052 } elsif ($state eq "Failed-Removed") {
1053 print "$name: failed previously and doesn't need building. Skipping.\n";
1056 if (!pkg_version_eq($pkg, $version)) {
1057 print "$name: version mismatch ($pkg->{'version'} registered). ",
1061 if ( $build_priority == 0 ) {
1062 delete $pkg->{'buildpri'}
1063 if $key eq 'permbuildpri' and defined $pkg->{'buildpri'}
1064 and $pkg->{'buildpri'} == $pkg->{$key};
1065 delete $pkg->{$key};
1067 $pkg->{'buildpri'} = $build_priority
1068 if $key eq 'permbuildpri';
1069 $pkg->{$key} = $build_priority;
1071 update_source_info($pkg);
1072 print "$name: set to build priority $build_priority\n" if $verbose;
1075 sub add_one_depwait {
1077 my $version = shift;
1079 my $pkg = get_source_info($name);
1081 if (!defined($pkg)) {
1082 print "$name: not registered yet.\n";
1085 $state = $pkg->{'state'};
1087 if ($state eq "Dep-Wait") {
1088 print "$name: merging with previously registered dependencies\n";
1091 if (isin( $state, qw(Needs-Build Failed BD-Uninstallable))) {
1092 print "$name: Warning: not registered for building previously, ".
1093 "but processing anyway.\n";
1095 elsif ($state eq "Not-For-Us") {
1096 print "$name: not suitable for this architecture anyway. Skipping.\n";
1099 elsif ($state eq "Failed-Removed") {
1100 print "$name: failed previously and doesn't need building. Skipping.\n";
1103 elsif ($state eq "Installed") {
1104 print "$name: Is already installed in archive. Skipping.\n";
1107 elsif ($state eq "Uploaded") {
1108 print "$name: Is already uploaded. Skipping.\n";
1111 elsif ($pkg->{'builder'} &&
1112 $user ne $pkg->{'builder'}) {
1113 print "$name: not taken by you, but by ".
1114 "$pkg->{'builder'}. Skipping.\n";
1117 elsif ( !pkg_version_eq($pkg,$version)) {
1118 print "$name: version mismatch ".
1119 "($pkg->{'version'} ".
1120 "by $pkg->{'builder'})\n";
1123 elsif ($fail_reason =~ /^\s*$/ ||
1124 !parse_deplist( $fail_reason, 1 )) {
1125 print "$name: Bad dependency list\n";
1128 change_state( \$pkg, 'Dep-Wait' );
1129 $pkg->{'builder'} = $user;
1130 if (defined $pkg->{'permbuildpri'}) {
1131 $pkg->{'buildpri'} = $pkg->{'permbuildpri'};
1133 delete $pkg->{'buildpri'};
1135 my $deplist = parse_deplist( $pkg->{'depends'} );
1136 my $new_deplist = parse_deplist( $fail_reason );
1137 # add new dependencies, maybe overwriting old entries
1138 foreach (keys %$new_deplist) {
1139 $deplist->{$_} = $new_deplist->{$_};
1141 $pkg->{'depends'} = build_deplist($deplist);
1142 log_ta( $pkg, "--dep-wait" );
1143 update_source_info($pkg);
1144 print "$name: registered as waiting for dependencies\n" if $verbose;
1154 local($/) = ""; # read in paragraph mode
1156 my( $version, $arch, $section, $priority, $builddep, $buildconf, $binaries );
1158 /^Package:\s*(\S+)$/mi and $name = $1;
1159 /^Version:\s*(\S+)$/mi and $version = $1;
1160 /^Architecture:\s*(\S+)$/mi and $arch = $1;
1161 /^Section:\s*(\S+)$/mi and $section = $1;
1162 /^Priority:\s*(\S+)$/mi and $priority = $1;
1163 /^Build-Depends:\s*(.*)$/mi and $builddep = $1;
1164 /^Build-Conflicts:\s*(.*)$/mi and $buildconf = $1;
1165 /^Binary:\s*(.*)$/mi and $binaries = $1;
1167 next if (defined $srcver{$name} and version_less( $version, $srcver{$name} ));
1168 $srcver{$name} = $version;
1170 $pkgs{$name}{'ver'} = $version;
1171 $pkgs{$name}{'bin'} = $binaries;
1172 $pkgs{$name}{'dep'} = $builddep;
1173 $pkgs{$name}{'conf'} = $buildconf;
1174 my $pkg = get_source_info($name);
1179 if ($arch eq "all" && !version_less( $version, $pkg->{'version'} )) {
1180 # package is now Arch: all, delete it from db
1181 change_state( \$pkg, 'deleted' );
1182 log_ta( $pkg, "--merge-sources" );
1183 print "$name ($pkg->{'version'}): deleted ".
1184 "from database, because now Arch: all\n"
1186 del_source_info($name);
1190 # The "Version" should always be the source version --
1191 # not a possible binNMU version number.
1192 $pkg->{'version'} = $version, $change++
1193 if ($pkg->{'state'} eq 'Installed' and
1194 !version_eq( $pkg->{'version'}, $version));
1195 # Always update priority and section, if available
1196 $pkg->{'priority'} = $priority, $change++
1197 if defined $priority and (not defined($pkg->{'priority'}) or $pkg->{'priority'} ne $priority);
1199 $pkg->{'section'} = $section, $change++
1200 if defined $section and (not defined($pkg->{'section'}) or $pkg->{'section'} ne $section);
1202 update_source_info($pkg) if $change;
1205 # Now that we only have the latest source version, build the list
1206 # of binary packages from the Sources point of view
1207 foreach $name (keys %pkgs) {
1208 foreach my $bin (split( /\s*,\s*/, $pkgs{$name}{'bin'} ) ) {
1209 $merge_binsrc{$bin} = $name;
1212 # remove installed packages that no longer have source available
1213 # or binaries installed
1214 my $db = get_all_source_info();
1215 foreach $name (keys %$db) {
1216 next if $name =~ /^_/;
1217 my $pkg = $db->{$name};
1218 if (not defined($pkgs{$name})) {
1219 change_state( \$pkg, 'deleted' );
1220 log_ta( $pkg, "--merge-sources" );
1221 print "$name ($pkg->{'version'}): ".
1222 "deleted from database, because ".
1223 "not in Sources anymore\n"
1225 del_source_info($name);
1227 next if !isin( $pkg->{'state'}, qw(Installed) );
1228 if ($full && not defined $merge_srcvers{$name}) {
1229 change_state( \$pkg, 'deleted' );
1230 log_ta( $pkg, "--merge-sources" );
1231 print "$name ($pkg->{'version'}): ".
1232 "deleted from database, because ".
1233 "binaries don't exist anymore\n"
1235 del_source_info($name);
1236 } elsif ($full && version_less( $merge_srcvers{$name}, $pkg->{'version'})) {
1237 print "$name ($pkg->{'version'}): ".
1238 "package is Installed but binaries are from ".
1239 $merge_srcvers{$name}. "\n"
1247 # This function looks through a Packages file and sets the state of
1248 # packages to 'Installed'
1249 sub parse_packages {
1252 local($/) = ""; # read in paragraph mode
1254 my( $name, $version, $depends, $source, $sourcev, $architecture, $provides, $binaryv, $binnmu );
1256 /^Package:\s*(\S+)$/mi and $name = $1;
1257 /^Version:\s*(\S+)$/mi and $version = $1;
1258 /^Depends:\s*(.*)$/mi and $depends = $1;
1259 /^Source:\s*(\S+)(\s*\((\S+)\))?$/mi and ($source,$sourcev) = ($1, $3);
1260 /^Architecture:\s*(\S+)$/mi and $architecture = $1;
1261 /^Provides:\s*(.*)$/mi and $provides = $1;
1262 next if !$name || !$version;
1263 next if ($arch ne $architecture and $architecture ne "all");
1264 next if (defined ($installed->{$name}) and $installed->{$name}{'version'} ne "" and
1265 version_lesseq( $version, $installed->{$name}{'version'} ));
1266 $installed->{$name}{'version'} = $version;
1267 $installed->{$name}{'depends'} = $depends;
1268 $installed->{$name}{'all'} = 1 if $architecture eq "all";
1269 undef $installed->{$name}{'Provider'};
1270 $installed->{$name}{'Source'} = $source ? $source : $name;
1272 foreach (split( /\s*,\s*/, $provides )) {
1273 if (not defined ($installed->{$_})) {
1274 $installed->{$_}{'version'} = "";
1275 $installed->{$_}{'Provider'} = $name;
1279 if ( $version =~ /\+b(\d+)$/ ) {
1282 $version = $sourcev if $sourcev;
1283 $binaryv = $version;
1284 $binaryv =~ s/\+b\d+$//;
1285 $installed->{$name}{'Sourcev'} = $sourcev ? $sourcev : $binaryv;
1286 $binaryv .= "+b$binnmu" if defined($binnmu);
1288 next if $architecture ne $arch;
1289 $name = $source if $source;
1290 next if defined($merge_srcvers{$name}) and $merge_srcvers{$name} eq $version;
1291 $merge_srcvers{$name} = $version;
1293 my $pkg = get_source_info($name);
1296 if (isin( $pkg->{'state'}, qw(Not-For-Us)) ||
1297 (isin($pkg->{'state'}, qw(Installed)) &&
1298 version_lesseq($binaryv, $pkg->{'installed_version'}))) {
1299 print "Skipping $name because State == $pkg->{'state'}\n"
1303 if ($pkg->{'binary_nmu_version'} ) {
1304 my $nmuver = binNMU_version($pkg->{'version'}, $pkg->{'binary_nmu_version'});
1305 if (version_less( $binaryv, $nmuver )) {
1306 print "Skipping $name ($version) because have newer ".
1307 "version ($nmuver) in db.\n"
1311 } elsif (version_less($version, $pkg->{'version'})) {
1312 print "Skipping $name ($version) because have newer ".
1313 "version ($pkg->{'version'}) in db.\n"
1318 if (!pkg_version_eq($pkg, $version) &&
1319 $pkg->{'state'} ne "Installed") {
1320 warn "Warning: $name: newer version than expected appeared ".
1321 "in archive ($version vs. $pkg->{'version'})\n";
1322 delete $pkg->{'builder'};
1325 if (!isin( $pkg->{'state'}, qw(Uploaded) )) {
1326 warn "Warning: Package $name was not in uploaded state ".
1327 "before (but in '$pkg->{'state'}').\n";
1328 delete $pkg->{'builder'};
1329 delete $pkg->{'depends'};
1333 $pkg->{'version'} = $version;
1336 change_state( \$pkg, 'Installed' );
1337 $pkg->{'package'} = $name;
1338 $pkg->{'installed_version'} = $binaryv;
1339 if (defined $pkg->{'permbuildpri'}) {
1340 $pkg->{'buildpri'} = $pkg->{'permbuildpri'};
1342 delete $pkg->{'buildpri'};
1344 $pkg->{'version'} = $version
1345 if version_less( $pkg->{'version'}, $version);
1346 delete $pkg->{'binary_nmu_version'};
1347 delete $pkg->{'binary_nmu_changelog'};
1348 log_ta( $pkg, "--merge-packages" );
1349 update_source_info($pkg);
1350 print "$name ($version) is up-to-date now.\n" if $verbose;
1353 check_dep_wait( "--merge-packages", $installed );
1358 my ($package, $name, $version, $installed);
1360 foreach $package (@_) {
1361 $package =~ s,^.*/,,; # strip path
1362 $package =~ s/\.(dsc|diff\.gz|tar\.gz|deb)$//; # strip extension
1363 $package =~ s/_[\w\d]+\.changes$//; # strip extension
1364 if ($package =~ /^([\w\d.+-]+)_([\w\d:.+~-]+)/) {
1365 ($name,$version) = ($1,$2);
1368 warn "$package: can't extract package name and version ".
1372 $installed->{$name}{'version'} = $version;
1375 check_dep_wait( "--pretend-avail", $installed );
1378 sub check_dep_wait {
1380 my $installed = shift;
1382 # check all packages in state Dep-Wait if dependencies are all
1385 my $db = get_all_source_info();
1386 foreach $name (keys %$db) {
1387 next if $name =~ /^_/;
1388 my $pkg = $db->{$name};
1389 next if $pkg->{'state'} ne "Dep-Wait";
1390 my $deps = $pkg->{'depends'};
1392 print "$name: was in state Dep-Wait, but with empty ",
1394 goto make_needs_build;
1396 my $deplist = parse_deplist($deps);
1400 foreach (keys %$deplist) {
1401 if (!exists $installed->{$_} ||
1402 ($deplist->{$_}->{'rel'} && $deplist->{$_}->{'version'} &&
1403 !version_compare( $installed->{$_}{'version'},
1404 $deplist->{$_}->{'rel'},
1405 $deplist->{$_}->{'version'}))) {
1407 $new_deplist->{$_} = $deplist->{$_};
1410 push( @removed_deps, $_ );
1415 change_state( \$pkg, 'Needs-Build' );
1416 log_ta( $pkg, $action );
1417 delete $pkg->{'builder'};
1418 delete $pkg->{'depends'};
1419 print "$name ($pkg->{'version'}) has all ",
1420 "dependencies available now\n" if $verbose;
1422 update_source_info($pkg);
1424 elsif (@removed_deps) {
1425 $pkg->{'depends'} = build_deplist( $new_deplist );
1426 print "$name ($pkg->{'version'}): some dependencies ",
1427 "(@removed_deps) available now, but not all yet\n"
1429 update_source_info($pkg);
1434 # This function accepts quinn-diff output (either from a file named on
1435 # the command line, or on stdin) and sets the packages named there to
1436 # state 'Needs-Build'.
1437 sub parse_quinn_diff {
1438 my $partial = shift;
1444 next if !m,^([-\w\d/]*)/ # section
1445 ([-\w\d.+]+)_ # package name
1446 ([\w\d:.~+-]+)\.dsc\s* # version
1447 \[([^:]*): # priority
1448 ([^]]+)\]\s*$,x; # rest of notes
1449 my($section,$name,$version,$priority,$notes) = ($1, $2, $3, $4, $5);
1450 $quinn_pkgs{$name}++;
1451 $section ||= "unknown";
1452 $priority ||= "unknown";
1453 $priority = "unknown" if $priority eq "-";
1454 $priority = "standard" if ($name eq "debian-installer");
1456 my $pkg = get_source_info($name);
1458 # Always update section and priority.
1459 if (defined($pkg)) {
1461 $pkg->{'section'} = $section, $change++ if not defined
1462 $pkg->{'section'} or $section ne "unknown";
1463 $pkg->{'priority'} = $priority, $change++ if not defined
1464 $pkg->{'priority'} or $priority ne "unknown";
1467 if (defined($pkg) &&
1468 $pkg->{'state'} =~ /^Dep-Wait/ &&
1469 version_less( $pkg->{'version'}, $version )) {
1470 change_state( \$pkg, 'Dep-Wait' );
1471 $pkg->{'version'} = $version;
1472 delete $pkg->{'binary_nmu_version'};
1473 delete $pkg->{'binary_nmu_changelog'};
1474 log_ta( $pkg, "--merge-quinn" );
1476 print "$name ($version) still waiting for dependencies.\n"
1479 elsif (defined($pkg) &&
1480 $pkg->{'state'} =~ /-Removed$/ &&
1481 version_eq($pkg->{'version'}, $version)) {
1482 # reinstantiate a package that has been removed earlier
1483 # (probably due to a quinn-diff malfunction...)
1484 my $newstate = $pkg->{'state'};
1485 $newstate =~ s/-Removed$//;
1486 change_state( \$pkg, $newstate );
1487 $pkg->{'version'} = $version;
1488 $pkg->{'notes'} = $notes;
1489 log_ta( $pkg, "--merge-quinn" );
1491 print "$name ($version) reinstantiated to $newstate.\n"
1494 elsif (defined($pkg) &&
1495 $pkg->{'state'} eq "Not-For-Us" &&
1496 version_less( $pkg->{'version'}, $version )) {
1497 # for Not-For-Us packages just update the version etc., but
1499 change_state( \$pkg, "Not-For-Us" );
1500 $pkg->{'package'} = $name;
1501 $pkg->{'version'} = $version;
1502 $pkg->{'notes'} = $notes;
1503 delete $pkg->{'builder'};
1504 log_ta( $pkg, "--merge-quinn" );
1506 print "$name ($version) still Not-For-Us.\n" if $verbose;
1508 elsif (!defined($pkg) ||
1509 $pkg->{'state'} ne "Not-For-Us" &&
1510 (version_less( $pkg->{'version'}, $version ) ||
1511 ($pkg->{'state'} eq "Installed" && version_less($pkg->{'installed_version'}, $version)))) {
1513 if (defined( $pkg->{'state'} ) && isin( $pkg->{'state'}, qw(Building Built Build-Attempted))) {
1514 send_mail( $pkg->{'builder'},
1515 "new version of $name (dist=$distribution)",
1516 "As far as I'm informed, you're currently ".
1517 "building the package $name\n".
1518 "in version $pkg->{'version'}.\n\n".
1519 "Now there's a new source version $version. ".
1520 "If you haven't finished\n".
1521 "compiling $name yet, you can stop it to ".
1522 "save some work.\n".
1523 "Just to inform you...\n".
1524 "(This is an automated message)\n" );
1525 print "$name: new version ($version) while building ".
1526 "$pkg->{'version'} -- sending mail ".
1527 "to builder ($pkg->{'builder'})\n"
1530 change_state( \$pkg, 'Needs-Build' );
1531 $pkg->{'package'} = $name;
1532 $pkg->{'version'} = $version;
1533 $pkg->{'section'} = $section;
1534 $pkg->{'priority'} = $priority;
1535 $pkg->{'notes'} = $notes;
1536 delete $pkg->{'builder'};
1537 delete $pkg->{'binary_nmu_version'};
1538 delete $pkg->{'binary_nmu_changelog'};
1539 log_ta( $pkg, "--merge-quinn" );
1542 print "$name ($version) needs rebuilding now.\n" if $verbose;
1544 elsif (defined($pkg) &&
1545 !version_eq( $pkg->{'version'}, $version ) &&
1546 isin( $pkg->{'state'}, qw(Installed Not-For-Us) )) {
1547 print "$name: skipping because version in db ".
1548 "($pkg->{'version'}) is >> than ".
1549 "what quinn-diff says ($version) ".
1550 "(state is $pkg->{'state'})\n"
1552 $dubious .= "$pkg->{'state'}: ".
1553 "db ${name}_$pkg->{'version'} >> ".
1554 "quinn $version\n" if !$partial;
1556 elsif ($verbose >= 2) {
1557 if ($pkg->{'state'} eq "Not-For-Us") {
1558 print "Skipping $name because State == ".
1559 "$pkg->{'state'}\n";
1561 elsif (!version_less($pkg->{'version'}, $version)) {
1562 print "Skipping $name because version in db ".
1563 "($pkg->{'version'}) is >= than ".
1564 "what quinn-diff says ($version)\n";
1567 update_source_info($pkg) if $change;
1571 send_mail( $conf::db_maint,
1572 "Dubious versions in " . table_name() . " "
1573 . $distribution . " table",
1574 "The following packages have a newer version in the ".
1575 "wanna-build database\n".
1576 "than what quinn-diff says, and this is strange for ".
1578 "It could be caused by a lame mirror, or the version ".
1579 "in the database\n".
1584 # Now re-check the DB for packages in states Needs-Build, Failed,
1585 # Dep-Wait or BD-Uninstallable and remove them if they're not listed
1586 # anymore by quinn-diff.
1589 my $db = get_all_source_info();
1590 foreach $name (keys %$db) {
1591 next if $name =~ /^_/;
1592 my $pkg = $db->{$name};
1593 next if defined $pkg->{'binary_nmu_version'};
1594 next if !isin( $pkg->{'state'},
1595 qw(Needs-Build Building Built Build-Attempted Uploaded Failed Dep-Wait BD-Uninstallable) );
1596 my $virtual_delete = $pkg->{'state'} eq 'Failed';
1598 if (!$quinn_pkgs{$name}) {
1599 change_state( \$pkg, $virtual_delete ?
1600 $pkg->{'state'}."-Removed" :
1602 log_ta( $pkg, "--merge-quinn" );
1603 print "$name ($pkg->{'version'}): ".
1604 ($virtual_delete ? "(virtually) " : "") . "deleted ".
1605 "from database, because not in quinn-diff anymore\n"
1607 if ($virtual_delete) {
1608 update_source_info($pkg);
1610 del_source_info($name);
1618 # for sorting priorities and sections
1620 %prioval = ( required => -5,
1628 'debian-installer' => -199,
1649 localizations => -178,
1650 interpreters => -177,
1675 electronics => -152,
1681 foreach my $i (keys %sectval) {
1682 $sectval{"contrib/$i"} = $sectval{$i}+40;
1683 $sectval{"non-free/$i"} = $sectval{$i}+80;
1685 $sectval{'unknown'} = -165;
1687 %catval = ( "none" => -20,
1688 "uploaded-fixed-pkg" => -19,
1689 "fix-expected" => -18,
1690 "reminder-sent" => -17,
1691 "nmu-offered" => -16,
1695 "compiler-error" => -12 );
1698 sub sort_list_func {
1699 my( $letter, $x, $ax, $bx );
1701 foreach $letter (split( "", $list_order )) {
1702 SWITCH: foreach ($letter) {
1704 $x = $b->{'buildpri'} <=> $a->{'buildpri'};
1705 return $x if $x != 0;
1709 $x = $prioval{$a->{'priority'}} <=> $prioval{$b->{'priority'}};
1710 return $x if $x != 0;
1714 $x = $sectval{$a->{'section'}} <=> $sectval{$b->{'section'}};
1715 return $x if $x != 0;
1719 $x = $a->{'package'} cmp $b->{'package'};
1720 return $x if $x != 0;
1724 $x = $a->{'builder'} cmp $b->{'builder'};
1725 return $x if $x != 0;
1729 $ax = ($a->{'notes'} =~ /^(out-of-date|partial)/) ? 0 :
1730 ($a->{'notes'} =~ /^uncompiled/) ? 2 : 1;
1731 $bx = ($b->{'notes'} =~ /^(out-of-date|partial)/) ? 0 :
1732 ($b->{'notes'} =~ /^uncompiled/) ? 2 : 1;
1734 return $x if $x != 0;
1738 my $ca = defined $a->{'failed_category'} ?
1739 $a->{'failed_category'} : "none";
1740 my $cb = defined $b->{'failed_category'} ?
1741 $b->{'failed_category'} : "none";
1742 $x = $catval{$ca} <=> $catval{$cb};
1743 return $x if $x != 0;
1747 my $pa = $prioval{$a->{'priority'}} >
1748 $prioval{'standard'};
1749 my $pb = $prioval{$b->{'priority'}} >
1750 $prioval{'standard'};
1752 return $x if $x != 0;
1762 my( $name, $pkg, @list );
1767 my $db = get_all_source_info(state => $state, user => $user, category => $category, list_min_age => $list_min_age);
1768 foreach $name (keys %$db) {
1769 next if $name =~ /^_/;
1770 push @list, $db->{$name};
1773 foreach $pkg (sort sort_list_func @list) {
1774 print "$pkg->{'section'}/$pkg->{'package'}_$pkg->{'version'}";
1775 print ": $pkg->{'state'}"
1777 print " by $pkg->{'builder'}"
1778 if $pkg->{'state'} ne "Needs-Build" && $pkg->{'builder'};
1779 print " [$pkg->{'priority'}:$pkg->{'notes'}";
1780 print ":PREV-FAILED"
1781 if $pkg->{'previous_state'} =~ /^Failed/;
1782 print ":bp{" . $pkg->{'buildpri'} . "}"
1783 if defined $pkg->{'buildpri'};
1784 print ":binNMU{" . $pkg->{'binary_nmu_version'} . "}"
1785 if defined $pkg->{'binary_nmu_version'};
1787 print " Reasons for failing:\n",
1789 defined $pkg->{'failed_category'} ? $pkg->{'failed_category'} : "none",
1791 join("\n ",split("\n",$pkg->{'failed'})), "\n"
1792 if $pkg->{'state'} =~ /^Failed/;
1793 print " Dependencies: $pkg->{'depends'}\n"
1794 if $pkg->{'state'} eq "Dep-Wait";
1795 print " Reasons for BD-Uninstallable:\n ",
1796 join("\n ",split("\n",$pkg->{'bd_problem'})), "\n"
1797 if $pkg->{'state'} eq "BD-Uninstallable";
1798 print " Previous state was $pkg->{'previous_state'} until ",
1799 "$pkg->{'state_change'}\n"
1800 if $verbose && $pkg->{'previous_state'};
1801 print " No previous state recorded\n"
1802 if $verbose && !$pkg->{'previous_state'};
1803 print " Previous failing reasons:\n ",
1804 join("\n ",split("\n",$pkg->{'old_failed'})), "\n"
1805 if $verbose && $pkg->{'old_failed'};
1807 $scnt{$pkg->{'state'}}++ if $state eq "all";
1809 if ($state eq "all") {
1810 foreach (sort keys %scnt) {
1811 print "Total $scnt{$_} package(s) in state $_.\n";
1814 print "Total $cnt package(s)\n";
1819 my( $name, $pkg, $key, $dist );
1820 my @firstkeys = qw(package version builder state section priority
1821 installed_version previous_state state_change);
1822 my @dists = $info_all_dists ? keys %conf::distributions : ($distribution);
1824 foreach $name (@_) {
1825 $name =~ s/_.*$//; # strip version
1826 foreach $dist (@dists) {
1827 my $pname = "$name" . ($info_all_dists ? "($dist)" : "");
1829 $pkg = get_readonly_source_info($name);
1830 if (!defined( $pkg )) {
1831 print "$pname: not registered\n";
1836 foreach $key (@firstkeys) {
1837 next if !defined $pkg->{$key};
1838 my $val = $pkg->{$key};
1840 $val = "\n$val" if isin( $key, qw(Failed Old-Failed));
1842 my $print_key = $key;
1843 $print_key = 'Package' if ($key eq 'package');
1844 $print_key = 'Version' if ($key eq 'version');
1845 $print_key = 'Builder' if ($key eq 'builder');
1846 $print_key = 'State' if ($key eq 'state');
1847 $print_key = 'Section' if ($key eq 'section');
1848 $print_key = 'Priority' if ($key eq 'priority');
1849 $print_key = 'Installed-Version' if ($key eq 'installed_version');
1850 $print_key = 'Previous-State' if ($key eq 'previous_state');
1851 $print_key = 'State-Change' if ($key eq 'state_change');
1852 printf " %-20s: %s\n", $print_key, $val;
1854 foreach $key (sort keys %$pkg) {
1855 next if isin( $key, @firstkeys );
1856 my $val = $pkg->{$key};
1857 next if !defined($val);
1859 $val = "\n$val" if isin( $key, qw(Failed Old-Failed));
1861 my $print_key = $key;
1862 $print_key = 'BD-Problem' if ($key eq 'bd_problem');
1863 $print_key = 'Binary-NMU-Changelog' if ($key eq 'binary_nmu_changelog');
1864 $print_key = 'Binary-NMU-Version' if ($key eq 'binary_nmu_version');
1865 $print_key = 'BuildPri' if ($key eq 'buildpri');
1866 $print_key = 'Depends' if ($key eq 'depends');
1867 $print_key = 'Failed' if ($key eq 'failed');
1868 $print_key = 'Failed-Category' if ($key eq 'failed_category');
1869 $print_key = 'Notes' if ($key eq 'notes');
1870 $print_key = 'Distribution' if ($key eq 'distribution');
1871 $print_key = 'Old-Failed' if ($key eq 'old_failed');
1872 $print_key = 'PermBuildPri' if ($key eq 'permbuildpri');
1873 $print_key = 'Rel' if ($key eq 'rel');
1874 printf " %-20s: %s\n", $print_key, $val;
1880 sub forget_packages {
1881 my( $name, $pkg, $key, $data );
1883 foreach $name (@_) {
1884 $name =~ s/_.*$//; # strip version
1885 $pkg = get_source_info($name);
1886 if (!defined( $pkg )) {
1887 print "$name: not registered\n";
1892 foreach $key (sort keys %$pkg) {
1893 my $val = $pkg->{$key};
1896 $data .= sprintf " %-20s: %s\n", $key, $val;
1898 send_mail( $conf::db_maint,
1899 "$name deleted from DB " . table_name() . " " . $distribution,
1900 "The package '$name' has been deleted from the database ".
1902 "Data registered about the deleted package:\n".
1903 "$data\n" ) if $conf::db_maint;
1904 change_state( \$pkg, 'deleted' );
1905 log_ta( $pkg, "--forget" );
1906 del_source_info($name);
1907 print "$name: deleted from database\n" if $verbose;
1912 $dbh->do("DELETE from " . user_table_name() .
1913 " WHERE distribution = ?", undef, $distribution) or die $dbh->errstr;
1919 print "Reading ASCII database from $file..." if $verbose >= 1;
1920 open( F, "<$file" ) or
1921 die "Can't open database $file: $!\n";
1923 local($/) = ""; # read in paragraph mode
1925 my( %thispkg, $name );
1927 s/\n[ \t]+/\376\377/g; # fix continuation lines
1928 s/\376\377\s*\376\377/\376\377/og;
1930 while( /^(\S+):[ \t]*(.*)[ \t]*$/mg ) {
1931 my ($key, $val) = ($1, $2);
1933 $key =~ tr/A-Z/a-z/;
1934 $val =~ s/\376\377/\n/g;
1935 $thispkg{$key} = $val;
1937 check_entry( \%thispkg );
1939 if (exists($thispkg{'package'})) {
1940 update_source_info(\%thispkg);
1942 elsif(exists($thispkg{'user'})) {
1943 # user in import, username in database.
1944 $dbh->do('INSERT INTO ' . user_table_name() .
1945 ' (username, distribution, last_seen)' .
1946 ' values (?, ?, ?)',
1947 undef, $thispkg{'user'}, $distribution,
1948 $thispkg{'last_seen'})
1949 or die $dbh->errstr;
1953 print "done\n" if $verbose >= 1;
1960 return if $op_mode eq "manual-edit"; # no checks then
1962 # check for required fields
1963 if (exists $pkg->{'user'}) {
1966 if (!exists $pkg->{'package'}) {
1967 print STDERR "Bad entry: ",
1968 join( "\n", map { "$_: $pkg->{$_}" } keys %$pkg ), "\n";
1969 die "Database entry lacks package or username field\n";
1971 # if no State: field, generate one (for old db compat)
1972 if (!exists($pkg->{'state'})) {
1974 exists $pkg->{'failed'} ? 'Failed' : 'Building';
1976 if (!exists $pkg->{'version'} and $pkg->{'state'} ne 'Not-For-Us') {
1977 die "Database entry for $pkg->{'package'} lacks Version: field\n";
1980 die "Bad state $pkg->{'state'} of package $pkg->{Package}\n"
1981 if !isin( $pkg->{'state'},
1982 qw(Needs-Build Building Built Build-Attempted Uploaded Installed Dep-Wait Dep-Wait-Removed
1983 Failed Failed-Removed Not-For-Us BD-Uninstallable
1989 my($name,$pkg,$key);
1991 print "Writing ASCII database to $file..." if $verbose >= 1;
1992 open( F, ">$file" ) or
1993 die "Can't open export $file: $!\n";
1995 my $db = get_all_source_info();
1996 foreach $name (keys %$db) {
1997 next if $name =~ /^_/;
1998 my $pkg = $db->{$name};
1999 foreach $key (keys %{$pkg}) {
2000 my $val = $pkg->{$key};
2001 next if !defined($val);
2004 $val =~ s/^ +$/ ./mg;
2005 print F "$key: $val\n";
2010 print "done\n" if $verbose >= 1;
2016 my $newstate = shift;
2017 my $state = \$pkg->{'state'};
2019 return if defined($$state) and $$state eq $newstate;
2020 $pkg->{'previous_state'} = $$state if defined($$state);
2021 $pkg->{'state_change'} = $curr_date;
2023 if (defined($$state) and $$state eq 'Failed') {
2024 $pkg->{'old_failed'} =
2025 "-"x20 . " $pkg->{'version'} " . "-"x20 . "\n" .
2026 $pkg->{'failed'} . "\n" .
2027 $pkg->{'old_failed'};
2028 delete $pkg->{'failed'};
2029 delete $pkg->{'failed_category'};
2031 if (defined($$state) and $$state eq 'BD-Uninstallable') {
2032 delete $pkg->{'bd_problem'};
2034 $$state = $newstate;
2040 my $dist = $distribution;
2044 $prevstate = $pkg->{'previous_state'};
2045 $str = "$action($dist): $pkg->{'package'}_$pkg->{'version'} ".
2046 "changed from $prevstate to $pkg->{'state'} ".
2047 "by $real_user as $user";
2049 my $transactlog = db_transactlog();
2050 if (!open( LOG, ">>$transactlog" )) {
2051 warn "Can't open log file $transactlog: $!\n";
2054 print LOG "$curr_date: $str\n";
2057 if (!($prevstate eq 'Failed' && $pkg->{'state'} eq 'Failed')) {
2058 $str .= " (with --override)"
2060 $mail_logs .= "$str\n";
2067 my $subject = shift;
2070 my $from = $conf::db_maint;
2071 my $domain = $conf::buildd_domain;
2073 $from .= "\@$domain" if $from !~ /\@/;
2075 $to .= '@' . $domain if $to !~ /\@/;
2076 $text =~ s/^\.$/../mg;
2077 local $SIG{'PIPE'} = 'IGNORE';
2078 open( PIPE, "| $conf::mailprog -oem $to" )
2079 or die "Can't open pipe to $conf::mailprog: $!\n";
2081 print PIPE "From: $from\n";
2082 print PIPE "Subject: $subject\n\n";
2083 print PIPE "$text\n";
2087 sub db_transactlog {
2088 return "$conf::basedir/$arch/$conf::transactlog";
2091 # for parsing input to dep-wait
2097 foreach (split( /\s*,\s*/, $deps )) {
2099 # verification requires > starting prompts, no | crap
2100 if (!/^(\S+)\s*(\(\s*(>(?:[>=])?)\s*(\S+)\s*\))?\s*$/) {
2105 my @alts = split( /\s*\|\s*/, $_ );
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;
2111 if (!/^(\S+)\s*(\(\s*(>=|=|==|>|>>|<<|<=)\s*(\S+)\s*\))?\s*$/) {
2112 warn( "parse_deplist: bad dependency $_\n" );
2115 my($dep, $rel, $relv) = ($1, $3, $4);
2116 $rel = ">>" if defined($rel) and $rel eq ">";
2117 $result{$dep}->{'package'} = $dep;
2118 if ($rel && $relv) {
2119 $result{$dep}->{'rel'} = $rel;
2120 $result{$dep}->{'version'} = $relv;
2123 return 1 if $verify;
2127 # for parsing Build-Depends from Sources
2128 sub parse_srcdeplist {
2135 foreach $dep (split( /\s*,\s*/, $deps )) {
2136 my @alts = split( /\s*\|\s*/, $dep );
2137 # Anything with an | is ignored, as it can be configured on a
2138 # per-buildd basis what will be installed
2139 next if $#alts != 0;
2141 if (!/^([^\s([]+)\s*(\(\s*([<=>]+)\s*(\S+)\s*\))?(\s*\[([^]]+)\])?/) {
2142 warn( "parse_srcdeplist: bad dependency $_\n" );
2145 my($dep, $rel, $relv, $archlist) = ($1, $3, $4, $6);
2147 $archlist =~ s/^\s*(.*)\s*$/$1/;
2148 my @archs = split( /\s+/, $archlist );
2149 my ($use_it, $ignore_it, $include) = (0, 0, 0);
2152 $ignore_it = 1 if substr($_, 1) eq $arch;
2154 $use_it = 1 if $_ eq $arch;
2158 warn "Warning: inconsistent arch restriction on ",
2159 "$pkg: $dep depedency\n"
2160 if $ignore_it && $use_it;
2161 next if $ignore_it || ($include && !$use_it);
2169 $result->{'package'} = $dep;
2170 $result->{'Neg'} = $neg;
2171 if ($rel && $relv) {
2172 $result->{'rel'} = $rel;
2173 $result->{'version'} = $relv;
2175 push @results, $result;
2184 foreach $key (keys %$list) {
2185 $result .= ", " if $result;
2187 $result .= " ($list->{$key}->{'rel'} $list->{$key}->{'version'})"
2188 if $list->{$key}->{'rel'} && $list->{$key}->{'version'};
2193 sub get_unsatisfied_dep {
2197 my $savedep = shift;
2199 my $pkgname = $dep->{'package'};
2201 if (defined $pkgs->{$pkgname}{'Provider'}) {
2202 # provides. leave them for buildd/sbuild.
2207 return $pkgs->{$pkgname}{'Unsatisfied'} if $savedep and defined($pkgs->{$pkgname}{'Unsatisfied'});
2209 # Return unsatisfied deps to a higher caller to process
2210 if ((!defined($pkgs->{$pkgname})) or
2211 (defined($dep->{'rel'}) and !version_compare( $pkgs->{$pkgname}{'version'}, $dep->{'rel'}, $dep->{'Version'} ) ) ) {
2213 $deplist{$pkgname} = $dep;
2214 my $deps = build_deplist(\%deplist);
2215 $pkgs->{$pkgname}{'Unsatisfied'} = $deps if $savedep;
2219 # set cache to "" to avoid infinite recursion
2220 $pkgs->{$pkgname}{'Unsatisfied'} = "" if $savedep;
2222 if (defined $pkgs->{$dep->{'package'}}{'depends'}) {
2223 my $deps = parse_deplist( $pkgs->{$dep->{'package'}}{'depends'} );
2224 foreach (keys %$deps) {
2227 my $ret = get_unsatisfied_dep($bd,$pkgs,$dep,1);
2229 my $retdep = parse_deplist( $ret );
2230 foreach (keys %$retdep) {
2231 $dep = $$retdep{$_};
2233 $dep->{'rel'} = '>=' if defined($dep->{'rel'}) and $dep->{'rel'} =~ '^=';
2235 if (defined($dep->{'rel'}) and $dep->{'rel'} =~ '^>' and defined ($pkgs->{$dep->{'package'}}) and
2236 version_compare($bd->{$pkgs->{$dep->{'package'}}{'Source'}}{'ver'},'>>',$pkgs->{$dep->{'package'}}{'Sourcev'})) {
2237 if (not defined($merge_binsrc{$dep->{'package'}})) {
2238 # the uninstallable package doesn't exist in the new source; look for something else that does.
2239 delete $$retdep{$dep->{'package'}};
2240 foreach (sort (split( /\s*,\s*/, $bd->{$pkgs->{$dep->{'package'}}{'Source'}}{'bin'}))) {
2241 next if ($pkgs->{$_}{'all'} or not defined $pkgs->{$_}{'version'});
2242 $dep->{'package'} = $_;
2243 $dep->{'rel'} = '>>';
2244 $dep->{'version'} = $pkgs->{$_}{'Version'};
2245 $$retdep{$_} = $dep;
2250 # sanity check to make sure the depending binary still exists, and the depended binary exists and dep-wait on a new version of it
2251 if ( defined($merge_binsrc{$pkgname}) and defined($pkgs->{$dep->{'package'}}{'version'}) ) {
2252 delete $$retdep{$dep->{'package'}};
2253 $dep->{'package'} = $pkgname;
2254 $dep->{'rel'} = '>>';
2255 $dep->{'version'} = $pkgs->{$pkgname}{'Version'};
2256 $$retdep{$pkgname} = $dep;
2258 delete $$retdep{$dep->{'package'}} if (defined ($dep->{'rel'}) and $dep->{'rel'} =~ '^>');
2261 $ret = build_deplist($retdep);
2262 $pkgs->{$pkgname}{'Unsatisfied'} = $ret if $savedep;
2270 sub call_edos_depcheck {
2271 my $packagesfile = shift;
2275 return if defined ($conf::distributions{$distribution}{noadw});
2277 # We need to check all of needs-build, as any new upload could make
2278 # something in needs-build have uninstallable deps
2279 # We also check everything in bd-uninstallable, as any new upload could
2280 # make that work again
2281 my %interesting_packages;
2282 my $db = get_all_source_info();
2283 foreach $key (keys %$db) {
2284 my $pkg = $db->{$key};
2285 if (defined $pkg and isin($pkg->{'state'}, qw/Needs-Build BD-Uninstallable/)) {
2286 $interesting_packages{$key} = undef;
2290 #print "I would look at these sources with edos-depcheck:\n";
2291 #print join " ", keys %interesting_packages,"\n";
2293 my $tmpfile_pattern = "/tmp/wanna-build-interesting-sources-$distribution.$$-";
2295 for( $i = 0;; ++$i ) {
2296 $tmpfile = $tmpfile_pattern . $i;
2297 last if ! -e $tmpfile;
2300 open SOURCES, '>', $tmpfile or die "Could not open temporary file $tmpfile\n";
2301 for my $key (keys %interesting_packages) {
2302 my $pkg = get_source_info($key);
2303 print SOURCES "Package: $key\n";
2304 print SOURCES "Version: $pkg->{'version'}\n";
2305 print SOURCES "Build-Depends: $srcs->{$key}{'dep'}\n" if $srcs->{$key}{'dep'};
2306 print SOURCES "Build-Conflicts: $srcs->{$key}{'conf'}\n" if $srcs->{$key}{'conf'};
2307 print SOURCES "Architecture: all\n";
2312 if (open(EDOS,"-|","wb-edos-builddebcheck", "-a", $arch, $packagesfile, $tmpfile))
2314 local($/) = ""; # read in paragraph mode
2316 my( $key, $reason ) ;
2318 /^Package:\s*(\S+)$/mi and $key = $1;
2319 /^Failed-Why:(([^\n]|\n ([^\n]|\.))*)$/msi and $reason = $1;
2320 $reason =~ s/^\s*//mg;
2321 $reason ||= 'No reason given by edos-debcheck';
2323 if (exists $interesting_packages{$key}) {
2324 $interesting_packages{$key} = $reason;
2326 #print "TODO: edos reported a package we do not care about now\n" if $verbose;
2331 print "ERROR: Could not run wb-edos-builddebcheck. I am continuing, assuming\n" .
2332 "all packages have installable build-dependencies."
2337 for my $key (keys %interesting_packages) {
2338 my $pkg = get_source_info($key);
2340 (defined $interesting_packages{$key} and $pkg->{'state'} eq 'Needs-Build') ||
2341 (not defined $interesting_packages{$key} and $pkg->{'state'} eq 'BD-Uninstallable');
2342 my $problemchange = $interesting_packages{$key} ne $pkg->{'bd_problem'};
2344 if (defined $interesting_packages{$key}) {
2345 change_state( \$pkg, 'BD-Uninstallable' );
2346 $pkg->{'bd_problem'} = $interesting_packages{$key};
2348 change_state( \$pkg, 'Needs-Build' );
2351 if ($problemchange) {
2352 if (defined $interesting_packages{$key}) {
2353 $pkg->{'bd_problem'} = $interesting_packages{$key};
2357 log_ta( $pkg, "--merge-all" );
2358 print "edos-builddebchange changed state of ${key}_$pkg->{'version'} to $pkg->{'state'}\n" if $verbose;
2360 if ($change || $problemchange) {
2361 update_source_info($pkg);
2368 ($prgname = $0) =~ s,^.*/,,;
2370 Usage: $prgname <options...> <package_version...>
2372 -v, --verbose: Verbose execution.
2373 -A arch: Architecture this operation is for.
2374 --take: Take package for building [default operation]
2375 -f, --failed: Record in database that a build failed due to
2376 deficiencies in the package (that aren't fixable without a new
2378 -u, --uploaded: Record in the database that the packages build
2379 correctly and were uploaded.
2380 -n, --no-build: Record in the database that the packages aren't
2381 desired for this architecture and shouldn't appear in listings even
2382 if they're out of date.
2383 --dep-wait: Record in the database that the packages are waiting
2384 for some source dependencies to become available
2385 --binNMU num: Schedule a re-build of the package with unchanged source, but
2386 a new version number (source-version + "+b<num>")
2387 --give-back: Mark a package as ready to build that is in state Building,
2388 Built or Build-Attempted. To give back a package in state Failed, use
2389 --override. This command will actually put the package in state
2390 BD-Uninstallable, until the installability of its Build-Dependencies
2391 were verified. This happens at each call of --merge-all, usually
2393 --merge-quinn: Merge quinn-diff output into database.
2394 --merge-packages: Merge Packages files into database.
2395 --pretend-avail: Pretend that given packages are available now and give
2396 free packages waiting for them
2397 -i SRC_PKG, --info SRC_PKG: Show information for source package
2398 -l STATE, --list=STATE: List all packages in state STATE; can be
2399 combined with -U to restrict to a specific user; STATE can
2401 -m MESSAGE, --message=MESSAGE: Give reason why package failed or
2402 source dependency list
2403 (used with -f, --dep-wait, and --binNMU)
2404 -o, --override: Override another user's lock on a package, i.e.
2405 take it over; a notice mail will be sent to the other user
2406 -U USER, --user=USER: select user name for which listings should
2407 apply, if not given all users are listed.
2408 if -l is missing, set user name to be entered in db; usually
2409 automatically choosen
2410 --import FILE: Import database from a ASCII file FILE
2411 --export FILE: Export database to a ASCII file FILE
2413 The remaining arguments (depending on operation) usually start with
2414 "name_version", the trailer is ignored. This allows to pass the names
2415 of .dsc files, for which file name completion can be used.
2416 --merge-packages and --merge-quinn take Package/quin--diff file names
2417 on the command line or read stdin. --list needs nothing more on the
2418 command line. --info takes source package names (without version).
2423 sub pkg_version_eq {
2425 my $version = shift;
2428 if (defined $pkg->{'binary_nmu_version'}) and
2429 version_compare(binNMU_version($pkg->{'version'},
2430 $pkg->{'binary_nmu_version'}),'=', $version);
2431 return version_compare( $pkg->{'version'}, "=", $version );
2435 return '"' . $arch . $schema_suffix . '".packages';
2438 sub user_table_name {
2439 return '"' . $arch . $schema_suffix . '".users';
2442 sub get_readonly_source_info {
2444 my $pkg = $dbh->selectrow_hashref('SELECT * FROM ' .
2445 table_name() . ' WHERE package = ? AND distribution = ?',
2446 undef, $name, $distribution);
2450 sub get_source_info {
2452 my $pkg = $dbh->selectrow_hashref('SELECT * FROM ' .
2453 table_name() . ' WHERE package = ? AND distribution = ?' .
2455 undef, $name, $distribution);
2459 sub get_all_source_info {
2462 my $q = 'SELECT * FROM ' . table_name()
2463 . ' WHERE distribution = ? ';
2464 my @args = ($distribution);
2465 if ($options{state} && uc($options{state}) ne "ALL") {
2466 $q .= ' AND upper(state) = ? ';
2467 push @args, uc($options{state});
2470 if ($options{user}) {
2471 #this basically means "this user, or no user at all":
2472 $q .= ' AND (builder = ? OR upper(state) = ?)';
2473 push @args, $options{user};
2474 push @args, "NEEDS-BUILD";
2477 if ($options{category}) {
2478 $q .= ' AND failed_category <> ? AND upper(state) = ? ';
2479 push @args, $options{category};
2480 push @args, "FAILED";
2483 if ($options{list_min_age} > 0) {
2484 $q .= ' AND age(state_change::timestamp) > ? ';
2485 push @args, $options{list_min_age} . " days";
2488 if ($options{list_min_age} < 0) {
2489 $q .= ' AND age(state_change::timestamp) < ? days ';
2490 push @args, -$options{list_min_age} . " days";
2493 my $db = $dbh->selectall_hashref($q, 'package', undef, @args);
2497 sub update_source_info {
2500 my $pkg2 = get_source_info($pkg->{'package'});
2501 if (! defined $pkg2)
2503 add_source_info($pkg);
2506 $dbh->do('UPDATE ' . table_name() . ' SET ' .
2511 'installed_version = ?, ' .
2512 'previous_state = ?, ' .
2513 'state_change = ?, ' .
2517 'old_failed = ?, ' .
2518 'binary_nmu_version = ?, ' .
2519 'binary_nmu_changelog = ?, ' .
2520 'failed_category = ?, ' .
2521 'permbuildpri = ?, ' .
2526 'WHERE package = ? AND distribution = ?',
2532 $pkg->{'installed_version'},
2533 $pkg->{'previous_state'},
2534 $pkg->{'state_change'},
2538 $pkg->{'old_failed'},
2539 $pkg->{'binary_nmu_version'},
2540 $pkg->{'binary_nmu_changelog'},
2541 $pkg->{'failed_category'},
2542 $pkg->{'permbuildpri'},
2546 $pkg->{'bd_problem'},
2548 $distribution) or die $dbh->errstr;
2551 sub add_source_info {
2553 $dbh->do('INSERT INTO ' . table_name() .
2554 ' (package, distribution) values (?, ?)',
2555 undef, $pkg->{'package'}, $distribution) or die $dbh->errstr;
2558 sub del_source_info {
2560 $dbh->do('DELETE FROM ' . table_name() .
2561 ' WHERE package = ? AND distribution = ?',
2562 undef, $name, $distribution) or die $dbh->errstr;
2567 my $user = $dbh->selectrow_hashref('SELECT * FROM ' .
2568 user_table_name() . ' WHERE username = ? AND distribution = ?',
2569 undef, $name, $distribution);
2573 sub update_user_info {
2575 $dbh->do('UPDATE ' . user_table_name() .
2576 ' SET last_seen = now() WHERE username = ?' .
2577 ' AND distribution = ?',
2578 undef, $user, $distribution)
2579 or die $dbh->errstr;
2585 $dbh->do('INSERT INTO ' . user_table_name() .
2586 ' (username, distribution, last_seen)' .
2587 ' values (?, ?, now())',
2588 undef, $user, $distribution)
2589 or die $dbh->errstr;