2017-06-09 12:35:50 +02:00
|
|
|
;;; GNU Guix --- Functional package management for GNU
|
2022-01-10 12:40:18 +01:00
|
|
|
;;; Copyright © 2017, 2021, 2022 Ricardo Wurmus <rekado@elephly.net>
|
2021-01-04 19:59:58 +01:00
|
|
|
;;; Copyright © 2021 Maxim Cournoyer <maxim.cournoyer@gmail.com>
|
2017-06-09 12:35:50 +02:00
|
|
|
;;;
|
|
|
|
;;; This file is part of GNU Guix.
|
|
|
|
;;;
|
|
|
|
;;; GNU Guix is free software; you can redistribute it and/or modify it
|
|
|
|
;;; under the terms of the GNU General Public License as published by
|
|
|
|
;;; the Free Software Foundation; either version 3 of the License, or (at
|
|
|
|
;;; your option) any later version.
|
|
|
|
;;;
|
|
|
|
;;; GNU Guix is distributed in the hope that it will be useful, but
|
|
|
|
;;; WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
;;; GNU General Public License for more details.
|
|
|
|
;;;
|
|
|
|
;;; You should have received a copy of the GNU General Public License
|
|
|
|
;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
(define-module (guix import texlive)
|
2022-01-20 22:55:55 +01:00
|
|
|
#:use-module (ice-9 ftw)
|
2017-06-09 12:35:50 +02:00
|
|
|
#:use-module (ice-9 match)
|
2021-11-15 17:38:05 +01:00
|
|
|
#:use-module (ice-9 rdelim)
|
2017-06-09 12:35:50 +02:00
|
|
|
#:use-module (srfi srfi-1)
|
2021-11-15 17:38:05 +01:00
|
|
|
#:use-module (srfi srfi-2)
|
|
|
|
#:use-module (srfi srfi-11)
|
2017-06-09 12:35:50 +02:00
|
|
|
#:use-module (srfi srfi-26)
|
Switch to Guile-Gcrypt.
This removes (guix hash) and (guix pk-crypto), which now live as part of
Guile-Gcrypt (version 0.1.0.)
* guix/gcrypt.scm, guix/hash.scm, guix/pk-crypto.scm,
tests/hash.scm, tests/pk-crypto.scm: Remove.
* configure.ac: Test for Guile-Gcrypt. Remove LIBGCRYPT and
LIBGCRYPT_LIBDIR assignments.
* m4/guix.m4 (GUIX_ASSERT_LIBGCRYPT_USABLE): Remove.
* README: Add Guile-Gcrypt to the dependencies; move libgcrypt as
"required unless --disable-daemon".
* doc/guix.texi (Requirements): Likewise.
* gnu/packages/bash.scm, guix/derivations.scm, guix/docker.scm,
guix/git.scm, guix/http-client.scm, guix/import/cpan.scm,
guix/import/cran.scm, guix/import/crate.scm, guix/import/elpa.scm,
guix/import/gnu.scm, guix/import/hackage.scm,
guix/import/texlive.scm, guix/import/utils.scm, guix/nar.scm,
guix/pki.scm, guix/scripts/archive.scm,
guix/scripts/authenticate.scm, guix/scripts/download.scm,
guix/scripts/hash.scm, guix/scripts/pack.scm,
guix/scripts/publish.scm, guix/scripts/refresh.scm,
guix/scripts/substitute.scm, guix/store.scm,
guix/store/deduplication.scm, guix/tests.scm, tests/base32.scm,
tests/builders.scm, tests/challenge.scm, tests/cpan.scm,
tests/crate.scm, tests/derivations.scm, tests/gem.scm,
tests/nar.scm, tests/opam.scm, tests/pki.scm,
tests/publish.scm, tests/pypi.scm, tests/store-deduplication.scm,
tests/store.scm, tests/substitute.scm: Adjust imports.
* gnu/system/vm.scm: Likewise.
(guile-sqlite3&co): Rename to...
(gcrypt-sqlite3&co): ... this. Add GUILE-GCRYPT.
(expression->derivation-in-linux-vm)[config]: Remove.
(iso9660-image)[config]: Remove.
(qemu-image)[config]: Remove.
(system-docker-image)[config]: Remove.
* guix/scripts/pack.scm: Adjust imports.
(guile-sqlite3&co): Rename to...
(gcrypt-sqlite3&co): ... this. Add GUILE-GCRYPT.
(self-contained-tarball)[build]: Call 'make-config.scm' without
#:libgcrypt argument.
(squashfs-image)[libgcrypt]: Remove.
[build]: Call 'make-config.scm' without #:libgcrypt.
(docker-image)[config, json]: Remove.
[build]: Add GUILE-GCRYPT to the extensions Remove (guix config) from
the imported modules.
* guix/self.scm (specification->package): Remove "libgcrypt", add
"guile-gcrypt".
(compiled-guix): Remove #:libgcrypt.
[guile-gcrypt]: New variable.
[dependencies]: Add it.
[*core-modules*]: Remove #:libgcrypt from 'make-config.scm' call.
Add #:extensions.
[*config*]: Remove #:libgcrypt from 'make-config.scm' call.
(%dependency-variables): Remove %libgcrypt.
(make-config.scm): Remove #:libgcrypt.
* build-aux/build-self.scm (guile-gcrypt): New variable.
(make-config.scm): Remove #:libgcrypt.
(build-program)[fake-gcrypt-hash]: New variable.
Add (gcrypt hash) to the imported modules. Adjust load path
assignments.
* gnu/packages/package-management.scm (guix)[propagated-inputs]: Add
GUILE-GCRYPT.
[arguments]: In 'wrap-program' phase, add GUILE-GCRYPT to the search
path.
2018-08-31 17:07:07 +02:00
|
|
|
#:use-module (gcrypt hash)
|
2021-11-15 17:38:05 +01:00
|
|
|
#:use-module (guix derivations)
|
2017-06-09 12:35:50 +02:00
|
|
|
#:use-module (guix memoization)
|
2021-11-15 17:38:05 +01:00
|
|
|
#:use-module (guix monads)
|
|
|
|
#:use-module (guix gexp)
|
2017-06-09 12:35:50 +02:00
|
|
|
#:use-module (guix store)
|
|
|
|
#:use-module (guix base32)
|
|
|
|
#:use-module (guix serialization)
|
|
|
|
#:use-module (guix svn-download)
|
|
|
|
#:use-module (guix import utils)
|
|
|
|
#:use-module (guix utils)
|
|
|
|
#:use-module (guix upstream)
|
|
|
|
#:use-module (guix packages)
|
|
|
|
#:use-module (guix build-system texlive)
|
2022-01-20 22:55:55 +01:00
|
|
|
#:export (files-differ?
|
|
|
|
texlive->guix-package
|
2021-11-15 17:38:05 +01:00
|
|
|
texlive-recursive-import))
|
2017-06-09 12:35:50 +02:00
|
|
|
|
|
|
|
;;; Commentary:
|
|
|
|
;;;
|
2021-11-15 17:38:05 +01:00
|
|
|
;;; Generate a package declaration template for corresponding package in the
|
|
|
|
;;; Tex Live Package Database (tlpdb). We fetch all sources from different
|
|
|
|
;;; locations in the SVN repository of the Texlive project.
|
2017-06-09 12:35:50 +02:00
|
|
|
;;;
|
|
|
|
;;; Code:
|
|
|
|
|
|
|
|
(define string->license
|
|
|
|
(match-lambda
|
|
|
|
("artistic2" 'gpl3+)
|
|
|
|
("gpl" 'gpl3+)
|
|
|
|
("gpl1" 'gpl1)
|
|
|
|
("gpl1+" 'gpl1+)
|
|
|
|
("gpl2" 'gpl2)
|
|
|
|
("gpl2+" 'gpl2+)
|
|
|
|
("gpl3" 'gpl3)
|
|
|
|
("gpl3+" 'gpl3+)
|
|
|
|
("lgpl2.1" 'lgpl2.1)
|
|
|
|
("lgpl3" 'lgpl3)
|
|
|
|
("knuth" 'knuth)
|
|
|
|
("pd" 'public-domain)
|
|
|
|
("bsd2" 'bsd-2)
|
|
|
|
("bsd3" 'bsd-3)
|
|
|
|
("bsd4" 'bsd-4)
|
|
|
|
("opl" 'opl1.0+)
|
|
|
|
("ofl" 'silofl1.1)
|
2021-11-15 17:38:05 +01:00
|
|
|
|
|
|
|
("lpplgpl" `(list lppl gpl1+))
|
2017-06-09 12:35:50 +02:00
|
|
|
("lppl" 'lppl)
|
|
|
|
("lppl1" 'lppl1.0+) ; usually means "or later"
|
|
|
|
("lppl1.2" 'lppl1.2+) ; usually means "or later"
|
|
|
|
("lppl1.3" 'lppl1.3+) ; usually means "or later"
|
|
|
|
("lppl1.3a" 'lppl1.3a)
|
|
|
|
("lppl1.3b" 'lppl1.3b)
|
|
|
|
("lppl1.3c" 'lppl1.3c)
|
|
|
|
("cc-by-2" 'cc-by-2.0)
|
|
|
|
("cc-by-3" 'cc-by-3.0)
|
|
|
|
("cc-by-sa-2" 'cc-by-sa2.0)
|
|
|
|
("cc-by-sa-3" 'cc-by-sa3.0)
|
|
|
|
("mit" 'expat)
|
|
|
|
("fdl" 'fdl1.3+)
|
|
|
|
("gfl" 'gfl1.0)
|
|
|
|
|
|
|
|
;; These are known non-free licenses
|
|
|
|
("noinfo" 'unknown)
|
|
|
|
("nosell" 'non-free)
|
|
|
|
("shareware" 'non-free)
|
|
|
|
("nosource" 'non-free)
|
|
|
|
("nocommercial" 'non-free)
|
|
|
|
("cc-by-nc-nd-1" 'non-free)
|
|
|
|
("cc-by-nc-nd-2" 'non-free)
|
|
|
|
("cc-by-nc-nd-2.5" 'non-free)
|
|
|
|
("cc-by-nc-nd-3" 'non-free)
|
|
|
|
("cc-by-nc-nd-4" 'non-free)
|
|
|
|
((x) (string->license x))
|
|
|
|
((lst ...) `(list ,@(map string->license lst)))
|
2021-11-15 17:38:05 +01:00
|
|
|
(x `(error unknown-license ,x))))
|
2017-06-09 12:35:50 +02:00
|
|
|
|
2021-11-15 17:38:05 +01:00
|
|
|
(define (guix-name name)
|
2017-06-09 12:35:50 +02:00
|
|
|
"Return a Guix package name for a given Texlive package NAME."
|
2021-11-15 17:38:05 +01:00
|
|
|
(string-append "texlive-"
|
2017-06-09 12:35:50 +02:00
|
|
|
(string-map (match-lambda
|
|
|
|
(#\_ #\-)
|
|
|
|
(#\. #\-)
|
|
|
|
(chr (char-downcase chr)))
|
|
|
|
name)))
|
|
|
|
|
2021-11-15 17:38:05 +01:00
|
|
|
(define (tlpdb-file)
|
2021-11-17 15:39:06 +01:00
|
|
|
(define texlive-bin
|
|
|
|
;; Resolve this variable lazily so that (gnu packages ...) does not end up
|
|
|
|
;; in the closure of this module.
|
|
|
|
(module-ref (resolve-interface '(gnu packages tex))
|
|
|
|
'texlive-bin))
|
|
|
|
|
2017-06-09 12:35:50 +02:00
|
|
|
(with-store store
|
2021-11-15 17:38:05 +01:00
|
|
|
(run-with-store store
|
|
|
|
(mlet* %store-monad
|
|
|
|
((drv (lower-object texlive-bin))
|
|
|
|
(built (built-derivations (list drv))))
|
|
|
|
(match (derivation->output-paths drv)
|
|
|
|
(((names . items) ...)
|
|
|
|
(return (string-append (first items)
|
|
|
|
"/share/tlpkg/texlive.tlpdb"))))))))
|
|
|
|
|
|
|
|
(define tlpdb
|
|
|
|
(memoize
|
|
|
|
(lambda ()
|
|
|
|
(let ((file (tlpdb-file))
|
|
|
|
(fields
|
|
|
|
'((name . string)
|
|
|
|
(shortdesc . string)
|
|
|
|
(longdesc . string)
|
|
|
|
(catalogue-license . string)
|
|
|
|
(catalogue-ctan . string)
|
|
|
|
(srcfiles . list)
|
|
|
|
(runfiles . list)
|
|
|
|
(docfiles . list)
|
|
|
|
(depend . simple-list)))
|
|
|
|
(record
|
|
|
|
(lambda* (key value alist #:optional (type 'string))
|
|
|
|
(let ((new
|
|
|
|
(or (and=> (assoc-ref alist key)
|
|
|
|
(lambda (existing)
|
|
|
|
(cond
|
|
|
|
((eq? type 'string)
|
|
|
|
(string-append existing " " value))
|
|
|
|
((or (eq? type 'list) (eq? type 'simple-list))
|
|
|
|
(cons value existing)))))
|
|
|
|
(cond
|
|
|
|
((eq? type 'string)
|
|
|
|
value)
|
|
|
|
((or (eq? type 'list) (eq? type 'simple-list))
|
|
|
|
(list value))))))
|
|
|
|
(acons key new (alist-delete key alist))))))
|
|
|
|
(call-with-input-file file
|
|
|
|
(lambda (port)
|
|
|
|
(let loop ((all (list))
|
|
|
|
(current (list))
|
|
|
|
(last-property #false))
|
|
|
|
(let ((line (read-line port)))
|
|
|
|
(cond
|
|
|
|
((eof-object? line) all)
|
|
|
|
|
|
|
|
;; End of record.
|
|
|
|
((string-null? line)
|
|
|
|
(loop (cons (cons (assoc-ref current 'name) current)
|
|
|
|
all)
|
|
|
|
(list) #false))
|
|
|
|
|
|
|
|
;; Continuation of a list
|
|
|
|
((and (zero? (string-index line #\space)) last-property)
|
|
|
|
;; Erase optional second part of list values like
|
|
|
|
;; "details=Readme" for files
|
|
|
|
(let ((plain-value (first
|
|
|
|
(string-split
|
|
|
|
(string-trim-both line) #\space))))
|
|
|
|
(loop all (record last-property
|
|
|
|
plain-value
|
|
|
|
current
|
|
|
|
'list)
|
|
|
|
last-property)))
|
|
|
|
(else
|
|
|
|
(or (and-let* ((space (string-index line #\space))
|
|
|
|
(key (string->symbol (string-take line space)))
|
|
|
|
(value (string-drop line (1+ space)))
|
|
|
|
(field-type (assoc-ref fields key)))
|
|
|
|
;; Erase second part of list keys like "size=29"
|
|
|
|
(cond
|
|
|
|
((eq? field-type 'list)
|
|
|
|
(loop all current key))
|
|
|
|
(else
|
|
|
|
(loop all (record key value current field-type) key))))
|
|
|
|
(loop all current #false))))))))))))
|
|
|
|
|
2022-01-20 22:55:55 +01:00
|
|
|
(define* (files-differ? directory package-name
|
|
|
|
#:key
|
|
|
|
(package-database tlpdb)
|
|
|
|
(type #false)
|
|
|
|
(direction 'missing))
|
|
|
|
"Return a list of files in DIRECTORY that differ from the expected installed
|
|
|
|
files for PACKAGE-NAME according to the PACKAGE-DATABASE. By default all
|
|
|
|
files considered, but this can be restricted by setting TYPE to 'runfiles,
|
|
|
|
'docfiles, or 'srcfiles. The names of files that are missing from DIRECTORY
|
|
|
|
are returned; by setting DIRECTION to anything other than 'missing, the names
|
|
|
|
of those files are returned that are unexpectedly installed."
|
|
|
|
(define (strip-directory-prefix file-name)
|
|
|
|
(string-drop file-name (1+ (string-length directory))))
|
|
|
|
(let* ((data (or (assoc-ref (package-database) package-name)
|
|
|
|
(error (format #false
|
|
|
|
"~a is not a valid package name in the TeX Live package database."
|
|
|
|
package-name))))
|
|
|
|
(files (if type
|
|
|
|
(or (assoc-ref data type) (list))
|
|
|
|
(append (or (assoc-ref data 'runfiles) (list))
|
|
|
|
(or (assoc-ref data 'docfiles) (list))
|
|
|
|
(or (assoc-ref data 'srcfiles) (list)))))
|
|
|
|
(existing (file-system-fold
|
|
|
|
(const #true) ;enter?
|
|
|
|
(lambda (path stat result) (cons path result)) ;leaf
|
|
|
|
(lambda (path stat result) result) ;down
|
|
|
|
(lambda (path stat result) result) ;up
|
|
|
|
(lambda (path stat result) result) ;skip
|
|
|
|
(lambda (path stat errno result) result) ;error
|
|
|
|
(list)
|
|
|
|
directory)))
|
|
|
|
(if (eq? direction 'missing)
|
|
|
|
(lset-difference string=?
|
|
|
|
files (map strip-directory-prefix existing))
|
|
|
|
;; List files that are installed but should not be.
|
|
|
|
(lset-difference string=?
|
|
|
|
(map strip-directory-prefix existing) files))))
|
|
|
|
|
2021-11-15 17:38:05 +01:00
|
|
|
(define (files->directories files)
|
2022-01-10 12:40:18 +01:00
|
|
|
(define name->parts (cut string-split <> #\/))
|
2021-11-17 15:41:05 +01:00
|
|
|
(map (cut string-join <> "/" 'suffix)
|
|
|
|
(delete-duplicates (map (lambda (file)
|
2022-01-10 12:40:18 +01:00
|
|
|
(drop-right (name->parts file) 1))
|
|
|
|
(sort files string<))
|
|
|
|
;; Remove sub-directories, i.e. more specific
|
|
|
|
;; entries with the same prefix.
|
|
|
|
(lambda (x y) (every equal? x y)))))
|
2021-11-15 17:38:05 +01:00
|
|
|
|
2022-07-19 23:44:11 +02:00
|
|
|
(define (tlpdb->package name version package-database)
|
2021-11-17 22:38:24 +01:00
|
|
|
(and-let* ((data (assoc-ref package-database name))
|
2021-11-15 17:38:05 +01:00
|
|
|
(dirs (files->directories
|
|
|
|
(map (lambda (dir)
|
|
|
|
(string-drop dir (string-length "texmf-dist/")))
|
|
|
|
(append (or (assoc-ref data 'docfiles) (list))
|
|
|
|
(or (assoc-ref data 'runfiles) (list))
|
|
|
|
(or (assoc-ref data 'srcfiles) (list))))))
|
|
|
|
(name (guix-name name))
|
2022-07-19 23:44:11 +02:00
|
|
|
;; TODO: we're ignoring the VERSION argument because that
|
|
|
|
;; information is distributed across %texlive-tag and
|
|
|
|
;; %texlive-revision.
|
2021-11-15 17:38:05 +01:00
|
|
|
(ref (svn-multi-reference
|
|
|
|
(url (string-append "svn://www.tug.org/texlive/tags/"
|
|
|
|
%texlive-tag "/Master/texmf-dist"))
|
|
|
|
(locations dirs)
|
|
|
|
(revision %texlive-revision)))
|
|
|
|
(source (with-store store
|
|
|
|
(download-multi-svn-to-store
|
|
|
|
store ref (string-append name "-svn-multi-checkout")))))
|
|
|
|
(values
|
|
|
|
`(package
|
|
|
|
(inherit (simple-texlive-package
|
|
|
|
,name
|
|
|
|
(list ,@dirs)
|
|
|
|
(base32
|
|
|
|
,(bytevector->nix-base32-string
|
|
|
|
(let-values (((port get-hash) (open-sha256-port)))
|
|
|
|
(write-file source port)
|
|
|
|
(force-output port)
|
|
|
|
(get-hash))))
|
|
|
|
,@(if (assoc-ref data 'srcfiles) '() '(#:trivial? #true))))
|
2022-07-19 23:44:11 +02:00
|
|
|
;; package->definition in (guix import utils) expects to see a
|
|
|
|
;; version field.
|
|
|
|
(version ,version)
|
2021-11-15 17:38:05 +01:00
|
|
|
,@(or (and=> (assoc-ref data 'depend)
|
|
|
|
(lambda (inputs)
|
2021-11-17 22:37:23 +01:00
|
|
|
`((propagated-inputs
|
2022-01-13 22:26:23 +01:00
|
|
|
(list ,@(map (lambda (tex-name)
|
|
|
|
(let ((name (guix-name tex-name)))
|
|
|
|
(string->symbol name)))
|
|
|
|
inputs))))))
|
2021-11-15 17:38:05 +01:00
|
|
|
'())
|
|
|
|
,@(or (and=> (assoc-ref data 'catalogue-ctan)
|
|
|
|
(lambda (url)
|
|
|
|
`((home-page ,(string-append "https://ctan.org" url)))))
|
|
|
|
'((home-page "https://www.tug.org/texlive/")))
|
|
|
|
(synopsis ,(assoc-ref data 'shortdesc))
|
|
|
|
(description ,(beautify-description
|
|
|
|
(assoc-ref data 'longdesc)))
|
|
|
|
(license ,(string->license
|
|
|
|
(assoc-ref data 'catalogue-license))))
|
|
|
|
(or (assoc-ref data 'depend) (list)))))
|
2017-06-09 12:35:50 +02:00
|
|
|
|
|
|
|
(define texlive->guix-package
|
|
|
|
(memoize
|
2022-07-19 23:44:11 +02:00
|
|
|
(lambda* (name #:key
|
|
|
|
repo
|
|
|
|
(version (number->string %texlive-revision))
|
|
|
|
(package-database tlpdb))
|
2021-11-15 17:38:05 +01:00
|
|
|
"Find the metadata for NAME in the tlpdb and return the `package'
|
2017-06-09 12:35:50 +02:00
|
|
|
s-expression corresponding to that package, or #f on failure."
|
2022-07-19 23:44:11 +02:00
|
|
|
(tlpdb->package name version (package-database)))))
|
2021-11-15 17:38:05 +01:00
|
|
|
|
2022-07-19 23:44:11 +02:00
|
|
|
(define* (texlive-recursive-import name #:key repo version)
|
2021-11-15 17:38:05 +01:00
|
|
|
(recursive-import name
|
2022-07-19 23:44:11 +02:00
|
|
|
#:repo repo
|
|
|
|
#:version version
|
2021-11-15 17:38:05 +01:00
|
|
|
#:repo->guix-package texlive->guix-package
|
|
|
|
#:guix-name guix-name))
|
2017-06-09 12:35:50 +02:00
|
|
|
|
2021-11-15 17:38:05 +01:00
|
|
|
;;; texlive.scm ends here
|