! 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.
This commit is contained in:
Petr Hodina 2022-08-30 14:04:09 +02:00
parent 9cf7157308
commit 523cd518cf

View File

@ -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)
@ -205,33 +208,154 @@ advanced 3D.")))
(modules '((guix build utils)
(ice-9 ftw)
(srfi srfi-26)))
(snippet
'(begin
(snippet '(begin
(for-each (lambda (name)
(delete-file-recursively name))
`("documentation" "extra" ".github" "hardfp" "modules" "opt" "README.md"
`("documentation" "extra" ".github"
"modules" "README.md"
,@(map (lambda (name)
(string-append "boot/" name))
(scandir "boot" (cut (file-name-predicate "^(kernel.*|COPYING\\.linux)$") <> #f)))))))
(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)
(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
(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"))))))
(license (list gpl2
(nonfree (string-append "file://boot/LICENCE.broadcom"))
(nonfree (string-append "file://opt/vc/LICENCE"))))))
(define-public atheros-firmware
(package