gnu: bcachefs-tools: Update to 1.11.0.

* gnu/packages/crates-io.scm (rust-rustix-for-bcachefs-tools):
New public variable.
* gnu/packages/file-systems.scm (bcachefs-tools-rust-target)
(bcachefs-tools-target/release, bcachefs-tools-cargo-args)
(bcachefs-tools-make-flags, bcachefs-tools-make-install-flags):
New variables.
(bcachefs-tools): Update to 1.11.0.
[build-system]: Switch to Cargo.
[arguments]: Remove #:make-flags.  Add Cargo keywords.
Run the test suite with upstream defaults.
Delete 'promote-mount.bcachefs.sh phase.
[native-inputs]: Remove python, python-docutils, python-pytest,
and valgrind.
[inputs]: Remove bash-minimal, coreutils-minimal, gawk, and util-linux.
Add clang.
(bcachefs-tools/static): Modify #:phases instead of #:make-flags,
and adjust accordingly.

Change-Id: I872f5dea88b75f855f3cdcbffbbd9c70d7ebe8d6
This commit is contained in:
Tobias Geerinckx-Rice 2024-09-01 02:00:00 +02:00
parent ff5d9ae0fa
commit 49cd866090
No known key found for this signature in database
GPG key ID: 0DB0FF884F556D79
2 changed files with 134 additions and 72 deletions

View file

@ -66141,7 +66141,7 @@ (define-public rust-rusticata-macros-4
(define-public rust-rustix-0.38 (define-public rust-rustix-0.38
(package (package
(name "rust-rustix") (name "rust-rustix")
(version "0.38.31") (version "0.38.31") ;XXX drop rust-rustix-for-bcachefs-tools when updating
(source (source
(origin (origin
(method url-fetch) (method url-fetch)
@ -66195,6 +66195,20 @@ (define-public rust-rustix-0.38
;; Apache 2.0, Apache 2.0 with LLVM exception, or Expat. ;; Apache 2.0, Apache 2.0 with LLVM exception, or Expat.
(license (list license:asl2.0 license:expat)))) (license (list license:asl2.0 license:expat))))
(define-public rust-rustix-for-bcachefs-tools
;; The package above is too old; too many dependents to update it directly.
(package
(inherit rust-rustix-0.38)
(name (package-name rust-rustix-0.38))
(version "0.38.34")
(source
(origin
(inherit (package-source rust-rustix-0.38))
(uri (crate-uri "rustix" version))
(file-name (string-append name "-" version ".tar.gz"))
(sha256
(base32 "03vkqa2ism7q56rkifyy8mns0wwqrk70f4i4fd53r97p8b05xp3h"))))))
(define-public rust-rustix-0.37 (define-public rust-rustix-0.37
(package (package
(inherit rust-rustix-0.38) (inherit rust-rustix-0.38)

View file

@ -34,8 +34,10 @@ (define-module (gnu packages file-systems)
#:use-module (guix gexp) #:use-module (guix gexp)
#:use-module ((guix licenses) #:prefix license:) #:use-module ((guix licenses) #:prefix license:)
#:use-module (guix packages) #:use-module (guix packages)
#:use-module (guix platform)
#:use-module (guix download) #:use-module (guix download)
#:use-module (guix git-download) #:use-module (guix git-download)
#:use-module (guix build-system cargo)
#:use-module (guix build-system cmake) #:use-module (guix build-system cmake)
#:use-module (guix build-system copy) #:use-module (guix build-system copy)
#:use-module (guix build-system gnu) #:use-module (guix build-system gnu)
@ -58,6 +60,7 @@ (define-module (gnu packages file-systems)
#:use-module (gnu packages check) #:use-module (gnu packages check)
#:use-module (gnu packages compression) #:use-module (gnu packages compression)
#:use-module (gnu packages cpp) #:use-module (gnu packages cpp)
#:use-module (gnu packages crates-io)
#:use-module (gnu packages crypto) #:use-module (gnu packages crypto)
#:use-module (gnu packages curl) #:use-module (gnu packages curl)
#:use-module (gnu packages cyrus-sasl) #:use-module (gnu packages cyrus-sasl)
@ -85,6 +88,7 @@ (define-module (gnu packages file-systems)
#:use-module (gnu packages libffi) #:use-module (gnu packages libffi)
#:use-module (gnu packages libunwind) #:use-module (gnu packages libunwind)
#:use-module (gnu packages linux) #:use-module (gnu packages linux)
#:use-module (gnu packages llvm)
#:use-module (gnu packages maths) #:use-module (gnu packages maths)
#:use-module (gnu packages man) #:use-module (gnu packages man)
#:use-module (gnu packages m4) #:use-module (gnu packages m4)
@ -589,10 +593,39 @@ (define-public gphotofs
(home-page "http://www.gphoto.org/proj/gphotofs/") (home-page "http://www.gphoto.org/proj/gphotofs/")
(license license:gpl2+))) (license license:gpl2+)))
(define bcachefs-tools-rust-target
(platform-rust-target (lookup-platform-by-target-or-system
(or (%current-target-system)
(%current-system)))))
(define bcachefs-tools-target/release
(string-append "target/" bcachefs-tools-rust-target "/release"))
(define bcachefs-tools-cargo-args
;; Distinct from -MAKE-FLAGS for use with cargo test in 'check.
#~(list "--release"
(string-append "--target=" #$bcachefs-tools-rust-target)))
;; XXX We want to share common make flags across different packages & phases,
;; but the cargo-build-system doesn't allow #:make-flags.
(define bcachefs-tools-make-flags
;; These result of these flags should be as minimal as possible.
;; Enable any optional features in the bcachefs-tools package instead.
#~(list (string-append "CARGO_BUILD_ARGS="
(string-join #$bcachefs-tools-cargo-args " "))
(string-append "CC=" #$(cc-for-target))
(string-append "PKG_CONFIG=" #$(pkg-config-for-target))))
(define bcachefs-tools-make-install-flags
#~(cons* (string-append "PREFIX=" #$output)
"INITRAMFS_DIR=$(PREFIX)/share/initramfs-tools"
"PKGCONFIG_UDEVRULESDIR=$(PREFIX)/lib/udev/rules.d"
#$bcachefs-tools-make-flags))
(define-public bcachefs-tools (define-public bcachefs-tools
(package (package
(name "bcachefs-tools") (name "bcachefs-tools")
(version "1.4.1") (version "1.11.0")
(source (source
(origin (origin
(method git-fetch) (method git-fetch)
@ -601,84 +634,74 @@ (define-public bcachefs-tools
(commit (string-append "v" version)))) (commit (string-append "v" version))))
(file-name (git-file-name name version)) (file-name (git-file-name name version))
(sha256 (sha256
(base32 "0axwbckqrw1v3v50nzhpkvpyjbjwy3rq5bv23db84x3xia497apq")))) (base32 "0m6z8z1cv78ay9yspypgr0kv70ck4wpln5n44f6n57i7sihqhrrg"))))
(build-system gnu-build-system) (build-system cargo-build-system)
(arguments (arguments
(list #:make-flags (list
#~(list (string-append "VERSION=" #$version) ; v…-nogit otherwise #:install-source? #f
(string-append "PREFIX=" #$output) ;; The Makefile CCs *every* C file anywhere beneath the build directory,
"INITRAMFS_DIR=$(PREFIX)/share/initramfs-tools" ;; even in Rust crates, creating ludicrous and totally bogus dependencies
"PKGCONFIG_UDEVRULESDIR=$(PREFIX)/lib/udev/rules.d" ;; such as the Android SDK. Put our crates elsewhere.
(string-append "CC=" #$(cc-for-target)) #:vendor-dir "../guix-vendor"
(string-append "PKG_CONFIG=" #$(pkg-config-for-target)) #:cargo-inputs
;; This will be less of an option in the future, as more `(("rust-aho-corasick" ,rust-aho-corasick-1)
;; code gets rewritten in Rust. ("rust-anstream" ,rust-anstream-0.6)
"NO_RUST=better") ("rust-anstyle" ,rust-anstyle-1)
#:phases ("rust-anstyle-parse" ,rust-anstyle-parse-0.2)
#~(modify-phases %standard-phases ("rust-anyhow" ,rust-anyhow-1)
(delete 'configure) ; no configure script ("rust-autocfg" ,rust-autocfg-1)
(replace 'check ("rust-bitfield" ,rust-bitfield-0.14)
;; The test suite is moribund upstream (never been useful), ("rust-clap" ,rust-clap-4)
;; but let's keep running it as a sanity check until then. ("rust-clap-complete" ,rust-clap-complete-4)
(lambda* (#:key tests? make-flags #:allow-other-keys) ("rust-either" ,rust-either-1)
(when tests? ("rust-errno" ,rust-errno-0.2)
;; We must manually build the test_helper first. ("rust-env-logger" ,rust-env-logger-0.10)
(apply invoke "make" "tests" make-flags) ("rust-libc" ,rust-libc-0.2)
(invoke (string-append ("rust-log" ,rust-log-0.4)
#$(this-package-native-input "python-pytest") ("rust-memoffset" ,rust-memoffset-0.8)
"/bin/pytest") "-k" ("rust-owo-colors" ,rust-owo-colors-4)
;; These fail (invalid argument) on kernels ("rust-rustix" ,rust-rustix-for-bcachefs-tools)
;; with a previous bcachefs version. ("rust-strum" ,rust-strum-0.26)
(string-append "not test_format and " ("rust-strum-macros" ,rust-strum-macros-0.26)
"not test_fsck and " ("rust-udev" ,rust-udev-0.7)
"not test_list and " ("rust-uuid" ,rust-uuid-1)
"not test_list_inodes and " ("rust-zeroize" ,rust-zeroize-1))
"not test_list_dirent"))))) #:phases
(add-after 'install 'promote-mount.bcachefs.sh #~(modify-phases %standard-phases
;; The (optional) mount.bcachefs requires rust:cargo. (replace 'build
;; This shell alternative does the job well enough for now. (lambda* (#:key parallel-build? #:allow-other-keys)
(lambda* (#:key inputs #:allow-other-keys) (apply invoke "make"
(define (whence file) "-j" (if parallel-build?
(dirname (search-input-file inputs file))) (number->string (parallel-job-count))
(let ((mount (string-append #$output "1")
"/sbin/mount.bcachefs"))) (string-append "VERSION=" #$version)
(delete-file mount) ; symlink to bcachefs #$bcachefs-tools-make-flags)))
(copy-file "mount.bcachefs.sh" mount) (add-before 'install 'patch-install
;; WRAP-SCRIPT causes bogus Insufficient arguments errors. ;; make install hard-codes target/release/bcachefs, which is
(wrap-program mount ;; incorrect when passing --target, as required to cross-compile or
`("PATH" ":" prefix ;; even just link statically. We always pass it, so always patch.
,(list (getcwd) (lambda _
(whence "bin/tail") (substitute* "Makefile"
(whence "bin/awk") (("target/release")
(whence "bin/mount")))))))))) #$bcachefs-tools-target/release))))
(replace 'install
(lambda _
(apply invoke "make" "install"
#$bcachefs-tools-make-install-flags))))))
(native-inputs (native-inputs
(cons* pkg-config (list pkg-config))
;; For generating documentation with rst2man.
python
python-docutils
;; For tests.
python-pytest
(if (member (%current-system) (package-supported-systems valgrind))
(list valgrind)
'())))
(inputs (inputs
(list bash-minimal (list clang
eudev eudev
keyutils keyutils
libaio libaio
libscrypt libscrypt
libsodium libsodium
liburcu liburcu
`(,util-linux "lib") `(,util-linux "lib") ;libblkid
lz4 lz4
zlib zlib
`(,zstd "lib") `(,zstd "lib")))
;; Only for mount.bcachefs.sh.
bash-minimal
coreutils-minimal
gawk
util-linux))
(home-page "https://bcachefs.org/") (home-page "https://bcachefs.org/")
(synopsis "Tools to create and manage bcachefs file systems") (synopsis "Tools to create and manage bcachefs file systems")
(description (description
@ -701,9 +724,34 @@ (define-public bcachefs-tools/static
(name "bcachefs-tools-static") (name "bcachefs-tools-static")
(arguments (arguments
(substitute-keyword-arguments (package-arguments bcachefs-tools) (substitute-keyword-arguments (package-arguments bcachefs-tools)
((#:make-flags make-flags) ((#:phases phases #~%standard-phases)
#~(append #$make-flags #~(modify-phases #$phases
(list "LDFLAGS=-static"))))) (add-after 'configure 'set-rust-flags
(lambda _
(setenv "RUSTFLAGS" (string-join
'("-C" "link-arg=-z"
"-C" "link-arg=muldefs"
"-C" "target-feature=+crt-static"
"-C" "relocation-model=static")
" "))))
(replace 'build
(lambda* (#:key parallel-build? #:allow-other-keys)
(apply invoke "make"
"-j" (if parallel-build?
(number->string (parallel-job-count))
"1")
(string-append "VERSION="
#$(package-version this-package))
#$bcachefs-tools-make-flags)))
(replace 'check
(lambda* (#:key tests? #:allow-other-keys)
(when tests?
(apply invoke "cargo" "test" #$bcachefs-tools-cargo-args))))
(replace 'install
(lambda _
(apply invoke "make" "install"
(string-append "PREFIX=" #$output)
#$bcachefs-tools-make-install-flags)))))))
(inputs (modify-inputs (package-inputs bcachefs-tools) (inputs (modify-inputs (package-inputs bcachefs-tools)
(prepend `(,eudev "static") (prepend `(,eudev "static")
`(,keyutils "static") `(,keyutils "static")