Build Process Overview
The package building process consists of five stages:Complete Package Build Flow
Stage 1: Dependency Extraction
Thespecreader tool scans intermediate spec files and extracts dependency information using rpmspec -q inside the chroot worker.
What Gets Extracted
For each package in a spec file:- Provides - Package name(s), version, and virtual packages
- BuildRequires - Packages needed to build (shared across all subpackages)
- Requires - Packages needed at runtime (per subpackage)
Example Output
A simple spec might produce:./../build/pkg_artifacts/specs.json
Rich Dependencies
Spec files can use complex requirement expressions:- Supported
- Partial Support
- Unsupported
and, or, with - Both options recorded, allowing maximum flexibility during installAll optional RPMs must be available, even if not used for a specific configuration.
Stage 2: Dependency Graphing
Thegrapher tool converts specs.json into a directed acyclic graph (DAG) representing package dependencies.
Graph Node Types
TypeLocalBuild - Build Nodes
TypeLocalBuild - Build Nodes
Represents a local package that can be builtStates:
StateBuild- Should be builtStateBuildError- Dependencies satisfied but build failedStateUpToDate- Package already available locally
TypeLocalRun - Run Nodes
TypeLocalRun - Run Nodes
Represents a package that can be installed or used as a dependencyStates:
StateMeta- Organizational node for imposing ordering
TypeRemoteRun - Remote Nodes
TypeRemoteRun - Remote Nodes
Unknown package needed as a dependency, must be resolved remotelyStates:
StateUnresolved- No source found yetStateCached- Remote source found and package cached locally
TypeGoal - Goal Nodes
TypeGoal - Goal Nodes
Special node grouping packages togetherStates:
StateMeta- If satisfied, all grouped packages are available
TypePureMeta - Pure Meta Nodes
TypePureMeta - Pure Meta Nodes
Purely organizational, used to resolve intra-package cyclesStates:
StateMeta- Organizational node
Graph Generation Process
Package Lookup and Versioning
Dependencies specify requirements with varying detail:- Simple name:
Requires: example - Version constraint:
Requires: example >= 1.0.0 - Double constraint:
Requires: example >= 1.0.0,Requires: example < 2.0.0 - Exact version:
Requires: example = 1.0.0
Versions are split into version and release components. Release numbers are only considered if both versions explicitly contain one.
Cycle Resolution
Circular dependencies are generally fatal errors, except for special cases: Solvable Cycles:- All nodes in cycle from the same SPEC file
- All dependencies are runtime dependencies
TypePureMeta node consolidating all cycle dependencies. Cycle nodes then depend on the meta node instead of each other.
Cycle Resolution Example
Cycle Resolution Example
Nodes After (meta node ID=8):The meta node consolidates requirements, breaking the cycle.
A-a and A-b are from the same spec and require each other:Before:Dynamic Dependencies
Some provides are only known after building. For example,bar may provide pkgconfig(bar), but this is only known after building bar.
These implicit provides create dynamic dependencies that result in graphs that may not be solvable until packages are built. The scheduler handles this by analyzing built RPMs and updating the graph.
Output location: ./../build/pkg_artifacts/graph.dot
Stage 3: Dependency Resolution
Thegraphpkgfetcher tool resolves unresolved remote nodes by finding or downloading missing packages.
Search Order
The tool searches five locations usingtdnf in a chroot:
Set
DISABLE_UPSTREAM_REPOS=y to disable all network-accessed repositories.How It Works
tdnfprioritizes local packages over remote downloads- Local packages are accessed via mounted overlay in chroot
- Cached RPMs are written through a writable mount
- Local folder is converted to a repo (changes not persisted outside chroot)
- Satisfied nodes are marked as
StateCached
./../build/pkg_artifacts/cached_graph.dot
Stage 4: Build Scheduling
Thescheduler tool orchestrates parallel package builds using a pool of pkgworker agents.
Scheduling Algorithm
Build Optimization
The scheduler avoids unnecessary rebuilds:- Skips building if package already exists
- But rebuilds if any build dependency was rebuilt
- This ensures consistency across the build
Dynamic Dependency Handling
When a package is built:
If dynamic dependencies exist, the full graph is maintained until enough packages are built to resolve all dynamic dependencies.
Output location:
./../build/pkg_artifacts/built_graph.dot
Stage 5: Package Building
Thepkgworker tool (invoked by scheduler) builds individual packages in isolated chroot environments.
Build Process
Visualizing Graphs
All graph files use GraphVizdot format and include human-readable information for debugging.
View Graphs Visually
Note: Graphs for large builds are often impractically large to visualize. They’re still useful for programmatic analysis or grepping for specific packages.
Graph Files
graph.dot- Initial graph from graphercached_graph.dot- After dependency resolutionbuilt_graph.dot- Final state after all builds
Next Steps
Image Generation
Learn how packages are composed into bootable images
Local Packages
Return to local package handling