1
0
mirror of https://github.com/containers/bootc.git synced 2026-02-05 15:45:53 +01:00

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 <walters@verbum.org>
This commit is contained in:
Colin Walters
2025-11-25 09:40:02 -05:00
parent 535f1e771c
commit e747216980
3 changed files with 31 additions and 31 deletions

View File

@@ -29,16 +29,19 @@ prefix ?= /usr
# We may in the future also want to include Fedora+derivatives as
# the code is really tiny.
# (Note we should also make installation of the units conditional on the rhsm feature)
CARGO_FEATURES ?= $(shell . /usr/lib/os-release; if echo "$$ID_LIKE" |grep -qF rhel; then echo rhsm; fi)
CARGO_FEATURES_DEFAULT ?= $(shell . /usr/lib/os-release; if echo "$$ID_LIKE" |grep -qF rhel; then echo rhsm; fi)
# You can set this to override all cargo features, including the defaults
CARGO_FEATURES ?= $(CARGO_FEATURES_DEFAULT)
all: bin manpages
bin:
cargo build --release --features "$(CARGO_FEATURES)"
# Build all binaries
.PHONY: bin
bin: manpages
cargo build --release --features "$(CARGO_FEATURES)" --bins
# Note this cargo build is run without features (such as rhsm)
.PHONY: manpages
manpages:
cargo run --package xtask -- manpages
cargo run --release --package xtask -- manpages
STORAGE_RELATIVE_PATH ?= $(shell realpath -m -s --relative-to="$(prefix)/lib/bootc/storage" /sysroot/ostree/bootc/storage)
install:

View File

@@ -121,36 +121,20 @@ cd %{name}-%{version}-build
%build
export SYSTEM_REINSTALL_BOOTC_INSTALL_PODMAN_PATH=%{system_reinstall_bootc_install_podman_path}
# Build this first to avoid feature skew
make manpages
# Build all binaries
%if 0%{?container_build}
# Container build: use cargo directly with cached dependencies
export CARGO_HOME=/var/roothome/.cargo
cargo build -j%{_smp_build_ncpus} --release %{?with_rhsm:--features rhsm} \
--bin=bootc --bin=system-reinstall-bootc --bin=bootc-initramfs-setup \
%{?with_tests:--bin tests-integration}
make manpages
# Container build: use cargo directly with cached dependencies to avoid RPM macro overhead
cargo build -j%{_smp_build_ncpus} --release %{?with_rhsm:--features rhsm} --bins
%else
# Build the main bootc binary
# Non-container build: use RPM macros for proper dependency tracking
%if %new_cargo_macros
%cargo_build %{?with_rhsm:-f rhsm}
%cargo_build %{?with_rhsm:-f rhsm} -- --bins
%else
%cargo_build %{?with_rhsm:--features rhsm}
%cargo_build %{?with_rhsm:--features rhsm} -- --bins
%endif
# Build the system reinstallation CLI binary
%global cargo_args -p system-reinstall-bootc
%if %new_cargo_macros
# In cargo-rpm-macros, the cargo_build macro does flag processing,
# so we need to pass '--' to signify that cargo_args is not part
# of the macro args
%cargo_build -- %cargo_args
%else
# Older macros from rust-toolset do *not* do flag processing, so
# '--' would be passed through to cargo directly, which is not
# what we want.
%cargo_build %cargo_args
%endif
make manpages
%endif
%if ! 0%{?container_build}

View File

@@ -0,0 +1,13 @@
use std assert
use tap.nu
tap begin "rhsm facts"
# Verify we have this feature
if ("/etc/rhsm" | path exists) {
bootc internals publish-rhsm-facts --help
let status = systemctl show -P ActiveState bootc-publish-rhsm-facts.service
assert equal $status "inactive"
}
tap ok