ig) as an example.
Prerequisites
Before adding a package, ensure you have:- Completed the Prerequisites setup
- Built or populated the Toolchain
- Familiarity with RPM SPEC files
Package Structure
Each package requires:- SPEC file - Contains information on the software and how to build and package it
- Signature file (JSON) - Contains hashes of source archives
- Source archives - The actual source code (
tar.gzfiles) - Optional files - Patches, helper scripts, etc.
Step 1: Create Package Directory
Step 2: Write the SPEC File
CreateSPECS/ig/ig.spec with the following structure:
Key SPEC File Sections
Metadata Section
Metadata Section
Defines package information: name, version, license, vendor, etc.
- Vendor - Always use “Microsoft Corporation”
- Distribution - Always use “Azure Linux”
- License - Must accurately reflect the software’s license
%prep Section
%prep Section
Prepares sources for building. Common macros:
%autosetup- Extracts and patches sources%setup- Manual source extraction control
%build Section
%build Section
Contains commands to compile the software. Use standard build tools like:
makecmakego build./configure && make
%install Section
%install Section
Installs files into
%{buildroot}. Files here will be packaged into the RPM.%check Section (Optional)
%check Section (Optional)
Runs tests to verify the build. This section is optional but recommended.
%files Section
%files Section
Lists all files to include in the RPM. Use macros like:
%{_bindir}-/usr/bin%{_libdir}-/usr/lib64or/usr/lib%license- License files%doc- Documentation files
Step 3: Obtain Source Files
Generate vendor archive (for Go packages)
For Go packages, create a vendor archive with dependencies:
The vendor archive is specific to Go packages. For other languages, you may need different dependency handling (e.g., for Python, Node.js, Rust).
Step 4: Build the Package
Build package
Build the package with source signature update:This command:
- Packs the SRPM from your spec
- Updates source signatures automatically
- Builds the package
- Runs tests if
%checksection exists
Step 5: Test the Package
Quick Test: Extract and Run
Container Testing
VM Testing
For comprehensive testing in a full VM environment:Step 6: Source Signatures
Azure Linux enforces hash checking for source files. Each*.spec file has a corresponding *.signatures.json file.
The build system automatically creates this during your first build with:
Manually Update Signatures
If you modify sources later:Package Build Dependencies
If your package has build dependencies that are also new, add them toSRPM_PACK_LIST:
Common Package Types
Go Packages
Require vendor archives with dependencies:- Use
go mod vendorto create vendor directory - Package vendor directory as separate source tarball
Python Packages
May need offline dependency bundles:- Use
pip downloadto get dependencies - Package as additional source tarball
Autotools Packages
Standard./configure && make pattern:
CMake Packages
Use CMake macros:Next Steps
After successfully building and testing your package:- Prepare for contribution - Review the Azure Linux contribution guidelines
- Open a pull request - Submit your package to the upstream repository
- Respond to feedback - Address any review comments from maintainers
Troubleshooting
Build fails with missing dependencies
Build fails with missing dependencies
Add missing dependencies to
BuildRequires: in your spec file:Source signature mismatch
Source signature mismatch
Update signatures after modifying sources:
%check section fails
%check section fails
Either fix the test or temporarily disable:
Go vendor archive issues
Go vendor archive issues
Ensure
go.mod and go.sum are up to date: