Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 21 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,28 +32,42 @@ prefix ?= /usr
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)
BOOTC_PROFILE ?= $(if $(wildcard target/rpm/bootc),rpm,release)
BOOTC_TARGET_DIR = target/$(BOOTC_PROFILE)

# Build all binaries
.PHONY: bin
bin: manpages
cargo build --release --features "$(CARGO_FEATURES)" --bins
if [ ! -x "$(BOOTC_TARGET_DIR)/bootc" ]; then \

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This completely breaks the buildsystem, no? We'd just silently be reusing old binaries...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, that patch is not good and not designed for merge. But it did its job for me.

It is very hard to iterate with bootc while having it compile three times to deploy

cargo build --release --features "$(CARGO_FEATURES)" --bins; \
fi

# Note this cargo build is run without features (such as rhsm)
.PHONY: manpages
manpages:
cargo run --release --package xtask -- manpages
if [ -x "$(BOOTC_TARGET_DIR)/bootc" ]; then \

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But yes, this is really really messy how we have our documentation depend on running the binary.

Maybe what is easier is to try to move instead to where we just validate the generated docs as a separate phase, but don't default to linking the two together.

It's effectively what we did for the tmt stuff

rm -rf target/man; \
if [ -x "$(BOOTC_TARGET_DIR)/xtask" ]; then \
BOOTC_DOCGEN_BIN="$(BOOTC_TARGET_DIR)/bootc" "$(BOOTC_TARGET_DIR)/xtask" manpages; \
else \
BOOTC_DOCGEN_BIN="$(BOOTC_TARGET_DIR)/bootc" cargo run --release --package xtask -- manpages; \
fi; \
else \
mkdir -p target/man; \
printf '.TH BOOTC 8\n.SH NAME\nbootc \\- bootable container system\n' > target/man/bootc.8; \
printf '.TH BOOTC-SETUP-ROOT-CONF 5\n.SH NAME\nbootc-setup-root.conf \\- bootc setup-root configuration\n' > target/man/bootc-setup-root-conf.5; \
fi

.PHONY: completion
completion: bin
mkdir -p target/completion
for shell in bash elvish fish powershell zsh; do \
target/release/bootc completion $$shell > target/completion/bootc.$$shell; \
$(BOOTC_TARGET_DIR)/bootc completion $$shell > target/completion/bootc.$$shell; \
done

STORAGE_RELATIVE_PATH ?= $(shell realpath -m -s --relative-to="$(prefix)/lib/bootc/storage" /sysroot/ostree/bootc/storage)
install: completion
install -D -m 0755 -t $(DESTDIR)$(prefix)/bin target/release/bootc
install -D -m 0755 -t $(DESTDIR)$(prefix)/bin target/release/system-reinstall-bootc
install -D -m 0755 -t $(DESTDIR)$(prefix)/bin $(BOOTC_TARGET_DIR)/bootc
install -D -m 0755 -t $(DESTDIR)$(prefix)/bin $(BOOTC_TARGET_DIR)/system-reinstall-bootc
install -d -m 0755 $(DESTDIR)$(prefix)/lib/bootc/bound-images.d
install -d -m 0755 $(DESTDIR)$(prefix)/lib/bootc/kargs.d
ln -s "$(STORAGE_RELATIVE_PATH)" "$(DESTDIR)$(prefix)/lib/bootc/storage"
Expand Down Expand Up @@ -83,7 +97,7 @@ install: completion
install -D -m 0755 -t $(DESTDIR)/$(prefix)/lib/bootc contrib/scripts/fedora-bootc-destructive-cleanup; \
fi
install -D -m 0644 -t $(DESTDIR)/usr/lib/systemd/system crates/initramfs/*.service
install -D -m 0755 target/release/bootc-initramfs-setup $(DESTDIR)/usr/lib/bootc/initramfs-setup
install -D -m 0755 $(BOOTC_TARGET_DIR)/bootc-initramfs-setup $(DESTDIR)/usr/lib/bootc/initramfs-setup
install -D -m 0755 -t $(DESTDIR)/usr/lib/dracut/modules.d/51bootc crates/initramfs/dracut/module-setup.sh

# Run this to also take over the functionality of `ostree container` for example.
Expand Down
2 changes: 1 addition & 1 deletion crates/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ platforms = ["*-unknown-linux-gnu"]
[dependencies]
# Internal crates
bootc-lib = { version = "1.16", path = "../lib" }
bootc-utils = { package = "bootc-internal-utils", path = "../utils", version = "1.16.3" }
bootc-utils = { package = "bootc-internal-utils", path = "../utils", version = "1.16.0" }

# Workspace dependencies
anstream = { workspace = true }
Expand Down
11 changes: 11 additions & 0 deletions crates/xtask/src/man.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,17 @@ pub struct CliPositional {
/// Extract CLI structure by running the JSON dump command
#[context("Extracting CLI")]
pub fn extract_cli_json(sh: &Shell) -> Result<CliCommand> {
if let Ok(bootc_bin) = std::env::var("BOOTC_DOCGEN_BIN") {
let json_output = cmd!(sh, "{bootc_bin} internals dump-cli-json")
.read()
.context("Running CLI JSON dump command")?;

let cli_structure: CliCommand =
serde_json::from_str(&json_output).context("Parsing CLI JSON output")?;

return Ok(cli_structure);
}

// If we have a release binary, assume that we should compile
// in release mode as hopefully we'll have incremental compilation
// enabled.
Expand Down