unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
From: Kaz Kylheku <kaz@kylheku.com>
To: Guillaume Le Vaillant <glv@posteo.net>
Cc: "Paul A. Patience" <paul@apatience.com>, 49517@debbugs.gnu.org
Subject: [bug#49517] [PATCH] gnu: txr: Build documentation and update to 265.
Date: Sun, 18 Jul 2021 20:23:07 -0700	[thread overview]
Message-ID: <11fc334731df77688afd107574be9c6c@mail.kylheku.com> (raw)
In-Reply-To: <874kcr7vt7.fsf@kitej>

On 2021-07-18 03:36, Guillaume Le Vaillant wrote:
> Hi Kaz,
> 
> I tried your patch and it doesn't fix all the timestamps in the
> environment used to build Guix packages:

OK,

I have a new patch which works for both the observed time
formats issued by Ghostscript, which I reproduced and tested.

Patch follows.

I extended the capture region to extract not only the XML
but that bit of PostScript with the dates which follows right
after it.

(I structured the script this way to avoid doing a regex search
and replace of the whole file, which is not only more time
consuming but risks more false positives than necessary.)

The replacement argument of regsub can be a function; the function
receives the original string and calculates its replacement.
So we can check for a trailing Z and act accordingly.

commit 920ae93cd768222db7387ee026f2d779d5e6de09 (HEAD -> master)
Author: Kaz Kylheku <kaz@kylheku.com>
Date:   Sat Jul 17 19:11:20 2021 -0700

     doc: reproducible PDF.

     * Makefile (txr-manpage.pdf): If SOURCE_DATE_EPOCH exists,
     then run pdf-clobber-stamps.tl.

     * pdf-clobber-stamps.tl: New file.

diff --git a/Makefile b/Makefile
index 0094985f..cac9b3c0 100644
--- a/Makefile
+++ b/Makefile
@@ -560,6 +560,7 @@ txr-manpage.html: txr.1 genman.txr
  txr-manpage.pdf: txr.1 checkman.txr
         $(TXR) checkman.txr $<
         tbl $< | pdfroff -ww -man --no-toc - > $@
+       [ $$SOURCE_DATE_EPOCH ] && $(TXR) pdf-clobber-stamps.tl || true

  #
  # Special targets used by ./configure
diff --git a/pdf-clobber-stamps.tl b/pdf-clobber-stamps.tl
new file mode 100644
index 00000000..78ea06c6
--- /dev/null
+++ b/pdf-clobber-stamps.tl
@@ -0,0 +1,22 @@
+(let* ((epoch (or (tointz (getenv "SOURCE_DATE_EPOCH")) 0))
+       (pdf (file-get-string "txr-manpage.pdf"))
+       (start (search-str pdf "<?xpacket begin="))
+       (end (if start (search-str pdf "/Creator(" start)))
+       (xml (if end [pdf start..end]))
+       (orig-len (len xml))
+       (isotime (time-string-utc epoch "%FT%T"))
+       (gstime (time-string-utc epoch "%Y%m%d%H%M%SZ0000")))
+  (unless xml
+    (format *stderr* "XML block not found in PDF")
+    (exit nil))
+  (upd xml
+    (regsub #/uuid:........-....-....-....-............/
+            "uuid:00000000-0000-0000-0000-000000000000")
+    (regsub #/Date>....-..-..T..:..:..(Z|[+\-]..:..)/
+            (ret `Date>@isotime@(if (ends-with "Z" @1) "Z" "+00:00")`))
+    (regsub #/Date\(D:..............[Z+\-]..../
+            `Date(D:@gstime`))
+  (assert (eql (len xml) orig-len))
+  (set [pdf start..end] xml)
+  (file-put-string "txr-manpage.pdf.temp" pdf)
+  (rename-path "txr-manpage.pdf.temp" "txr-manpage.pdf"))





      parent reply	other threads:[~2021-07-19  3:28 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-11  0:37 [bug#49517] [PATCH] gnu: txr: Build documentation and update to 265 Paul A. Patience
2021-07-12  1:01 ` Paul A. Patience
2021-07-13 23:45   ` Paul A. Patience
2021-07-17  9:57     ` Guillaume Le Vaillant
2021-07-17 22:51       ` Kaz Kylheku
2021-07-18  3:43         ` Kaz Kylheku
2021-07-18 10:36           ` Guillaume Le Vaillant
2021-07-18 12:59             ` Paul A. Patience
2021-07-20  9:07               ` bug#49517: " Guillaume Le Vaillant
2021-07-18 20:27             ` [bug#49517] " Kaz Kylheku
2021-07-18 21:28               ` Paul A. Patience
2021-07-19 12:08                 ` Guillaume Le Vaillant
2021-07-19 21:31                   ` Kaz Kylheku
2021-07-20  9:18                     ` Guillaume Le Vaillant
2021-07-19  3:23             ` Kaz Kylheku [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=11fc334731df77688afd107574be9c6c@mail.kylheku.com \
    --to=kaz@kylheku.com \
    --cc=49517@debbugs.gnu.org \
    --cc=glv@posteo.net \
    --cc=paul@apatience.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).