Overview
License Check scans directories containing RPM packages and validates:- Proper use of
%licensedirectives - License files not incorrectly marked as
%docfiles - License files placed in
/usr/share/licenses/ - Detection of duplicated license files
- Compliance with license naming conventions
Usage
Parameters
Required Parameters
Directories to recursively scan for RPM files to validate. Multiple directories can be specified.
Path to a file containing license names to check for. This file defines valid license identifiers.
Directory to store temporary files during validation.
The distribution tag for the packages being validated (e.g.,
azl3).Full path to
worker_chroot.tar.gz file used to create a clean validation environment.Optional Parameters
Path to a file containing license exceptions. This file can define per-package and global exceptions using regex patterns.
Level of license validation to perform. Valid values:
none- Skip license checkingdefault- Standard validation (recommended)pedantic- Strict validation treating warnings as errors
Path to save the detailed validation results in JSON format.
Path to save a human-readable summary of the validation results.
Logging Options
Path to file for log output.
Log level: panic, fatal, error, warn, info, debug, trace.
Validation Modes
Default Mode
The default mode performs standard validation and reports errors for:- License files marked as
%docinstead of%license - Files in
/usr/share/licenses/not marked as license files - Warnings for duplicated license files
Pedantic Mode
Pedantic mode is stricter and treats all warnings as errors, including:- Duplicated license files (both
%licenseand%doc) - All issues flagged in default mode
None Mode
Skips all license validation.Error Types
License Check categorizes issues into three types:1. Bad %doc Files
A documentation file that appears to be a license file but is marked with%doc instead of %license.
How to fix: Mark the file using %license in your spec file, ideally without a buildroot path:
2. Bad General Files
A file placed in/usr/share/licenses/ that is not flagged as a license file.
How to fix: Use %license instead of manually placing files:
3. Duplicated License Files
A license file that is both a%license and a %doc file.
How to fix: Remove the duplicate entry. If the files are equivalent, keep only the %license entry.
Examples
Basic Validation
Validate RPMs in a directory:Multiple Directories
Validate RPMs across multiple directories:Save Results
Generate detailed results and summary files:Pedantic Mode
Run with strict validation:Exception Files
Exception files allow you to suppress false positives using regex patterns.Format
The exception file supports per-package and global exceptions:Example Exception File
Querying Package Contents
You can inspect package contents using RPM commands:Exit Codes
License Check uses the following exit codes:- 0 - All validations passed (or only warnings in default mode)
- 1 - One or more packages have license errors
Best Practices
- Use %license directive: Always use
%licensefor license files in spec files - Avoid manual paths: Prefer
%license COPYINGover%license %{_docdir}/%{name}/COPYING - Review exceptions: Regularly review and minimize exception file entries
- Run in CI/CD: Integrate license checking into your build pipeline
- Keep exceptions documented: Document why each exception exists
Related Tools
- Spec Reader - Parse RPM spec files
- Validator - Validate image configurations
- Downloader - Download files with retry logic