Skip to content

Commit 4c2377b

Browse files
cgwaltersjmarrero
authored andcommitted
docs: Add a packaging-and-integration guide
Signed-off-by: Colin Walters <walters@verbum.org>
1 parent fc09d06 commit 4c2377b

File tree

2 files changed

+133
-0
lines changed

2 files changed

+133
-0
lines changed

docs/src/SUMMARY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464

6565
# More information
6666

67+
- [Packaging and integration](packaging-and-integration.md)
6768
- [Package manager integration](package-managers.md)
6869
- [Relationship with other projects](relationships.md)
6970
- [Relationship with OCI artifacs](relationship-oci-artifacts.md)
Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
# Packaging and Integration
2+
3+
This document describes how to build and package bootc for distribution in operating systems.
4+
5+
### Build Requirements
6+
7+
- Rust toolchain (see `rust-toolchain.toml` for the version)
8+
- `coreutils` and `make`
9+
10+
### Basic Build Commands
11+
12+
The primary build targets are:
13+
14+
```bash
15+
make all
16+
```
17+
18+
This builds:
19+
- Binary artifacts (`cargo build --release`)
20+
- Man pages (via `cargo xtask manpages`)
21+
22+
The built binaries are placed in `target/release/`:
23+
- `bootc` - The main bootc CLI
24+
- `system-reinstall-bootc` - System reinstallation tool
25+
- `bootc-initramfs-setup` - Initramfs setup utility
26+
27+
### Installation
28+
29+
The `install` target supports the standard `DESTDIR` variable for staged installations, which is essential for packaging:
30+
31+
```bash
32+
make install DESTDIR=/path/to/staging/root
33+
```
34+
35+
36+
The install target handles:
37+
- Binary installation to `$(prefix)/bin`
38+
- Man pages to `$(prefix)/share/man/man{5,8}`
39+
- systemd units to `$(prefix)/lib/systemd/system`
40+
- Documentation and examples to `$(prefix)/share/doc/bootc`
41+
- Dracut module to `/usr/lib/dracut/modules.d/51bootc`
42+
- Base image configuration files
43+
44+
### Optional Installation Targets
45+
46+
#### install-ostree-hooks
47+
48+
For distributions that need bootc to provide compatibility with `ostree container` commands:
49+
50+
```bash
51+
make install-ostree-hooks DESTDIR=/tmp/stage
52+
```
53+
54+
This creates symbolic links in `$(prefix)/libexec/libostree/ext/` for:
55+
- `ostree-container`
56+
- `ostree-ima-sign`
57+
- `ostree-provisional-repair`
58+
59+
## Source Packaging
60+
61+
### Vendored Dependencies
62+
63+
bootc is written in Rust and has numerous dependencies. For distribution packaging, we recommend using a vendored tarball of Rust crates to ensure reproducible builds and avoid network access during the build process.
64+
65+
#### Generating the Vendor Tarball
66+
67+
Use the `cargo xtask package` command to generate both source and vendor tarballs:
68+
69+
```bash
70+
cargo xtask package
71+
```
72+
73+
This creates two files in the `target/` directory:
74+
- `bootc-<version>.tar.zstd` - Source tarball with git archive contents
75+
- `bootc-<version>-vendor.tar.zstd` - Vendored Rust dependencies
76+
77+
The source tarball includes a `.cargo/vendor-config.toml` file that configures cargo to use the vendored dependencies.
78+
79+
#### Using Vendored Dependencies in Builds
80+
81+
When building with vendored dependencies:
82+
83+
1. Extract both tarballs into your build directory
84+
2. Extract the vendor tarball to create a `vendor/` directory
85+
3. Ensure `.cargo/vendor-config.toml` is in place (included in source tarball)
86+
4. Build normally with `make all`
87+
88+
The cargo build will automatically use the vendored crates instead of fetching from crates.io.
89+
90+
### Version Management
91+
92+
The version is derived from git tags. The `cargo xtask package` command automatically determines the version:
93+
- If the current commit has a tag: uses the tag (e.g., `v1.0.0` becomes `1.0.0`)
94+
- Otherwise: generates a timestamp-based version with commit hash (e.g., `202501181430.g1234567890`)
95+
96+
This ensures that development snapshots have monotonically increasing version numbers.
97+
98+
## Cargo Features
99+
100+
The build respects the `CARGO_FEATURES` environment variable. By default, the Makefile auto-detects whether to enable the `rhsm` (Red Hat Subscription Manager) feature based on the build environment's `/usr/lib/os-release`.
101+
102+
To explicitly control features:
103+
104+
```bash
105+
make all CARGO_FEATURES="rhsm"
106+
```
107+
108+
## Integration Testing
109+
110+
For distributions that want to include integration tests, use:
111+
112+
```bash
113+
make install-all DESTDIR=/tmp/stage
114+
```
115+
116+
This installs:
117+
- Everything from `make install`
118+
- Everything from `make install-ostree-hooks`
119+
- The integration test binary as `bootc-integration-tests`
120+
121+
## Base image content
122+
123+
Alongside building the binary here, you may also want to prepare
124+
a base image. For that, see [bootc-images](bootc-images.md).
125+
126+
## Additional Resources
127+
128+
- See `Makefile` for all available targets and variables
129+
- See `crates/xtask/src/xtask.rs` for cargo xtask implementation details
130+
- See `contrib/packaging/bootc.spec` for an example RPM spec file that
131+
uses all of the above.
132+

0 commit comments

Comments
 (0)