* [PATCH] download: Add url-fetch/xz-file.
@ 2023-01-25 9:07 Hilton Chain
2023-02-25 17:48 ` Ludovic Courtès
2023-02-25 19:25 ` Tobias Geerinckx-Rice
0 siblings, 2 replies; 3+ messages in thread
From: Hilton Chain @ 2023-01-25 9:07 UTC (permalink / raw)
To: guix-patches; +Cc: guix-devel
* guix/download.scm (url-fetch/xz-file): New variable.
---
guix/download.scm | 43 +++++++++++++++++++++++++++++++++++++++++++
1 file changed, 43 insertions(+)
diff --git a/guix/download.scm b/guix/download.scm
index 2e9ecb43fc..cce62c4185 100644
--- a/guix/download.scm
+++ b/guix/download.scm
@@ -41,6 +41,7 @@ (define-module (guix download)
(url-fetch* . url-fetch)
url-fetch/executable
url-fetch/tarbomb
+ url-fetch/xz-file
url-fetch/zipbomb
download-to-store))
@@ -602,6 +603,48 @@ (define tar
#:graft? #f
#:local-build? #t)))
+(define* (url-fetch/xz-file url hash-algo hash
+ #:optional name
+ #:key (system (%current-system))
+ (guile (default-guile)))
+ "Similar to 'url-fetch' but decompress the xz file at URL as the result.
+This is mainly used for adding xz-compressed patches to a origin definition."
+ (define file-name
+ (match url
+ ((head _ ...)
+ (basename head))
+ (_
+ (basename url))))
+ (define xz
+ (module-ref (resolve-interface '(gnu packages compression)) 'xz))
+
+ (mlet %store-monad ((drv (url-fetch* url hash-algo hash
+ (or name (basename file-name ".xz"))
+ #:system system
+ #:guile guile))
+ (guile (package->derivation guile system)))
+ ;; Take the xz file, and simply decompress it.
+ ;; Use ungrafted xz so that the resulting file doesn't depend on whether
+ ;; grafts are enabled.
+ (gexp->derivation (or name file-name)
+ (with-imported-modules '((guix build utils))
+ #~(begin
+ (use-modules (guix build utils))
+ (setenv "XZ_OPT"
+ (string-join (%xz-parallel-args)))
+
+ (copy-file #$drv #$file-name)
+ (make-file-writable #$file-name)
+ (invoke (string-append #+xz "/bin/unxz")
+ #$file-name)
+
+ (copy-file (basename #$file-name ".xz")
+ #$output)))
+ #:system system
+ #:guile-for-build guile
+ #:graft? #f
+ #:local-build? #t)))
+
(define* (url-fetch/zipbomb url hash-algo hash
#:optional name
#:key (system (%current-system))
base-commit: 718223c58c20fa066527fb30da2b5dccca82913f
--
2.39.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] download: Add url-fetch/xz-file.
2023-01-25 9:07 [PATCH] download: Add url-fetch/xz-file Hilton Chain
@ 2023-02-25 17:48 ` Ludovic Courtès
2023-02-25 19:25 ` Tobias Geerinckx-Rice
1 sibling, 0 replies; 3+ messages in thread
From: Ludovic Courtès @ 2023-02-25 17:48 UTC (permalink / raw)
To: Hilton Chain; +Cc: guix-patches, guix-devel
Hi,
Hilton Chain <hako@ultrarare.space> skribis:
> * guix/download.scm (url-fetch/xz-file): New variable.
This LGTM, but do you know of a package that would use it?
I think we should add it if and only if it’s going to be used in Guix
proper.
Thanks,
Ludo’.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] download: Add url-fetch/xz-file.
2023-01-25 9:07 [PATCH] download: Add url-fetch/xz-file Hilton Chain
2023-02-25 17:48 ` Ludovic Courtès
@ 2023-02-25 19:25 ` Tobias Geerinckx-Rice
1 sibling, 0 replies; 3+ messages in thread
From: Tobias Geerinckx-Rice @ 2023-02-25 19:25 UTC (permalink / raw)
To: Hilton Chain; +Cc: guix-patches, guix-devel
Hi Hilton,
I agree with Ludo' and also wonder if a generic
‘url-fetch/compressed-file’ wouldn't be better. There are closure
arguments to be made for this xz-only approach. I don't know if they're
convincing. Cluebats welcome.
(I was going to bring up ‘url-fetch/tarbomb’ as an example, but it
doesn't actually handle anything besides gzip! Madness.)
On 2023-01-25 10:07, Hilton Chain wrote:
> + (setenv "XZ_OPT"
> + (string-join (%xz-parallel-args)))
Why set this kluge…
> + (invoke (string-append #+xz "/bin/unxz")
> + #$file-name)
…when we have full control over xz's arguments?
Kind regards,
T G-R
Sent from a Web browser. Excuse or enjoy my brevity.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-02-25 19:26 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-01-25 9:07 [PATCH] download: Add url-fetch/xz-file Hilton Chain
2023-02-25 17:48 ` Ludovic Courtès
2023-02-25 19:25 ` Tobias Geerinckx-Rice
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/guix.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).