General Principles
Follow Fedora Standards
Terra packages should follow Fedora Packaging Guidelines unless Terra-specific exceptions apply.When in doubt, check how Fedora packages similar software and follow their conventions.
Quality Over Quantity
- Package software that provides real value to users
- Ensure packages are well-tested before submission
- Maintain packages you contribute - don’t abandon them
- Upstream bug fixes when possible rather than patching locally
Respect Licensing
- Only package software with compatible licenses (MIT, GPL, Apache, BSD, etc.)
- Always include license files in packages
- Document license information accurately in spec files
- For Rust packages, include dependency licenses
Spec File Standards
Header Section
Every spec file must have complete metadata:Version and Release
- Version: Upstream version number (1.2.3, not v1.2.3)
- Release: Start at 1, increment for packaging changes
- Use
%?distmacro for distribution tag
Source Handling
Dependencies
BuildRequires
List all build-time dependencies:Use
pkgconfig(name) for library dependencies when possible - it’s more portable.Requires
Runtime dependencies are often auto-detected, but specify when needed:Build Sections
%prep - Prepare Sources
%build - Compile
%install - Install Files
File Lists
Be specific about what files are included:Common File Locations
%{_bindir}-/usr/bin- User executables%{_sbindir}-/usr/sbin- System executables%{_libdir}-/usr/lib64(or/usr/lib) - Libraries%{_datadir}-/usr/share- Architecture-independent data%{_sysconfdir}-/etc- Configuration files%{_mandir}-/usr/share/man- Man pages%{_docdir}-/usr/share/doc- Documentation
Shell Completions
For tools with shell completions:Scriptlets
Use scriptlets for system integration:Changelog
Maintain an accurate changelog:Use
rpmdev-bumpspec to automatically add changelog entries with proper formatting.Terra-Specific Macros
anda-srpm-macros
For Rust packages, use Terra’s macros:%{crates_source}- Automatically construct crates.io URLs- Cargo build macros with Terra optimizations
Vendor Definition
Packages built in Terra CI include:Language-Specific Guidelines
Rust Packages
Python Packages
Go Packages
Packaging Best Practices
Directory Organization
Organize packages by category:Naming Conventions
Patch Management
Keep patches organized and documented:- Descriptive names explaining what the patch does
- Numbered sequentially (0001-fix.patch, 0002-feature.patch)
- Include upstream PR/issue numbers when applicable
Security Considerations
- Keep packages updated with security fixes
- Don’t disable security features (PIE, RELRO, stack protector)
- Validate checksums for sources
- Review code before packaging unknown software
Performance Optimization
Use mold Linker (Rust/C++)
Enable Compiler Optimizations
Parallel Builds
Testing Requirements
Before submitting packages:Common Issues and Solutions
File not found during build
File not found during build
Ensure source URLs are correct and accessible:Check that % and % macros are expanded correctly.
Debuginfo package errors
Debuginfo package errors
For some packages, disable debuginfo:Only do this when necessary (e.g., pre-compiled binaries).
Rust dependency build failures
Rust dependency build failures
Update Cargo.lock or use
%cargo_prep_online to fetch dependencies:Cross-architecture builds fail
Cross-architecture builds fail
Add architecture-specific conditionals:
Review Checklist
Before submitting your package, verify:- Spec file has complete metadata (Name, Version, License, URL, Summary)
- All sources have checksums or use trusted URLs
- BuildRequires lists all build dependencies
- License files are included in %files
- Files are installed to standard locations
- Package builds successfully on x86_64 and aarch64
- Package installs and runs correctly
- Changelog entry is present and formatted correctly
- No unnecessary files are packaged
- Update script (update.rhai) works if present
Additional Resources
Fedora Packaging Guidelines
Official Fedora packaging standards
RPM Packaging Guide
Comprehensive RPM packaging tutorial
Testing Guide
How to test your packages
Cargo RPM Macros
Rust packaging tools