Source: olsrd
Version: 0.6.6.2-1
Severity: wishlist
Tags: patch upstream
User: reproducible-builds@lists.alioth.debian.org
Usertags: timestamps fileordering hostname
X-Debbugs-Cc: reproducible-builds@lists.alioth.debian.org

Hi!

While working on the "reproducible builds" effort [1], we have noticed
that olsrd could not be built reproducibly.
It embeds the build date/time and hostname into the binary and links
object files in an unsorted order.

The attached patch strips the non-deterministic data and sorts
source/header files to enable reproducible building.

Regards,
 Reiner

[1]: https://wiki.debian.org/ReproducibleBuilds
diff --git a/debian/patches/reproducible-build.patch b/debian/patches/reproducible-build.patch
new file mode 100644
index 0000000..515c73a
--- /dev/null
+++ b/debian/patches/reproducible-build.patch
@@ -0,0 +1,141 @@
+Author: Reiner Herrmann <rei...@reiner-h.de>
+Description: Enable reproducible building
+ - Strip build date and hostname
+ - Sort source/header files obtained with wildcards
+
+--- a/Makefile
++++ b/Makefile
+@@ -89,8 +89,6 @@
+ 	$(MAKECMDPREFIX)$(RM) "$@"
+ 	$(MAKECMDPREFIX)echo "#include \"defs.h\"" >> "$@" 
+ 	$(MAKECMDPREFIX)echo "const char olsrd_version[] = \"olsr.org -  $(VERS)`./make/hash_source.sh`\";"  >> "$@"
+-	$(MAKECMDPREFIX)date +"const char build_date[] = \"%Y-%m-%d %H:%M:%S\";" >> "$@" 
+-	$(MAKECMDPREFIX)echo "const char build_host[] = \"$(shell hostname)\";" >> "$@" 
+ 
+ 
+ .PHONY: help libs clean_libs libs_clean clean distclean uberclean install_libs uninstall_libs libs_install libs_uninstall install_bin uninstall_bin install_olsrd uninstall_olsrd install uninstall build_all install_all uninstall_all clean_all gui clean_gui 
+--- a/lib/httpinfo/src/olsrd_httpinfo.c
++++ b/lib/httpinfo/src/olsrd_httpinfo.c
+@@ -818,7 +818,7 @@
+   const struct plugin_param *pparam;
+   struct ipaddr_str mainaddrbuf;
+ 
+-  abuf_appendf(abuf, "Version: %s (built on %s on %s)\n<br>", olsrd_version, build_date, build_host);
++  abuf_appendf(abuf, "Version: %s\n<br>", olsrd_version);
+   abuf_appendf(abuf, "OS: %s\n<br>", OS);
+ 
+   {
+@@ -1451,11 +1451,10 @@
+ {
+   abuf_appendf(abuf,
+                   "<strong>" PLUGIN_NAME " version " PLUGIN_VERSION "</strong><br/>\n" "by Andreas T&oslash;nnesen (C)2005.<br/>\n"
+-                  "Compiled "
+ #ifdef ADMIN_INTERFACE
+-                  "<em>with experimental admin interface</em> "
++                  "<em>Compiled with experimental admin interface</em> "
+ #endif /* ADMIN_INTERFACE */
+-                  "%s at %s<hr/>\n" "This plugin implements a HTTP server that supplies\n"
++                  "<hr/>\n" "This plugin implements a HTTP server that supplies\n"
+                   "the client with various dynamic web pages representing\n"
+                   "the current olsrd status.<br/>The different pages include:\n"
+                   "<ul>\n<li><strong>Configuration</strong> - This page displays information\n"
+@@ -1483,8 +1482,7 @@
+                   "<li><strong>About</strong> - this help page.</li>\n</ul>" "<hr/>\n" "Send questions or comments to\n"
+                   "<a href=\"mailto:olsr-us...@olsr.org\">olsr-us...@olsr.org</a> or\n"
+                   "<a href=\"mailto:andreto-at-olsr.org\">andreto-at-olsr.org</a><br/>\n"
+-                  "Official olsrd homepage: <a href=\"http://www.olsr.org/\";>http://www.olsr.org</a><br/>\n", build_date,
+-                  build_host);
++                  "Official olsrd homepage: <a href=\"http://www.olsr.org/\";>http://www.olsr.org</a><br/>\n");
+ }
+ 
+ static void
+--- a/lib/jsoninfo/src/olsrd_jsoninfo.c
++++ b/lib/jsoninfo/src/olsrd_jsoninfo.c
+@@ -1079,8 +1079,6 @@
+   abuf_json_float(abuf, "linkQualityNatThreshold", olsr_cnf->lq_nat_thresh);
+ 
+   abuf_json_string(abuf, "olsrdVersion", olsrd_version);
+-  abuf_json_string(abuf, "olsrdBuildDate", build_date);
+-  abuf_json_string(abuf, "olsrdBuildHost", build_host);
+ 
+ #if defined _WIN32 || defined _WIN64
+   abuf_json_string(abuf, "os", "Windows");
+--- a/lib/txtinfo/src/olsrd_txtinfo.c
++++ b/lib/txtinfo/src/olsrd_txtinfo.c
+@@ -632,7 +632,7 @@
+ static void
+ ipc_print_version(struct autobuf *abuf)
+ {
+-abuf_appendf(abuf, "Version: %s (built on %s on %s)\n", olsrd_version, build_date, build_host);
++abuf_appendf(abuf, "Version: %s\n", olsrd_version);
+ }
+ static void
+ ipc_print_interface(struct autobuf *abuf)
+--- a/src/builddata.h
++++ b/src/builddata.h
+@@ -42,7 +42,5 @@
+ #define _OLSR_BUILDDATA_H
+ 
+ extern const char olsrd_version[];
+-extern const char build_date[];
+-extern const char build_host[];
+ 
+ #endif /* _OLSR_BUILDDATA_H */
+--- a/src/main.c
++++ b/src/main.c
+@@ -332,8 +332,7 @@
+   assert(sizeof(int16_t) == 2);
+   assert(sizeof(int32_t) == 4);
+ 
+-  printf("\n *** %s ***\n Build date: %s on %s\n http://www.olsr.org\n\n";,
+-      olsrd_version, build_date, build_host);
++  printf("\n *** %s ***\n http://www.olsr.org\n\n";, olsrd_version);
+ 
+   if (argc == 2) {
+     if (strcmp(argv[1], "-h") == 0 || strcmp(argv[1], "/?") == 0) {
+--- a/src/olsr.c
++++ b/src/olsr.c
+@@ -195,7 +195,7 @@
+ 
+   if (olsr_cnf->debug_level > 0 && olsr_cnf->clear_screen && isatty(1)) {
+     clear_console();
+-    printf("       *** %s (%s on %s) ***\n", olsrd_version, build_date, build_host);
++    printf("       *** %s ***\n", olsrd_version);
+   }
+ 
+   if (changes_neighborhood) {
+--- a/Makefile.inc
++++ b/Makefile.inc
+@@ -211,8 +211,8 @@
+ CPPFLAGS +=     -DUSE_FPM
+ 
+ # search sources and headers in current dir and in src/
+-SRCS +=		$(wildcard src/common/*.c src/*.c *.c)
+-HDRS +=		$(wildcard src/common/*.h src/*.h *.h)
++SRCS +=		$(sort $(wildcard src/common/*.c src/*.c *.c))
++HDRS +=		$(sort $(wildcard src/common/*.h src/*.h *.h))
+ 
+ ifeq ($(OS),UNKNOWN)
+ all: help
+--- a/make/Makefile.linux
++++ b/make/Makefile.linux
+@@ -17,8 +17,8 @@
+ SBINDIR =	$(DESTDIR)$(sbindir)
+ SHAREDIR =	$(DESTDIR)$(datarootdir)
+ 
+-SRCS += 	$(wildcard src/linux/*.c src/unix/*.c)
+-HDRS +=		$(wildcard src/linux/*.h src/unix/*.h)
++SRCS += 	$(sort $(wildcard src/linux/*.c src/unix/*.c))
++HDRS +=		$(sort $(wildcard src/linux/*.h src/unix/*.h))
+ 
+ CPPFLAGS +=
+ LIBS +=		
diff --git a/debian/patches/series b/debian/patches/series
index 478b665..1fa152a 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -3,3 +3,4 @@
 260-quagga-plugin-detect-protocol-version.patch
 290-hardcode-etc-olsrd-olsrd-conf.patch
 310-hardening-fixes.patch
+reproducible-build.patch

Attachment: signature.asc
Description: Digital signature

_______________________________________________
Reproducible-builds mailing list
Reproducible-builds@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/reproducible-builds

Reply via email to