Archived
1
0
Fork 0

gnu: xen: Update package style.

* gnu/packages/virtualization.scm (xen)
[arguments]: Rewrite as G-expressions.  Use SEARCH-INPUT-FILE whenever
possible.  Put SUBSTITUTE* features to use.
[native-inputs, inputs]: Remove input labels.
This commit is contained in:
Tobias Geerinckx-Rice 2023-09-24 02:00:00 +02:00
parent 11f1d72dd8
commit 91097713ee
No known key found for this signature in database
GPG key ID: 0DB0FF884F556D79

View file

@ -2291,164 +2291,150 @@ DOS or Microsoft Windows.")
"1cdzpxbihkdn4za8ly0lgkbxrafjzbxjflhfn83kyg4bam1vv7mn")))) "1cdzpxbihkdn4za8ly0lgkbxrafjzbxjflhfn83kyg4bam1vv7mn"))))
(build-system gnu-build-system) (build-system gnu-build-system)
(arguments (arguments
`(#:configure-flags (list
(list "--enable-rpath" #:configure-flags
"--disable-qemu-traditional" ; It tries to do "git clone" #~(list "--enable-rpath"
"--disable-rombios" ; would try to "git clone" via etherboot. "--disable-qemu-traditional" ; tries to "git clone"
;; TODO: Re-enable stubdom (it's "more secure" to use it). "--disable-rombios" ; tries to "git clone" via etherboot
"--disable-stubdom" ; tries to "git clone" old patched newlib. ;; TODO: Re-enable stubdom (it's "more secure" to use it).
(string-append "--with-initddir=" "--disable-stubdom" ; tries to "git clone" old patched newlib
(assoc-ref %outputs "out") (string-append "--with-initddir=" #$output "/etc/init.d")
"/etc/init.d") (string-append "--with-system-qemu="
(string-append "--with-system-qemu=" (search-input-file %build-inputs
(assoc-ref %build-inputs "qemu") "bin/qemu-system-i386"))
"/bin/qemu-system-i386") (string-append "--with-system-seabios="
(string-append "--with-system-seabios=" (search-input-file %build-inputs
(assoc-ref %build-inputs "seabios") "share/firmware/bios.bin"))
"/share/firmware/bios.bin") (string-append "--with-system-ovmf="
(string-append "--with-system-ovmf=" (search-input-file %build-inputs
(assoc-ref %build-inputs "ovmf") "share/firmware/ovmf_ia32.bin")))
"/share/firmware/ovmf_ia32.bin")) #:make-flags
#:make-flags (list "-j" "1" #~(list "-j" "1"
"XEN_BUILD_DATE=Thu Jan 1 01:00:01 CET 1970" "XEN_BUILD_DATE=Thu Jan 1 01:00:01 CET 1970"
"XEN_BUILD_TIME=01:00:01" "XEN_BUILD_TIME=01:00:01"
"XEN_BUILD_HOST=" "XEN_BUILD_HOST="
"ETHERBOOT_NICS=" "ETHERBOOT_NICS="
"SMBIOS_REL_DATE=01/01/1970" "SMBIOS_REL_DATE=01/01/1970"
"VGABIOS_REL_DATE=01 Jan 1970" "VGABIOS_REL_DATE=01 Jan 1970"
; QEMU_TRADITIONAL_LOC ;; QEMU_TRADITIONAL_LOC
; QEMU_UPSTREAM_LOC ;; QEMU_UPSTREAM_LOC
"SYSCONFIG_DIR=/tmp/etc/default" "SYSCONFIG_DIR=/tmp/etc/default"
(string-append "BASH_COMPLETION_DIR=" (string-append "BASH_COMPLETION_DIR=" #$output
(assoc-ref %outputs "out") "/etc/bash_completion.d")
"/etc/bash_completion.d") (string-append "BOOT_DIR=" #$output "/boot")
(string-append "BOOT_DIR=" (string-append "DEBUG_DIR=" #$output "/lib/debug")
(assoc-ref %outputs "out") (string-append "EFI_DIR=" #$output "/lib/efi")
"/boot") "MINIOS_UPSTREAM_URL=")
(string-append "DEBUG_DIR=" #:test-target "test"
(assoc-ref %outputs "out") #:phases
"/lib/debug") #~(modify-phases %standard-phases
(string-append "EFI_DIR=" (add-after 'unpack 'unpack-mini-os
(assoc-ref %outputs "out") (lambda* (#:key inputs #:allow-other-keys)
"/lib/efi") ; TODO lib64 ? (let ((mini-os (dirname (search-input-file inputs "minios.mk"))))
"MINIOS_UPSTREAM_URL=" (copy-recursively mini-os "extras/mini-os"))))
;(string-append "DISTDIR=" (add-after 'unpack-mini-os 'patch
; (assoc-ref %outputs "out")) (lambda* (#:key inputs #:allow-other-keys)
) (substitute* "tools/firmware/Rules.mk"
#:test-target "test" (("override XEN_TARGET_ARCH = x86_32" match)
#:phases (string-append match "\noverride CC = "
(modify-phases %standard-phases (search-input-file inputs
(add-after 'unpack 'unpack-mini-os "bin/i686-linux-gnu-gcc")))
(lambda* (#:key inputs #:allow-other-keys) (("^CFLAGS =$" match)
(copy-recursively (assoc-ref inputs "mini-os") "extras/mini-os"))) (string-append match " -I" (assoc-ref inputs "cross-libc")
(add-after 'unpack-mini-os 'patch "/include\n")))
(lambda* (#:key inputs outputs #:allow-other-keys) (substitute* "config/x86_32.mk"
(substitute* "tools/firmware/Rules.mk" (("(CFLAGS += )-m32 -march=i686" _ match)
(("override XEN_TARGET_ARCH = x86_32") (string-append match "-march=i686 -I"
(string-append "override XEN_TARGET_ARCH = x86_32 (assoc-ref inputs "cross-libc") "/include")))
override CC = " (assoc-ref inputs "cross-gcc") "/bin/i686-linux-gnu-gcc")) ;; /var is not in /gnu/store, so don't try to create it.
(("^CFLAGS =$") (substitute* '("tools/Makefile"
(string-append "CFLAGS=-I" (assoc-ref inputs "cross-libc") "tools/xenstore/Makefile"
"/include\n"))) "tools/xenpaging/Makefile")
(substitute* "config/x86_32.mk" (("\\$\\(INSTALL_DIR\\) .*XEN_(DUMP|LOG|RUN|LIB|PAGING)_DIR.*")
(("CFLAGS += -m32 -march=i686") "\n")
(string-append "CFLAGS += -march=i686 -I" (("\\$\\(INSTALL_DIR\\) .*XEN_(RUN|LIB)_STORED.*") "\n"))
(assoc-ref inputs "cross-libc") ;; Prevent xen from creating /etc.
"/include"))) (substitute* "tools/examples/Makefile"
;; /var is not in /gnu/store , so don't try to create it. ((" install-(configs|readmes)") ""))
(substitute* '("tools/Makefile" ;; Set rpath.
"tools/xenstore/Makefile" (substitute* "tools/pygrub/setup.py"
"tools/xenpaging/Makefile") (("library_dirs =" match)
(("\\$\\(INSTALL_DIR\\) .*XEN_(DUMP|LOG|RUN|LIB|PAGING)_DIR.*") ;; TODO: extra_link_args = ['-Wl,-rpath=/opt/foo'],
"\n") (string-append "runtime_library_dirs = ['" #$output "/lib'],"
(("\\$\\(INSTALL_DIR\\) .*XEN_(RUN|LIB)_STORED.*") "\n" match)))))
"\n")) (add-before 'configure 'patch-xen-script-directory
;; Prevent xen from creating /etc . (lambda _
(substitute* "tools/examples/Makefile" (substitute* '("configure"
((" install-readmes") "") "tools/configure"
((" install-configs") "")) "docs/configure")
;; Set rpath. (("(XEN_SCRIPT_DIR=).*" _ match)
(substitute* "tools/pygrub/setup.py" (string-append match #$output "/etc/xen/scripts")))))
(("library_dirs =") (add-before 'configure 'set-environment-up
; TODO: extra_link_args = ['-Wl,-rpath=/opt/foo'], (lambda* (#:key make-flags #:allow-other-keys)
(string-append "runtime_library_dirs = ['" (define (cross? x)
(assoc-ref outputs "out") (string-contains x "cross-i686-linux"))
"/lib'],\nlibrary_dirs ="))))) (define (filter-environment! filter-predicate
(add-before 'configure 'patch-xen-script-directory environment-variable-names)
(lambda* (#:key outputs #:allow-other-keys) (for-each
(substitute* '("configure" (lambda (env-name)
"tools/configure" (let* ((env-value (getenv env-name))
"docs/configure") (search-path (search-path-as-string->list env-value))
(("XEN_SCRIPT_DIR=.*") (new-search-path (filter filter-predicate
(string-append "XEN_SCRIPT_DIR=" search-path))
(assoc-ref outputs "out") (new-env-value (list->search-path-as-string
"/etc/xen/scripts"))))) new-search-path ":")))
(add-before 'configure 'set-environment-up (setenv env-name new-env-value)))
(lambda* (#:key make-flags #:allow-other-keys) environment-variable-names))
(define (cross? x) (setenv "CROSS_C_INCLUDE_PATH" (getenv "C_INCLUDE_PATH"))
(string-contains x "cross-i686-linux")) (setenv "CROSS_CPLUS_INCLUDE_PATH" (getenv "CPLUS_INCLUDE_PATH"))
(define (filter-environment! filter-predicate (setenv "CROSS_LIBRARY_PATH" (getenv "LIBRARY_PATH"))
environment-variable-names) (filter-environment! cross?
(for-each '("CROSS_C_INCLUDE_PATH"
(lambda (env-name) "CROSS_CPLUS_INCLUDE_PATH"
(let* ((env-value (getenv env-name)) "CROSS_LIBRARY_PATH"))
(search-path (search-path-as-string->list env-value)) (filter-environment! (lambda (e) (not (cross? e)))
(new-search-path (filter filter-predicate '("C_INCLUDE_PATH" "CPLUS_INCLUDE_PATH"
search-path)) "LIBRARY_PATH"))
(new-env-value (list->search-path-as-string ;; Guix tries to be helpful and automatically adds
new-search-path ":"))) ;; mini-os-git-checkout/include to the include path,
(setenv env-name new-env-value))) ;; but actually we don't want it to be there (yet).
environment-variable-names)) (filter-environment! (lambda (e)
(setenv "CROSS_C_INCLUDE_PATH" (getenv "C_INCLUDE_PATH")) (not
(setenv "CROSS_CPLUS_INCLUDE_PATH" (getenv "CPLUS_INCLUDE_PATH")) (string-contains e
(setenv "CROSS_LIBRARY_PATH" (getenv "LIBRARY_PATH")) "mini-os-git-checkout")))
(filter-environment! cross? '("C_INCLUDE_PATH" "CPLUS_INCLUDE_PATH"
'("CROSS_C_INCLUDE_PATH" "CROSS_CPLUS_INCLUDE_PATH" "LIBRARY_PATH"))
"CROSS_LIBRARY_PATH")) (setenv "EFI_VENDOR" "guix")))
(filter-environment! (lambda (e) (not (cross? e))) (replace 'build
'("C_INCLUDE_PATH" "CPLUS_INCLUDE_PATH" (lambda* (#:key make-flags #:allow-other-keys)
"LIBRARY_PATH")) (apply invoke "make" "world" make-flags))))))
;; Guix tries to be helpful and automatically adds
;; mini-os-git-checkout/include to the include path,
;; but actually we don't want it to be there (yet).
(filter-environment! (lambda (e)
(not
(string-contains e
"mini-os-git-checkout")))
'("C_INCLUDE_PATH" "CPLUS_INCLUDE_PATH"
"LIBRARY_PATH"))
(setenv "EFI_VENDOR" "guix")))
(replace 'build
(lambda* (#:key make-flags #:allow-other-keys)
(apply invoke "make" "world" make-flags))))))
(inputs (inputs
`(("acpica" ,acpica) ; TODO: patch iasl invocation. (list acpica ; TODO: patch iasl invocation
("bridge-utils" ,bridge-utils) ; TODO: patch invocations. bridge-utils ; TODO: patch invocations
("glib" ,glib) glib
("iproute" ,iproute) ; TODO: patch invocations. iproute ; TODO: patch invocations
("libaio" ,libaio) libaio
("libx11" ,libx11) libx11
("yajl" ,yajl) yajl
("ncurses" ,ncurses) ncurses
("openssl" ,openssl) openssl
("ovmf" ,ovmf) ovmf
("pixman" ,pixman) pixman
("qemu" ,qemu-minimal) qemu-minimal
("seabios" ,seabios) seabios
("util-linux" ,util-linux "lib") ; uuid `(,util-linux "lib") ; uuid
; TODO: ocaml-findlib, ocaml-nox. ;; TODO: ocaml-findlib, ocaml-nox.
("xz" ,xz) ; for liblzma xz ; for liblzma
("zlib" ,zlib))) zlib))
(native-inputs (native-inputs
`(("dev86" ,dev86) (list dev86
("bison" ,bison) bison
("cmake" ,cmake-minimal) cmake-minimal
("figlet" ,figlet) figlet
("flex" ,flex) flex
("gettext" ,gettext-minimal) gettext-minimal
("libnl" ,libnl) libnl
("mini-os" (origin
,(origin
(method git-fetch) (method git-fetch)
(uri (git-reference (uri (git-reference
(url "https://xenbits.xen.org/git-http/mini-os.git") (url "https://xenbits.xen.org/git-http/mini-os.git")
@ -2459,17 +2445,17 @@ override CC = " (assoc-ref inputs "cross-gcc") "/bin/i686-linux-gnu-gcc"))
(commit "f57858b7e8ef8dd48394dd08cec2bef3c9fb92f5"))) (commit "f57858b7e8ef8dd48394dd08cec2bef3c9fb92f5")))
(sha256 (sha256
(base32 "04y7grxs47amvjcq1rq4jgk174rhid5m2z9w8wrv7rfd2xhazxy1")) (base32 "04y7grxs47amvjcq1rq4jgk174rhid5m2z9w8wrv7rfd2xhazxy1"))
(file-name (string-append name "-" version "-mini-os-git-checkout")))) (file-name (string-append name "-" version "-mini-os-git-checkout")))
("perl" ,perl) perl
; TODO: markdown ;; TODO: markdown.
("pkg-config" ,pkg-config) pkg-config
("python" ,python-2) python-2
("wget" ,wget) wget
("cross-gcc" ,(cross-gcc "i686-linux-gnu" (cross-gcc "i686-linux-gnu"
#:xbinutils (cross-binutils "i686-linux-gnu") #:xbinutils (cross-binutils "i686-linux-gnu")
#:libc (cross-libc "i686-linux-gnu"))) #:libc (cross-libc "i686-linux-gnu"))
("cross-libc" ,(cross-libc "i686-linux-gnu")) ; header files (cross-libc "i686-linux-gnu") ; header files
("cross-libc-static" ,(cross-libc "i686-linux-gnu") "static"))) `(,(cross-libc "i686-linux-gnu") "static")))
(home-page "https://xenproject.org/") (home-page "https://xenproject.org/")
(synopsis "Xen Virtual Machine Monitor") (synopsis "Xen Virtual Machine Monitor")
(description "This package provides the Xen Virtual Machine Monitor (description "This package provides the Xen Virtual Machine Monitor