X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=bin%2Fwanna-build;h=cdfd60c86b03c80684ad730a2c8b476fdfd3c139;hb=4056cd30f3cfda96a2fd3ed622b15cbe31738586;hp=002d4521aae60fce335cf0dedb7c8365ce067591;hpb=fbca5553e2638c679991ba3c90e3e38ad4927fd5;p=wannabuild.git diff --git a/bin/wanna-build b/bin/wanna-build index 002d452..cdfd60c 100755 --- a/bin/wanna-build +++ b/bin/wanna-build @@ -24,9 +24,8 @@ package conf; $basedir ||= "/var/lib/debbuild"; $dbbase ||= "build-db"; $transactlog ||= "transactions.log"; -#$mailprog ||= "/usr/sbin/sendmail"; -$mailprog = "/bin/true"; -require "/etc/wanna-build.conf"; +$mailprog ||= "/usr/sbin/sendmail"; +require "/org/wanna-build/etc/wanna-build.conf"; die "$conf::basedir is not a directory\n" if ! -d $conf::basedir; die "dbbase is empty\n" if ! $dbbase; die "transactlog is empty\n" if ! $transactlog; @@ -40,6 +39,7 @@ use POSIX; use FileHandle; use File::Copy; use DBI; +use lib '/org/wanna-build/bin'; use WannaBuild; our ($verbose, $mail_logs, $list_order, $list_state, @@ -302,8 +302,18 @@ END { } } -$dbh = DBI->connect("DBI:Pg:database=wanna-build") || - die "FATAL: Cannot open database: $DBI::errstr\n"; +my $schema_suffix = ''; +# TODO: Base this on something else, like an option that is passed. +if ($real_user eq 'nobody') { + $dbh = DBI->connect("DBI:Pg:service=wanna-build") || + die "FATAL: Cannot open database: $DBI::errstr\n"; + $schema_suffix = '_public'; +} +else +{ + $dbh = DBI->connect("DBI:Pg:service=wanna-build-privileged") || + die "FATAL: Cannot open database: $DBI::errstr\n"; +} # TODO: This shouldn't be needed, file a bug. $dbh->{pg_server_prepare} = 0; @@ -887,6 +897,12 @@ sub add_one_needsbuild { } $state = $pkg->{'state'}; + if ($state eq "Needs-Build") + { + print "$name: Already in Needs-Build.\n"; + return; + } + if ($state eq "BD-Uninstallable") { if ($opt_override) { print "$name: Forcing uninstallability mark to be removed. This is not permanent and might be reset with the next trigger run\n"; @@ -928,7 +944,8 @@ sub add_one_needsbuild { } } if (defined ($pkg->{'builder'}) && $user ne $pkg->{'builder'} && - !($pkg->{'builder'} =~ /^(\w+)-\w+/ && $1 eq $user)) { + !($pkg->{'builder'} =~ /^(\w+)-\w+/ && $1 eq $user) && + !$opt_override) { print "$name: not taken by you, but by ". "$pkg->{'builder'}. Skipping.\n"; return; @@ -1759,9 +1776,9 @@ sub list_packages { next if $category && $pkg->{'state'} eq "Failed" && $pkg->{'failed_category'} ne $category; next if ($list_min_age > 0 && - ($ctime-parse_date($pkg->{'State-Change'})) < $list_min_age)|| + ($ctime-parse_date($pkg->{'state_change'})) < $list_min_age)|| ($list_min_age < 0 && - ($ctime-parse_date($pkg->{'State-Change'})) > -$list_min_age); + ($ctime-parse_date($pkg->{'state_change'})) > -$list_min_age); push( @list, $pkg ); } @@ -1791,7 +1808,7 @@ sub list_packages { join("\n ",split("\n",$pkg->{'bd_problem'})), "\n" if $pkg->{'state'} eq "BD-Uninstallable"; print " Previous state was $pkg->{'previous_state'} until ", - "$pkg->{'State-Change'}\n" + "$pkg->{'state_change'}\n" if $verbose && $pkg->{'previous_state'}; print " No previous state recorded\n" if $verbose && !$pkg->{'previous_state'}; @@ -1834,15 +1851,39 @@ sub info_packages { chomp( $val ); $val = "\n$val" if isin( $key, qw(Failed Old-Failed)); $val =~ s/\n/\n /g; - printf " %-20s: %s\n", $key, $val; + my $print_key = $key; + $print_key = 'Package' if ($key eq 'package'); + $print_key = 'Version' if ($key eq 'version'); + $print_key = 'Builder' if ($key eq 'builder'); + $print_key = 'State' if ($key eq 'state'); + $print_key = 'Section' if ($key eq 'section'); + $print_key = 'Priority' if ($key eq 'priority'); + $print_key = 'Installed-Version' if ($key eq 'installed_version'); + $print_key = 'Previous-State' if ($key eq 'previous_state'); + $print_key = 'State-Change' if ($key eq 'state_change'); + printf " %-20s: %s\n", $print_key, $val; } foreach $key (sort keys %$pkg) { next if isin( $key, @firstkeys ); my $val = $pkg->{$key}; + next if !defined($val); chomp( $val ); $val = "\n$val" if isin( $key, qw(Failed Old-Failed)); $val =~ s/\n/\n /g; - printf " %-20s: %s\n", $key, $val; + my $print_key = $key; + $print_key = 'BD-Problem' if ($key eq 'bd_problem'); + $print_key = 'Binary-NMU-Changelog' if ($key eq 'binary_nmu_changelog'); + $print_key = 'Binary-NMU-Version' if ($key eq 'binary_nmu_version'); + $print_key = 'BuildPri' if ($key eq 'buildpri'); + $print_key = 'Depends' if ($key eq 'depends'); + $print_key = 'Failed' if ($key eq 'failed'); + $print_key = 'Failed-Category' if ($key eq 'failed_category'); + $print_key = 'Notes' if ($key eq 'notes'); + $print_key = 'Distribution' if ($key eq 'distribution'); + $print_key = 'Old-Failed' if ($key eq 'old_failed'); + $print_key = 'PermBuildPri' if ($key eq 'permbuildpri'); + $print_key = 'Rel' if ($key eq 'rel'); + printf " %-20s: %s\n", $print_key, $val; } } } @@ -1939,18 +1980,18 @@ sub check_entry { join( "\n", map { "$_: $pkg->{$_}" } keys %$pkg ), "\n"; die "Database entry lacks package or username field\n"; } - if (!exists $pkg->{'version'}) { - die "Database entry for $pkg->{'package'} lacks Version: field\n"; - } # if no State: field, generate one (for old db compat) if (!exists($pkg->{'state'})) { $pkg->{'state'} = exists $pkg->{'failed'} ? 'Failed' : 'Building'; } + if (!exists $pkg->{'version'} and $pkg->{'state'} ne 'Not-For-Us') { + die "Database entry for $pkg->{'package'} lacks Version: field\n"; + } # check state field die "Bad state $pkg->{'state'} of package $pkg->{Package}\n" if !isin( $pkg->{'state'}, - qw(Needs-Build Building Built Build-Attempted Uploaded Installed Dep-Wait + qw(Needs-Build Building Built Build-Attempted Uploaded Installed Dep-Wait Dep-Wait-Removed Failed Failed-Removed Not-For-Us BD-Uninstallable ) ); } @@ -1963,7 +2004,7 @@ sub change_state { return if defined($$state) and $$state eq $newstate; $pkg->{'previous_state'} = $$state if defined($$state); - $pkg->{'State-Change'} = $curr_date; + $pkg->{'state_change'} = $curr_date; if (defined($$state) and $$state eq 'Failed') { $pkg->{'old_failed'} = @@ -2315,6 +2356,7 @@ sub usage { Usage: $prgname Options: -v, --verbose: Verbose execution. + -A arch: Architecture this operation is for. --take: Take package for building [default operation] -f, --failed: Record in database that a build failed due to deficiencies in the package (that aren't fixable without a new @@ -2375,17 +2417,18 @@ sub pkg_version_eq { } sub table_name { - return $arch; + return '"' . $arch . $schema_suffix . '".packages'; } sub user_table_name { - return $arch . '_users'; + return '"' . $arch . $schema_suffix . '".users'; } sub get_source_info { my $name = shift; my $pkg = $dbh->selectrow_hashref('SELECT * FROM ' . - table_name() . ' WHERE package = ? AND distribution = ?', + table_name() . ' WHERE package = ? AND distribution = ?' . + 'FOR UPDATE', undef, $name, $distribution); return $pkg; }