Subject: [PATCH v3 4/7] gnu: Add asahi-fwextract.

From: Roman Scherer <[email-masked]>
Date: Sun, 5 Mar 2023 17:14:00 +0100

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

diff --git a/gnu/packages/firmware.scm b/gnu/packages/firmware.scm
index a876aa727a..0d52349240 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 pyproject)
   #:use-module (guix build-system trivial)
   #:use-module (gnu packages)
   #:use-module (gnu packages admin)
@@ -77,6 +78,47 @@ (define-module (gnu packages firmware)
   #:use-module (gnu packages xml)
   #:use-module (ice-9 match))
 
+(define-public asahi-fwextract
+  (let ((commit "0ac64c9ce1c460f4576162a82d239d7e8688a79e"))
+    (package
+      (name "asahi-fwextract")
+      (version (git-version "0.5.3" "0" commit))
+      (source
+       (origin
+         (method git-fetch)
+         (uri (git-reference
+               (url "https://github.com/AsahiLinux/asahi-installer")
+               (commit commit)))
+         (file-name (git-file-name name version))
+         (sha256
+          (base32 "1kj9ycy3f34fzm9bnirlcw9zm2sgipwrqzphdg5k099rbjbc7zmj"))
+         (modules '((guix build utils)))
+         (snippet
+          '(begin
+             (delete-file-recursively "vendor")
+             (with-output-to-file "entry_points.txt"
+               (lambda ()
+                 (format #t "[console_scripts]\n")
+                 (format #t "asahi-fwextract = asahi_firmware.update:main")))))))
+      (build-system pyproject-build-system)
+      (arguments
+       (list
+        #:phases
+        #~(modify-phases %standard-phases
+            (add-after 'create-entrypoints '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