Go Code Standards
When contributing to the Azure Linux toolkit, all Go code must adhere to Go formatting standards as described by the fmt package.Formatting Go Code
To format your Go code, run the following command in your Azure Linux toolkit:- Format all Go code according to Go standards
- Organize imports
- Remove unused dependencies
- Update go.mod and go.sum files
Testing Go Code
Before submitting a PR with Go tool changes, ensure all tests pass:SPEC File Standards
SPEC files are the core of package definitions in Azure Linux. Follow these standards when creating or modifying SPEC files.Package Location
Ensure packages are located in the appropriate directory:- SPECS - Fully supported packages with timely CVE maintenance
- SPECS-EXTENDED - Experimental or proof-of-concept packages
SPEC File Requirements
Release Tag
Increment theRelease tag when:
- Making changes to an existing package
- Packages depend on static components you modified (Golang,
*-staticsubpackages, etc.)
Check Section
All SPEC files must include a%check section:
- Add a
%checksection if not already present - Verify tests pass with
RUN_CHECK=y - Results will not fail a build, but logs should be checked
Changelog Entries
Add clear changelog entries for all modifications:Clean SPEC Files
When graduating packages from SPECS-EXTENDED to SPECS:- Remove references, macros, comments, etc. only applicable to other distros
- Ensure the SPEC file is specific to Azure Linux
Package Sources
All package sources must be properly managed:Source Location
Sources should be:- Compressed and placed on the source server (preferred)
- Or located in
SPECS/<package>/SOURCESorSPECS/<package>
Source Hashes
All source files must have up-to-date hashes in*.signatures.json files:
Upstream Sources
Packages must have a viable upstream source that actively addresses CVEs.Manifest File Standards
Several manifest files must be kept up-to-date for package management.cgmanifest Files
cgmanifest files record all package sources and must be:- Up-to-date
- Alphabetically sorted
./cgmanifest.json./toolkit/tools/cgmanifest.json./toolkit/scripts/toolchain/cgmanifest.json.github/workflows/cgmanifest.json
LICENSE-MAP Files
LICENSE-MAP files indicate which licenses are being used by Azure Linux’s packages and where packages may be derived from. Files to maintain:./LICENSES-AND-NOTICES/SPECS/data/licenses.json./LICENSES-AND-NOTICES/SPECS/LICENSES-MAP.md
Toolchain Manifests
If your changes affect the toolchain, update these manifests to match the latest package versions in SPEC files:toolchain_x86_64.txttoolchain_aarch64.txtpkggen_core_x86_64.txtpkggen_core_aarch64.txt
Package Requirements
General Requirements
All packages must meet these requirements:- Viable Upstream Source - Package needs a viable upstream source that actively addresses CVEs
- No Project-Specific Code - Package must not include project specific code
- Multiple Use Cases - For SPECS packages, the package needs to offer value for multiple use cases
Static Dependencies
When modifying packages with static components:- Identify dependent packages that contain a
BuildRequireson your package - Increment the
Releasetag for all dependent packages - This applies to:
- Golang packages
*-staticsubpackages- Other packages creating static links
- Investigating
makecommands in dependent packages - Consulting an Azure Linux developer
Build Standards
Building Packages
All packages must successfully build before submission. See the building instructions for detailed guidance.Building the Toolchain
If you modified toolchain packages:- Verify the toolchain builds successfully
- Update all toolchain manifests
- Test the build with:
Documentation Standards
When making changes to the build system or adding new features:- Update relevant documentation in toolkit/docs
- Ensure documentation is clear and comprehensive
- Include examples where appropriate
- Update any affected tutorials or guides
Code Review Standards
During code review, expect reviewers to check for:- Adherence to these coding standards
- Proper formatting (Go code, SPEC files)
- Complete and accurate manifest files
- Appropriate test coverage
- Clear and accurate documentation
- Security best practices
- Performance considerations