From: Kurt Roeckx Date: Mon, 28 Sep 2009 17:09:43 +0000 (+0000) Subject: Move the transaction log to the database. X-Git-Url: https://git.donarmstrong.com/?p=wannabuild.git;a=commitdiff_plain;h=ac04b196d55fb260d3de704970f3b4047dd3944e Move the transaction log to the database. --- diff --git a/bin/wanna-build b/bin/wanna-build index 5fe9034..f11fa94 100755 --- a/bin/wanna-build +++ b/bin/wanna-build @@ -2046,13 +2046,13 @@ sub log_ta { "changed from $prevstate to $pkg->{'state'} ". "by $real_user as $user"; - my $transactlog = db_transactlog(); - if (!open( LOG, ">>$transactlog" )) { - warn "Can't open log file $transactlog: $!\n"; - return; - } - print LOG "$curr_date: $str\n"; - close( LOG ); + $dbh->do('INSERT INTO ' . transactions_table_name() . + ' (package, distribution, version, action, ' . + ' prevstate, state, real_user, set_user, time) ' . + ' values (?, ?, ?, ?, ?, ?, ?, ?, ?)', + undef, $pkg->{'package'}, $distribution, + $pkg->{'version'}, $action, $prevstate, $pkg->{'state'}, + $real_user, $user, 'now()') or die $dbh->errstr; if (!($prevstate eq 'Failed' && $pkg->{'state'} eq 'Failed')) { $str .= " (with --override)" @@ -2084,10 +2084,6 @@ sub send_mail { close( PIPE ); } -sub db_transactlog { - return "$conf::basedir/$arch/$conf::transactlog"; -} - # for parsing input to dep-wait sub parse_deplist { my $deps = shift; @@ -2439,6 +2435,10 @@ sub user_table_name { return '"' . $arch . $schema_suffix . '".users'; } +sub transactions_table_name { + return '"' . $arch . $schema_suffix . '".transactions'; +} + sub get_readonly_source_info { my $name = shift; my $pkg = $dbh->selectrow_hashref('SELECT * FROM ' .