From 816f103231dc53f7afae5e2445810e6a58bcf926 Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Tue, 13 Feb 2024 22:01:33 +0100 Subject: [PATCH] Enable Rust parts, including mount.bcachefs. --- debian/README.todo | 11 -------- debian/changelog | 18 +++++++++++++ debian/control | 28 +++++++++++++++++++- debian/patches/relax-dep-versions.patch | 35 +++++++++++++++++++++++++ debian/patches/series | 1 + debian/rules | 24 ++++++++++++++--- 6 files changed, 102 insertions(+), 15 deletions(-) delete mode 100644 debian/README.todo create mode 100644 debian/patches/relax-dep-versions.patch diff --git a/debian/README.todo b/debian/README.todo deleted file mode 100644 index 93db89a..0000000 --- a/debian/README.todo +++ /dev/null @@ -1,11 +0,0 @@ -Enable rust build, which is currently disabled in debian/rule -with NO_RUST=true. - -Dependencies available in Debian: librust-byteorder-dev librust-rpassword-dev -librust-either-dev librust-errno-dev librust-itertools-dev librust-getset-dev -librust-uuid-dev librust-libudev-dev librust-libc-dev librust-anyhow-dev -librust-clap-dev librust-colored-dev librust-chrono-dev librust-log-dev -librust-atty-dev - -Missing dependencies: librust-gag-dev librust-parse-display-dev -librust-bch-bindgen-dev diff --git a/debian/changelog b/debian/changelog index 7007b3c..8a4202d 100644 --- a/debian/changelog +++ b/debian/changelog @@ -8,6 +8,24 @@ bcachefs-tools (1:1.6.3-0.1) UNRELEASED; urgency=medium hack that makes bcachefs-tools work with bindgen older than 0.69.4 (which isn't in Debian yet). * Build-depend on systemd-dev, since udev.pc has moved there. + * Enable Rust parts, including mount.bcachefs. (Closes: #1060256) + * Include the right .mk flags to get DEB_HOST_RUST_TYPE etc., and + export that (needed for Debian's cargo wrapper). + * Override CARGO, and set CARGO_HOME during installation. + * Run prepare-debian in dh_auto_configure, and clean up the vendor dir + in dh_auto_clean. + * Remove Cargo.lock before the build, so that we can use Debian's versions + of all Rust crates. Also remove it in dh_auto_clean, so that it does not + take a diff. + * revert-bindgen-changes.patch: New patch, loosen required versions + of Rust crates + - errno (0.2 -> >= 0.2, < 1; Debian has 0.4) + - udev (0.7 -> >= 0.7, < 1; Debian has 0.8) + - memoffset (0.8.0 -> 0.6; Debian has 0.6.5, so a downgrade) + - paste (1.0.11 -> 1.0; Debian has 1.0.8, so a downgrade) + - bindgen (0.69.4 -> 0.66; see revert-bindgen-changes.patch above) + * Add build-dependency on all relevant Rust crates, and on python3:native + due to use of the Cargo wrapper. -- Steinar H. Gunderson Wed, 21 Feb 2024 19:32:51 +0100 diff --git a/debian/control b/debian/control index edcb923..9023256 100644 --- a/debian/control +++ b/debian/control @@ -6,6 +6,7 @@ Standards-Version: 4.6.1 Rules-Requires-Root: no Build-Depends: debhelper-compat (= 13), cargo, + python3:native, pkg-config, python3-docutils, python3-pytest, @@ -21,7 +22,32 @@ Build-Depends: debhelper-compat (= 13), libzstd-dev, systemd-dev, uuid-dev, - zlib1g-dev + zlib1g-dev, +# -- Cargo.toml + librust-atty-0.2-dev (>= 0.2.14-~~), + librust-log-0.4-dev, + librust-log-0+std-dev, + librust-colored-2-dev, + librust-clap-4-dev (>= 4.0.32-~~), + librust-clap-4+derive-dev, + librust-clap-4+wrap-help-dev, + librust-clap-complete-4-dev (>= 4.3.2-~~), + librust-anyhow-1.0-dev, + librust-libc-0.2-dev, + librust-udev-0-dev (>= 0.7-~~), + librust-uuid-1-dev (>= 1.2.2-~~), + librust-errno-0-dev (>= 0.2), + librust-either-1-dev (>= 1.5), + librust-rpassword-7-dev, + librust-byteorder-1-dev (>= 1.3), +# -- bch_bindgen/Cargo.toml +# anyhow, uuid, byteorder are covered above + librust-bitfield-0-dev (>= 0.14.0-~~), + librust-memoffset-0.6-dev, + librust-bitflags-1-dev (>= 1.3.2-~~), + librust-paste-1.0-dev, + librust-pkg-config-0.3-dev, + librust-bindgen-0.66-dev Homepage: https://bcachefs.org/ Vcs-Git: https://salsa.debian.org/jcc/bcachefs-tools.git Vcs-Browser: https://salsa.debian.org/jcc/bcachefs-tools diff --git a/debian/patches/relax-dep-versions.patch b/debian/patches/relax-dep-versions.patch new file mode 100644 index 0000000..26dc19f --- /dev/null +++ b/debian/patches/relax-dep-versions.patch @@ -0,0 +1,35 @@ +Index: bcachefs-tools/bch_bindgen/Cargo.toml +=================================================================== +--- bcachefs-tools.orig/bch_bindgen/Cargo.toml ++++ bcachefs-tools/bch_bindgen/Cargo.toml +@@ -12,11 +12,11 @@ crate-type = ["lib"] + anyhow = "1.0" + uuid = "1.2.2" + bitfield = "0.14.0" +-memoffset = "0.8.0" ++memoffset = "0.6" + byteorder = "1.3" + bitflags = "1.3.2" +-paste = "1.0.11" ++paste = "1.0" + + [build-dependencies] + pkg-config = "0.3" +-bindgen = "0.69.2" ++bindgen = "0.66" +Index: bcachefs-tools/Cargo.toml +=================================================================== +--- bcachefs-tools.orig/Cargo.toml ++++ bcachefs-tools/Cargo.toml +@@ -16,9 +16,9 @@ clap = { version = "4.0.32", features = + clap_complete = "4.3.2" + anyhow = "1.0" + libc = "0.2.69" +-udev = "0.7.0" ++udev = ">= 0.7, < 1" + uuid = "1.2.2" +-errno = "0.2" ++errno = ">= 0.2, < 1" + either = "1.5" + rpassword = "7" + bch_bindgen = { path = "bch_bindgen" } diff --git a/debian/patches/series b/debian/patches/series index 242cf6b..5af4f95 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -1 +1,2 @@ revert-bindgen-changes.patch +relax-dep-versions.patch diff --git a/debian/rules b/debian/rules index fd52350..1772945 100755 --- a/debian/rules +++ b/debian/rules @@ -1,15 +1,20 @@ #!/usr/bin/make -f +include /usr/share/dpkg/architecture.mk +include /usr/share/rustc/architecture.mk + +export DEB_HOST_RUST_TYPE DEB_HOST_GNU_TYPE + export DEB_BUILD_MAINT_OPTIONS=hardening=+all -# Do not build rust code (dependencies currently unmet) -export NO_RUST=-true +export CARGO=/usr/share/cargo/bin/cargo +export CARGO_HOME=$(CURDIR)/debian/cargo_home +export DEB_CARGO_CRATE=bcachefs-tools_$(DEB_VERSION_UPSTREAM) PREFIX := /usr ROOT_SBINDIR := /usr/sbin DEB_BUILD_ARCH ?= $(shell dpkg-architecture -qDEB_BUILD_ARCH) - ifeq ($(DEB_BUILD_ARCH),amd64) DEB_BUILD_MAINT_OPTIONS += optimize=-lto endif @@ -17,7 +22,20 @@ endif %: dh $@ +override_dh_auto_configure: + $(CARGO) prepare-debian $(CURDIR)/vendor --link-from-system + +override_dh_auto_build: + $(RM) Cargo.lock + dh_auto_build -- CARGO="$(CARGO)" + override_dh_auto_install: dh_auto_install -- "PREFIX=$(PREFIX)" "ROOT_SBINDIR=$(ROOT_SBINDIR)" +override_dh_auto_clean: + ! [ -d $(CURDIR)/vendor ] || $(RM) -r $(CURDIR)/vendor + ! [ -d $(CARGO_HOME) ] || $(RM) -r $(CARGO_HOME) + $(RM) Cargo.lock + dh_auto_clean + override_dh_auto_test: -- 2.39.2