Hi Santiago, Quoting Santiago Vila (2018-11-29 14:32:08) > Previously, I asked for a way to choose the timestamp format in the filename.
welcome back! :D
> 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.
Okay. Why?
> 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.
I think I don't understand something here. How would two build logs have the
same file name with second-precision but not the same file name with
sub-second-precision?
> So, what I would really need is a way to provide the timestamp externally.
Do you? Why not just put the build logs into two distinct directories?
> 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?
The environment variable name should probably be different because what you are
supplying there is not just a timestamp but more of a build log filename suffix
because any string could be passed that way.
Thanks!
cheers, josch
signature.asc
Description: signature

