File reproducible.patch of Package nmh

Author: Bernhard M. Wiedemann <bwiedemann suse de>
Date: 2018-07-23

https://savannah.nongnu.org/support/index.php?109535

Allow to override build date
in order to make builds reproducible.
See https://reproducible-builds.org/ for why this is good
and https://reproducible-builds.org/specs/source-date-epoch/
for the definition of this variable.
This date call only works with GNU date.

Index: nmh-1.7.1/config/version.sh
===================================================================
--- nmh-1.7.1.orig/config/version.sh
+++ nmh-1.7.1/config/version.sh
@@ -6,13 +6,13 @@
 set -e
 
 version=${1?}
-host=`uname -n`
+host=${HOSTNAME:-`uname -n`}
 if test -d "$srcdir/.git"; then
     git=" `git -C $srcdir describe --long --dirty`"
 else
     git=
 fi
-date="`TZ=GMT0 date +'%Y-%m-%d %T'` +0000"
+date="$(TZ=GMT0 date --date="@${SOURCE_DATE_EPOCH:-$(date +%s)}" '+%Y-%m-%d %T +0000')"
 
 cat <<E
 char *version_str = "nmh-$version$git built $date on $host";
Index: nmh-1.7.1/man/mh-chart-gen.sh
===================================================================
--- nmh-1.7.1.orig/man/mh-chart-gen.sh
+++ nmh-1.7.1/man/mh-chart-gen.sh
@@ -13,7 +13,7 @@ nmhmandir=`dirname $0`
 # from the local build environment when building distribution packages.
 LC_TIME=C; export LC_TIME
 unset LANG
-datestamp=`date +%Y-%m-%d`
+datestamp="$(date --utc --date="@${SOURCE_DATE_EPOCH:-$(date +%s)}" '+%B %d, %Y')"
 
 cat <<__HOOPY_FROOD
 .TH MH-CHART %manext7% "${datestamp}" "%nmhversion%"
openSUSE Build Service is sponsored by