Hello Johannes.

Previously, I asked for a way to choose the timestamp format in the filename.

As you explained, this would involve a new configuration option,
and I can understand that you don't like it.

My use case is now a little bit different:

I call sbuild from a shell script. In addition to the build log
itself, I keep "logs" for two other things: The memory used during the
build (at one-second intervals) and the junk which remains in /tmp
after the build.

I'd like those three logs to have the same timestamp.

Also, because some packages FTBFS randomly and in those cases I want
to know how randomly they fail, sometimes I tell my autobuilders
to build the same package over and over again.

Because of this I'd also like to use sub-second precision, to avoid
several build logs to have the same filename.

So, what I would really need is a way to provide the timestamp externally.

Something like this:

export SBUILD_LOG_TIMESTAMP=$(date "+%Y%m%dT%H%M%S.%3NZ")
sbuild -d buster some-package

The following patch would make the above to work:

--- a/lib/Sbuild/Build.pm
+++ b/lib/Sbuild/Build.pm
@@ -2970,7 +2970,11 @@ sub open_build_log {
     } else {
        $filename .= $self->get('Package');
     }
-    $filename .= '_' . $self->get('Host Arch') . "-$date";
+    my $log_timestamp = $ENV{'SBUILD_LOG_TIMESTAMP'};
+    if ($log_timestamp eq "") {
+      $log_timestamp = $date;
+    }
+    $filename .= '_' . $self->get('Host Arch') . "-$log_timestamp";
     $filename .= ".build" if $self->get_conf('SBUILD_MODE') ne 'buildd';
 
     open($saved_stdout, ">&STDOUT") or warn "Can't redirect stdout\n";

(Sorry for my poor perl, which I don't really speak, I'm almost sure
there is a shorter way to do the same).

Would honoring an environment variable like this, when it does exist,
be more acceptable for you than the new configuration option we were
discussing before?

Thanks.

Reply via email to