From 523cd518cf896fd6a4b595fc9b6fb1aee265cd11 Mon Sep 17 00:00:00 2001 From: Petr Hodina Date: Tue, 30 Aug 2022 14:04:09 +0200 Subject: [PATCH] ! nongnu: raspberrypi-firmware: Change build system to binary. * nongnu/packages/lnux.scm (raspberrypi-firmware): [build-system]: Change to binary-build-system. [source]: Keep 'opt' and 'hardfp' directories. [outputs]: Add 'opt' and 'opt-fp'. [arguments]: Replace install and patchelf phases. --- nongnu/packages/linux.scm | 196 +++++++++++++++++++++++++++++++------- 1 file changed, 160 insertions(+), 36 deletions(-) diff --git a/nongnu/packages/linux.scm b/nongnu/packages/linux.scm index 347ad25..54d6fa3 100644 --- a/nongnu/packages/linux.scm +++ b/nongnu/packages/linux.scm @@ -33,7 +33,9 @@ (define-module (nongnu packages linux) #:use-module (gnu packages) #:use-module (gnu packages base) + #:use-module (gnu packages bootstrap) #:use-module (gnu packages compression) + #:use-module (gnu packages gcc) #:use-module (gnu packages linux) #:use-module (guix licenses) #:use-module (guix packages) @@ -44,6 +46,7 @@ #:use-module (guix build-system copy) #:use-module (guix build-system gnu) #:use-module (guix build-system linux-module) + #:use-module (nonguix build-system binary) #:use-module (guix build-system trivial) #:use-module (ice-9 match) #:use-module (nonguix licenses) @@ -194,44 +197,165 @@ kernel module to run properly and support features like hibernation and advanced 3D."))) (define-public raspberrypi-firmware -(package - (name "raspberrypi-firmware") - (version "1.20220331") - (source (origin - (method git-fetch) - (uri (git-reference - (url "https://github.com/raspberrypi/firmware") - (commit version))) - (modules '((guix build utils) - (ice-9 ftw) - (srfi srfi-26))) - (snippet - '(begin - (for-each (lambda (name) - (delete-file-recursively name)) - `("documentation" "extra" ".github" "hardfp" "modules" "opt" "README.md" - ,@(map (lambda (name) - (string-append "boot/" name)) - (scandir "boot" (cut (file-name-predicate "^(kernel.*|COPYING\\.linux)$") <> #f))))))) - (file-name (git-file-name name version)) - (sha256 - (base32 - "1hd1vkghkgdlmw04fap28f68nsf7d7i8dq6h9r4xa0h9y4f6j6ag")))) + (package + (name "raspberrypi-firmware") + (version "1.20220331") + (source (origin + (method git-fetch) + (uri (git-reference + (url "https://github.com/raspberrypi/firmware") + (commit version))) + (modules '((guix build utils) + (ice-9 ftw) + (srfi srfi-26))) + (snippet '(begin + (for-each (lambda (name) + (delete-file-recursively name)) + `("documentation" "extra" ".github" + "modules" "README.md" + ,@(map (lambda (name) + (string-append "boot/" name)) + (scandir "boot" + (cut (file-name-predicate + "^(kernel.*|COPYING\\.linux)$") + <> #f))))))) + (file-name (git-file-name name version)) + (sha256 + (base32 + "1hd1vkghkgdlmw04fap28f68nsf7d7i8dq6h9r4xa0h9y4f6j6ag")))) + (build-system binary-build-system) + (outputs '("out" "opt" "opt-fp")) (arguments - '(#:install-plan - '(("boot/" ".")))) - (build-system copy-build-system) - (synopsis "Firmware for the Raspberry Pi boards") - (description "Pre-compiled binaries of the current Raspberry Pi kernel + (list #:phases #~(modify-phases %standard-phases + (delete 'validate-runpath) + (replace 'install + (lambda* _ + (copy-recursively "boot/" + #$output) + (copy-recursively "opt/vc" + (ungexp output "opt")) + (copy-recursively "hardfp/opt/vc" + (ungexp output "opt-fp")))) + (replace 'patchelf + (lambda* _ + (use-modules (ice-9 ftw) + (ice-9 regex) + (srfi srfi-1) + (ice-9 textual-ports)) + (let* ((ld-so (string-append #$glibc + #$(glibc-dynamic-linker))) + (bin (string-append (getcwd) "/opt/vc/bin")) + (bin-fp (string-append (getcwd) + "/hardfp/opt/vc/bin")) + (lib-so (string-append (getcwd) + "/opt/vc/lib")) + (lib-fp-so (string-append (getcwd) + "/hardfp/opt/vc/lib")) + (lib (string-append (ungexp output "opt") + "/lib")) + (lib-fp (string-append (ungexp output + "opt-fp") + "/lib")) + (rpath (string-join (list "$ORIGIN" + (string-append #$glibc + "/lib") + (string-append (ungexp + output + "opt") + "/lib")) ":")) + (rpath-bin (string-join (list (string-append #$glibc + "/lib") + (string-append + (ungexp + output + "opt") + "/lib")) ":")) + (rpath-fp (string-join (list "$ORIGIN" + (string-append #$glibc + "/lib") + (string-append + (ungexp + output + "opt-fp") + "/lib")) ":"))) + (for-each (lambda (file) + (display (string-append bin "/" file + " +")) + (if (member file + '("dtoverlay-post" + "dtoverlay-pre")) + '() + '((invoke "patchelf" + "--set-rpath" + rpath-bin + (string-append bin "/" + file))))) + (scandir bin + (lambda (name) + (string-match "^[^.].*$" + name)))) + (for-each (lambda (file) + (if (member file + '("dtoverlay-post" + "dtoverlay-pre")) + '() + '((invoke "patchelf" + "--set-rpath" rpath-fp + (string-append bin-fp + "/" + file))))) + (scandir bin-fp + (lambda (name) + (string-match "^[^.].*$" + name)))) + (for-each (lambda (file) + (invoke "patchelf" "--set-rpath" + rpath + (string-append lib-so "/" + file))) + (scandir lib-so + (lambda (name) + (string-contains name ".so")))) + (for-each (lambda (file) + (invoke "patchelf" "--set-rpath" + rpath + (string-append lib-so + "/plugins/" + file))) + (scandir (string-append lib-so + "/plugins") + (lambda (name) + (string-contains name ".so")))) + (for-each (lambda (file) + (invoke "patchelf" "--set-rpath" + rpath-fp + (string-append lib-fp-so "/" + file))) + (scandir lib-fp-so + (lambda (name) + (string-contains name ".so")))) + (for-each (lambda (file) + (invoke "patchelf" "--set-rpath" + rpath-fp + (string-append lib-fp-so + "/plugins/" + file))) + (scandir (string-append lib-fp-so + "/plugins") + (lambda (name) + (string-contains name ".so")))))))))) + (inputs (list glibc + `(,gcc "lib"))) + (synopsis "Firmware for the Raspberry Pi boards") + (description + "Pre-compiled binaries of the current Raspberry Pi kernel and modules, userspace libraries, and bootloader/GPU firmware.") - (home-page "https://github.com/raspberrypi/firmware") - (supported-systems '("armhf-linux" "aarch64-linux")) - (license - (list gpl2 - (nonfree - (string-append "file://boot/LICENCE.broadcom")) - (nonfree - (string-append "file://opt/vc/LICENCE")))))) + (home-page "https://github.com/raspberrypi/firmware") + (supported-systems '("armhf-linux" "aarch64-linux")) + (license (list gpl2 + (nonfree (string-append "file://boot/LICENCE.broadcom")) + (nonfree (string-append "file://opt/vc/LICENCE")))))) (define-public atheros-firmware (package