From 5056a15007196dc0537a45d717a42b133d8ea710fdeb04dfa28f18d0e052a463 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Chv=C3=A1tal?= Date: Fri, 2 Nov 2018 07:21:32 +0000 Subject: [PATCH] Accepting request 645935 from home:bmwiedemann:branches:M17N add groff-reproducible-mdate.patch and groff-use-SDE.patch to allow to override build time to make package build reproducible (boo#1047218) OBS-URL: https://build.opensuse.org/request/show/645935 OBS-URL: https://build.opensuse.org/package/show/M17N/groff?expand=0&rev=64 --- groff-full.changes | 6 + groff-full.spec | 6 + groff-reproducible-mdate.patch | 25 ++++ groff-use-SDE.patch | 221 +++++++++++++++++++++++++++++++++ groff.changes | 6 + groff.spec | 6 + 6 files changed, 270 insertions(+) create mode 100644 groff-reproducible-mdate.patch create mode 100644 groff-use-SDE.patch diff --git a/groff-full.changes b/groff-full.changes index 3c674c3..6316942 100644 --- a/groff-full.changes +++ b/groff-full.changes @@ -1,3 +1,9 @@ +------------------------------------------------------------------- +Wed Oct 30 23:50:14 UTC 2018 - Bernhard Wiedemann + +- add groff-reproducible-mdate.patch and groff-use-SDE.patch to allow + to override build time to make package build reproducible (boo#1047218) + ------------------------------------------------------------------- Mon Mar 19 11:47:37 CET 2018 - kukuk@suse.de diff --git a/groff-full.spec b/groff-full.spec index 8a8fa35..77aad49 100644 --- a/groff-full.spec +++ b/groff-full.spec @@ -58,6 +58,10 @@ Patch9: 0002-documentation-for-the-locale-keyword.patch Patch10: groff-force-locale-usage.patch # PATCH-FIX-UPSTREAM fix build with multiple threads ; taken from upstream Patch11: groff-multi-thread.patch +# PATCH-FIX-UPSTREAM e4290210f2c1db5292d97678197a986d6822d044 +Patch12: groff-use-SDE.patch +# PATCH-FIX-UPSTREAM 677274dafc5dd5f79f2a6d16270b21d2f5a16c5b +Patch13: groff-reproducible-mdate.patch BuildRequires: bison BuildRequires: fdupes BuildRequires: gcc-c++ @@ -156,6 +160,8 @@ the -X option. %patch9 -p1 -b .locale2 %patch10 -p1 -b .force-locale %patch11 -b .multithread +%patch12 -p1 +%patch13 -p1 %build PATH=$PWD/src/roff/troff:$PWD/src/preproc/pic:$PWD/src/preproc/eqn:$PWD/src/preproc/tbl:$PWDsrc/preproc/refer:$PWD/src/preproc/soelim:$PATH diff --git a/groff-reproducible-mdate.patch b/groff-reproducible-mdate.patch new file mode 100644 index 0000000..d8e7aa9 --- /dev/null +++ b/groff-reproducible-mdate.patch @@ -0,0 +1,25 @@ +Author: Bernhard M. Wiedemann +Date: 2018-11-01 +Subject: make package build reproducible + +sometimes our patches touch .man input files +and mdate picks up their mtime for use in man-page headers +so we clamp the mtime to SOURCE_DATE_EPOCH if set +similar to https://www.fabiankeil.de/sourcecode/electrobsd/ElectroBSD-r312620-6cfa243f1516/0079-contrib-groff-mdate.sh-Use-EPOCH_DATE-when-set.diff + +upstream commit 677274dafc5dd5f79f2a6d16270b21d2f5a16c5b +rewrote it to similar perl, too + +Index: groff-1.22.3/mdate.sh +=================================================================== +--- groff-1.22.3.orig/mdate.sh ++++ groff-1.22.3/mdate.sh +@@ -19,4 +19,7 @@ + # + # Print the modification date of $1 `nicely'. + +-perl -MPOSIX -le 'print strftime("%d %B %Y", localtime((stat $ARGV[0])[9]))' $1 ++perl -MPOSIX -le ' ++$t=((stat $ARGV[0])[9]); ++$t=$ENV{SOURCE_DATE_EPOCH} if($ENV{SOURCE_DATE_EPOCH} && $t > $ENV{SOURCE_DATE_EPOCH}); ++print strftime("%d %B %Y", gmtime($t))' $1 diff --git a/groff-use-SDE.patch b/groff-use-SDE.patch new file mode 100644 index 0000000..6de43e3 --- /dev/null +++ b/groff-use-SDE.patch @@ -0,0 +1,221 @@ +commit e4290210f2c1db5292d97678197a986d6822d044 +Author: Colin Watson +Date: Fri Jul 29 03:25:26 2016 +0100 + + Implement `SOURCE_DATE_EPOCH' for reproducible builds. + + * src/include/curtime.h: New file. + * src/libs/libgroff/curtime.cpp: New file. + * src/libs/libgroff/libgroff.am (libgroff_a_SOURCES): Add + src/libs/libgroff/curtime.cpp. + + * src/roff/troff/input.cpp (init_registers): Use `current_time' + instead of `time(0)'. + * src/devices/grohtml/post-html.cpp + (html_printer::do_file_components): Likewise. + (html_printer::~html_printer): Likewise. + * src/devices/grops/ps.cpp (ps_printer::~ps_printer): Likewise. + * src/devices/gropdf/gropdf.pl: Use `$ENV{SOURCE_DATE_EPOCH}` if + available in preference to `time`. + + * doc/groff.texi (Environment): Document `SOURCE_DATE_EPOCH'. + * src/devices/grohtml/grohtml.1.man (ENVIRONMENT): Likewise. + * src/devices/gropdf/gropdf.1.man (ENVIRONMENT): Likewise. + * src/devices/grops/grops.1.man (ENVIRONMENT): Likewise. + +Index: groff-1.22.3/src/devices/grohtml/post-html.cpp +=================================================================== +--- groff-1.22.3.orig/src/devices/grohtml/post-html.cpp ++++ groff-1.22.3/src/devices/grohtml/post-html.cpp +@@ -28,6 +28,7 @@ along with this program. If not, see + +@@ -5013,7 +5014,7 @@ void html_printer::do_file_components (v + .put_string(Version_string) + .end_comment(); + +- t = time(0); ++ t = current_time(); + html.begin_comment("CreationDate: ") + .put_string(ctime(&t), strlen(ctime(&t))-1) + .end_comment(); +@@ -5126,7 +5127,7 @@ html_printer::~html_printer() + .put_string(Version_string) + .end_comment(); + +- t = time(0); ++ t = current_time(); + html.begin_comment("CreationDate: ") + .put_string(ctime(&t), strlen(ctime(&t))-1) + .end_comment(); +Index: groff-1.22.3/src/devices/gropdf/gropdf.pl +=================================================================== +--- groff-1.22.3.orig/src/devices/gropdf/gropdf.pl ++++ groff-1.22.3/src/devices/gropdf/gropdf.pl +@@ -239,13 +239,14 @@ elsif (exists($ppsz{$papersz})) + @defaultmb=@mediabox=(0,0,$ppsz{$papersz}->[0],$ppsz{$papersz}->[1]); + } + +-my (@dt)=localtime(time); ++my (@dt)=localtime($ENV{SOURCE_DATE_EPOCH} || time); + my $dt=PDFDate(\@dt); + + my %info=('Creator' => "(groff version $cfg{GROFF_VERSION})", + 'Producer' => "(gropdf version $cfg{GROFF_VERSION})", + 'ModDate' => "($dt)", + 'CreationDate' => "($dt)"); ++ + while (<>) + { + chomp; +Index: groff-1.22.3/src/devices/grops/ps.cpp +=================================================================== +--- groff-1.22.3.orig/src/devices/grops/ps.cpp ++++ groff-1.22.3/src/devices/grops/ps.cpp +@@ -28,6 +28,7 @@ along with this program. If not, see +@@ -1390,7 +1391,7 @@ ps_printer::~ps_printer() + #else + time_t + #endif +- t = time(0); ++ t = current_time(); + fputs(ctime(&t), out.get_file()); + } + for (font_pointer_list *f = font_list; f; f = f->next) { +Index: groff-1.22.3/src/include/curtime.h +=================================================================== +--- /dev/null ++++ groff-1.22.3/src/include/curtime.h +@@ -0,0 +1,23 @@ ++/* Copyright (C) 2015 Free Software Foundation, Inc. ++ ++This file is part of groff. ++ ++groff is free software; you can redistribute it and/or modify it under ++the terms of the GNU General Public License as published by the Free ++Software Foundation, either version 2 of the License, or ++(at your option) any later version. ++ ++groff is distributed in the hope that it will be useful, but WITHOUT ANY ++WARRANTY; without even the implied warranty of MERCHANTABILITY or ++FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License ++for more details. ++ ++The GNU General Public License version 2 (GPL2) is available in the ++internet at . */ ++ ++#ifdef LONG_FOR_TIME_T ++long ++#else ++time_t ++#endif ++current_time(); +Index: groff-1.22.3/src/libs/libgroff/curtime.cpp +=================================================================== +--- /dev/null ++++ groff-1.22.3/src/libs/libgroff/curtime.cpp +@@ -0,0 +1,51 @@ ++/* Copyright (C) 2015 Free Software Foundation, Inc. ++ ++This file is part of groff. ++ ++groff is free software; you can redistribute it and/or modify it under ++the terms of the GNU General Public License as published by the Free ++Software Foundation, either version 2 of the License, or ++(at your option) any later version. ++ ++groff is distributed in the hope that it will be useful, but WITHOUT ANY ++WARRANTY; without even the implied warranty of MERCHANTABILITY or ++FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License ++for more details. ++ ++The GNU General Public License version 2 (GPL2) is available in the ++internet at . */ ++ ++#include ++#include ++#include ++#include ++#include ++ ++#include "errarg.h" ++#include "error.h" ++ ++#ifdef LONG_FOR_TIME_T ++long ++#else ++time_t ++#endif ++current_time() ++{ ++ char *source_date_epoch = getenv("SOURCE_DATE_EPOCH"); ++ ++ if (source_date_epoch) { ++ errno = 0; ++ char *endptr; ++ long epoch = strtol(source_date_epoch, &endptr, 10); ++ ++ if ((errno == ERANGE && (epoch == LONG_MAX || epoch == LONG_MIN)) || ++ (errno != 0 && epoch == 0)) ++ fatal("$SOURCE_DATE_EPOCH: strtol: %1", strerror(errno)); ++ if (endptr == source_date_epoch) ++ fatal("$SOURCE_DATE_EPOCH: no digits found: %1", endptr); ++ if (*endptr != '\0') ++ fatal("$SOURCE_DATE_EPOCH: trailing garbage: %1", endptr); ++ return epoch; ++ } else ++ return time(0); ++} +Index: groff-1.22.3/src/roff/troff/input.cpp +=================================================================== +--- groff-1.22.3.orig/src/roff/troff/input.cpp ++++ groff-1.22.3/src/roff/troff/input.cpp +@@ -36,6 +36,7 @@ along with this program. If not, see tm_sec)); +Index: groff-1.22.3/src/libs/libgroff/Makefile.sub +=================================================================== +--- groff-1.22.3.orig/src/libs/libgroff/Makefile.sub ++++ groff-1.22.3/src/libs/libgroff/Makefile.sub +@@ -32,6 +32,7 @@ OBJS=\ + cmap.$(OBJEXT) \ + color.$(OBJEXT) \ + cset.$(OBJEXT) \ ++ curtime.$(OBJEXT) \ + device.$(OBJEXT) \ + errarg.$(OBJEXT) \ + error.$(OBJEXT) \ +@@ -82,6 +83,7 @@ CCSRCS=\ + $(srcdir)/cmap.cpp \ + $(srcdir)/color.cpp \ + $(srcdir)/cset.cpp \ ++ $(srcdir)/curtime.cpp \ + $(srcdir)/device.cpp \ + $(srcdir)/errarg.cpp \ + $(srcdir)/error.cpp \ diff --git a/groff.changes b/groff.changes index 3c674c3..6316942 100644 --- a/groff.changes +++ b/groff.changes @@ -1,3 +1,9 @@ +------------------------------------------------------------------- +Wed Oct 30 23:50:14 UTC 2018 - Bernhard Wiedemann + +- add groff-reproducible-mdate.patch and groff-use-SDE.patch to allow + to override build time to make package build reproducible (boo#1047218) + ------------------------------------------------------------------- Mon Mar 19 11:47:37 CET 2018 - kukuk@suse.de diff --git a/groff.spec b/groff.spec index 85e8408..611abf1 100644 --- a/groff.spec +++ b/groff.spec @@ -57,6 +57,10 @@ Patch9: 0002-documentation-for-the-locale-keyword.patch Patch10: groff-force-locale-usage.patch # PATCH-FIX-UPSTREAM fix build with multiple threads ; taken from upstream Patch11: groff-multi-thread.patch +# PATCH-FIX-UPSTREAM e4290210f2c1db5292d97678197a986d6822d044 +Patch12: groff-use-SDE.patch +# PATCH-FIX-UPSTREAM 677274dafc5dd5f79f2a6d16270b21d2f5a16c5b +Patch13: groff-reproducible-mdate.patch BuildRequires: bison BuildRequires: fdupes BuildRequires: gcc-c++ @@ -155,6 +159,8 @@ the -X option. %patch9 -p1 -b .locale2 %patch10 -p1 -b .force-locale %patch11 -b .multithread +%patch12 -p1 +%patch13 -p1 %build PATH=$PWD/src/roff/troff:$PWD/src/preproc/pic:$PWD/src/preproc/eqn:$PWD/src/preproc/tbl:$PWDsrc/preproc/refer:$PWD/src/preproc/soelim:$PATH