Bug#835985: nmh: please make the build reproducible

Chris Lamb lamby at debian.org
Mon Aug 29 19:39:10 UTC 2016


Source: nmh
Version: 1.6-12
Severity: wishlist
Tags: patch
User: reproducible-builds at lists.alioth.debian.org
Usertags: filesystem
X-Debbugs-Cc: reproducible-builds at lists.alioth.debian.org

Hi,

Whilst working on the Reproducible Builds effort [0], I noticed
that nmh could not be built reproducibly due to non-deterministic
filesystem ordering.

Patch attached.

 [0] https://reproducible-builds.org/


Regards,

-- 
      ,''`.
     : :'  :     Chris Lamb
     `. `'`      lamby at debian.org / chris-lamb.co.uk
       `-
-------------- next part --------------
--- a/.pc/11-repro/config/version.sh	2016-08-29 20:27:47.169277506 +0100
--- b/.pc/11-repro/config/version.sh	1970-01-01 01:00:00.000000000 +0100
@@ -1,42 +0,0 @@
-#!/bin/sh
-#
-# version.sh -- script to create version string(s) for nmh.
-#
-# You need to pass the script the version number to use.
-#
-
-if [ -z "$1" ]; then
-    echo "usage: version.sh VERSION" 1>&2
-    exit 1
-fi
-
-VERSION=$1
-OFS="$IFS"
-IFS=:
-HOSTNAME=unknown
-
-# Find out the name of the host we are compiling on
-for prog in uname hostname
-do
-    for dir in $PATH
-    do
-	if [ ! -f $dir/$prog ]; then
-	    continue
-	fi
-	case $prog in
-	    uname)	HOSTNAME=`$prog -n`
-			;;
-	    hostname)	HOSTNAME=`$prog`
-			;;
-	esac
-	break
-    done
-    if [ X"$HOSTNAME" != X  -a  X"$HOSTNAME" != Xunknown ]; then
-	break
-    fi
-done
-
-IFS=" "
-
-echo "char *version_str = \"nmh-$VERSION [compiled on $HOSTNAME at `date`]\";"
-echo "char *version_num = \"nmh-$VERSION\";"
--- a/.pc/11-repro/man/mh-chart-gen.sh	2016-08-29 20:27:47.169277506 +0100
--- b/.pc/11-repro/man/mh-chart-gen.sh	1970-01-01 01:00:00.000000000 +0100
@@ -1,45 +0,0 @@
-#!/bin/sh
-#
-# Generates mh-chart.man from other .man files that have a SYNOPSIS
-# section.
-
-nmhmandir=`dirname $0`
-
-# The following ensures the generated date field in the manpage is divorced
-# from the local build environment when building distribution packages.
-LC_TIME=C; export LC_TIME
-unset LANG
-datestamp=`date '+%B %d, %Y'`
-
-cat <<__HOOPY_FROOD
-.TH MH-CHART %manext7% "${datestamp}" "%nmhversion%"
-.\"
-.\" %nmhwarning%
-.\"
-.SH NAME
-mh-chart \- Chart of nmh Commands
-.SH SYNOPSIS
-.na
-__HOOPY_FROOD
-
-for i in $nmhmandir/*.man; do
-  case $i in
-    */mh-chart.man) ;;
-    *) if grep '^\.ad' "$i" >/dev/null; then
-         #### Extract lines from just after .SH SYNOPSIS to just before .ad.
-         #### Filter out the "typical usage:" section in pick.man.
-         awk '/.SH SYNOPSIS/,/^(\.ad|typical usage:)/ {
-                if ($0 !~ /^(\.SH SYNOPSIS|\.na|\.ad|typical usage:)/) print
-              }' "$i"
-         echo
-       fi ;;
-  esac
-done
-
-cat <<'EOF'
-.ad
-
-.SH "SEE ALSO"
-.IR nmh (7),
-.IR mh\-mime (7)
-EOF
--- a/.pc/applied-patches	2016-08-29 20:27:47.165277461 +0100
--- b/.pc/applied-patches	2016-08-29 20:31:59.860110655 +0100
@@ -5,4 +5,3 @@
 05-valgrind
 09-automake
 10-mhuninstall
-11-repro
--- a/config/version.sh	2016-08-29 20:27:47.169277506 +0100
--- b/config/version.sh	2016-08-29 20:31:59.000000000 +0100
@@ -38,5 +38,5 @@
 
 IFS=" "
 
-echo "char *version_str = \"nmh-$VERSION\";"
+echo "char *version_str = \"nmh-$VERSION [compiled on $HOSTNAME at `date`]\";"
 echo "char *version_num = \"nmh-$VERSION\";"
--- a/debian/patches/11-repro	2016-08-29 20:27:47.169277506 +0100
--- b/debian/patches/11-repro	2016-08-29 20:31:59.772109677 +0100
@@ -1,5 +1,5 @@
---- a/config/version.sh
-+++ b/config/version.sh
+--- nmh-1.6.orig/config/version.sh
++++ nmh-1.6/config/version.sh
 @@ -38,5 +38,5 @@ done
  
  IFS=" "
@@ -18,3 +18,12 @@
  
  cat <<__HOOPY_FROOD
  .TH MH-CHART %manext7% "${datestamp}" "%nmhversion%"
+@@ -22,7 +22,7 @@ mh-chart \- Chart of nmh Commands
+ .na
+ __HOOPY_FROOD
+ 
+-for i in $nmhmandir/*.man; do
++find man -name '*.man' | LC_ALL=C sort | while read i; do
+   case $i in
+     */mh-chart.man) ;;
+     *) if grep '^\.ad' "$i" >/dev/null; then
--- a/man/mh-chart-gen.sh	2016-08-29 20:27:47.173277551 +0100
--- b/man/mh-chart-gen.sh	2016-08-29 20:31:59.000000000 +0100
@@ -9,7 +9,7 @@
 # from the local build environment when building distribution packages.
 LC_TIME=C; export LC_TIME
 unset LANG
-datestamp="$(date --utc --date="@${SOURCE_DATE_EPOCH:-$(date +%s)}" '+%B %d, %Y')"
+datestamp=`date '+%B %d, %Y'`
 
 cat <<__HOOPY_FROOD
 .TH MH-CHART %manext7% "${datestamp}" "%nmhversion%"


More information about the Reproducible-builds mailing list