Hi Ken,

> We received the following bug report today:
>       http://savannah.nongnu.org/support/?109535
> It seems to me like reproducible builds are probably a pretty good
> idea


> and nmh should support them, and the patch looks relatively small.

It tinkers with the hostname too.

    $ curl -sSgL 
'https://savannah.nongnu.org/support/download.php?file_id=44608' |
    > grep host
    -host=`uname -n`
    +host=${HOSTNAME:-`uname -n`}
     char *version_str = "nmh-$version$git built $date on $host";

> But to be completely portable the date line should be (from here):
> https://wiki.debian.org/ReproducibleBuilds/TimestampsProposal#Bash_.2F_POSIX_shell
> DATE_FMT="%Y-%m-%d %T +0000"
> date=$(TZ=GMT0 date --date="@$SOURCE_DATE_EPOCH" "+$DATE_FMT" 2>/dev/null || 
> date -u -r "$SOURCE_DATE_EPOCH" "+$DATE_FMT" 2>/dev/null || date -u 
> "+$DATE_FMT")

https://reproducible-builds.org/specs/source-date-epoch/ says

    The value MUST be an ASCII representation of an integer with no
    fractional component, identical to the output format of date +%s. 
    If the value is malformed, the build process SHOULD exit with a
    non-zero error code. 

So I think `:-' is the wrong test, and `:' should be used.

The `+0000' is being hard-coded into date's output, rather than asking
date for the TZ to spot if the attempt to use UTC failed.

I've found some fine documentation.

    POSIX      https://manned.org/date.1p
    Coreutils  https://manned.org/date.1
    Plan9      https://manned.org/date.1plan9
    OpenBSD    https://man.openbsd.org/date
    FreeBSD    https://www.freebsd.org/cgi/man.cgi?date
    macOSĀ¹     https://ss64.com/osx/date.html (Maybe.)

How about

    fmt='%Y-%m-%d %T %z'
    now="${SOURCE_DATE_EPOCH-$(date +%s)}"
        exec 2>/dev/null
        date -u -d "@$now" +"$fmt" ||
        date -u -r "$now" +"$fmt" ||
        date -u +"$fmt"
    printf '%q\n' "$fmt" "$now" "$date"

Tried with Coreutils and FreeBSD.

I think we should stick with `yyyy-mm-dd' rather than switching to
podium-style, like

Cheers, Ralph.


Reply via email to