[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Newbie: Define package that downloads multiple files from an open di
From: |
Simon Tournier |
Subject: |
Re: Newbie: Define package that downloads multiple files from an open directory |
Date: |
Fri, 26 May 2023 12:14:11 +0200 |
Hi,
On ven., 26 mai 2023 at 05:22, Rodrigo Morales <moralesrodrigo1100@gmail.com>
wrote:
> | (define-public my-package-1
> | (package
> | (name "my-package-1")
> | (version "1.0")
> | (home-page "My home-page")
> | (synopsis "My synopsis")
> | (description "My description")
> | (license gpl3+)
> | (source
> | (origin
> | (method url-fetch)
> | (uri
> "http://tug.ctan.org/tex-archive/macros/latex/contrib/blindtext/blindtext.dtx")
> | (sha256
> | (base32
> | "10sfm4648v1ywki639jsl5darkcil1is462w0v65xxr75k4l1ywl"))))
> | (build-system copy-build-system)
> | (arguments
> | '(#:install-plan
> | '(("blindtext.dtx" "share/"))))))
> `----
[...]
> Let's suppose I want to define a single Guix package that downloads
> the files `blindtext.dtx' and `blindtext.ins' (that is, two files
> instead of one) and makes them available at
> `~/.guix-profile/share'. What would the package definition look like?
You could add an ’inputs’ that is an ’origin’ with the file you want.
Something like:
--8<---------------cut here---------------start------------->8---
(arguments
`(#:install-plan
'(("blindtext.dtx" "share/"))
#:phases
(modify-phases %standard-phases
(add-after 'unpack 'add-ins
(lambda* (#:key outputs inputs #:allow-other-keys)
(let ((out (string-append (assoc-ref outputs "out") "/share/")))
(mkdir-p out)
(copy-file (assoc-ref inputs "ins")
(string-append out "/blindtext.ins"))))))))
(inputs
`(("ins" ,(origin
(method url-fetch)
(uri
"http://tug.ctan.org/tex-archive/macros/latex/contrib/blindtext/blindtext.ins")
(sha256
(base32
"1jfcyz6dw6q65b4hxi39917i9i5lkh3mh8v9zhpn4qqzgc1yj2bp"))))))))
--8<---------------cut here---------------end--------------->8---
and then,
--8<---------------cut here---------------start------------->8---
$ tree $(guix build -L /tmp/pkg my-package-1)
/gnu/store/3l2r0sc93dii3j9clfgfwv4j3gnh3ynh-my-package-1-1.0
└── share
├── blindtext.dtx
└── blindtext.ins
2 directories, 2 files
--8<---------------cut here---------------end--------------->8---
However, since it looks like TeXLive packages, you might be interested
by ’simple-texlive-package’ from (gnu packages tex).
--8<---------------cut here---------------start------------->8---
(define* (simple-texlive-package name locations hash
#:key trivial?)
"Return a template for a simple TeX Live package with the given NAME,
downloading from a list of LOCATIONS in the TeX Live repository, and expecting
the provided output HASH. If TRIVIAL? is provided, all files will simply be
copied to their outputs; otherwise the TEXLIVE-BUILD-SYSTEM is used."
--8<---------------cut here---------------end--------------->8---
Well, this procedure is not exported and it’s probably not exactly what
you want.
Hope that helps,
simon