Source: fim
Version: 0.5~rc2-1
Severity: wishlist
Tags: patch upstream
User: reproducible-bui...@lists.alioth.debian.org
Usertags: fileordering timestamps locale
X-Debbugs-Cc: reproducible-bui...@lists.alioth.debian.org

Dear Maintainer,

While working on the “reproducible builds” effort [1], we have noticed
that 'fim' could not be built reproducibly.

The attached patch fixes the order in which files are joined in header
files, strips the build date from fim binary, makes the embeded vim2html
script honour the SOURCE_DATE_EPOCH environment variable when building
the documentation, and force language to be English when using bison to
make a grammar that is going to be parsed using English keywords. Once
applied, fim can be built reproducibly in our current experimental
framework.

Regards,
Alexis Bienvenüe.

 [1]: https://wiki.debian.org/ReproducibleBuilds





diff -Nru fim-0.5~rc2/debian/changelog fim-0.5~rc2/debian/changelog
--- fim-0.5~rc2/debian/changelog	2016-02-17 16:15:03.000000000 +0100
+++ fim-0.5~rc2/debian/changelog	2016-04-13 20:20:02.000000000 +0200
@@ -1,3 +1,13 @@
+fim (0.5~rc2-1.0~reproducible1) unstable; urgency=medium
+
+  * Make the build reproducible :
+    - Set locale to C when sorting files
+    - Strip build date from fim binary
+    - makes embeded vim2html script honour SOURCE_DATE_EPOCH
+    - fix language problem when parsing bison output
+
+ -- Alexis Bienvenüe <p...@passoire.fr>  Tue, 12 Apr 2016 10:56:22 +0200
+
 fim (0.5~rc2-1) unstable; urgency=medium
 
   * New upstream release snapshot (Closes: #814673).
diff -Nru fim-0.5~rc2/debian/patches/english_bison.patch fim-0.5~rc2/debian/patches/english_bison.patch
--- fim-0.5~rc2/debian/patches/english_bison.patch	1970-01-01 01:00:00.000000000 +0100
+++ fim-0.5~rc2/debian/patches/english_bison.patch	2016-04-13 19:16:05.000000000 +0200
@@ -0,0 +1,17 @@
+Description: Call bison with LC_ALL=C
+ If the current language is not English, the terms that bison outputs
+ in src/yacc.tab.output won't be recognized by the yacc2grammar.awk
+ script, and the file grammar.h won't be built correctly.
+Author: Alexis Bienvenüe <p...@passoire.fr>
+
+--- fim-0.5~rc2.orig/src/Makefile.am
++++ fim-0.5~rc2/src/Makefile.am
+@@ -19,7 +19,7 @@ lex.yy.cc: lex.lex yacc.tab.cpp
+ 	$(SED) -i 's/^.*extern.*isatty.*int.*$$//g' $@
+ 
+ yacc.tab.hpp yacc.tab.cpp: yacc.ypp lex.lex
+-	$(YACC) $(YFLAGS) $< -o $@
++	LC_ALL=C $(YACC) $(YFLAGS) $< -o $@
+ 
+ FIM_LIB_OBJECTS = yacc.tab.o lex.yy.o
+ 
diff -Nru fim-0.5~rc2/debian/patches/series fim-0.5~rc2/debian/patches/series
--- fim-0.5~rc2/debian/patches/series	1970-01-01 01:00:00.000000000 +0100
+++ fim-0.5~rc2/debian/patches/series	2016-04-13 19:13:50.000000000 +0200
@@ -0,0 +1,4 @@
+sort_locale.patch
+strip_build_date.petch
+vim2html_SOURCE_DATE_EPOCH.patch
+english_bison.patch
diff -Nru fim-0.5~rc2/debian/patches/sort_locale.patch fim-0.5~rc2/debian/patches/sort_locale.patch
--- fim-0.5~rc2/debian/patches/sort_locale.patch	1970-01-01 01:00:00.000000000 +0100
+++ fim-0.5~rc2/debian/patches/sort_locale.patch	2016-04-12 17:56:23.000000000 +0200
@@ -0,0 +1,21 @@
+Description: Sort locale
+ Set sort locale to C, so that the order is always the same.
+ This helps reproducible build.
+Author: Alexis Bienvenüe <p...@passoire.fr>
+
+--- fim-0.5~rc2.orig/src/Makefile.am
++++ fim-0.5~rc2/src/Makefile.am
+@@ -46,10 +46,10 @@ SDLDevice.o: default_icon_byte_array.h
+ 
+ # in the following : for some freebsd oddity, i was forced to replace ..0-9_]\+ with ..0-9_]*
+ version.h:	../config.h
+-	$(GREP) define $< | $(GREP) FIM | $(SORT) | $(SED) 's/^#//g;s/define //g;s/^\([A-Za-z0-9_]*\).*$$/+\1  /g;s/^/\"/g;s/$$/\"/g' > $@
++	$(GREP) define $< | $(GREP) FIM | LC_ALL=C $(SORT) | $(SED) 's/^#//g;s/define //g;s/^\([A-Za-z0-9_]*\).*$$/+\1  /g;s/^/\"/g;s/$$/\"/g' > $@
+ 	$(ECHO) "\"\n\"" >> $@
+-	$(GREP) define $< | $(GREP) FIM.*'"' | $(SORT) | $(SED) 's/^#//g;s/define //g;s/^\([A-Za-z0-9_]*\) "\(.*\)"$$/"\1 = \\"\2\\"\\n"/g'   >> $@
+-	$(GREP) undef $< | $(GREP) FIM | $(SORT) | $(SED) 's/^#//g;s/.*undef //g;s/^\([A-Za-z0-9_]*\).\+$$/-\1  /g;s/^/\"/g;s/$$/\"/g' >> $@
++	$(GREP) define $< | $(GREP) FIM.*'"' | LC_ALL=C $(SORT) | $(SED) 's/^#//g;s/define //g;s/^\([A-Za-z0-9_]*\) "\(.*\)"$$/"\1 = \\"\2\\"\\n"/g'   >> $@
++	$(GREP) undef $< | $(GREP) FIM | LC_ALL=C $(SORT) | $(SED) 's/^#//g;s/.*undef //g;s/^\([A-Za-z0-9_]*\).\+$$/-\1  /g;s/^/\"/g;s/$$/\"/g' >> $@
+ 	$(ECHO)  '"\n'CXXFLAGS=$(CXXFLAGS)'\n"' >> $@
+ 
+ help.cpp: fim.h
diff -Nru fim-0.5~rc2/debian/patches/strip_build_date.petch fim-0.5~rc2/debian/patches/strip_build_date.petch
--- fim-0.5~rc2/debian/patches/strip_build_date.petch	1970-01-01 01:00:00.000000000 +0100
+++ fim-0.5~rc2/debian/patches/strip_build_date.petch	2016-04-12 17:56:23.000000000 +0200
@@ -0,0 +1,16 @@
+Description: Strip build date
+ Strip build date from version string, to get reproducible build.
+Author: Alexis Bienvenüe <p...@passoire.fr>
+
+--- fim-0.5~rc2.orig/src/fim.cpp
++++ fim-0.5~rc2/src/fim.cpp
+@@ -1564,8 +1564,7 @@ fim_perr_t main(int argc,char *argv[])
+ 			    ", by "
+ 			    FIM_AUTHOR
+ 	#endif /* FIM_AUTHOR  */
+-			    ", built on %s\n",
+-			    __DATE__
++			    "\n",
+ 	    		    " ( based on fbi version 1.31 (c) by 1999-2004 " FBI_AUTHOR_NAME " )\n"
+ 	#ifdef FIM_WITH_LIBPNG
+ 	#ifdef PNG_HEADER_VERSION_STRING 
diff -Nru fim-0.5~rc2/debian/patches/vim2html_SOURCE_DATE_EPOCH.patch fim-0.5~rc2/debian/patches/vim2html_SOURCE_DATE_EPOCH.patch
--- fim-0.5~rc2/debian/patches/vim2html_SOURCE_DATE_EPOCH.patch	1970-01-01 01:00:00.000000000 +0100
+++ fim-0.5~rc2/debian/patches/vim2html_SOURCE_DATE_EPOCH.patch	2016-04-12 17:56:23.000000000 +0200
@@ -0,0 +1,21 @@
+Description: Make vim2html.pl honour SOURCE_DATE_EPOCH
+ Make the embedded vim2html.pl script honour the SOURCE_DATE_EPOCH
+ environment variable, to make the build reproducible.
+ See https://reproducible-builds.org/specs/source-date-epoch/
+Author: Alexis Bienvenüe <p...@passoire.fr>
+
+--- fim-0.5~rc2.orig/doc/vim2html.pl
++++ fim-0.5~rc2/doc/vim2html.pl
+@@ -9,10 +9,10 @@
+ 
+ use strict;
+ use vars qw/%url $date/;
++use POSIX qw(strftime);
+ 
+ %url = ();
+-$date = `date`;
+-chop $date;
++$date = strftime("%Y-%m-%d", gmtime($ENV{SOURCE_DATE_EPOCH} || time));
+ 
+ sub maplink
+ {

Reply via email to