Subject: Re: bug#42162: gforge.inria.fr to be taken off-line in Dec. 2020

From: Ludovic Courtès <[email-masked]>
Date: Wed, 13 Jan 2021 11:39:19 +0100

Hi Maxim,

Maxim Cournoyer <[email-masked]> skribis:

>> The following packages have their source on gforge.inria.fr:
>>
>> scheme@(guile-user)> ,pp packages-on-gforge
>> $7 = (#<package [email-masked] gnu/packages/statistics.scm:3931 7f632401a640>
>>  #<package [email-masked] gnu/packages/ocaml.scm:295 7f63235eb3c0>
>>  #<package [email-masked] gnu/packages/ocaml.scm:357 7f63235eb280>

[...]

> I ran the code you had attached to the original message and got:
>
> ,pp packages-on-gforge
> $2 = ()
> scheme@(guile-user)> ,pp archived-source
> $3 = ()

Oh, it’s due to a bug, where the wrong ‘origin?’ predicate was taken.
After hiding the “wrong” one:

  #:use-module ((guix swh) #:hide (origin?))

I get:

--8<---------------cut here---------------start------------->8---
scheme@(guix-user)> ,pp packages-on-gforge
$1 = (#<package [email-masked] gnu/packages/statistics.scm:3964 7fa8a522b280>
 #<package [email-masked] gnu/packages/ocaml.scm:281 7fa8a4f44dc0>
 #<package [email-masked] gnu/packages/ocaml.scm:343 7fa8a4f44c80>
 #<package [email-masked] gnu/packages/multiprecision.scm:158 7fa8afd8aa00>
 #<package [email-masked] gnu/packages/maths.scm:3083 7fa8a69c8d20>
 #<package [email-masked] gnu/packages/maths.scm:3229 7fa8a69c8be0>
 #<package [email-masked] gnu/packages/maths.scm:3182 7fa8a69c8c80>
 #<package [email-masked] gnu/packages/maths.scm:3253 7fa8a69c8b40>
 #<package [email-masked] gnu/packages/gcc.scm:932 7fa8a64cbdc0>
 #<package [email-masked] gnu/packages/gcc.scm:997 7fa8a64cbc80>
 #<package [email-masked] gnu/packages/gcc.scm:983 7fa8a64cbd20>
 #<package [email-masked] gnu/packages/algebra.scm:104 7fa8a4f66500>
 #<package [email-masked] gnu/packages/algebra.scm:672 7fa8a4f70be0>
 #<package [email-masked] gnu/packages/algebra.scm:325 7fa8a4f660a0>)
scheme@(guix-user)> ,pp archived-source
$2 = (#<package [email-masked] gnu/packages/ocaml.scm:281 7fa8a4f44dc0>
 #<package [email-masked] gnu/packages/ocaml.scm:343 7fa8a4f44c80>
 #<package [email-masked] gnu/packages/maths.scm:3083 7fa8a69c8d20>
 #<package [email-masked] gnu/packages/maths.scm:3229 7fa8a69c8be0>
 #<package [email-masked] gnu/packages/maths.scm:3182 7fa8a69c8c80>
 #<package [email-masked] gnu/packages/maths.scm:3253 7fa8a69c8b40>
 #<package [email-masked] gnu/packages/gcc.scm:997 7fa8a64cbc80>
 #<package [email-masked] gnu/packages/gcc.scm:983 7fa8a64cbd20>)
--8<---------------cut here---------------end--------------->8---

Attaching the fixed script for clarity.

BTW, gforge.inria.fr shutdown has been delayed a bit, but most active
projects have started migrating to gitlab.inria.fr or elsewhere, so
hopefully we should be able to start updating our package recipes
accordingly.  It’s likely, though, that tarballs were lost in the
migration.

For example, Scotch is now at <https://gitlab.inria.fr/scotch/scotch>.
<https://gitlab.inria.fr/scotch/scotch/-/releases> shows “assets” for
the 6.1.0 release, but these are auto-generated tarballs instead of the
handcrafted one found on gforge.inria.fr (but this one is fine since its
tarball is archived as-is on SWH.)

ISL, MPFI, and GMP-ECM haven’t migrated, it seems.  CMH is now at
<https://gitlab.inria.fr/cmh/cmh> but without its tarballs.

Andreas, do you happen to know about the status of these?

We can already change Scotch and CMH to ‘git-fetch’ I think.  That
doesn’t solve the problem for earlier Guix revisions though, and I hope
Disarchive will save us!

Thanks,
Ludo’.

(use-modules (guix) (gnu)
             (guix svn-download)
             (guix git-download)
             ((guix swh) #:hide (origin?))
             (ice-9 match)
             (srfi srfi-1)
             (srfi srfi-26))

(define (gforge? package)
  (define (gforge-string? str)
    (string-contains str "gforge.inria.fr"))

  (match (package-source package)
    ((? origin? o)
     (match (origin-uri o)
       ((? string? url)
        (gforge-string? url))
       (((? string? urls) ...)
        (any gforge-string? urls))                ;or 'find'
       ((? git-reference? ref)
        (gforge-string? (git-reference-url ref)))
       ((? svn-reference? ref)
        (gforge-string? (svn-reference-url ref)))
       (_ #f)))
    (_ #f)))

(define packages-on-gforge
  (fold-packages (lambda (package result)
                   (if (gforge? package)
                       (cons package result)
                       result))
                 '()))

(define archived-source
  (filter (lambda (package)
            (let* ((origin (package-source package))
                   (hash  (origin-hash origin)))
              (lookup-content (content-hash-value hash)
                              (symbol->string
                               (content-hash-algorithm hash)))))
          packages-on-gforge))