From mboxrd@z Thu Jan 1 00:00:00 1970 From: Danny Milosavljevic Subject: bug#27593: [PATCH v3] gnu: groff: Remove timestamps. Date: Sun, 9 Jul 2017 23:27:46 +0200 Message-ID: <20170709232746.7a7af62b@scratchpost.org> References: <20170706025451.312ddebe@scratchpost.org> <20170706014708.16491-1-dannym@scratchpost.org> <87wp7hahpm.fsf@fastmail.com> <87eftpv177.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="MP_/Y/3bjIPG_buy4b9YndXb.uG" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:37462) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dUJkL-0003AN-9U for bug-guix@gnu.org; Sun, 09 Jul 2017 17:28:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dUJkI-0004aV-1n for bug-guix@gnu.org; Sun, 09 Jul 2017 17:28:05 -0400 Received: from debbugs.gnu.org ([208.118.235.43]:56545) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dUJkH-0004aI-TJ for bug-guix@gnu.org; Sun, 09 Jul 2017 17:28:01 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1dUJkH-0008KR-Nm for bug-guix@gnu.org; Sun, 09 Jul 2017 17:28:01 -0400 Sender: "Debbugs-submit" Resent-Message-ID: In-Reply-To: <87eftpv177.fsf@gnu.org> List-Id: Bug reports for GNU Guix List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guix-bounces+gcggb-bug-guix=m.gmane.org@gnu.org Sender: "bug-Guix" To: Ludovic =?UTF-8?Q?Court=C3=A8s?= Cc: 27593@debbugs.gnu.org --MP_/Y/3bjIPG_buy4b9YndXb.uG Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Hi Ludo, On Sun, 09 Jul 2017 21:51:08 +0200 ludo@gnu.org (Ludovic Court=C3=A8s) wrote: > Debian has a SOURCE_DATE_EPOCH patch: >=20 > http://sources.debian.net/patches/groff/1.22.3-9/source-date-epoch.patc= h/ >=20 > Perhaps we could just use that? That way, the default behavior of groff > would remained unchanged. Yeah, it seems to work fine. Apparently git send-email doesn't work for me right now. So I attached the patch manually here... --MP_/Y/3bjIPG_buy4b9YndXb.uG Content-Type: text/x-patch Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename=0001-gnu-groff-Remove-timestamps.patch =46rom 2545f9001d674a8bd216ecc13fa939ed31ccfc91 Mon Sep 17 00:00:00 2001 From: Danny Milosavljevic Date: Thu, 6 Jul 2017 03:47:08 +0200 Subject: [PATCH v3] gnu: groff: Remove timestamps. Tags: patch Fixes . * gnu/packages/patches/groff-source-date-epoch.patch: New file. * gnu/local.mk: Add it. * gnu/packages/groff.scm (groff)[source]: Add it. --- gnu/local.mk | 1 + gnu/packages/groff.scm | 4 +- gnu/packages/patches/groff-source-date-epoch.patch | 299 +++++++++++++++++= ++++ 3 files changed, 303 insertions(+), 1 deletion(-) create mode 100644 gnu/packages/patches/groff-source-date-epoch.patch diff --git a/gnu/local.mk b/gnu/local.mk index 23b8f449a..0fe6cdc39 100644 --- a/gnu/local.mk +++ b/gnu/local.mk @@ -645,6 +645,7 @@ dist_patch_DATA =3D \ %D%/packages/patches/graphite2-ffloat-store.patch \ %D%/packages/patches/grep-gnulib-lock.patch \ %D%/packages/patches/grep-timing-sensitive-test.patch \ + %D%/packages/patches/groff-source-date-epoch.patch \ %D%/packages/patches/gsl-test-i686.patch \ %D%/packages/patches/gspell-dash-test.patch \ %D%/packages/patches/guile-1.8-cpp-4.5.patch \ diff --git a/gnu/packages/groff.scm b/gnu/packages/groff.scm index d7f45d4fc..c2f33736f 100644 --- a/gnu/packages/groff.scm +++ b/gnu/packages/groff.scm @@ -40,7 +40,9 @@ (uri (string-append "mirror://gnu/groff/groff-" version ".tar.gz")) (sha256 (base32 - "1998v2kcs288d3y7kfxpvl369nqi06zbbvjzafyvyl3pr7bajj1s= ")))) + "1998v2kcs288d3y7kfxpvl369nqi06zbbvjzafyvyl3pr7bajj1s= ")) + (patches (search-patches "groff-source-date-epoch.patch")) + (modules '((guix build utils))))) (build-system gnu-build-system) (outputs '("out" "doc")) ;12MiB of PS, PDF, HTML, and exam= ples diff --git a/gnu/packages/patches/groff-source-date-epoch.patch b/gnu/packa= ges/patches/groff-source-date-epoch.patch new file mode 100644 index 000000000..53c590b04 --- /dev/null +++ b/gnu/packages/patches/groff-source-date-epoch.patch @@ -0,0 +1,299 @@ +Adds support for the environment variable SOURCE_DATE_EPOCH. + +See: https://sources.debian.net/patches/groff/1.22.3-9/source-date-epoch.p= atch/ + +From abc23bc9245e18468817f2838361c3a08f7521e2 Mon Sep 17 00:00:00 2001 +From: Colin Watson +Date: Thu, 5 Nov 2015 11:47:34 +0000 +Subject: Implement `SOURCE_DATE_EPOCH' for reproducible builds. + +Author: Colin Watson +Forwarded: yes +Last-Update: 2015-11-05 + +Patch-Name: source-date-epoch.patch +--- + doc/groff.texinfo | 6 +++++ + src/devices/grohtml/grohtml.man | 7 ++++++ + src/devices/grohtml/post-html.cpp | 5 ++-- + src/devices/gropdf/gropdf.man | 7 ++++++ + src/devices/gropdf/gropdf.pl | 3 ++- + src/devices/grops/grops.man | 7 ++++++ + src/devices/grops/ps.cpp | 3 ++- + src/include/curtime.h | 23 ++++++++++++++++++ + src/libs/libgroff/Makefile.sub | 2 ++ + src/libs/libgroff/curtime.cpp | 51 ++++++++++++++++++++++++++++++++++= +++++ + src/roff/troff/input.cpp | 3 ++- + 11 files changed, 112 insertions(+), 5 deletions(-) + create mode 100644 src/include/curtime.h + create mode 100644 src/libs/libgroff/curtime.cpp + +diff --git a/doc/groff.texinfo b/doc/groff.texinfo +index 066b5274..1d3c7a9f 100644 +--- a/doc/groff.texinfo ++++ b/doc/groff.texinfo +@@ -1453,6 +1453,12 @@ default directory (on Unix and GNU/Linux systems, t= his is usually + @item GROFF_TYPESETTER + @tindex GROFF_TYPESETTER@r{, environment variable} + The default output device. ++ ++@item SOURCE_DATE_EPOCH ++@tindex SOURCE_DATE_EPOCH@r{, environment variable} ++A timestamp (expressed as seconds since the Unix epoch) to use in place of ++the current time when initializing time-based built-in registers such as ++@code{\n[seconds]}. + @end table +=20 + Note that MS-DOS and MS-Windows ports of @code{groff} use semi-colons, +diff --git a/src/devices/grohtml/grohtml.man b/src/devices/grohtml/grohtml= .man +index 51eae224..4be4abbc 100644 +--- a/src/devices/grohtml/grohtml.man ++++ b/src/devices/grohtml/grohtml.man +@@ -419,6 +419,13 @@ and + for more details. + . + . ++.TP ++.SM ++.B SOURCE_DATE_EPOCH ++A timestamp (expressed as seconds since the Unix epoch) to use as the ++creation timestamp in place of the current time. ++. ++. + .\" -------------------------------------------------------------------- + .SH BUGS + .\" -------------------------------------------------------------------- +diff --git a/src/devices/grohtml/post-html.cpp b/src/devices/grohtml/post-= html.cpp +index fefbf014..b5fc5167 100644 +--- a/src/devices/grohtml/post-html.cpp ++++ b/src/devices/grohtml/post-html.cpp +@@ -28,6 +28,7 @@ along with this program. If not, see . */ + #include "html.h" + #include "html-text.h" + #include "html-table.h" ++#include "curtime.h" +=20 + #include +=20 +@@ -5013,7 +5014,7 @@ void html_printer::do_file_components (void) + .put_string(Version_string) + .end_comment(); +=20 +- t =3D time(0); ++ t =3D 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(); +=20 +- t =3D time(0); ++ t =3D current_time(); + html.begin_comment("CreationDate: ") + .put_string(ctime(&t), strlen(ctime(&t))-1) + .end_comment(); +diff --git a/src/devices/gropdf/gropdf.man b/src/devices/gropdf/gropdf.man +index 3bbace6a..cc0c82f1 100644 +--- a/src/devices/gropdf/gropdf.man ++++ b/src/devices/gropdf/gropdf.man +@@ -1029,6 +1029,13 @@ and + for more details. + . + . ++.TP ++.SM ++.B SOURCE_DATE_EPOCH ++A timestamp (expressed as seconds since the Unix epoch) to use as the ++creation timestamp in place of the current time. ++. ++. + .\" -------------------------------------------------------------------- + .SH FILES + .\" -------------------------------------------------------------------- +diff --git a/src/devices/gropdf/gropdf.pl b/src/devices/gropdf/gropdf.pl +index 035d1238..c25c4c67 100644 +--- a/src/devices/gropdf/gropdf.pl ++++ b/src/devices/gropdf/gropdf.pl +@@ -239,13 +239,14 @@ elsif (exists($ppsz{$papersz})) + @defaultmb=3D@mediabox=3D(0,0,$ppsz{$papersz}->[0],$ppsz{$papersz}->[= 1]); + } +=20 +-my (@dt)=3Dlocaltime(time); ++my (@dt)=3Dlocaltime($ENV{SOURCE_DATE_EPOCH} || time); + my $dt=3DPDFDate(\@dt); +=20 + my %info=3D('Creator' =3D> "(groff version $cfg{GROFF_VERSION})", + 'Producer' =3D> "(gropdf version $cfg{GROFF_VERSION})", + 'ModDate' =3D> "($dt)", + 'CreationDate' =3D> "($dt)"); ++ + while (<>) + { + chomp; +diff --git a/src/devices/grops/grops.man b/src/devices/grops/grops.man +index 99fb7486..272c2d18 100644 +--- a/src/devices/grops/grops.man ++++ b/src/devices/grops/grops.man +@@ -1419,6 +1419,13 @@ and + for more details. + . + . ++.TP ++.SM ++.B SOURCE_DATE_EPOCH ++A timestamp (expressed as seconds since the Unix epoch) to use as the ++creation timestamp in place of the current time. ++. ++. + .\" -------------------------------------------------------------------- + .SH FILES + .\" -------------------------------------------------------------------- +diff --git a/src/devices/grops/ps.cpp b/src/devices/grops/ps.cpp +index 745a503b..03e65372 100644 +--- a/src/devices/grops/ps.cpp ++++ b/src/devices/grops/ps.cpp +@@ -28,6 +28,7 @@ along with this program. If not, see . */ + #include "cset.h" + #include "nonposix.h" + #include "paper.h" ++#include "curtime.h" +=20 + #include "ps.h" + #include +@@ -1390,7 +1391,7 @@ ps_printer::~ps_printer() + #else + time_t + #endif +- t =3D time(0); ++ t =3D current_time(); + fputs(ctime(&t), out.get_file()); + } + for (font_pointer_list *f =3D font_list; f; f =3D f->next) { +diff --git a/src/include/curtime.h b/src/include/curtime.h +new file mode 100644 +index 00000000..a4105196 +--- /dev/null ++++ b/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(); +diff --git a/src/libs/libgroff/Makefile.sub b/src/libs/libgroff/Makefile.s= ub +index 840d9934..4cb4937a 100644 +--- a/src/libs/libgroff/Makefile.sub ++++ b/src/libs/libgroff/Makefile.sub +@@ -32,6 +32,7 @@ OBJS=3D\ + cmap.$(OBJEXT) \ + color.$(OBJEXT) \ + cset.$(OBJEXT) \ ++ curtime.$(OBJEXT) \ + device.$(OBJEXT) \ + errarg.$(OBJEXT) \ + error.$(OBJEXT) \ +@@ -82,6 +83,7 @@ CCSRCS=3D\ + $(srcdir)/cmap.cpp \ + $(srcdir)/color.cpp \ + $(srcdir)/cset.cpp \ ++ $(srcdir)/curtime.cpp \ + $(srcdir)/device.cpp \ + $(srcdir)/errarg.cpp \ + $(srcdir)/error.cpp \ +diff --git a/src/libs/libgroff/curtime.cpp b/src/libs/libgroff/curtime.cpp +new file mode 100644 +index 00000000..00821b7f +--- /dev/null ++++ b/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 =3D getenv("SOURCE_DATE_EPOCH"); ++ ++ if (source_date_epoch) { ++ errno =3D 0; ++ char *endptr; ++ long epoch =3D strtol(source_date_epoch, &endptr, 10); ++ ++ if ((errno =3D=3D ERANGE && (epoch =3D=3D LONG_MAX || epoch =3D=3D LO= NG_MIN)) || ++ (errno !=3D 0 && epoch =3D=3D 0)) ++ fatal("$SOURCE_DATE_EPOCH: strtol: %1", strerror(errno)); ++ if (endptr =3D=3D source_date_epoch) ++ fatal("$SOURCE_DATE_EPOCH: no digits found: %1", endptr); ++ if (*endptr !=3D '\0') ++ fatal("$SOURCE_DATE_EPOCH: trailing garbage: %1", endptr); ++ return epoch; ++ } else ++ return time(0); ++} +diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp +index 9594f074..f7d2c18a 100644 +--- a/src/roff/troff/input.cpp ++++ b/src/roff/troff/input.cpp +@@ -36,6 +36,7 @@ along with this program. If not, see . */ + #include "input.h" + #include "defs.h" + #include "unicode.h" ++#include "curtime.h" +=20 + // Needed for getpid() and isatty() + #include "posix.h" +@@ -8138,7 +8139,7 @@ static void init_registers() + #else /* not LONG_FOR_TIME_T */ + time_t + #endif /* not LONG_FOR_TIME_T */ +- t =3D time(0); ++ t =3D current_time(); + // Use struct here to work around misfeature in old versions of g++. + struct tm *tt =3D localtime(&t); + set_number_reg("seconds", int(tt->tm_sec)); --MP_/Y/3bjIPG_buy4b9YndXb.uG--