Generated Chicken eggs

This commit is contained in:
Daniel Ziltener 2023-12-30 00:35:02 +01:00
parent c616f18984
commit fd1ea3a97b
Signed by: zilti
GPG key ID: B38976E82C9DAE42
4 changed files with 15330 additions and 657 deletions

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -1,6 +1,131 @@
;; -*- geiser-scheme-implementation: chicken; mode: scheme; -*- ;; -*- geiser-scheme-implementation: chicken; mode: scheme; -*-
(import (rss)) (import (rss)
(chicken io)
(chicken port)
(chicken pretty-print)
(chicken process)
(chicken string))
(define licenses
'((AGPL . license:agpl3+)
(Artistic . license:clarified-artistic)
(BSD . license:bsd-2)
(BSD-1 . license:bsd-1)
(|BSD 1-clause| . license:bsd-1)
(BSD-2-Clause . license:bsd-2)
(BSD3 . license:bsd-3)
(|BSD 3-clause| . license:bsd-3)
(bsd . license:bsd-3)
(GPL . license:gpl3)
(GPL-2 . license:gpl2)
(GPLv2 . license:gpl2)
(GPL-3 . license:gpl3)
(GPLv3 . license:gpl3)
(GPL-3.0 . license:gpl3)
(ISC . license:isc)
(LGPL . license:lgpl3+)
(LGPL-2 . license:lgpl2.0)
(LGPL-2.0+ . license:lgpl2.0+)
(LGPL-2.1 . license:lgpl2.1)
(LGPL-2.1-or-later . license:lgpl2.1+)
(LGPL-3 . license:lgpl3)
(LGPLv3 . license:lgpl3)
(MIT . license:expat)
(OpenLDAP . license:openldap2.8)
(SRFI . license:bsd-1)
(zlib . license:zlib)
(ZLIB-Acknowledgement . license:zlib)
(public-domain . license:public-domain)
(|Public Domain| . license:public-domain)
(|public domain| . license:public-domain)
(unknown . license:unlicense)
(unlicense . license:unlicense)))
(define egg-blacklist
'(("procedural-macros" . #f)))
(define (process-egg? eggrec)
(alist-ref (egg-name eggrec) egg-blacklist
string=? #t))
(define (rss-feed-item->title+version+desc feed-item)
(let ((chunks (string-split (rss:item-title feed-item)))
(desc (rss:item-description feed-item)))
(make-egg (car chunks) (cadr chunks) desc #f #f #f #f #f #f )))
(define (symbolify in)
(if (string? in)
(string->symbol in)
in))
(define (ref-or-keep x)
(alist-ref x licenses eqv? x))
(define (egg-add-deps+license eggrec)
(when (process-egg? eggrec)
(print "Parsing " (egg-name eggrec) " version " (egg-version eggrec))
(with-input-from-pipe
(string-append
"/home/zilti/projects/guixchannel/zilti/packages/eggfile-fetcher.sh "
(egg-name eggrec) " " (egg-version eggrec))
(lambda ()
(let* ((egg-alist (read))
(checksum (read)))
(egg-checksum-set! eggrec checksum)
(egg-dependencies-set! eggrec (alist-ref 'dependencies egg-alist eqv? '()))
(egg-test-dependencies-set! eggrec (alist-ref 'test-dependencies egg-alist eqv? '()))
(egg-build-dependencies-set! eggrec (alist-ref 'build-dependencies egg-alist eqv? '()))
(egg-foreign-dependencies-set! eggrec (alist-ref 'foreign-dependencies egg-alist eqv? '()))
(egg-license-set! eggrec (alist-ref (symbolify (car (alist-ref 'license egg-alist))) licenses)))))))
(define-record egg name version description checksum dependencies test-dependencies build-dependencies foreign-dependencies license)
(define (parse-rss)
(let
((eggrecs (map rss-feed-item->title+version+desc
(rss:feed-items
(with-input-from-file "/home/zilti/projects/guixchannel/zilti/packages/chicken-eggs-5.xml"
rss:read)))))
(set! eggs eggrecs)
(map egg-add-deps+license eggrecs)
eggrecs))
(define (prepend-chicken-to-dependency x)
(if (not (symbol? x))
(prepend-chicken-to-dependency (car x))
(string->symbol (string-append "chicken-" (symbol->string x)))))
(define (generate-guix-package eggrec)
(when (process-egg? eggrec)
(print "Generating " (egg-name eggrec) " version " (egg-version eggrec))
(with-output-to-file "chicken.scm"
(lambda ()
(pretty-print
`(define-public ,(string->symbol (string-append "chicken-" (egg-name eggrec)))
(package
(name ,(string-append "chicken-" (egg-name eggrec)))
(version ,(egg-version eggrec))
(source
(origin
(method url-fetch)
(uri (egg-uri ,(egg-name eggrec) version))
(sha256
(base32
,(egg-checksum eggrec)))))
(propagated-inputs
(list ,@(map prepend-chicken-to-dependency (egg-dependencies eggrec))))
(native-inputs
(list ,@(map prepend-chicken-to-dependency (egg-test-dependencies eggrec))
,@(map prepend-chicken-to-dependency (egg-build-dependencies eggrec))))
(build-system chicken-build-system)
(arguments '(#:egg-name ,(egg-name eggrec)))
(synopsis ,(egg-description eggrec))
(home-page ,(string-append
"https://wiki.call-cc.org/eggref/5/" (egg-name eggrec)))
(description ,(egg-description eggrec))
(license ,(egg-license eggrec))))))
#:text #:append)))
(define (main #!optional args)
(map generate-guix-package (parse-rss)))

View file

@ -0,0 +1,12 @@
#!/usr/bin/env bash
curdir=$(pwd)
tmptar=$(mktemp)
tmpdir=$(mktemp -d)
trap "rm -rf '$tmptar'" exit;
trap "rm -rf '$tmpdir'" exit;
curl -L "https://code.call-cc.org/egg-tarballs/5/$1/$1-$2.tar.gz" > $tmptar
cd $tmpdir
tar xzf $tmptar
cat $1-$2/$1.egg
echo "\"$(guix hash $tmptar)\""