Skip to content

Commit d28e835

Browse files
jeckersbjmarrero
authored andcommitted
build: Don't build bootc to generate man pages in the RPM
`make manpages` builds bootc with the docgen feature, dumps its CLI as JSON and syncs the generated options/subcommands sections of docs/src/man/*.md before converting them to roff. The CI `validate` job already enforces (via `update-generated from-code --check`) that those committed sections match the CLI, so in a release build the sync is a no-op that costs a full extra build of bootc (~7 minutes in Koji). Add `xtask manpages --no-sync` and a `make manpages-no-sync` target that only do the conversion, and use it from the spec. The output is identical to `make manpages`. xtask itself still needs to be built, and it must not disturb the %cargo_build state that %cargo_test reuses. %cargo_prep symlinks target/release to target/rpm, and the %cargo_* macros run cargo with RUSTC_BOOTSTRAP=1, which some build scripts (proc-macro2, anyhow, thiserror) track. Building xtask with plain `cargo run --release` therefore caused %cargo_test to rebuild 100+ crates. Add XTASK_PROFILE and CARGO variables to the Makefile, and have the spec build xtask with the `rpm` profile and `%{__cargo}`. Assisted-by: AI Signed-off-by: John Eckersberg <dev@eckersberg.com>
1 parent 982bd88 commit d28e835

4 files changed

Lines changed: 52 additions & 5 deletions

File tree

‎Makefile‎

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,17 @@ DISABLE_DOCS ?=
6161
# make install SKIP_BUILD=1
6262
SKIP_BUILD ?=
6363

64+
# Cargo profile used to build xtask (e.g. for man pages). RPM builds set this
65+
# to `rpm` so xtask shares the %cargo_build profile instead of clobbering its
66+
# state through the target/release -> target/rpm symlink from %cargo_prep.
67+
XTASK_PROFILE ?= release
68+
69+
# The cargo command used by the build targets. RPM builds set this to
70+
# %{__cargo} so the environment (e.g. RUSTC_BOOTSTRAP) matches the
71+
# %cargo_* macros; otherwise build scripts that depend on it re-run and
72+
# invalidate the shared build state.
73+
CARGO ?= cargo
74+
6475
# Build all binaries
6576
.PHONY: bin
6677
# The man pages are built first so that the production binary below
@@ -69,13 +80,19 @@ ifneq ($(DISABLE_DOCS),1)
6980
bin: manpages
7081
endif
7182
bin:
72-
cargo build --release $(CARGO_OPTIONS) --bins
83+
$(CARGO) build --release $(CARGO_OPTIONS) --bins
7384

7485
# The docgen feature this adds implies install-to-disk, so the man pages
7586
# document the full CLI regardless of CARGO_OPTIONS.
7687
.PHONY: manpages
7788
manpages:
78-
cargo run --release --package xtask -- manpages -- $(CARGO_OPTIONS)
89+
$(CARGO) run --profile $(XTASK_PROFILE) --package xtask -- manpages -- $(CARGO_OPTIONS)
90+
91+
# Convert the man page markdown in docs/src/man without building bootc to
92+
# sync its generated CLI sections; CI ensures those are already up to date.
93+
.PHONY: manpages-no-sync
94+
manpages-no-sync:
95+
$(CARGO) run --profile $(XTASK_PROFILE) --package xtask -- manpages --no-sync
7996

8097
.PHONY: completion
8198
ifneq ($(SKIP_BUILD),1)

‎contrib/packaging/bootc.spec‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,6 @@ cd %{name}-%{version}-build
138138

139139
%build
140140
export SYSTEM_REINSTALL_BOOTC_INSTALL_PODMAN_PATH=%{system_reinstall_bootc_install_podman_path}
141-
# Build this first to avoid feature skew
142-
make manpages
143141

144142
# Build all binaries
145143
%if 0%{?container_build}
@@ -157,6 +155,17 @@ cargo build -j%{_smp_build_ncpus} --release %{?with_rhsm:--features rhsm} %{?wit
157155
%endif
158156
%endif
159157

158+
# The generated CLI sections in the man page sources are kept in sync by CI,
159+
# so just convert them; this avoids building bootc a second time.
160+
# Outside of container builds, use the same cargo environment and profile as
161+
# %%cargo_build/%%cargo_test, so xtask doesn't invalidate their shared state
162+
# (target/release is a symlink to target/rpm, created by %%cargo_prep).
163+
%if 0%{?container_build}
164+
make manpages-no-sync
165+
%else
166+
make manpages-no-sync XTASK_PROFILE=rpm CARGO="%{__cargo}"
167+
%endif
168+
160169
%if ! 0%{?container_build}
161170
%cargo_vendor_manifest
162171
# https://pagure.io/fedora-rust/rust-packaging/issue/33

‎crates/xtask/src/man.rs‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -835,6 +835,13 @@ pub fn generate_man_pages(sh: &Shell, cargo_options: &[String]) -> Result<()> {
835835
generate_pages(sh, false)
836836
}
837837

838+
/// Generate manuals from the Markdown as-is, without building bootc to sync
839+
/// the generated CLI sections first.
840+
#[context("Generating manpages")]
841+
pub fn generate_man_pages_no_sync(sh: &Shell) -> Result<()> {
842+
generate_pages(sh, false)
843+
}
844+
838845
/// Get version from Cargo.toml
839846
#[context("Querying package version")]
840847
fn get_package_version() -> Result<String> {

‎crates/xtask/src/xtask.rs‎

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,11 @@ struct Cli {
7979
enum Commands {
8080
/// Generate man pages
8181
Manpages {
82+
/// Only convert the markdown in docs/src/man, without first building
83+
/// bootc to sync its generated CLI sections. CI verifies those are up
84+
/// to date, so this is suitable for packaging a release.
85+
#[arg(long, conflicts_with = "cargo_options")]
86+
no_sync: bool,
8287
/// Extra options for cargo when building bootc, after `--`
8388
/// (e.g. `-- --no-default-features --features install-to-disk`)
8489
#[arg(last = true)]
@@ -395,7 +400,16 @@ fn try_main() -> Result<()> {
395400
let sh = xshell::Shell::new()?;
396401

397402
match cli.command {
398-
Commands::Manpages { cargo_options } => man::generate_man_pages(&sh, &cargo_options),
403+
Commands::Manpages {
404+
no_sync,
405+
cargo_options,
406+
} => {
407+
if no_sync {
408+
man::generate_man_pages_no_sync(&sh)
409+
} else {
410+
man::generate_man_pages(&sh, &cargo_options)
411+
}
412+
}
399413
Commands::GuideManpages => man::generate_guide_man_pages(&sh),
400414
Commands::CheckDocs => man::check_docs(),
401415
Commands::UpdateGenerated { command } => match command {

0 commit comments

Comments
 (0)