Subject: [bug#77148] [PATCH 3/9] gnu: Add skiboot-qemu.

From: Efraim Flashner <[email-masked]>
Date: Fri, 21 Mar 2025 10:53:04 +0200

* gnu/packages/firmware.scm (skiboot-qemu): New variable.

Change-Id: Ieb90171de7e74a4617e2c50b62c317b152d3a0c5
---
 gnu/packages/firmware.scm | 65 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 65 insertions(+)

diff --git a/gnu/packages/firmware.scm b/gnu/packages/firmware.scm
index 88ee0f5777c..35bfa6425ac 100644
--- a/gnu/packages/firmware.scm
+++ b/gnu/packages/firmware.scm
@@ -55,6 +55,7 @@ (define-module (gnu packages firmware)
   #:use-module (gnu packages base)
   #:use-module (gnu packages bash)
   #:use-module (gnu packages bison)
+  #:use-module (gnu packages bootloaders)
   #:use-module (gnu packages check)
   #:use-module (gnu packages cmake)
   #:use-module (gnu packages compression)
@@ -830,6 +831,70 @@ (define-public sgabios
 after an operating system boots.")
       (license license:asl2.0))))
 
+(define-public skiboot-qemu
+  (package
+    (name "skiboot")
+    (version "7.1")
+    (source (origin
+              (method git-fetch)
+              (uri (git-reference
+                    (url "https://github.com/open-power/skiboot")
+                    (commit (string-append "v" version))))
+              (file-name (git-file-name name version))
+              (sha256
+               (base32
+                "1gpgviphai9biw6cmq1bl50i1419b0q6n5c8vjmq7zx3a46mjwqv"))))
+    (build-system gnu-build-system)
+    (arguments
+     (list #:make-flags
+           #~(list (string-append "SKIBOOT_VERSION=" #$version)
+                   #$@(if (target-little-endian?)
+                          #~("HOSTEND=LITTLE")
+                          #~("HOSTEND=BIG"))
+                   "USE_VALGRIND=0")
+           #:target #f              ; Package produces firmware.
+           #:parallel-tests? #f
+           #:phases
+           #~(modify-phases %standard-phases
+               (delete 'configure)  ; No configure script.
+               (add-after 'unpack 'patch-files
+                 (lambda _
+                   (substitute* "external/common/get_arch.sh"
+                     (("/bin/sh") (which "sh")))))
+               (add-before 'check 'pre-check
+                 (lambda _
+                   (delete-file "external/pflash/test/tests/01-info")
+                   (substitute* "libc/test/run-time.c"
+                     (("/usr/include/assert\\.h")
+                      (search-input-file %build-inputs "include/assert.h")))
+                   (substitute* "external/test/test.sh"
+                     (("/bin/true") (which "true")))
+                   (substitute* "libstb/secvar/test/Makefile.check"
+                     (("check: secvar-check") "check:\n"))))
+               (replace 'install
+                 (lambda _
+                   (install-file "skiboot.lid"
+                                 (string-append #$output "/share/qemu")))))))
+    (native-inputs
+     (append
+       (if (not (string-prefix? "powerpc64" (%current-system)))
+           (list (cross-gcc "powerpc64-linux-gnu")
+                 (cross-binutils "powerpc64-linux-gnu")))
+       (list dtc perl)))
+    (inputs (list openssl))
+    (home-page "https://github.com/open-power/skiboot/")
+    (synopsis "OPAL boot and runtime firmware for POWER")
+    (description
+     "@acronym{OPAL, OpenPower Abstraction Layer} firmware comes in several parts.
+The OPAL image is three parts:
+@enumerate
+@item skiboot (includes OPAL runtime services)
+@item skiroot - the bootloader environment, with the kernel and initramfs
+(containing the petitboot bootloader)
+@end enumerate
+They may be all part of one payload or three separate images.")
+    (license license:asl2.0)))
+
 (define-public slof-qemu
   (package
     (name "slof")
-- 
Efraim Flashner   <[email-masked]>   אפרים פלשנר
GPG key = A28B F40C 3E55 1372 662D  14F7 41AA E7DC CA3D 8351
Confidentiality cannot be guaranteed on emails sent or received unencrypted