Commit a1772567 authored by Axel Beckert's avatar Axel Beckert

Add SOURCE_DATE_EPOCH support to reproducible-build.diff patch

parent bfa7ebba
......@@ -4,6 +4,7 @@ mp4h (1.3.1-11) UNRELEASED; urgency=medium
GPL, none of the copied files are. They're all either too small to be
copyrightable or have a license without any relevant restrictions.
* debian/copyright: Only mention web.archive.org URL to make DUCK happy.
* Add SOURCE_DATE_EPOCH support to reproducible-build.diff patch.
-- Axel Beckert <abe@debian.org> Sat, 17 Oct 2015 14:04:19 +0200
......
Description: Reduce build meta data in documentation
This is part of the effort to make the build of this package
reproducible.
reproducible. SOURCE_DATE_EPOCH support based on
https://wiki.debian.org/ReproducibleBuilds/TimestampsProposal#C
Author: Axel Beckert <abe@debian.org>
Last-Update: 2015-10-16
Index: mp4h/doc/mp4h.mp4h
===================================================================
--- mp4h.orig/doc/mp4h.mp4h 2015-05-12 23:42:36.014901057 +0200
+++ mp4h/doc/mp4h.mp4h 2015-05-12 23:42:36.014901057 +0200
--- mp4h.orig/doc/mp4h.mp4h 2015-10-17 18:25:46.328298589 +0200
+++ mp4h/doc/mp4h.mp4h 2015-10-17 18:25:46.328298589 +0200
@@ -664,7 +664,7 @@
<set-var version="0.10.1" />
This is version <get-var version />
......@@ -37,3 +39,61 @@ Index: mp4h/doc/mp4h.mp4h
<timer/>
</example>
Index: mp4h/src/builtin.c
===================================================================
--- mp4h.orig/src/builtin.c 2015-10-17 18:25:46.296298676 +0200
+++ mp4h/src/builtin.c 2015-10-17 18:31:45.859324014 +0200
@@ -36,6 +36,8 @@
#undef MP4H_MODULE
#include "builtin.h"
+#include <errno.h>
+#include <limits.h>
#define CHECK_SAFETY_LEVEL(sl) \
if (safety_level > sl) \
@@ -1513,6 +1515,8 @@
const char *format, *timespec;
struct tm *timeptr;
char *endp = NULL;
+ char *source_date_epoch;
+ unsigned long long epoch;
format = predefined_attribute ("format", &argc, argv, FALSE);
timespec = predefined_attribute ("time", &argc, argv, FALSE);
@@ -1533,8 +1537,33 @@
return;
}
}
- else
- epoch_time = time ((time_t *)NULL);
+ else {
+ source_date_epoch = getenv("SOURCE_DATE_EPOCH");
+ if (source_date_epoch) {
+ errno = 0;
+ epoch = strtoull(source_date_epoch, &endp, 10);
+ if ((errno == ERANGE && (epoch == ULLONG_MAX || epoch == 0))
+ || (errno != 0 && epoch == 0)) {
+ fprintf(stderr, "Environment variable $SOURCE_DATE_EPOCH: strtoull: %s\n", strerror(errno));
+ exit(EXIT_FAILURE);
+ }
+ if (endp == source_date_epoch) {
+ fprintf(stderr, "Environment variable $SOURCE_DATE_EPOCH: No digits were found: %s\n", endp);
+ exit(EXIT_FAILURE);
+ }
+ if (*endp != '\0') {
+ fprintf(stderr, "Environment variable $SOURCE_DATE_EPOCH: Trailing garbage: %s\n", endp);
+ exit(EXIT_FAILURE);
+ }
+ if (epoch > ULONG_MAX) {
+ fprintf(stderr, "Environment variable $SOURCE_DATE_EPOCH: value must be smaller than or equal to: %lu but was found to be: %llu \n", ULONG_MAX ,epoch);
+ exit(EXIT_FAILURE);
+ }
+ epoch_time = epoch;
+ } else {
+ epoch_time = time ((time_t *)NULL);
+ }
+ }
timeptr = (struct tm *) localtime (&epoch_time);
if (format)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment