Bug#1042734: binutils-mingw-w64 FTBFS: Patch debian/patches/specify-timestamp.patch does not apply

2023-08-08 Thread Nicolas Dandrimont
Control: tags -1 + patch pending

On Mon, Jul 31, 2023 at 11:37:39AM +0300, Adrian Bunk wrote:
> Source: binutils-mingw-w64
> Version: 11
> Severity: serious
> Tags: ftbfs
> 
> https://tests.reproducible-builds.org/debian/rb-pkg/unstable/amd64/binutils-mingw-w64.html
> https://buildd.debian.org/status/fetch.php?pkg=binutils-mingw-w64&arch=riscv64&ver=11&stamp=1690696627&raw=0
> 
> ...
> pplying patch debian/patches/specify-timestamp.patch
> patching file upstream/bfd/peXXigen.c
> Hunk #2 FAILED at 840.
> 1 out of 2 hunks FAILED -- rejects in file upstream/bfd/peXXigen.c
> patching file upstream/ld/pe-dll.c
> Hunk #2 FAILED at 1232.
> 1 out of 2 hunks FAILED -- rejects in file upstream/ld/pe-dll.c
> patching file upstream/ld/emultempl/pe.em
> patching file upstream/ld/emultempl/pep.em
> Patch debian/patches/specify-timestamp.patch does not apply (enforce with -f)
> make[1]: *** [debian/rules:71: unpack] Error 1
> 

A patch implementing SOURCE_DATE_EPOCH support for --insert-timestamp was merged
upstream, so this debian-specific implementation can be dropped.

http://sourceware.org/git/?p=binutils-gdb.git;a=commitdiff;h=6badd1020f5bebd3f60a780b8e41a1b581046087

Attached is a git-format-patch for a NMU of binutils-mingw-w64 dropping the
patch. I've uploaded it to DELAYED/2.

Cheers,
Nicolas
From 1c70e29cafe59e1f099a546ae157eef62bbab0e6 Mon Sep 17 00:00:00 2001
From: Nicolas Dandrimont 
Date: Tue, 8 Aug 2023 18:13:53 +0200
Subject: [PATCH] Drop specify-timestamp.patch, applied upstream in binutils
 2.41 (Closes: #1042734)

---
 debian/changelog   |   8 ++
 debian/patches/series  |   1 -
 debian/patches/specify-timestamp.patch | 128 -
 3 files changed, 8 insertions(+), 129 deletions(-)
 delete mode 100644 debian/patches/specify-timestamp.patch

diff --git a/debian/changelog b/debian/changelog
index 4ce45da..f254c82 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,11 @@
+binutils-mingw-w64 (11+nmu1) unstable; urgency=medium
+
+  * Non-maintainer upload.
+  * Drop specify-timestamp.patch, applied upstream in binutils 2.41
+(Closes: #1042734)
+
+ -- Nicolas Dandrimont   Tue, 08 Aug 2023 18:18:48 +0200
+
 binutils-mingw-w64 (11) unstable; urgency=medium
 
   * In preparation for binutils 2.41, drop pr30079.patch, merged
diff --git a/debian/patches/series b/debian/patches/series
index df17d1d..1d58fe7 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -1,5 +1,4 @@
 testsuite-timeout.patch
-specify-timestamp.patch
 dont-run-objcopy.patch
 disable-flags.patch
 reproducible-import-libraries.patch
diff --git a/debian/patches/specify-timestamp.patch b/debian/patches/specify-timestamp.patch
deleted file mode 100644
index f268ea4..000
--- a/debian/patches/specify-timestamp.patch
+++ /dev/null
@@ -1,128 +0,0 @@
-Description: Allow the PE timestamp to be specified
-Author: Stephen Kitt 
-
 a/upstream/bfd/peXXigen.c
-+++ b/upstream/bfd/peXXigen.c
-@@ -74,6 +74,9 @@
- #include 
- #include 
- 
-+#include 
-+#include 
-+
- /* NOTE: it's strange to be including an architecture specific header
-in what's supposed to be general (to PE/PEI) code.  However, that's
-where the definitions are, and they don't vary per architecture
-@@ -837,9 +840,36 @@
- 
-   /* Use a real timestamp by default, unless the no-insert-timestamp
-  option was chosen.  */
--  if ((pe_data (abfd)->timestamp) == -1)
--H_PUT_32 (abfd, time (0), filehdr_out->f_timdat);
--  else
-+  if ((pe_data (abfd)->timestamp) == -1) {
-+time_t now;
-+char *source_date_epoch;
-+unsigned long long epoch;
-+char *endptr;
-+
-+now = time (NULL);
-+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)) {
-+_bfd_error_handler("Environment variable $SOURCE_DATE_EPOCH: strtoull: %s\n",
-+   strerror(errno));
-+  } else if (endptr == source_date_epoch) {
-+_bfd_error_handler("Environment variable $SOURCE_DATE_EPOCH: No digits were found: %s\n",
-+   endptr);
-+  } else if (*endptr != '\0') {
-+_bfd_error_handler("Environment variable $SOURCE_DATE_EPOCH: Trailing garbage: %s\n",
-+   endptr);
-+  } else if (epoch > ULONG_MAX) {
-+_bfd_error_handler("Environment variable $SOURCE_DATE_EPOCH: value must be smaller than or equal to: %lu but was found to be: %llu\n",
-+   ULONG_MAX, epoch);
-+  } else {
-+now = epoch;
-+  }
-+}
-+H_PUT_32 (abfd, now, filehdr_out->f_timdat);
-+  } else
- H_PUT_32 (abfd, pe_data (abfd)->timestamp, filehdr_out->f_timdat);
- 
-   PUT_FILEHDR_SYMPTR (abfd, filehdr_in->f_symptr,
 a/upstream/ld/pe-dll.c
-+++ b/upstream/ld/pe-dll.c
-@@ -27,6 +27,

Bug#1042734: binutils-mingw-w64 FTBFS: Patch debian/patches/specify-timestamp.patch does not apply

2023-07-31 Thread Adrian Bunk
Source: binutils-mingw-w64
Version: 11
Severity: serious
Tags: ftbfs

https://tests.reproducible-builds.org/debian/rb-pkg/unstable/amd64/binutils-mingw-w64.html
https://buildd.debian.org/status/fetch.php?pkg=binutils-mingw-w64&arch=riscv64&ver=11&stamp=1690696627&raw=0

...
pplying patch debian/patches/specify-timestamp.patch
patching file upstream/bfd/peXXigen.c
Hunk #2 FAILED at 840.
1 out of 2 hunks FAILED -- rejects in file upstream/bfd/peXXigen.c
patching file upstream/ld/pe-dll.c
Hunk #2 FAILED at 1232.
1 out of 2 hunks FAILED -- rejects in file upstream/ld/pe-dll.c
patching file upstream/ld/emultempl/pe.em
patching file upstream/ld/emultempl/pep.em
Patch debian/patches/specify-timestamp.patch does not apply (enforce with -f)
make[1]: *** [debian/rules:71: unpack] Error 1