2025-09-19 15:40:44 -04:00
|
|
|
# Understanding Makefile vs Justfile:
|
|
|
|
|
#
|
2025-10-31 17:47:17 -04:00
|
|
|
# This file should primarily *only* involve
|
|
|
|
|
# invoking tools which *do not* have side effects outside
|
|
|
|
|
# of the current working directory. In particular, this file MUST NOT:
|
2025-09-19 15:40:44 -04:00
|
|
|
# - Spawn podman or virtualization tools
|
|
|
|
|
# - Invoke `sudo`
|
|
|
|
|
#
|
|
|
|
|
# Stated positively, the code invoked from here is only expected to
|
|
|
|
|
# operate as part of "a build" that results in a bootc binary
|
|
|
|
|
# plus data files. The two key operations are `make`
|
2025-10-31 17:47:17 -04:00
|
|
|
# and `make install`. As this is Rust, the generated binaries are in
|
|
|
|
|
# the current directory under `target/` by default. Some rules may place
|
|
|
|
|
# other generated files there.
|
|
|
|
|
#
|
2025-09-22 14:48:13 -04:00
|
|
|
# We expect code run from here is (or can be) inside a container with low
|
2025-09-19 15:40:44 -04:00
|
|
|
# privileges - running as a nonzero UID even.
|
2025-09-22 14:48:13 -04:00
|
|
|
#
|
|
|
|
|
# Understanding Makefile vs xtask.rs: Basically use xtask.rs if what
|
|
|
|
|
# you're doing would turn into a mess of bash code, whether inline here
|
|
|
|
|
# or externally in e.g. ./ci/somebashmess.sh etc.
|
2025-10-31 17:47:17 -04:00
|
|
|
#
|
|
|
|
|
# In particular, the Justfile contains rules for things like integration
|
|
|
|
|
# tests which might spawn VMs, etc.
|
2025-09-19 15:40:44 -04:00
|
|
|
|
2022-12-02 11:03:50 -05:00
|
|
|
prefix ?= /usr
|
|
|
|
|
|
2025-08-19 12:07:19 +02:00
|
|
|
# Enable rhsm if we detect the build environment is RHEL-like.
|
|
|
|
|
# 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)
|
2025-11-25 09:40:02 -05:00
|
|
|
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)
|
2025-08-19 12:07:19 +02:00
|
|
|
|
2025-11-25 09:40:02 -05:00
|
|
|
# Build all binaries
|
|
|
|
|
.PHONY: bin
|
|
|
|
|
bin: manpages
|
|
|
|
|
cargo build --release --features "$(CARGO_FEATURES)" --bins
|
2025-06-06 11:11:58 -04:00
|
|
|
|
2025-11-25 09:40:02 -05:00
|
|
|
# Note this cargo build is run without features (such as rhsm)
|
2025-09-17 16:17:12 -04:00
|
|
|
.PHONY: manpages
|
|
|
|
|
manpages:
|
2025-11-25 09:40:02 -05:00
|
|
|
cargo run --release --package xtask -- manpages
|
2025-09-04 18:11:14 -04:00
|
|
|
|
2026-01-21 17:03:28 +01:00
|
|
|
.PHONY: completion
|
2026-01-23 16:59:14 +01:00
|
|
|
completion: bin
|
2026-01-21 17:03:28 +01:00
|
|
|
mkdir -p target/completion
|
|
|
|
|
for shell in bash elvish fish powershell zsh; do \
|
|
|
|
|
target/release/bootc completion $$shell > target/completion/bootc.$$shell; \
|
|
|
|
|
done
|
|
|
|
|
|
2025-09-02 12:01:51 -04:00
|
|
|
STORAGE_RELATIVE_PATH ?= $(shell realpath -m -s --relative-to="$(prefix)/lib/bootc/storage" /sysroot/ostree/bootc/storage)
|
2026-01-21 17:03:28 +01:00
|
|
|
install: completion
|
2023-10-12 15:29:31 -04:00
|
|
|
install -D -m 0755 -t $(DESTDIR)$(prefix)/bin target/release/bootc
|
2025-01-25 14:20:22 +01:00
|
|
|
install -D -m 0755 -t $(DESTDIR)$(prefix)/bin target/release/system-reinstall-bootc
|
2024-07-22 10:57:01 -04:00
|
|
|
install -d -m 0755 $(DESTDIR)$(prefix)/lib/bootc/bound-images.d
|
2024-07-16 15:05:02 -04:00
|
|
|
install -d -m 0755 $(DESTDIR)$(prefix)/lib/bootc/kargs.d
|
2025-09-02 12:01:51 -04:00
|
|
|
ln -s "$(STORAGE_RELATIVE_PATH)" "$(DESTDIR)$(prefix)/lib/bootc/storage"
|
2025-07-16 14:23:52 -04:00
|
|
|
install -D -m 0755 crates/cli/bootc-generator-stub $(DESTDIR)$(prefix)/lib/systemd/system-generators/bootc-systemd-generator
|
2023-10-14 17:51:42 -04:00
|
|
|
install -d $(DESTDIR)$(prefix)/lib/bootc/install
|
2025-09-17 16:17:12 -04:00
|
|
|
install -D -m 0644 -t $(DESTDIR)$(prefix)/share/man/man5 target/man/*.5; \
|
|
|
|
|
install -D -m 0644 -t $(DESTDIR)$(prefix)/share/man/man8 target/man/*.8; \
|
2026-01-21 17:03:28 +01:00
|
|
|
install -D -m 0644 target/completion/bootc.bash $(DESTDIR)$(prefix)/share/bash-completion/completions/bootc
|
2026-01-22 17:22:00 +01:00
|
|
|
install -D -m 0644 target/completion/bootc.elvish $(DESTDIR)$(prefix)/share/elvish/lib/bootc.elv
|
2026-01-21 17:03:28 +01:00
|
|
|
install -D -m 0644 target/completion/bootc.fish $(DESTDIR)$(prefix)/share/fish/vendor_completions.d/bootc.fish
|
2026-01-22 17:22:00 +01:00
|
|
|
install -D -m 0644 target/completion/bootc.powershell $(DESTDIR)$(prefix)/share/powershell/Modules/Bootc/Bootc.psm1
|
|
|
|
|
install -D -m 0644 target/completion/bootc.zsh $(DESTDIR)$(prefix)/share/zsh/site-functions/_bootc
|
2024-12-16 16:38:29 -05:00
|
|
|
install -D -m 0644 -t $(DESTDIR)/$(prefix)/lib/systemd/system systemd/*.service systemd/*.timer systemd/*.path systemd/*.target
|
2024-12-19 16:24:48 -05:00
|
|
|
install -D -m 0644 -t $(DESTDIR)/$(prefix)/share/doc/bootc/baseimage/base/usr/lib/ostree/ baseimage/base/usr/lib/ostree/prepare-root.conf
|
|
|
|
|
install -d -m 755 $(DESTDIR)/$(prefix)/share/doc/bootc/baseimage/base/sysroot
|
|
|
|
|
cp -PfT baseimage/base/ostree $(DESTDIR)/$(prefix)/share/doc/bootc/baseimage/base/ostree
|
2025-01-03 10:53:47 -05:00
|
|
|
# Ensure we've cleaned out any possibly older files
|
|
|
|
|
rm -vrf $(DESTDIR)$(prefix)/share/doc/bootc/baseimage/dracut
|
2025-01-09 10:59:15 -05:00
|
|
|
rm -vrf $(DESTDIR)$(prefix)/share/doc/bootc/baseimage/systemd
|
|
|
|
|
# Copy dracut and systemd config files
|
2025-01-03 10:53:47 -05:00
|
|
|
cp -Prf baseimage/dracut $(DESTDIR)$(prefix)/share/doc/bootc/baseimage/dracut
|
2025-01-09 10:59:15 -05:00
|
|
|
cp -Prf baseimage/systemd $(DESTDIR)$(prefix)/share/doc/bootc/baseimage/systemd
|
2025-11-10 23:19:35 +00:00
|
|
|
# Install fedora-bootc-destructive-cleanup in fedora derivatives
|
|
|
|
|
ID=$$(. /usr/lib/os-release && echo $$ID); \
|
|
|
|
|
ID_LIKE=$$(. /usr/lib/os-release && echo $$ID_LIKE); \
|
|
|
|
|
if [ "$$ID" = "fedora" ] || [[ "$$ID_LIKE" == *"fedora"* ]]; then \
|
|
|
|
|
install -D -m 0755 -t $(DESTDIR)/$(prefix)/lib/bootc contrib/scripts/fedora-bootc-destructive-cleanup; \
|
|
|
|
|
fi
|
2025-11-18 13:59:57 -05:00
|
|
|
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 -t $(DESTDIR)/usr/lib/dracut/modules.d/51bootc crates/initramfs/dracut/module-setup.sh
|
2023-11-03 16:06:57 -04:00
|
|
|
|
2024-11-25 14:17:49 -05:00
|
|
|
# Run this to also take over the functionality of `ostree container` for example.
|
|
|
|
|
# Only needed for OS/distros that have callers invoking `ostree container` and not bootc.
|
|
|
|
|
install-ostree-hooks:
|
|
|
|
|
install -d $(DESTDIR)$(prefix)/libexec/libostree/ext
|
|
|
|
|
for x in ostree-container ostree-ima-sign ostree-provisional-repair; do \
|
|
|
|
|
ln -sf ../../../bin/bootc $(DESTDIR)$(prefix)/libexec/libostree/ext/$$x; \
|
|
|
|
|
done
|
|
|
|
|
|
2024-12-06 15:52:20 -05:00
|
|
|
# Install the main binary, the ostree hooks, and the integration test suite.
|
|
|
|
|
install-all: install install-ostree-hooks
|
2025-08-07 15:16:38 -04:00
|
|
|
install -D -m 0755 target/release/tests-integration $(DESTDIR)$(prefix)/bin/bootc-integration-tests
|
2024-05-31 16:01:41 -04:00
|
|
|
|
2025-09-22 14:48:13 -04:00
|
|
|
build-unit-tests:
|
|
|
|
|
cargo t --no-run
|
|
|
|
|
|
|
|
|
|
# We separate the build of the unit tests from actually running them in some cases
|
|
|
|
|
install-unit-tests: build-unit-tests
|
|
|
|
|
cargo t --no-run --frozen
|
|
|
|
|
install -D -m 0755 -t $(DESTDIR)/usr/lib/bootc/units/ $$(cargo t --no-run --message-format=json | jq -r 'select(.profile.test == true and .executable != null) | .executable')
|
|
|
|
|
install -d -m 0755 /usr/bin/
|
|
|
|
|
echo -e '#!/bin/bash\nset -xeuo pipefail\nfor f in /usr/lib/bootc/units/*; do echo $$f && $$f; done' > $(DESTDIR)/usr/bin/bootc-units && chmod a+x $(DESTDIR)/usr/bin/bootc-units
|
|
|
|
|
|
2024-05-31 16:01:41 -04:00
|
|
|
test-bin-archive: all
|
2024-12-06 15:52:20 -05:00
|
|
|
$(MAKE) install-all DESTDIR=tmp-install && $(TAR_REPRODUCIBLE) --zstd -C tmp-install -cf target/bootc.tar.zst . && rm tmp-install -rf
|
2023-02-04 15:55:14 -05:00
|
|
|
|
2025-03-01 12:51:56 -05:00
|
|
|
# This gates CI by default. Note that for clippy, we gate on
|
|
|
|
|
# only the clippy correctness and suspicious lints, plus a select
|
|
|
|
|
# set of default rustc warnings.
|
|
|
|
|
# We intentionally don't gate on this for local builds in cargo.toml
|
|
|
|
|
# because it impedes iteration speed.
|
2025-08-26 09:50:01 -04:00
|
|
|
CLIPPY_CONFIG = -A clippy::all -D clippy::correctness -D clippy::suspicious -D clippy::disallowed-methods -Dunused_imports -Ddead_code
|
2025-09-22 14:48:13 -04:00
|
|
|
validate:
|
2024-07-15 17:44:59 -04:00
|
|
|
cargo fmt -- --check -l
|
2024-09-18 11:33:00 -04:00
|
|
|
cargo test --no-run
|
2025-07-16 14:23:52 -04:00
|
|
|
(cd crates/ostree-ext && cargo check --no-default-features)
|
|
|
|
|
(cd crates/lib && cargo check --no-default-features)
|
2025-03-01 12:51:56 -05:00
|
|
|
cargo clippy -- $(CLIPPY_CONFIG)
|
2024-09-18 11:33:00 -04:00
|
|
|
env RUSTDOCFLAGS='-D warnings' cargo doc --lib
|
2025-09-22 14:48:13 -04:00
|
|
|
.PHONY: validate
|
2025-03-01 12:51:56 -05:00
|
|
|
fix-rust:
|
|
|
|
|
cargo clippy --fix --allow-dirty -- $(CLIPPY_CONFIG)
|
|
|
|
|
.PHONY: fix-rust
|
2024-07-15 17:44:59 -04:00
|
|
|
|
2024-07-17 13:44:37 -04:00
|
|
|
update-generated:
|
|
|
|
|
cargo xtask update-generated
|
|
|
|
|
.PHONY: update-generated
|
|
|
|
|
|
2023-01-18 17:39:03 -05:00
|
|
|
vendor:
|
|
|
|
|
cargo xtask $@
|
|
|
|
|
.PHONY: vendor
|
|
|
|
|
|
|
|
|
|
package-rpm:
|
|
|
|
|
cargo xtask $@
|
|
|
|
|
.PHONY: package-rpm
|