OpenAI Codex CLI Instructions for xpack
xpack - Universal Linux Package Builder
- Language: Go ≥1.18
- Type: CLI for binary-to-package conversion
- Formats: .deb, .rpm, .tar.gz
- Purpose: Automate Linux package creation
# Development
go build -o xpack src/Core/main.go
./bin/xpack -i ./bin -arch amd64 -v 1.1.1
# Test
go test ./...
go fmt ./...
go vet ./...
# Distribution
./Scripts/BinBuilder.sh # Multi-platform build- Same input must produce identical output
- No timestamps (use SOURCE_DATE_EPOCH)
- Deterministic file ordering
- Consistent compression
- Debian: Follow Debian Policy Manual
- RPM: Follow RPM Packaging Guidelines
- Tarball: Standard Unix layout
- Use
lintianfor .deb packages - Use
rpmlintfor .rpm packages - Test installation on target systems
src/
├── Core/main.go # CLI entry point
├── base/ # Utilities
└── packager/ # Package builders
Scripts/
├── BinBuilder.sh # Multi-platform builder
└── installer.sh # One-line installer
dist/ # Output packages
Binary → CLI Args → Metadata → Package Structure → Build → Validate → Output
// ✅ GOOD
if err != nil {
return fmt.Errorf("failed to create package '%s': %w", name, err)
}
// ❌ BAD
if err != nil {
return err
}// ✅ GOOD
type PackageMetadata struct {
Name string
Version string
Architecture string
Maintainer string
Description string
}
func BuildDeb(meta PackageMetadata, binPath string) error
// ❌ BAD
func BuildDeb(name, version, arch, maintainer, desc, binPath string) error// ✅ Sort for reproducibility
sort.Strings(files)
for _, file := range files {
addToPackage(file)
}// ✅ Validate package names
if !regexp.MustCompile(`^[a-z0-9][a-z0-9+.-]+$`).MatchString(name) {
return fmt.Errorf("invalid package name: %s", name)
}Update when features change:
- README.md - Usage, features
- INSTALLATION.md - Install methods
- LEARN.md - Advanced usage, guides
- CHANGELOG.md - Version changes
- Unit tests: Metadata, file operations
- Integration tests: Full package creation
- Validation: lintian, rpmlint
- Installation: Test on Debian, RHEL/Fedora
- Control file with metadata
- Maintainer scripts (preinst, postinst, prerm, postrm)
- File layout: /usr/bin, /usr/share/doc
- Spec file with metadata
- Scriptlets (%pre, %post, %preun, %postun)
- File layout: /usr/bin, /usr/share/doc
- Standard Unix layout
- Install script
- Checksum file
❌ Non-deterministic builds ❌ Invalid package metadata ❌ Missing validation ❌ Breaking package standards ❌ Generic error messages
- ✅
go buildpasses - ✅
go test ./...passes - ✅ Packages validate (lintian, rpmlint)
- ✅ Reproducible builds
- ✅ Documentation updated
- ✅ Standards compliant