make reproducible
[fw/altos] / debian / patches / 0001-Use-strip-nondeterminism-to-fix-JAR-timestamps.patch
1 From 630f457666b48321be0a5b6fbf391efef1fa3eb4 Mon Sep 17 00:00:00 2001
2 From: Keith Packard <keithp@keithp.com>
3 Date: Sun, 3 Feb 2019 12:48:45 -0800
4 Subject: [PATCH] Use strip-nondeterminism to fix JAR timestamps
5
6 .jar files are just zip files, and contain dates. These will cause the
7 build to be non-reproducible. Use strip-nondeterminism to smash all of
8 these back to a fixed value.
9
10 Signed-off-by: Keith Packard <keithp@keithp.com>
11 ---
12  altoslib/Makefile.am              |  3 +++
13  altosui/Makefile.am               |  6 ++++++
14  altosuilib/Makefile.am            |  3 +++
15  configure.ac                      | 20 ++++++++++++++++++++
16  map-server/altos-mapd/Makefile.am |  6 ++++++
17  map-server/altos-mapj/Makefile.am |  6 ++++++
18  micropeak/Makefile.am             |  6 ++++++
19  telegps/Makefile.am               |  6 ++++++
20  8 files changed, 56 insertions(+)
21
22 diff --git a/altoslib/Makefile.am b/altoslib/Makefile.am
23 index 447830e5..dfae0f69 100644
24 --- a/altoslib/Makefile.am
25 +++ b/altoslib/Makefile.am
26 @@ -207,3 +207,6 @@ bin:
27  
28  $(JAR): classaltoslib.stamp
29         jar cf $@ -C bin org
30 +if STRIP_NONDETERMINISM
31 +       $(STRIP_NONDETERMINISM) $@
32 +endif
33 diff --git a/altosui/Makefile.am b/altosui/Makefile.am
34 index 7cc1f4ea..eec15786 100644
35 --- a/altosui/Makefile.am
36 +++ b/altosui/Makefile.am
37 @@ -255,12 +255,18 @@ $(JAR): classaltosui.stamp Manifest.txt $(JAVA_ICONS) $(ALTOSLIB_CLASS) $(ALTOSU
38                 $(ICONJAR) \
39                 -C classes altosui \
40                 -C ../libaltos libaltosJNI
41 +if STRIP_NONDETERMINISM
42 +       $(STRIP_NONDETERMINISM) $@
43 +endif
44  
45  $(FATJAR): classaltosui.stamp Manifest-fat.txt $(ALTOSLIB_CLASS) $(ALTOSUILIB_CLASS) $(FREETTS_CLASS) $(JFREECHART_CLASS) $(JCOMMON_CLASS) $(LIBALTOS) $(JAVA_ICONS)
46         jar cfm $@ Manifest-fat.txt \
47                 $(ICONJAR) \
48                 -C classes altosui \
49                 -C ../libaltos libaltosJNI
50 +if STRIP_NONDETERMINISM
51 +       $(STRIP_NONDETERMINISM) $@
52 +endif
53  
54  Manifest.txt: Makefile
55         echo 'Main-Class: altosui.AltosUI' > $@
56 diff --git a/altosuilib/Makefile.am b/altosuilib/Makefile.am
57 index c00144f8..3b2e49d4 100644
58 --- a/altosuilib/Makefile.am
59 +++ b/altosuilib/Makefile.am
60 @@ -101,3 +101,6 @@ $(JAVAROOT):
61  
62  $(JAR): classaltosuilib.stamp $(ICONS)
63         jar cf $@ $(ICONJAR) -C $(JAVAROOT) .
64 +if STRIP_NONDETERMINISM
65 +       $(STRIP_NONDETERMINISM) $@
66 +endif
67 diff --git a/configure.ac b/configure.ac
68 index 466f5369..a2d84ce6 100644
69 --- a/configure.ac
70 +++ b/configure.ac
71 @@ -395,6 +395,25 @@ if test "x$HAVE_ASCIIDOCTOR_PDF" = "xno"; then
72  fi
73  AM_CONDITIONAL([ASCIIDOCTOR_PDF], [test x$HAVE_ASCIIDOCTOR_PDF != xno])
74  
75 +AC_ARG_WITH([strip-nondeterminism],
76 +           [AS_HELP_STRING([--with-strip-nondeterminism],
77 +                           [Name of non-deterministic build data stripping tool])],
78 +           [],
79 +           [with_strip_nondeterminism=auto])
80 +
81 +if test "x$with_strip_nondeterminism" != "xno"; then
82 +       if test "x$with_strip_nondeterminism" = "xauto"; then
83 +               with_strip_nondeterminism="strip-nondeterminism"
84 +               AC_CHECK_PROG([HAVE_STRIP_NONDETERMINISM],[$with_strip_nondeterminism], yes, no)
85 +       else
86 +               HAVE_STRIP_NONDETERMINISM=yes
87 +       fi
88 +else
89 +       HAVE_STRIP_NONDETERMINISM=no
90 +fi
91 +AM_CONDITIONAL([STRIP_NONDETERMINISM], [test x$HAVE_STRIP_NONDETERMINISM != xno])
92 +AC_SUBST(STRIP_NONDETERMINISM, "$with_strip_nondeterminism")
93 +
94  PKG_CHECK_MODULES([JANSSON], [jansson])
95  
96  AC_ARG_WITH([readline],
97 @@ -572,6 +591,7 @@ echo "    STlink support..............: ${HAVE_STLINK}"
98  echo "    Newlib-nano support.........: ${NEWLIB_NANO}"
99  echo "    i386 and amd64 libaltos.....: ${MULTI_ARCH}"
100  echo "    install shared mime info....: ${INSTALL_SHARED_MIME_INFO}"
101 +echo "    Strip jar timestamps........: ${STRIP_NONDETERMINISM}"
102  echo ""
103  echo "  Java"
104  echo "    freetts.....................: ${FREETTS}"
105 diff --git a/map-server/altos-mapd/Makefile.am b/map-server/altos-mapd/Makefile.am
106 index 39f67536..315a33d5 100644
107 --- a/map-server/altos-mapd/Makefile.am
108 +++ b/map-server/altos-mapd/Makefile.am
109 @@ -42,12 +42,18 @@ classes/altosmapd:
110  $(JAR): classaltosmapd.stamp Manifest.txt $(ALTOSLIB_CLASS)
111         jar cfm $@ Manifest.txt \
112                 -C classes altosmapd
113 +if STRIP_NONDETERMINISM
114 +       $(STRIP_NONDETERMINISM) $@
115 +endif
116  
117  altosmapddir=$(datadir)/java
118  
119  $(FATJAR): classaltosmapd.stamp Manifest-fat.txt $(ALTOSLIB_CLASS)
120         jar cfm $@ Manifest-fat.txt \
121                 -C classes altosmapd
122 +if STRIP_NONDETERMINISM
123 +       $(STRIP_NONDETERMINISM) $@
124 +endif
125  
126  altos-mapd: Makefile
127         echo "#!/bin/sh" > $@
128 diff --git a/map-server/altos-mapj/Makefile.am b/map-server/altos-mapj/Makefile.am
129 index f447adb6..98d4f170 100644
130 --- a/map-server/altos-mapj/Makefile.am
131 +++ b/map-server/altos-mapj/Makefile.am
132 @@ -31,12 +31,18 @@ classes/altosmap:
133  $(JAR): classaltosmap.stamp Manifest.txt $(ALTOSLIB_CLASS)
134         jar cfm $@ Manifest.txt \
135                 -C classes altosmap
136 +if STRIP_NONDETERMINISM
137 +       $(STRIP_NONDETERMINISM) $@
138 +endif
139  
140  altosmapdir=$(datadir)/java
141  
142  $(FATJAR): classaltosmap.stamp Manifest-fat.txt $(ALTOSLIB_CLASS)
143         jar cfm $@ Manifest-fat.txt \
144                 -C classes altosmap
145 +if STRIP_NONDETERMINISM
146 +       $(STRIP_NONDETERMINISM) $@
147 +endif
148  
149  altos-mapj: Makefile
150         echo "#!/bin/sh" > $@
151 diff --git a/micropeak/Makefile.am b/micropeak/Makefile.am
152 index f01c5c9f..7e9b490d 100644
153 --- a/micropeak/Makefile.am
154 +++ b/micropeak/Makefile.am
155 @@ -222,12 +222,18 @@ $(JAR): classmicropeak.stamp Manifest.txt $(JAVA_ICONS) $(ALTOSLIB_CLASS) $(ALTO
156                 $(ICONJAR) \
157                 -C classes org \
158                 -C ../libaltos libaltosJNI
159 +if STRIP_NONDETERMINISM
160 +       $(STRIP_NONDETERMINISM) $@
161 +endif
162  
163  $(FATJAR): classmicropeak.stamp Manifest-fat.txt $(ALTOSLIB_CLASS) $(ALTOSUILIB_CLASS) $(JFREECHART_CLASS) $(JCOMMON_CLASS) $(JAVA_ICONS)
164         jar cfm $@ Manifest-fat.txt \
165                 $(ICONJAR) \
166                 -C classes org \
167                 -C ../libaltos libaltosJNI
168 +if STRIP_NONDETERMINISM
169 +       $(STRIP_NONDETERMINISM) $@
170 +endif
171  
172  classaltosui.stamp: $(ALTOSLIB_CLASS) $(ALTOSUILIB_CLASS)
173  
174 diff --git a/telegps/Makefile.am b/telegps/Makefile.am
175 index 3443b288..ae1e83e9 100644
176 --- a/telegps/Makefile.am
177 +++ b/telegps/Makefile.am
178 @@ -227,12 +227,18 @@ $(JAR): classtelegps.stamp Manifest.txt $(JAVA_ICONS) $(ALTOSLIB_CLASS) $(ALTOSU
179                 $(ICONJAR) \
180                 -C classes org \
181                 -C ../libaltos libaltosJNI
182 +if STRIP_NONDETERMINISM
183 +       $(STRIP_NONDETERMINISM) $@
184 +endif
185  
186  $(FATJAR): classtelegps.stamp Manifest-fat.txt $(ALTOSLIB_CLASS) $(ALTOSUILIB_CLASS) $(JFREECHART_CLASS) $(JCOMMON_CLASS) $(JAVA_ICONS)
187         jar cfm $@ Manifest-fat.txt \
188                 $(ICONJAR) \
189                 -C classes org \
190                 -C ../libaltos libaltosJNI
191 +if STRIP_NONDETERMINISM
192 +       $(STRIP_NONDETERMINISM) $@
193 +endif
194  
195  libaltos.so: build-libaltos
196         -rm -f "$@"
197 -- 
198 2.20.1
199