Archived
1
0
Fork 0

gnu: genimage: Factorise substitutions.

* gnu/packages/genimage.scm (genimage)[arguments]: Factorise input
substitution for great line savings; also fun.  Don't sneakily replace
mkdosfs with mkfs.vfat.  Remove obsolete fixes.  Fix tests in their
own 'fix-failing-tests phase.  Don't explicitly return #t from any
phases.
This commit is contained in:
Tobias Geerinckx-Rice 2021-10-20 22:02:55 +02:00
parent 9792e14a66
commit 5c8c7f74e6
No known key found for this signature in database
GPG key ID: 0DB0FF884F556D79

View file

@ -1,6 +1,7 @@
;;; GNU Guix --- Functional package management for GNU ;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2018 Danny Milosavljevic <dannym@scratchpost.org> ;;; Copyright © 2018 Danny Milosavljevic <dannym@scratchpost.org>
;;; Copyright © 2021 Vincent Legoll <vincent.legoll@gmail.com> ;;; Copyright © 2021 Vincent Legoll <vincent.legoll@gmail.com>
;;; Copyright © 2021 Tobias Geerinckx-Rice <me@tobias.gr>
;;; ;;;
;;; This file is part of GNU Guix. ;;; This file is part of GNU Guix.
;;; ;;;
@ -56,97 +57,37 @@
(patches (search-patches "genimage-signedness.patch")))) (patches (search-patches "genimage-signedness.patch"))))
(build-system gnu-build-system) (build-system gnu-build-system)
(arguments (arguments
`(#:phases `(#:modules
((ice-9 match)
,@%gnu-build-system-modules)
#:phases
(modify-phases %standard-phases (modify-phases %standard-phases
(add-after 'unpack 'guixify (add-after 'unpack 'guixify
(lambda* (#:key inputs #:allow-other-keys) (lambda* (#:key inputs #:allow-other-keys)
;; Note to maintainers: Check ".def =" lines in source. (map (match-lambda
(substitute* "config.c" ((input directory regexp)
(("\\.def = \"cpio\"") (substitute* "config.c"
(string-append ".def = \"" (((format #f "\\.def = \"(~a)\"" regexp) _ command)
(assoc-ref inputs "cpio") (format #f ".def = \"~a/~a/~a\""
"/bin/cpio\"")) (assoc-ref inputs input) directory command)))))
(("\\.def = \"dd\"") '(("cpio" "bin" "cpio")
(string-append ".def = \"" ("coreutils" "bin" "dd")
(assoc-ref inputs "coreutils") ("e2fsprogs" "sbin" "debugfs|e2fsck|mke2fs|tune2fs")
"/bin/dd\"")) ("genext2fs" "bin" "genext2fs")
(("\\.def = \"debugfs\"") ("cdrkit-libre" "bin" "genisoimage")
(string-append ".def = \"" ("mtools" "bin" "mcopy|mmd")
(assoc-ref inputs "e2fsprogs") ;; mkcramfs is obsolete.
"/sbin/debugfs\"")) ("dosfstools" "sbin" "mkdosfs")
(("\\.def = \"e2fsck\"") ("mtd-utils" "sbin" "mkfs.(jffs2|ubifs)|ubinize")
(string-append ".def = \"" ("squashfs-tools" "bin" "mksquashfs")
(assoc-ref inputs "e2fsprogs") ("qemu" "bin" "qemu-img")
"/sbin/e2fsck\"")) ("tar" "bin" "tar")
(("\\.def = \"genext2fs\"") ("u-boot-tools" "bin" "mkimage")))
(string-append ".def = \""
(assoc-ref inputs "genext2fs")
"/bin/genext2fs\""))
(("\\.def = \"genisoimage\"")
(string-append ".def = \""
(assoc-ref inputs "cdrkit-libre")
"/bin/genisoimage\""))
(("\\.def = \"mcopy\"")
(string-append ".def = \""
(assoc-ref inputs "mtools")
"/bin/mcopy\""))
(("\\.def = \"mmd\"")
(string-append ".def = \""
(assoc-ref inputs "mtools")
"/bin/mmd\""))
;;; Note: mkcramfs is obsolete.
(("\\.def = \"mkdosfs\"")
(string-append ".def = \""
(assoc-ref inputs "dosfstools")
"/sbin/mkfs.fat\""))
(("\\.def = \"mke2fs\"")
(string-append ".def = \""
(assoc-ref inputs "e2fsprogs")
"/sbin/mke2fs\""))
(("\\.def = \"mkfs\\.jffs2\"")
(string-append ".def = \""
(assoc-ref inputs "mtd-utils")
"/sbin/mkfs.jffs2\""))
(("\\.def = \"mkfs\\.ubifs\"")
(string-append ".def = \""
(assoc-ref inputs "mtd-utils")
"/sbin/mkfs.ubifs\""))
(("\\.def = \"mksquashfs\"")
(string-append ".def = \""
(assoc-ref inputs "squashfs-tools")
"/bin/mksquashfs\""))
(("\\.def = \"qemu-img\"")
(string-append ".def = \""
(assoc-ref inputs "qemu")
"/bin/qemu-img\""))
(("\\.def = \"tar\"")
(string-append ".def = \""
(assoc-ref inputs "tar")
"/bin/tar\""))
(("\\.def = \"tune2fs\"")
(string-append ".def = \""
(assoc-ref inputs "e2fsprogs")
"/sbin/tune2fs\""))
(("\\.def = \"ubinize\"")
(string-append ".def = \""
(assoc-ref inputs "mtd-utils")
"/sbin/ubinize\""))
(("\\.def = \"mkimage\"")
(string-append ".def = \""
(assoc-ref inputs "u-boot-tools")
"/bin/mkimage\"")))
(substitute* "test/basic-images.test"
;; Work around bug in sharness.sh.
(("mkdosfs")
"mkfs.fat")
;; Work around bug in sharness.sh.
(("dd,mkfs\\.fat,mcopy")
"dd,mkfs_fat,mcopy")
;; Should be in the next upstream release.
(("qemu_img") "qemu-img"))
(substitute* "util.c" (substitute* "util.c"
(("\"/bin/sh\"") (("\"/bin/sh\"")
(string-append "\"" (assoc-ref inputs "bash") "/bin/sh\""))) (string-append "\"" (assoc-ref inputs "bash") "/bin/sh\"")))))
(add-before 'check 'fix-failing-tests
(lambda _
;; We don't have /etc/passwd so uid 0 is not known as "root". ;; We don't have /etc/passwd so uid 0 is not known as "root".
;; Thus patch it out. ;; Thus patch it out.
(substitute* '("test/ext2test.dump" (substitute* '("test/ext2test.dump"
@ -154,16 +95,14 @@
"test/ext4test.dump" "test/ext4test.dump"
"test/ext2test-percent.dump" "test/ext2test-percent.dump"
"test/mke2fs.dump") "test/mke2fs.dump")
(("root") "unknown")) (("root") "unknown"))))
#t))
(add-before 'check 'setenv-check (add-before 'check 'setenv-check
(lambda _ (lambda _
;; Our container doesn't provide access to /etc/mtab ;; Our container doesn't provide access to /etc/mtab
(setenv "EXT2FS_NO_MTAB_OK" "1") (setenv "EXT2FS_NO_MTAB_OK" "1")
;; Make test reproducible ;; Make test reproducible
(setenv "GENIMAGE_MKFJFFS2" "mkfs.jffs2 -U") (setenv "GENIMAGE_MKFJFFS2" "mkfs.jffs2 -U")
(setenv "GENIMAGE_MKE2FS" "mke2fs -E no_copy_xattrs") (setenv "GENIMAGE_MKE2FS" "mke2fs -E no_copy_xattrs")))
#t))
(replace 'check (replace 'check
(lambda _ (lambda _
(invoke "make" "TEST_LOG_COMPILER=" "check")))))) (invoke "make" "TEST_LOG_COMPILER=" "check"))))))