Subject: [bug#43442] Subversion keyword substitution

From: Ludovic Courtès <[email-masked]>
Date: Fri, 24 Mar 2023 18:22:06 +0100

Hi Timothy,

Timothy Sample <[email-masked]> skribis:

> I was starting with doing a simple check for the “easy” Subversion
> repositories.  That is, no externals (‘recursive?’) and no
> ‘svn-multi-fetch’ [1].  I immediately hit a problem.  Guix hashes the
> export of the repository with the keywords processed, while SWH hashes
> it with unprocessed keywords.

Ouch.  I had forgotten keywords were also a thing in Subversion.  :-/

Can we tell Subversion to not expand them?  That could be the way
forward in Guix, though it won’t help for past revisions.

How frequent is the use of keywords though?  I tried the patch below to
turn off keyword substitution, and then ran

  guix build -S --check -v1 --keep-going

for the 407 packages identified by:

--8<---------------cut here---------------start------------->8---
scheme@(guile-user)> (define svn (fold-packages (lambda (p lst)
						  (if (and (not (hidden-package? p))
							   (not (package-superseded p))
							   (origin? (package-source p))
							   (memq (origin-method (package-source p))
								 (list svn-fetch svn-multi-fetch)))
						      (cons p lst)
						      lst))
						'()))
scheme@(guile-user)> (length svn)
$8 = 407
--8<---------------cut here---------------end--------------->8---

That led to:

--8<---------------cut here---------------start------------->8---
guix build: error: build of `/gnu/store/2byn59zmdbc4bz2wknnv0df4n67bdvgr-texlive-pdftex-59745-checkout.drv', `/gnu/store/2gj88z4plmwhraghxj5626zpiir1ck6k-libsmpeg-0.4.5-401-checkout.drv', `/gnu/store/2zygylsb2b333rzrvjyrh4qybw799hl3-ghmm-0.9-rc3-0.2341-checkout.drv', `/gnu/store/4a81qlka5w73rprapzi1w63xzb01n0r8-java-geronimo-xbean-reflect-4.5.drv', `/gnu/store/4mabgwil0ygwm3bkka3nzfbrwg1kk0wz-texlive-kpathsea-59745-checkout.drv', `/gnu/store/5ivk83abj22bs9ka10dk1v67kyczcd80-texlive-dvips-59745-checkout.drv', `/gnu/store/6zhnahylfr1zmpwzb8qzh8qp3yf9yl1p-texlive-tex-plain-59745-checkout.drv', `/gnu/store/f1sjmghs0f4v0y2pnljqaplifq52qbn2-texlive-cm-59745-checkout.drv', `/gnu/store/kd7kahaq71gi8j6zbabr0njqw60sjjxc-libsmpeg-0.4.5-399-checkout.drv', `/gnu/store/q3kip5bxkkdh14kx81afakbmpy7l4lr4-texlive-latexconfig-59745-checkout.drv', `/gnu/store/qskxc2c30fdclmrjp7nk35n1q2sl6sp8-texlive-tetex-59745-checkout.drv', `/gnu/store/wibsxy4kxlpq8lr76wvwgdyc2x5farr4-texlive-hyphen-base-59745-checkout.drv' failed
--8<---------------cut here---------------end--------------->8---

That’s 11 failures out of 407.

So, how about applying the ‘--ignore-keywords’ change and updating
hashes accordingly?

> [1] More precisely, I was going to process recursive ‘svn-fetch’ origins
> because a lot of them are needlessly marked as recursive.  In some
> (many?) cases, the repositories don’t actually have external references,
> so the flag does nothing.  I was only going to skip the ones where it
> makes a difference.

We should remove that recursive flag when it has no effect.  Perhaps we
could proceed similarly?

Thanks,
Ludo’.

diff --git a/guix/build/svn.scm b/guix/build/svn.scm
index 2d960cb364..863c48e46d 100644
--- a/guix/build/svn.scm
+++ b/guix/build/svn.scm
@@ -1,5 +1,5 @@
 ;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2014, 2020 Ludovic Courtès <[email-masked]>
+;;; Copyright © 2014, 2020, 2023 Ludovic Courtès <[email-masked]>
 ;;; Copyright © 2014 Sree Harsha Totakura <[email-masked]>
 ;;; Copyright © 2018 Mark H Weaver <[email-masked]>
 ;;; Copyright © 2020 Simon Tournier <[email-masked]>
@@ -47,6 +47,11 @@ (define* (svn-fetch url revision directory
            ;; verify the checksum later.  This can be removed when
            ;; ca-certificates package is added.
            "--trust-server-cert" "-r" (number->string revision)
+
+           ;; Disable keyword substitution (keywords are CVS-like strings
+           ;; like "$Date$", "$Id$", and so on).
+           "--ignore-keywords"
+
            `(,@(if (and user-name password)
                    (list (string-append "--username=" user-name)
                          (string-append "--password=" password))