enable reproducible builds
authorBdale Garbee <bdale@gag.com>
Sun, 3 Jul 2016 23:06:29 +0000 (01:06 +0200)
committerBdale Garbee <bdale@gag.com>
Sun, 3 Jul 2016 23:06:29 +0000 (01:06 +0200)
debian/changelog
debian/patches/reproducible_build [new file with mode: 0644]
debian/patches/series

index 1dc7920740472befe4d99cde872c17eb523f32c2..739faa37e2b07f16a6b1f7d89c11b3b73506687a 100644 (file)
@@ -1,3 +1,9 @@
+cc1111 (2.9.0-7) unstable; urgency=low
+
+  * patch from Chris Lamb to enable reproducible builds, closes: #829493
+
+ -- Bdale Garbee <bdale@gag.com>  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 (file)
index 0000000..40ab1ab
--- /dev/null
@@ -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 <h
+ #include <assert.h>
+ #include <time.h>
+ #include <sys/stat.h>
++#include <errno.h>
++#include <limits.h>
+ #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)
+         {
index 99eef02ace1446ad749bec1ccf3735a89bfb0ed3..0bb616300127817d9cfc34247de9691b66199fbd 100644 (file)
@@ -5,3 +5,4 @@
 05_fix_format_not_a_string_literal
 updated_makebin
 suppress-additional-output-when-disabling-warning-18
+reproducible_build