[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Why linux-libre source code is not in sources.json

From: zimoun
Subject: Re: Why linux-libre source code is not in sources.json
Date: Thu, 9 Sep 2021 19:18:46 +0200


On Thu, 9 Sept 2021 at 11:51, Maxime Devos <> wrote:

> > where ’make-linux-libre-source’ returns a ’computed-origin-method’.  And
> > the ’origin-uri’ of ’linux-libre-5.14-pristine-source’ is a ’gexp’.
> > Then inside this ’gexp’, you can read the ’%upstream-linux-source’ URL:
> >
> > --8<---------------cut here---------------start------------->8---
> > #<gexp-input native
> >  #<origin
> >   #"mirror://"
> >   #<content-hash 
> > sha256:06lbjsbr86qa8yai5gfclbfxvcqsw33kxj9b4r93hh6z1wajmx82>
> > --8<---------------cut here---------------end--------------->8---
> >
> > and I do not know if it is possible to extract such thing.
> To extract the <origin> from the <gexp-input>, use gexp-input-thing.
> To extract the <gexp-input> from the <gexp>, use the unexported
> gexp-references.

Thanks!  It does the job. :-)

I will fix sources.json if no one beats me.

With the (ugly) snippet below,  I get almost the linux-libre, I guess.
The question is now how does SWH ingest the script with the URL:


Another story. :-)


--8<---------------cut here---------------start------------->8---
$ guix repl /tmp/linux.scm | grep linux-libre


--8<---------------cut here---------------end--------------->8---

--8<---------------cut here---------------start------------->8---
(use-modules (guix packages)
             (guix gexp)
             (gnu packages)
             (gnu packages linux)
             (srfi srfi-1)
             (ice-9 match))

(define gexp-references (@@ (guix gexp) gexp-references))

(define (thing->string thing)
  (match thing
    ((? gexp-input? g)
     (match (gexp-input-thing g)
       ((? origin? o)
        (origin-uri o))
       (_ #f)))
    (_ #f)))

(define (get-uri pkg)
  (match (package-source pkg)
    ((? origin? o)
     (match (origin-uri o)
       ((? string? s)
        (list s))
       ((? list? lst)
       ((? promise? prom)
        (match (force prom)
          ((? gexp? g)
           (filter (lambda (x) x)
                    (map thing->string
                         (gexp-references g)))))
           (list #f))))
        (list #f))))
    (_ #f)))

(define all-packages
   (fold-packages (lambda (package lst)
                    (if (or (package-superseded package)
                            (package-replacement package))
                        (cons package lst)))
   (lambda (p1 p2)
     (string<? (package-name p1)
               (package-name p2)))))

(map (lambda (p)
       (format #t "~a~%" (get-uri p)))
--8<---------------cut here---------------end--------------->8---

reply via email to

[Prev in Thread] Current Thread [Next in Thread]