From: Hilton Chain <hako@ultrarare.space>
To: guix-patches@gnu.org
Cc: guix-devel@gnu.org
Subject: [PATCH] download: Add url-fetch/xz-file.
Date: Wed, 25 Jan 2023 17:07:45 +0800 [thread overview]
Message-ID: <87sffz2d9a.wl-hako@ultrarare.space> (raw)
* 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
next reply other threads:[~2023-01-25 9:09 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-25 9:07 Hilton Chain [this message]
2023-02-25 17:48 ` [PATCH] download: Add url-fetch/xz-file Ludovic Courtès
2023-07-03 7:37 ` bug#61052: " Hilton Chain via Guix-patches via
2023-02-25 19:25 ` Tobias Geerinckx-Rice
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87sffz2d9a.wl-hako@ultrarare.space \
--to=hako@ultrarare.space \
--cc=guix-devel@gnu.org \
--cc=guix-patches@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/guix.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.