]> git.donarmstrong.com Git - wannabuild.git/commitdiff
Move the transaction log to the database.
authorKurt Roeckx <kurt@roeckx.be>
Mon, 28 Sep 2009 17:09:43 +0000 (17:09 +0000)
committerKurt Roeckx <kurt@roeckx.be>
Mon, 28 Sep 2009 17:09:43 +0000 (17:09 +0000)
bin/wanna-build

index 5fe90344fa03b5991a468894e7d29c5143e9ecb5..f11fa949cd6e7d4b3435ba2d6bacd290f52744db 100755 (executable)
@@ -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 ' .