Skip to content

Commit 57baa18

Browse files
committed
Add a Rust feature systemd-supports-mount-extra
Set the feature on if detect rhel >= 9.6 or fedora Refer to Colin's pointer #1752 (comment) Signed-off-by: Huijing Hei <[email protected]>
1 parent 40c2b02 commit 57baa18

File tree

4 files changed

+36
-4
lines changed

4 files changed

+36
-4
lines changed

Makefile

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,24 @@ prefix ?= /usr
2929
# We may in the future also want to include Fedora+derivatives as
3030
# the code is really tiny.
3131
# (Note we should also make installation of the units conditional on the rhsm feature)
32-
CARGO_FEATURES_DEFAULT ?= $(shell . /usr/lib/os-release; if echo "$$ID_LIKE" |grep -qF rhel; then echo rhsm; fi)
32+
# Enable systemd-supports-mount-extra for RHEL >= 9.6 or non-RHEL systems (Fedora, etc.)
33+
CARGO_FEATURES_DEFAULT ?= $(shell \
34+
. /usr/lib/os-release; \
35+
features=""; \
36+
if echo "$$ID_LIKE" |grep -qF rhel; then \
37+
features="rhsm"; \
38+
fi; \
39+
if [ "$$ID" != "rhel" ] || [ -z "$$VERSION_ID" ]; then \
40+
features="$$features systemd-supports-mount-extra"; \
41+
else \
42+
major=$${VERSION_ID%%.*}; \
43+
minor=$${VERSION_ID#*.}; \
44+
if [ "$$major" -gt 9 ] || ([ "$$major" -eq 9 ] && [ "$$minor" -ge 6 ]); then \
45+
features="$$features systemd-supports-mount-extra"; \
46+
fi; \
47+
fi; \
48+
echo "$$features" | sed 's/^ //'; \
49+
)
3350
# You can set this to override all cargo features, including the defaults
3451
CARGO_FEATURES ?= $(CARGO_FEATURES_DEFAULT)
3552

contrib/packaging/bootc.spec

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,17 @@
1212
%bcond_with rhsm
1313
%endif
1414

15+
# systemd.mount-extra support requires RHEL >= 9.6
16+
%if 0%{?rhel} == 9
17+
%define rhel_minor %(source /usr/lib/os-release; echo $VERSION_ID | cut -f2 -d".")
18+
%endif
19+
20+
%if 0%{?rhel} > 9 || (0%{?rhel} == 9 && 0%{?rhel_minor} >= 6) || 0%{?fedora}
21+
%bcond_without systemd_supports_mount_extra
22+
%else
23+
%bcond_with systemd_supports_mount_extra
24+
%endif
25+
1526
%global rust_minor %(rustc --version | cut -f2 -d" " | cut -f2 -d".")
1627

1728
# https://github.com/bootc-dev/bootc/issues/1640
@@ -127,13 +138,13 @@ make manpages
127138
# Build all binaries
128139
%if 0%{?container_build}
129140
# Container build: use cargo directly with cached dependencies to avoid RPM macro overhead
130-
cargo build -j%{_smp_build_ncpus} --release %{?with_rhsm:--features rhsm} --bins
141+
cargo build -j%{_smp_build_ncpus} --release %{?with_rhsm:--features rhsm} %{?with_systemd_supports_mount_extra:--features systemd-supports-mount-extra} --bins
131142
%else
132143
# Non-container build: use RPM macros for proper dependency tracking
133144
%if %new_cargo_macros
134-
%cargo_build %{?with_rhsm:-f rhsm} -- --bins
145+
%cargo_build %{?with_rhsm:-f rhsm} %{?with_systemd_supports_mount_extra:-f systemd-supports-mount-extra} -- --bins
135146
%else
136-
%cargo_build %{?with_rhsm:--features rhsm} -- --bins
147+
%cargo_build %{?with_rhsm:--features rhsm} %{?with_systemd_supports_mount_extra:--features systemd-supports-mount-extra} -- --bins
137148
%endif
138149
%endif
139150

crates/lib/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,9 @@ install-to-disk = []
8282
# This featuares enables `bootc internals publish-rhsm-facts` to integrate with
8383
# Red Hat Subscription Manager
8484
rhsm = []
85+
# This feature enables support for systemd.mount-extra kernel argument,
86+
# which requires RHEL >= 9.6
87+
systemd-supports-mount-extra = []
8588
# Implementation detail of man page generation.
8689
docgen = ["clap_mangen"]
8790

crates/lib/src/install.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -994,6 +994,7 @@ async fn install_container(
994994
// For seperate /boot filesystem, the better workaround is
995995
// to inject kernel arguments during installation.
996996
// See discussion in https://github.com/bootc-dev/bootc/issues/1388
997+
#[cfg(feature = "systemd-supports-mount-extra")]
997998
if let Some(boot) = root_setup.boot.as_ref() {
998999
if !boot.source.is_empty() {
9991000
let mount_extra = format!(

0 commit comments

Comments
 (0)