Skip to content

Commit e747216

Browse files
committed
cli: Fix rhsm feature propagation and manpage build order
The rhsm feature was not being propagated from the CLI crate to the lib crate, causing `bootc internals publish-rhsm-facts` to never be compiled in even when building with CARGO_FEATURES=rhsm. I think this was broken when I refactored the build recently. Change things so we build the manpages before the production binary, ensuring the production binary always ends up with the right feature flags. Fixes: https://issues.redhat.com/browse/RHEL-130799 Assisted-by: Claude Code (Sonnet 4.5) Signed-off-by: Colin Walters <[email protected]>
1 parent 535f1e7 commit e747216

File tree

3 files changed

+31
-31
lines changed

3 files changed

+31
-31
lines changed

Makefile

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,19 @@ 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 ?= $(shell . /usr/lib/os-release; if echo "$$ID_LIKE" |grep -qF rhel; then echo rhsm; fi)
32+
CARGO_FEATURES_DEFAULT ?= $(shell . /usr/lib/os-release; if echo "$$ID_LIKE" |grep -qF rhel; then echo rhsm; fi)
33+
# You can set this to override all cargo features, including the defaults
34+
CARGO_FEATURES ?= $(CARGO_FEATURES_DEFAULT)
3335

34-
all: bin manpages
35-
36-
bin:
37-
cargo build --release --features "$(CARGO_FEATURES)"
36+
# Build all binaries
37+
.PHONY: bin
38+
bin: manpages
39+
cargo build --release --features "$(CARGO_FEATURES)" --bins
3840

41+
# Note this cargo build is run without features (such as rhsm)
3942
.PHONY: manpages
4043
manpages:
41-
cargo run --package xtask -- manpages
44+
cargo run --release --package xtask -- manpages
4245

4346
STORAGE_RELATIVE_PATH ?= $(shell realpath -m -s --relative-to="$(prefix)/lib/bootc/storage" /sysroot/ostree/bootc/storage)
4447
install:

contrib/packaging/bootc.spec

Lines changed: 9 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -121,36 +121,20 @@ cd %{name}-%{version}-build
121121

122122
%build
123123
export SYSTEM_REINSTALL_BOOTC_INSTALL_PODMAN_PATH=%{system_reinstall_bootc_install_podman_path}
124-
%if 0%{?container_build}
125-
# Container build: use cargo directly with cached dependencies
126-
export CARGO_HOME=/var/roothome/.cargo
127-
cargo build -j%{_smp_build_ncpus} --release %{?with_rhsm:--features rhsm} \
128-
--bin=bootc --bin=system-reinstall-bootc --bin=bootc-initramfs-setup \
129-
%{?with_tests:--bin tests-integration}
124+
# Build this first to avoid feature skew
130125
make manpages
131-
%else
132-
# Build the main bootc binary
133-
%if %new_cargo_macros
134-
%cargo_build %{?with_rhsm:-f rhsm}
135-
%else
136-
%cargo_build %{?with_rhsm:--features rhsm}
137-
%endif
138126

139-
# Build the system reinstallation CLI binary
140-
%global cargo_args -p system-reinstall-bootc
127+
# Build all binaries
128+
%if 0%{?container_build}
129+
# 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
131+
%else
132+
# Non-container build: use RPM macros for proper dependency tracking
141133
%if %new_cargo_macros
142-
# In cargo-rpm-macros, the cargo_build macro does flag processing,
143-
# so we need to pass '--' to signify that cargo_args is not part
144-
# of the macro args
145-
%cargo_build -- %cargo_args
134+
%cargo_build %{?with_rhsm:-f rhsm} -- --bins
146135
%else
147-
# Older macros from rust-toolset do *not* do flag processing, so
148-
# '--' would be passed through to cargo directly, which is not
149-
# what we want.
150-
%cargo_build %cargo_args
136+
%cargo_build %{?with_rhsm:--features rhsm} -- --bins
151137
%endif
152-
153-
make manpages
154138
%endif
155139

156140
%if ! 0%{?container_build}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
use std assert
2+
use tap.nu
3+
4+
tap begin "rhsm facts"
5+
6+
# Verify we have this feature
7+
if ("/etc/rhsm" | path exists) {
8+
bootc internals publish-rhsm-facts --help
9+
let status = systemctl show -P ActiveState bootc-publish-rhsm-facts.service
10+
assert equal $status "inactive"
11+
}
12+
13+
tap ok

0 commit comments

Comments
 (0)