2022-12-02 11:03:50 -05:00
|
|
|
prefix ?= /usr
|
|
|
|
|
|
2024-06-06 07:48:47 -04:00
|
|
|
SOURCE_DATE_EPOCH ?= $(shell git log -1 --pretty=%ct)
|
|
|
|
|
# https://reproducible-builds.org/docs/archives/
|
|
|
|
|
TAR_REPRODUCIBLE = tar --mtime="@${SOURCE_DATE_EPOCH}" --sort=name --owner=0 --group=0 --numeric-owner --pax-option=exthdr.name=%d/PaxHeaders/%f,delete=atime,delete=ctime
|
|
|
|
|
|
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)
|
|
|
|
|
CARGO_FEATURES ?= $(shell . /usr/lib/os-release; if echo "$$ID_LIKE" |grep -qF rhel; then echo rhsm; fi)
|
|
|
|
|
|
2022-12-02 11:03:50 -05:00
|
|
|
all:
|
2025-08-19 12:07:19 +02:00
|
|
|
cargo build --release --features "$(CARGO_FEATURES)"
|
2025-06-06 11:11:58 -04:00
|
|
|
|
2022-12-02 11:03:50 -05:00
|
|
|
install:
|
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
|
2024-07-25 14:18:34 -04:00
|
|
|
ln -s /sysroot/ostree/bootc/storage $(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
|
2023-11-03 16:06:57 -04:00
|
|
|
# Support installing pre-generated man pages shipped in source tarball, to avoid
|
2024-01-17 16:23:42 -05:00
|
|
|
# a dependency on pandoc downstream. But in local builds these end up in target/man,
|
|
|
|
|
# so we honor that too.
|
|
|
|
|
for d in man target/man; do \
|
|
|
|
|
if test -d $$d; then \
|
|
|
|
|
install -D -m 0644 -t $(DESTDIR)$(prefix)/share/man/man5 $$d/*.5; \
|
|
|
|
|
install -D -m 0644 -t $(DESTDIR)$(prefix)/share/man/man8 $$d/*.8; \
|
|
|
|
|
fi; \
|
|
|
|
|
done
|
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
|
2025-01-06 15:22:40 -05:00
|
|
|
install -d -m 0755 $(DESTDIR)/$(prefix)/lib/systemd/system/multi-user.target.wants
|
|
|
|
|
ln -s ../bootc-status-updated.path $(DESTDIR)/$(prefix)/lib/systemd/system/multi-user.target.wants/bootc-status-updated.path
|
2025-01-22 14:17:57 -05:00
|
|
|
ln -s ../bootc-status-updated-onboot.target $(DESTDIR)/$(prefix)/lib/systemd/system/multi-user.target.wants/bootc-status-updated-onboot.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-04-30 11:22:31 -04: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 \
|
|
|
|
|
ln -s ../bootc-destructive-cleanup.service $(DESTDIR)/$(prefix)/lib/systemd/system/multi-user.target.wants/bootc-destructive-cleanup.service; \
|
|
|
|
|
install -D -m 0755 -t $(DESTDIR)/$(prefix)/lib/bootc contrib/scripts/fedora-bootc-destructive-cleanup; \
|
|
|
|
|
fi
|
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
|
|
|
|
|
|
2025-08-07 15:16:38 -04:00
|
|
|
# Install code in the initramfs, off by default except in builds from git main right now
|
|
|
|
|
# Also the systemd unit hardcodes /usr so we give up the farce of supporting $(prefix)
|
|
|
|
|
install-initramfs:
|
|
|
|
|
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 initramfs files, including dracut module
|
|
|
|
|
install-initramfs-dracut: install-initramfs
|
|
|
|
|
install -D -m 0755 -t $(DESTDIR)/usr/lib/dracut/modules.d/51bootc crates/initramfs/dracut/module-setup.sh
|
|
|
|
|
|
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
|
|
|
|
2022-12-02 11:03:50 -05:00
|
|
|
bin-archive: all
|
2024-06-06 07:48:47 -04:00
|
|
|
$(MAKE) install DESTDIR=tmp-install && $(TAR_REPRODUCIBLE) --zstd -C tmp-install -cf target/bootc.tar.zst . && rm tmp-install -rf
|
2022-12-02 11:03:50 -05:00
|
|
|
|
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
|
|
|
|
2024-06-10 14:07:11 -04:00
|
|
|
test-tmt:
|
|
|
|
|
cargo xtask test-tmt
|
2023-01-18 17:39:03 -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
|
2024-07-15 17:44:59 -04:00
|
|
|
validate-rust:
|
|
|
|
|
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
|
2024-07-15 17:44:59 -04:00
|
|
|
.PHONY: validate-rust
|
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
|
|
|
|
|
|
|
|
validate: validate-rust
|
tests: Add pytest and nushell based tests
I've been trying to keep this project in "one" programming
language by writing even tests in Rust...but specifically
for our integration tests it's pretty painful not just to
compile them but have to deal with baking them into the base image.
The tmt framework is very GHA like in that it scrapes the
git source tree and copies it into the target environment, which
works really well with scripts.
Now, if you know me you know I am not a fan of dynamic programming
languages like bash and Python. I'm one of those folks that actually
tries to use Rust for things that feel like "scripts" i.e. they're
*mostly* about forking external processes (see the xtask/
crate which uses "xshell").
Some of our testing code is in Rust too. However...there's a giant
tension here because:
- Iteration speed is very important for tests and scripts
- The artifact being an architecture-dependent binary pushes us
to inject it into container images; having the binary part
of the bootc image under test conceptually forces us to reprovision
for each test change, which is super expensive
Most other people when faced with the testing challenge would
just write shell scripts (or Python); that's definitely what tmt
expects people to do.
The podman project has a mix of a "bats" suite which is all
bash based, and a Go-based framework.
The thing is: bash is easy to mess up and has very little ability
to do static analysis. Go (and Python) are very verbose for forking external
processes.
I've been using https://www.nushell.sh/ for my interactive shell
for quite a while; I know just enough to get by day to day
(but honestly sometimes I still type "bash" and run a few things there
that I know how to express in bash but not nu)
Anyways though, nushell has a lot of desirable properties for
tests (which are basically scripts):
- Architecture independent
- Running an external process requires zero ceremony; it's the
default!
- But it *is* easy to e.g. scrape JSON from an external binary
into a rich data structure
- A decently rich standard library
The downside is, it's a new language. And in the end, I'm
not going to say it's the only way to write tests...maybe we
do end up with some more bash. It wouldn't be the end of the world.
But...after playing with this, I definitely like the result.
OK, and after some debate we decided to add Python too, so this
demos a pytest test.
Signed-off-by: Colin Walters <walters@verbum.org>
2024-06-22 09:18:49 -04:00
|
|
|
ruff check
|
2023-11-01 14:56:53 +01:00
|
|
|
.PHONY: validate
|
|
|
|
|
|
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
|