Overview
Spec Reader is a critical component of the Azure Linux build system that:- Parses RPM spec files to extract package metadata
- Resolves build and runtime dependencies
- Generates JSON output for build orchestration
- Supports parallel processing for improved performance
- Handles toolchain and pre-built package detection
Usage
Parameters
Required Parameters
Directory to scan for SPEC files.
Output file path to export the JSON results.
Directory containing source RPMs (SRPMs).
Directory containing built binary RPMs.
Directory containing pre-built toolchain RPMs. Should contain top-level directories for each architecture.
The distribution tag the spec files will be built with (e.g.,
azl3).Optional Parameters
Path to a file containing a list of specific spec files to parse. If empty, all specs in the input directory will be parsed.
Number of concurrent goroutines to use for parsing. Adjust based on available CPU cores.
Directory to store temporary files while parsing. Required if using a worker chroot.
Full path to
worker_chroot.tar.gz. If empty, specs will be parsed in the host environment (less isolated but faster).Path to a file listing RPMs created by the toolchain. These RPMs will be marked as pre-built in the output.
The target architecture for the RPM binaries (e.g.,
x86_64, aarch64).Whether to run the spec file’s
%check section during package build analysis.Logging and Profiling
Path to file for log output.
Log level: panic, fatal, error, warn, info, debug, trace.
File to store timing information for performance analysis.
Path to save CPU profiling data.
Path to save memory profiling data.
Examples
Basic Parsing
Parse all spec files in a directory:Parse Specific Specs
Parse only specific spec files listed in a file:Using Worker Chroot
Parse specs in an isolated chroot environment for better consistency:With Toolchain Manifest
Mark toolchain packages as pre-built:Parallel Processing
Adjust worker count for faster parsing on multi-core systems:Cross-Architecture Build
Parse specs for a different target architecture:With Performance Profiling
Profile the parsing process:Output Format
Spec Reader generates a JSON file containing structured information about packages, including:- Package names and versions
- Build and runtime dependencies
- Architecture information
- Source and binary RPM relationships
- Toolchain package markers
Example Output Structure
Spec List File Format
The spec list file should contain one spec file name per line (without the .spec extension):Worker Chroot
Using a worker chroot provides several benefits:- Isolation: Specs are parsed in a clean, consistent environment
- Reproducibility: Results are not affected by host system packages
- Safety: Prevents spec parsing from affecting the host system
Parsing without a worker chroot is faster but less isolated. Use a worker chroot for production builds to ensure consistency.
Performance Tuning
Worker Count
The--workers flag controls parallelism:
- Default: 100 workers
- Low-core systems: Use 50-100 workers
- High-core systems: Use 200+ workers
- Memory-constrained: Reduce workers to avoid OOM errors
Build Directory
Place the build directory on fast storage (SSD) for better performance.Troubleshooting
Out of Memory
Reduce the number of workers:Slow Parsing
- Increase worker count on multi-core systems
- Use faster storage for build directory
- Parse without worker chroot (less safe but faster)
Missing Dependencies
Ensure all required directories contain the necessary RPMs:- Check
--srpm-dircontains source RPMs - Check
--rpm-dircontains built RPMs - Check
--toolchain-rpms-dircontains toolchain packages
Related Tools
- Grapher - Build dependency graphs from spec data
- Scheduler - Schedule package builds based on dependencies
- License Check - Validate RPM license files