Subject: [bug#61959] [PATCH 3/7] gnu: Add asahi-fwextract.

From: Roman Scherer <[email-masked]>
Date: Sat, 4 Mar 2023 15:46:36 +0100

* gnu/packages/firmware.scm (asahi-fwextract): New variable.
---
 gnu/packages/firmware.scm | 35 +++++++++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)

diff --git a/gnu/packages/firmware.scm b/gnu/packages/firmware.scm
index a876aa727a..3e3cfe96a9 100644
--- a/gnu/packages/firmware.scm
+++ b/gnu/packages/firmware.scm
@@ -34,6 +34,7 @@ (define-module (gnu packages firmware)
   #:use-module (guix git-download)
   #:use-module (guix build-system gnu)
   #:use-module (guix build-system meson)
+  #:use-module (guix build-system python)
   #:use-module (guix build-system trivial)
   #:use-module (gnu packages)
   #:use-module (gnu packages admin)
@@ -77,6 +78,40 @@ (define-module (gnu packages firmware)
   #:use-module (gnu packages xml)
   #:use-module (ice-9 match))
 
+(define-public asahi-fwextract
+  (package
+    (name "asahi-fwextract")
+    (version "0.5.3")
+    (source
+     (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://github.com/AsahiLinux/asahi-installer")
+             (commit (string-append "v" version))))
+       (file-name (git-file-name name version))
+       (sha256
+        (base32 "1kj9ycy3f34fzm9bnirlcw9zm2sgipwrqzphdg5k099rbjbc7zmj"))))
+    (build-system python-build-system)
+    (arguments
+     `(#:phases
+       (modify-phases %standard-phases
+         (add-after 'unpack 'remove-vendor
+           (lambda* (#:key outputs #:allow-other-keys)
+             (delete-file-recursively "vendor")))
+         (add-after 'install 'wrap-program
+           (lambda* (#:key inputs outputs #:allow-other-keys)
+             (let ((out (assoc-ref outputs "out")))
+               (wrap-program (string-append out "/bin/asahi-fwextract")
+                 `("LD_LIBRARY_PATH" ":" prefix
+                   (,(string-append (assoc-ref inputs "lzfse") "/lib"))))))))))
+    (inputs (list lzfse))
+    (home-page "https://github.com/AsahiLinux/asahi-installer")
+    (synopsis "Asahi Linux firmware extractor")
+    (description "The Asahi Linux firmware extractor transform the firmware archive
+provided by the Asahi Linux installer into a manifest and CPIO and TAR
+archives that are compatible with the Linux kernel.")
+    (license license:expat)))
+
 (define-public ath9k-htc-firmware
   (package
     (name "ath9k-htc-firmware")
-- 
2.39.1