Project

General

Profile

Feature #2828

Reproducible builds

Added by stbuehler over 1 year ago. Updated over 1 year ago.

Status:
Fixed
Priority:
Normal
Assignee:
-
Category:
core
Target version:
Start date:
2017-10-18
Due date:
% Done:

100%

Estimated time:
Missing in 1.5.x:

Description

Using __DATE__ and __TIME__ macros in C leads to non-reproducible builds (goal: create the exact same files when run in the same environment again).

lighttpd.spec shows how opensuse patches the sources to replace those macros with a timestamp from their changelog.

I would be nice to offer a cleaner API here (or maybe simply (optionally) remove the timestamp completely).

Otoh it seems more recent gcc versions might support SOURCE_DATE_EPOCH.

Associated revisions

Revision cddc4814 (diff)
Added by gstrauss over 1 year ago

[core] reproducible build: hide DATE TIME (fixes #2828)

reproducible build: hide DATE TIME unless compiled with
-DNONREPRODUCIBLE_BUILD

x-ref:
"Reproducible builds"
https://redmine.lighttpd.net/issues/2828

History

#1

Updated by gstrauss over 1 year ago

In lighttpd's case, I'd be fine with removing DATE and TIME from server.c, where this info is used only for display when showing version (lighttpd -v) or showing help (lighttpd -h) For most people, installing the package would already have package build info in package database. For those building from source, the timestamps on the lighttpd executable would probably suffice for "when was this built?" as long as timestamp was preserved when installed out of the build area.

FYI: I wrote a multi-platform set of macros that stores ident information in the .comment section of the binary, instead of in .data.
https://github.com/gstrauss/plasma/blob/master/plasma_ident.h
This separate section could be separated from the binary after the build and stored separately in a database, keyed by a checksum of the binary after the .comment section has been removed.

#2

Updated by gstrauss over 1 year ago

--- a/src/server.c
+++ b/src/server.c
@@ -538,8 +538,10 @@ static int server_oneshot_init(server *srv, int fd) {

 static void show_version (void) {
        char *b = PACKAGE_DESC TEXT_SSL \
-" - a light and fast webserver\n" \
+" - a light and fast webserver\n" 
+#ifdef NONREPRODUCIBLE_BUILD
 "Build-Date: " __DATE__ " " __TIME__ "\n";
+#endif
 ;
        write_all(STDOUT_FILENO, b, strlen(b));
 }
@@ -705,7 +707,10 @@ static void show_features (void) {
 }

 static void show_help (void) {
-       char *b = PACKAGE_DESC TEXT_SSL " ("__DATE__ " " __TIME__ ")" \
+       char *b = PACKAGE_DESC TEXT_SSL
+#ifdef NONREPRODUCIBLE_BUILD
+" ("__DATE__ " " __TIME__ ")" 
+#endif
 " - a light and fast webserver\n" \
 "usage:\n" \
 " -f <name>  filename of the config-file\n" \
#3

Updated by gstrauss over 1 year ago

  • Category set to core
  • Status changed from New to Patch Pending
  • Target version changed from 1.4.x to 1.4.46
#4

Updated by gstrauss over 1 year ago

  • Status changed from Patch Pending to Fixed
  • % Done changed from 0 to 100

Also available in: Atom