X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=bin%2Fwanna-build;h=772964c15c7682b12669875580c55bcc6f19e950;hb=f48436de6bd2a05f46763a6cafc84ef043d74fc5;hp=002d4521aae60fce335cf0dedb7c8365ce067591;hpb=3e2a517cc4ddbb4d4d64b2cb4bcfe8e77eddbad0;p=wannabuild.git diff --git a/bin/wanna-build b/bin/wanna-build index 002d452..772964c 100755 --- a/bin/wanna-build +++ b/bin/wanna-build @@ -24,8 +24,7 @@ package conf; $basedir ||= "/var/lib/debbuild"; $dbbase ||= "build-db"; $transactlog ||= "transactions.log"; -#$mailprog ||= "/usr/sbin/sendmail"; -$mailprog = "/bin/true"; +$mailprog ||= "/usr/sbin/sendmail"; require "/etc/wanna-build.conf"; die "$conf::basedir is not a directory\n" if ! -d $conf::basedir; die "dbbase is empty\n" if ! $dbbase; @@ -302,8 +301,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; @@ -1759,9 +1768,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 +1800,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'}; @@ -1939,18 +1948,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 +1972,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'} = @@ -2375,11 +2384,11 @@ 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 {