Package Build Strategies
The Azure Linux ecosystem provides thousands of packages, but most are not used in a typical image. You can choose to:- Build all packages - Complete rebuild of the entire package repository
- Build for specific image - Only packages needed for a target image
- Build specific packages - Targeted builds for development and testing
Build All Packages
To rebuild all Azure Linux packages:Building all packages can take many hours. Use parallel builds with
-j$(nproc) to utilize all CPU cores.Build Packages for Specific Image
Build only the packages needed for a specific image by specifying a configuration file:- All packages included in the image
- All packages needed to build those packages (dependencies)
- Significantly fewer packages than a full build
Targeted Package Building
For rapid iteration on specific packages, use targeted builds:Targeted building downloads dependencies from packages.microsoft.com and rebuilds only the specified SPEC files. This is ideal for developing or modifying packages.
Package Build Workflow
Step 1: SRPM Creation
The build system first creates Source RPMs (SRPMs) from SPEC files and sources:- Scans local
*.specfiles inSPECS/ - Locates source files for each package
- Creates
*.src.rpmfiles bundling specs with sources
Step 2: RPM Building
The SRPMs are then built into binary RPMs:- Resolves package dependencies
- Builds packages in correct dependency order
- Uses parallel workers to build multiple packages simultaneously
- Places built RPMs in
../out/RPMS/
Working with Package Sources
Download Pre-packaged Sources
UseDOWNLOAD_SRPMS=y to download pre-packaged SRPMs instead of packing from local specs:
Specify Source URL
Provide a custom source server for downloading package sources:Package Build Variables
Key Variables
Space-separated list of spec names to pack into SRPMs. If empty, all specs under
SPECS_DIR are packed.Example: SRPM_PACK_LIST="kernel golang openssh"Explicit list of packages to build. Skipped if already up-to-date.Example:
PACKAGE_BUILD_LIST="vim nano"Force rebuild these packages even if up-to-date.Example:
PACKAGE_REBUILD_LIST="kernel openssh"Pretend these packages are already built (useful when a dependency is broken).Example:
PACKAGE_IGNORE_LIST="ncurses"y- Rebuild worker chroot if changedn- Reuse existing worker chroot (faster for iterative builds)
y- Build packages locally from specsn- Download all packages from repos
Package Testing
Enable package tests during build:%check section of the spec file to validate the built package.
Advanced Package Builds
Build from Custom SPECS Directory
Update Source Signatures
When you modify source files, update their signature hashes:Clean Package Builds
Remove built artifacts before rebuilding:Build Outputs
Built packages are placed in:Next Steps
After building packages, you can:- Create Images from the built packages
- Add New Packages to the distribution
- Review the Build Variables Reference