nmh-workers
[Top] [All Lists]

Re: [nmh-workers] Reproducible build patch

2018-07-24 12:00:29
    Date:        Tue, 24 Jul 2018 16:40:48 +0100
    From:        Ralph Corderoy <ralph@inputplus.co.uk>
    Message-ID:  <20180724154048.AEB24214E0@orac.inputplus.co.uk>

  | It tells the reader that an empty value, an error, isn't ignored as if
  | it wasn't specified.

I know what the intent is, but if you want that, you have to make it
happen, it doesn't "just work".

  | But it will throw up a non-reproducible build, as would, like you say,
  | misleading the reader by ignoring an empty string as if it's valid.

The way it was, it would make a non-reprodible build for any
invalie value of SOURCE_DATE_EPOCH - being null is just one
of many possible invalid values.

The point is that the "try this" or "try this" ... stuff in order to find
an arg sequence for date that works also allows invalid values
for the input time to be ignored,

that is, on a system that does not support

        date -d @NNN ....

date will (should) fail, but on a system where -d @NNN is
supported, date will fail if NNN is invalid, and given stderr is
sent o /dev/null, will fail in a more or less indistinguishable way.

Then it just tries the next one, and eventually just uses "date -u +fmt"
which  uses the current time, which is no different than if we had
set now=$(date +%s) and allowed the NNN to be valid.

  | That's like saying no error checking should occur because if no errors
  | are intended then they shouldn't be caused.

It depends upon the error - but here there is no error checking happening,
it is just being ignored in a different wat.

If you really want sane error checking, you probably want

if [ "${SOURCE_DATE_EPOCH+set}" ]
then
        case "${SOURCE_DATE_EPOCH}" in
        '' | *[!0-9]*)
                printf '%s\n' >&2 \
                     "Invalid SOURCE_DATE_EPOCH='${SOURCE_DATE_EPOCH}'"
                exit 1
                ;;
        esac
fii

or something along those lines.    That way at least the source of the problem
is known.   If you do that, you don't need to rely as much upon versions of
date doing proper error checking of their input (I have no idea how good
NetBSD is at detecting a bad value after date -d@... (which is supported, as
is -r) for example, it might just convert digits and ignore later noise.

kre

ps: -e is one of the lest relaible features of sh (not in implementations, so
much, but its definition, and then usage expectations) - it is best not to
rely upon it, and rather add "|| fail Message" after any command that you
actually want to check the exit status off (where fail is a function that 
DTRT).


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

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