nongnu: Use provided install script in linux-firmware subpackages.

A simple copy is not enough, since some firmware files are just links. The
copy-firmware.sh script invoked by make install does the right thing, based on
File: and Link: entries in WHENCE.

Add a helper function select-firmware which modifies the WHENCE list to skip
the files not matching the given regex. Use it to specify the files to install
in linux-firmware subpackages, then just invoke make install as usual.

* nongnu/packages/linux.scm (amdgpu-firmware, atheros-firmware,
ibt-hw-firmware, iwlwifi-firmware, radeon-firmware, realtek-firmware,
amd-microcode)[arguments]: Drop custom 'install phase. Add 'select-firmware
phase to remove unneeded entries from the WHENCE file.
(select-firmware): New helper function.

Signed-off-by: Jonathan Brielmaier <jonathan.brielmaier@web.de>
This commit is contained in:
Timotej Lazar 2021-08-21 00:15:51 +02:00 committed by Jonathan Brielmaier
parent 9bb89eff12
commit a031e2cde3
No known key found for this signature in database
GPG key ID: ECFC83988B4E4B9F

View file

@ -119,25 +119,25 @@ if your hardware is supported by one of the smaller firmware packages.")
(string-append "https://git.kernel.org/pub/scm/linux/kernel/git/" (string-append "https://git.kernel.org/pub/scm/linux/kernel/git/"
"firmware/linux-firmware.git/plain/WHENCE"))))) "firmware/linux-firmware.git/plain/WHENCE")))))
(define (select-firmware keep)
"Modify linux-firmware copy list to retain only files matching KEEP regex."
`(lambda _
(use-modules (ice-9 regex))
(substitute* "WHENCE"
(("^(File|Link): *([^ ]*)(.*)" _ type file rest)
(string-append (if (string-match ,keep file) type "Skip") ": " file rest)))))
(define-public amdgpu-firmware (define-public amdgpu-firmware
(package (package
(inherit linux-firmware) (inherit linux-firmware)
(name "amdgpu-firmware") (name "amdgpu-firmware")
(build-system gnu-build-system)
(arguments (arguments
`(#:tests? #f `(#:license-file-regexp "LICENSE.amdgpu"
#:license-file-regexp "LICENSE.amdgpu" ,@(substitute-keyword-arguments (package-arguments linux-firmware)
#:phases ((#:phases phases)
(modify-phases %standard-phases `(modify-phases ,phases
(replace 'install (add-after 'unpack 'select-firmware
(lambda* (#:key outputs #:allow-other-keys) ,(select-firmware "^amdgpu/")))))))
(let* ((out (assoc-ref outputs "out"))
(fw-dir (string-append out "/lib/firmware"))
(bin-dir (string-append fw-dir "/amdgpu")))
(mkdir-p bin-dir)
(copy-recursively "./amdgpu" bin-dir)
#t)))
(delete 'validate-runpath))))
(home-page "http://support.amd.com/en-us/download/linux") (home-page "http://support.amd.com/en-us/download/linux")
(synopsis "Nonfree firmware for AMD graphics chips") (synopsis "Nonfree firmware for AMD graphics chips")
(description "Nonfree firmware for AMD graphics chips. While most AMD (description "Nonfree firmware for AMD graphics chips. While most AMD
@ -155,19 +155,12 @@ advanced 3D.")
(inherit amdgpu-firmware) (inherit amdgpu-firmware)
(name "radeon-firmware") (name "radeon-firmware")
(arguments (arguments
`(#:tests? #f `(#:license-file-regexp "LICENSE.radeon"
#:license-file-regexp "LICENSE.radeon" ,@(substitute-keyword-arguments (package-arguments linux-firmware)
#:phases ((#:phases phases)
(modify-phases %standard-phases `(modify-phases ,phases
(replace 'install (add-after 'unpack 'select-firmware
(lambda* (#:key outputs #:allow-other-keys) ,(select-firmware "^radeon/")))))))
(let* ((out (assoc-ref outputs "out"))
(fw-dir (string-append out "/lib/firmware"))
(bin-dir (string-append fw-dir "/radeon")))
(mkdir-p bin-dir)
(copy-recursively "./radeon" bin-dir)
#t)))
(delete 'validate-runpath))))
(synopsis "Nonfree firmware for older AMD graphics chips") (synopsis "Nonfree firmware for older AMD graphics chips")
(description "Nonfree firmware for AMD graphics chips. While most AMD (description "Nonfree firmware for AMD graphics chips. While most AMD
graphics cards can be run with the free Mesa, some cards require a nonfree graphics cards can be run with the free Mesa, some cards require a nonfree
@ -204,30 +197,13 @@ and modules, userspace libraries, and bootloader/GPU firmware.")
(package (package
(inherit linux-firmware) (inherit linux-firmware)
(name "atheros-firmware") (name "atheros-firmware")
(build-system gnu-build-system)
(arguments (arguments
`(#:tests? #f `(#:license-file-regexp "LICEN[CS]E.*[Aa]th"
#:license-file-regexp ,@(substitute-keyword-arguments (package-arguments linux-firmware)
"LICEN[CS]E.*[Aa]th" ((#:phases phases)
#:phases `(modify-phases ,phases
(modify-phases %standard-phases (add-after 'unpack 'select-firmware
(replace 'install ,(select-firmware "^(ar[3579]|ath[1369]|htc_[79]|qca/|wil6)")))))))
(lambda* (#:key outputs #:allow-other-keys)
(let* ((out (assoc-ref outputs "out"))
(fw-dir (string-append out "/lib/firmware"))
(bin-dir (string-append fw-dir "/ar3k")))
(for-each (lambda (dir)
(let ((bin-dir (string-append fw-dir "/" dir)))
(mkdir-p bin-dir)
(copy-recursively dir bin-dir)))
'("ar3k" "ath6k" "ath9k_htc" "ath10k" "qca"))
(for-each (lambda (file)
(install-file file fw-dir))
(append (find-files "." "^a(r|th).*\\.(bin|fw)$")
(find-files "." "^htc_.*\\.fw$")
(find-files "." "^wil.*\\.(brd|fw)$")))
#t)))
(delete 'validate-runpath))))
(synopsis "Nonfree firmware blobs for Atheros wireless cards") (synopsis "Nonfree firmware blobs for Atheros wireless cards")
(description "Nonfree firmware blobs for Atheros wireless cards. This (description "Nonfree firmware blobs for Atheros wireless cards. This
package contains nonfree firmware for the following chips: package contains nonfree firmware for the following chips:
@ -398,19 +374,12 @@ WLAN.TF.2.1-00021-QCARMSWP-1 (ath10k/QCA9377/hw1.0/firmware-6.bin)
(inherit linux-firmware) (inherit linux-firmware)
(name "ibt-hw-firmware") (name "ibt-hw-firmware")
(arguments (arguments
`(#:tests? #f `(#:license-file-regexp "LICENCE.ibt_firmware"
#:license-file-regexp "LICENCE.ibt_firmware" ,@(substitute-keyword-arguments (package-arguments linux-firmware)
#:phases ((#:phases phases)
(modify-phases %standard-phases `(modify-phases ,phases
(replace 'install (add-after 'unpack 'select-firmware
(lambda* (#:key outputs #:allow-other-keys) ,(select-firmware "^intel/ibt-")))))))
(let* ((out (assoc-ref outputs "out"))
(fw-dir (string-append out "/lib/firmware/intel")))
(for-each (lambda (file)
(install-file file fw-dir))
(find-files "intel" "ibt-.*\\.(bseq|ddc|sfi)$"))
#t)))
(delete 'validate-runpath))))
(home-page "http://www.intel.com/support/wireless/wlan/sb/CS-016675.htm") (home-page "http://www.intel.com/support/wireless/wlan/sb/CS-016675.htm")
(synopsis "Non-free firmware for Intel bluetooth chips") (synopsis "Non-free firmware for Intel bluetooth chips")
(description "This firmware is required by the btintel kernel module to (description "This firmware is required by the btintel kernel module to
@ -425,21 +394,13 @@ laptops).")
(package (package
(inherit linux-firmware) (inherit linux-firmware)
(name "iwlwifi-firmware") (name "iwlwifi-firmware")
(build-system gnu-build-system)
(arguments (arguments
`(#:tests? #f `(#:license-file-regexp "LICENCE.iwlwifi_firmware"
#:license-file-regexp "LICENCE.iwlwifi_firmware" ,@(substitute-keyword-arguments (package-arguments linux-firmware)
#:phases ((#:phases phases)
(modify-phases %standard-phases `(modify-phases ,phases
(replace 'install (add-after 'unpack 'select-firmware
(lambda* (#:key outputs #:allow-other-keys) ,(select-firmware "^iwlwifi-")))))))
(let* ((out (assoc-ref outputs "out"))
(fw-dir (string-append out "/lib/firmware")))
(for-each (lambda (file)
(install-file file fw-dir))
(find-files "." "iwlwifi-.*\\.ucode$"))
#t)))
(delete 'validate-runpath))))
(home-page "https://wireless.wiki.kernel.org/en/users/drivers/iwlwifi") (home-page "https://wireless.wiki.kernel.org/en/users/drivers/iwlwifi")
(synopsis "Nonfree firmware for Intel wifi chips") (synopsis "Nonfree firmware for Intel wifi chips")
(description "The proprietary iwlwifi kernel module is required by many (description "The proprietary iwlwifi kernel module is required by many
@ -454,23 +415,13 @@ support for 5GHz and 802.11ac, among others.")
(package (package
(inherit linux-firmware) (inherit linux-firmware)
(name "realtek-firmware") (name "realtek-firmware")
(build-system gnu-build-system)
(arguments (arguments
`(#:tests? #f `(#:license-file-regexp "LICENCE.rtlwifi_firmware.txt"
#:license-file-regexp "LICENCE.rtlwifi_firmware.txt" ,@(substitute-keyword-arguments (package-arguments linux-firmware)
#:phases ((#:phases phases)
(modify-phases %standard-phases `(modify-phases ,phases
(replace 'install (add-after 'unpack 'select-firmware
(lambda* (#:key outputs #:allow-other-keys) ,(select-firmware "^(rtlwifi|rtl_nic|rtl_bt)/")))))))
(let* ((out (assoc-ref outputs "out"))
(fw-dir (string-append out "/lib/firmware")))
(for-each (lambda (dir)
(let ((bin-dir (string-append fw-dir "/" dir)))
(mkdir-p bin-dir)
(copy-recursively dir bin-dir)))
'("rtlwifi" "rtl_nic" "rtl_bt"))
#t)))
(delete 'validate-runpath))))
(home-page "https://wireless.wiki.kernel.org/en/users/drivers/rtl819x") (home-page "https://wireless.wiki.kernel.org/en/users/drivers/rtl819x")
(synopsis "Nonfree firmware for Realtek ethernet, wifi, and bluetooth chips") (synopsis "Nonfree firmware for Realtek ethernet, wifi, and bluetooth chips")
(description (description
@ -820,22 +771,13 @@ your CPU.")
(package (package
(inherit linux-firmware) (inherit linux-firmware)
(name "amd-microcode") (name "amd-microcode")
(build-system gnu-build-system)
(arguments (arguments
`(#:tests? #f `(#:license-file-regexp "LICENSE.amd-ucode"
#:license-file-regexp "LICENSE.amd-ucode" ,@(substitute-keyword-arguments (package-arguments linux-firmware)
#:phases ((#:phases phases)
(modify-phases %standard-phases `(modify-phases ,phases
(replace 'install (add-after 'unpack 'select-firmware
(lambda* (#:key outputs #:allow-other-keys) ,(select-firmware "^amd-ucode/")))))))
(let* ((out (assoc-ref outputs "out"))
(fw-dir (string-append out "/lib/firmware"))
(bin-dir (string-append fw-dir "/amd-ucode")))
(for-each (lambda (file)
(install-file file bin-dir))
(find-files "amd-ucode" "^microcode_amd.*\\.bin$"))
#t)))
(delete 'validate-runpath))))
(synopsis "Processor microcode firmware for AMD CPUs") (synopsis "Processor microcode firmware for AMD CPUs")
(description "Updated system processor microcode for AMD x86-64 (description "Updated system processor microcode for AMD x86-64
processors. AMD releases microcode updates to correct processor behavior as processors. AMD releases microcode updates to correct processor behavior as