From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id 4KB7Eq7x0GOOQgEAbAwnHQ (envelope-from ) for ; Wed, 25 Jan 2023 10:09:02 +0100 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id iH98Eq7x0GNWagAAauVa8A (envelope-from ) for ; Wed, 25 Jan 2023 10:09:02 +0100 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 96CFC1283F for ; Wed, 25 Jan 2023 10:09:01 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pKblY-0003YV-Vw; Wed, 25 Jan 2023 04:08:25 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pKblR-0003WI-Fs; Wed, 25 Jan 2023 04:08:19 -0500 Received: from mail.boiledscript.com ([144.168.59.46]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pKblO-00032p-3M; Wed, 25 Jan 2023 04:08:17 -0500 Date: Wed, 25 Jan 2023 17:07:45 +0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ultrarare.space; s=dkim; t=1674637686; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type; bh=EJvNdeN4Vy+EQYuAf55Ty8L8DYWCL5GMEfN88ZYOHt4=; b=GRT4VzGl0fbVPTlIgLn5xlN6O5/Y3hGt76Hg+r6lbPuHmM0O87G8RXsfFUsVAgGI+dpRBT 4IHkb2IGTHX7FFKM0IAZwyHWtd6Vnkbc0Wej3Wp5zk//DbQ4WafzR9DTdHAQ9SaGgKM232 va3CwZ7sSomBubk17XuKO8gTRCVPX/6hXHHwWRiDe4wY9LCydxX3u7w8YVUovID4TBre4S 4EQ/G6iKH7V3qhmwBxnpb5NHn8gEqZykz4/MENCxQo8AHTAKsvq/BjDIMEKBxpkwSHRriZ zPXQ+hl45nE2noafgwe7KAJuxh39OQX1sAmP69iw9qk7/Z/328CA/RHV94v0ig== Message-ID: <87sffz2d9a.wl-hako@ultrarare.space> From: Hilton Chain To: guix-patches@gnu.org Cc: guix-devel@gnu.org Subject: [PATCH] download: Add url-fetch/xz-file. MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Spamd-Bar: / Received-SPF: pass client-ip=144.168.59.46; envelope-from=hako@ultrarare.space; helo=mail.boiledscript.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: guix-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+larch=yhetil.org@gnu.org Sender: guix-devel-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1674637742; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=EJvNdeN4Vy+EQYuAf55Ty8L8DYWCL5GMEfN88ZYOHt4=; b=BzaNmOLmKXxKmSbIs1/5pyiCIJRtaqzsRyTXS63TfRUSRHpuI1y7uQjo7XQc03vaXs2Fpo dZV6zisEG4LuV51lGQmOf0tPIRCgb7Hp0FKy9jHxCeqthgy6T1mIKL9okDrp4NLzDoR6W+ XbxWgnvszqxsPrL0U4AId+BNyaJdT2wR1zITRwvAdpVI+l+TYZf9ah5UdIgjWbaaeTtjis o6oYMTBBpu45AINb47uFwDzxS3Lli8F4m0SOc8fTHcSpZDyruSB66G3ibVBzhd3Zx7w51O Dr+z0p6lSB0LxmSWUIf/bVAaCLqFVAhQIv+9zXAN3o2CC3GDaLTZoS0DDPIOFg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=ultrarare.space header.s=dkim header.b=GRT4VzGl; spf=pass (aspmx1.migadu.com: domain of "guix-devel-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-devel-bounces+larch=yhetil.org@gnu.org"; dmarc=pass (policy=reject) header.from=ultrarare.space ARC-Seal: i=1; s=key1; d=yhetil.org; t=1674637742; a=rsa-sha256; cv=none; b=KlxBmm7c2PeAs1GFxCDiaPXh/s7ctjeRaRkEeuz8zLeZQJaQAeB5jcYF4jwC+SaUsGOFwz DRYxJfX2hl3G1+358OndonWn0nn4Ev4of9i7YMjrAj7XhRL2N7st2y3KLWgjUGYfbF0cm5 weEpKo0zkXvGOX5Ve7q6HLzjZh+wORguMkYT6PXyf0O2pbOhbNzfm60WfrJNxEYQ/SAqZe mcroD+43KpigaVBKAJAa44ko2NtJUhIonZSLSriAR1tOKOd7Vm6KVtB+ycglaZoY8vAToq f856mYyHNqg+CEbElvr5M8+c2ofKilhxys0Vh/sQ/PVnRy0tx3jJ9BgG8iZ30w== X-Migadu-Scanner: scn1.migadu.com Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=ultrarare.space header.s=dkim header.b=GRT4VzGl; spf=pass (aspmx1.migadu.com: domain of "guix-devel-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-devel-bounces+larch=yhetil.org@gnu.org"; dmarc=pass (policy=reject) header.from=ultrarare.space X-Migadu-Spam-Score: -3.07 X-Spam-Score: -3.07 X-Migadu-Queue-Id: 96CFC1283F X-TUID: g902GAaZbMBX * 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