nmh-workers
[Top] [All Lists]

Re: [nmh-workers] Reproducible build patch

2018-07-23 18:09:45
On Mon, 23 Jul 2018 09:17:45 -0400 Ken Hornstein <kenh@pobox.com> wrote:
Ken Hornstein writes:
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.  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"
SOURCE_DATE_EPOCH="${SOURCE_DATE_EPOCH:-$(date +s)}"
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_F
MT")

I ... think that's right (note, I haven't tested it yet).  Everyone ok
with this?

How about something like

timestamp() {
    _TIME="${SOURCE_DATE_EPOCH:-$(date +%s)}"
    if date --help 2>/dev/null; then src=-d@ ; else src=-r ; fi
    date ${src}$_TIME +"%Y-%m-%d %T +0000"
}

Tested in linux, FreeBSD & Mac.

$  timestamp
2018-07-23 16:02:33 +0000
$ SOURCE_DATE_EPOCH=12345
$ timestamp
1969-12-31 19:25:45 +0000

-- 
nmh-workers
https://lists.nongnu.org/mailman/listinfo/nmh-workers

<Prev in Thread] Current Thread [Next in Thread>