From 337760d761d1e0a31c59b61b4ac1ae84cd2fee0c Mon Sep 17 00:00:00 2001 From: Bdale Garbee Date: Mon, 4 Jul 2016 01:06:29 +0200 Subject: [PATCH] enable reproducible builds --- debian/changelog | 6 +++ debian/patches/reproducible_build | 68 +++++++++++++++++++++++++++++++ debian/patches/series | 1 + 3 files changed, 75 insertions(+) create mode 100644 debian/patches/reproducible_build diff --git a/debian/changelog b/debian/changelog index 1dc7920..739faa3 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +cc1111 (2.9.0-7) unstable; urgency=low + + * patch from Chris Lamb to enable reproducible builds, closes: #829493 + + -- Bdale Garbee Mon, 04 Jul 2016 01:06:12 +0200 + cc1111 (2.9.0-6) unstable; urgency=low * patch from Eric Cooper to suppress additional output when disabling diff --git a/debian/patches/reproducible_build b/debian/patches/reproducible_build new file mode 100644 index 0000000..40ab1ab --- /dev/null +++ b/debian/patches/reproducible_build @@ -0,0 +1,68 @@ +--- cc1111-2.9.0.orig/as/asranlib/asranlib.c ++++ cc1111-2.9.0/as/asranlib/asranlib.c +@@ -22,6 +22,8 @@ along with this program. If not, see + #include + #include ++#include ++#include + #include "dbuf_string.h" + #include "lkar.h" + +@@ -593,6 +595,47 @@ do_ranlib (const char *archive) + char tmpfile[] = "arXXXXXX"; + struct stat stat_buf; + int can_stat; ++ time_t now; ++ char *endptr; ++ char *source_date_epoch; ++ unsigned long long epoch; ++ ++ source_date_epoch = getenv ("SOURCE_DATE_EPOCH"); ++ ++ if (source_date_epoch) ++ { ++ errno = 0; ++ epoch = strtoull (source_date_epoch, &endptr, 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 (1); ++ } ++ ++ if (endptr == source_date_epoch) ++ { ++ fprintf (stderr, "Environment variable $SOURCE_DATE_EPOCH: No digits were found: %s\n", endptr); ++ exit (1); ++ } ++ ++ if (*endptr != '\0') ++ { ++ fprintf (stderr, "Environment variable $SOURCE_DATE_EPOCH: Trailing garbage: %s\n", endptr); ++ exit (1); ++ } ++ ++ 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 (1); ++ } ++ ++ now = epoch; ++ } ++ else ++ now = time (NULL); + + #ifdef _WIN32 + if (NULL == _mktemp (tmpfile) || NULL == (outfp = fopen (tmpfile, "wb"))) +@@ -628,7 +671,7 @@ do_ranlib (const char *archive) + + symtab_size = 4 + 4 * nsym + str_length; + +- fprintf (outfp, ARMAG AR_SYMBOL_TABLE_NAME "%-12d%-6d%-6d%-8d%-10d" ARFMAG, (int) time (NULL), 0, 0, 0, symtab_size); ++ fprintf (outfp, ARMAG AR_SYMBOL_TABLE_NAME "%-12d%-6d%-6d%-8d%-10d" ARFMAG, (int) now, 0, 0, 0, symtab_size); + + if (symtab_size & 1) + { diff --git a/debian/patches/series b/debian/patches/series index 99eef02..0bb6163 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -5,3 +5,4 @@ 05_fix_format_not_a_string_literal updated_makebin suppress-additional-output-when-disabling-warning-18 +reproducible_build -- 2.30.2