Documentation
¶
Overview ¶
Package binpkg implements local binhost management.
Package binpkg implements binary package building and management.
Package binpkg implements GPKG format writing.
Package binpkg implements binary package format handling.
Supports both modern GPKG (.gpkg.tar) and legacy TBZ2 (.tbz2) formats.
Example:
binPkg, err := binpkg.LoadBinaryPackage("/path/to/zlib-1.2.13.gpkg.tar")
if err != nil {
return err
}
// Check compatibility
if !binPkg.IsCompatible(desiredUSE) {
return errors.New("incompatible USE flags")
}
// Extract to directory
if err := binPkg.Extract("/var/tmp/portage/sys-libs/zlib-1.2.13/image"); err != nil {
return err
}
Package binpkg implements binary package signing.
Package binpkg implements TBZ2 format writing.
Package binpkg implements remote binhost uploading.
Index ¶
- func ExtractGPKG(packagePath, destDir string) error
- func ExtractTBZ2(packagePath, destDir string) error
- type BinaryFormat
- type BinaryPackage
- func (bp *BinaryPackage) Extract(destDir string) error
- func (bp *BinaryPackage) GetMetadata() (*BuildMetadata, error)
- func (bp *BinaryPackage) IsCompatible(desiredUSE []string) bool
- func (bp *BinaryPackage) IsFresh(maxAge time.Duration) bool
- func (bp *BinaryPackage) String() string
- func (bp *BinaryPackage) Verify() error
- type BinaryPackageBuilder
- func (b *BinaryPackageBuilder) Build() (*BinaryPackage, error)
- func (b *BinaryPackageBuilder) BuildWithOptions(opts BuildOptions) (*BinaryPackage, error)
- func (b *BinaryPackageBuilder) SetCompression(compression CompressionType)
- func (b *BinaryPackageBuilder) SetFormat(format BinaryFormat)
- func (b *BinaryPackageBuilder) SetOutputDir(dir string) error
- func (b *BinaryPackageBuilder) SetSigner(signer PackageSigner)
- type Binhost
- type BinhostManager
- func (m *BinhostManager) Add(pkg *BinaryPackage) error
- func (m *BinhostManager) Clean() error
- func (m *BinhostManager) GenerateIndex() error
- func (m *BinhostManager) Initialize() error
- func (m *BinhostManager) List() []*BinaryPackage
- func (m *BinhostManager) Remove(category, name, version string) error
- func (m *BinhostManager) Scan() error
- type BinhostType
- type BinhostUploader
- type BuildMetadata
- type BuildOptions
- type CompressionType
- type GPGSigner
- type GPKGWriter
- type HTTPUploader
- func (u *HTTPUploader) SetAuth(username, password string)
- func (u *HTTPUploader) SetTimeout(timeout time.Duration)
- func (u *HTTPUploader) Upload(pkg *BinaryPackage) error
- func (u *HTTPUploader) UploadDirectory(localDir, remoteDir string) error
- func (u *HTTPUploader) UploadFile(localPath, remotePath string) error
- type PackageSigner
- type RSASigner
- type SSHSigner
- type SSHUploader
- type SelectionResult
- type SelectionStrategy
- type Selector
- type SelectorOptions
- type Signature
- type SignatureType
- type Stats
- type TBZ2Writer
- type UploadOptions
- type XPAK
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExtractGPKG ¶
ExtractGPKG extracts GPKG package contents to destination directory.
Extracts only the image.tar.{compression} member which contains installed files.
func ExtractTBZ2 ¶
ExtractTBZ2 extracts TBZ2 package contents to destination directory.
Extracts the tar.bz2 archive, stopping before XPAK metadata.
Types ¶
type BinaryFormat ¶
type BinaryFormat int
BinaryFormat represents binary package format.
const ( // FormatGPKG is the modern GPKG format (.gpkg.tar, GLEP 78) // - Zstd compression // - Metadata in tar header // - Signature support // - Portage 3.0.30+ FormatGPKG BinaryFormat = iota // FormatTBZ2 is the legacy TBZ2 format (.tbz2) // - XPAK metadata // - Bzip2 compression // - Backward compatibility FormatTBZ2 // FormatUnknown indicates unknown or unsupported format FormatUnknown )
func DetectFormat ¶
func DetectFormat(path string) BinaryFormat
DetectFormat detects binary package format from file path.
func (BinaryFormat) Extension ¶
func (bf BinaryFormat) Extension() string
Extension returns file extension for format.
func (BinaryFormat) String ¶
func (bf BinaryFormat) String() string
String returns string representation of binary format.
type BinaryPackage ¶
type BinaryPackage struct {
// Package is the package metadata
Package *pkg.Package
// Format is the binary package format (GPKG or TBZ2)
Format BinaryFormat
// Path is the file path to the binary package
Path string
// Size is the package file size in bytes
Size int64
// Checksum is the SHA256 checksum
Checksum string
// Signature is the package signature (optional)
Signature *Signature
// BuildInfo contains build-time metadata
BuildInfo *BuildMetadata
}
BinaryPackage represents a binary package (pre-compiled).
func LoadBinaryPackage ¶
func LoadBinaryPackage(path string) (*BinaryPackage, error)
LoadBinaryPackage loads a binary package from file.
Automatically detects format (GPKG or TBZ2) and uses appropriate reader.
func LoadGPKG ¶
func LoadGPKG(path string) (*BinaryPackage, error)
LoadGPKG loads a GPKG format binary package.
GPKG format (GLEP 78):
- Modern tar-based format
- Zstd compression
- Metadata in special tar members
- Signature support
func LoadTBZ2 ¶
func LoadTBZ2(path string) (*BinaryPackage, error)
LoadTBZ2 loads a TBZ2 format binary package.
TBZ2 format (legacy):
- Bzip2-compressed tar archive
- XPAK metadata appended to end
- Format: [tar.bz2 data]XPAK[XPAK footer]
func (*BinaryPackage) Extract ¶
func (bp *BinaryPackage) Extract(destDir string) error
Extract extracts the binary package contents to destination directory.
This is the installation image directory (D in Portage).
func (*BinaryPackage) GetMetadata ¶
func (bp *BinaryPackage) GetMetadata() (*BuildMetadata, error)
GetMetadata extracts metadata without extracting full package.
This is useful for quickly checking package information without extraction.
func (*BinaryPackage) IsCompatible ¶
func (bp *BinaryPackage) IsCompatible(desiredUSE []string) bool
IsCompatible checks if this binary package is compatible with desired USE flags.
A binary package is compatible if:
- All required USE flags are present
- No conflicting USE flags are present
func (*BinaryPackage) IsFresh ¶
func (bp *BinaryPackage) IsFresh(maxAge time.Duration) bool
IsFresh checks if the binary package is newer than the given maximum age.
func (*BinaryPackage) String ¶
func (bp *BinaryPackage) String() string
String returns string representation of binary package.
func (*BinaryPackage) Verify ¶
func (bp *BinaryPackage) Verify() error
Verify verifies the package signature and checksum.
type BinaryPackageBuilder ¶
type BinaryPackageBuilder struct {
// Package is the installed package to build from
Package *state.InstalledPackage
// WorkDir is the temporary directory for building
WorkDir string
// OutputDir is where the final package will be placed
OutputDir string
// Format is the binary package format (GPKG or TBZ2)
Format BinaryFormat
// Compression is the compression type
Compression CompressionType
// Signer is optional package signer
Signer PackageSigner
// IncludeBuildLog includes build.log in package metadata
IncludeBuildLog bool
// Verbose enables detailed logging
Verbose bool
}
BinaryPackageBuilder builds binary packages from installed packages.
Example:
builder := binpkg.NewBinaryPackageBuilder(installedPkg, "/tmp/build") builder.SetFormat(binpkg.FormatGPKG) builder.SetCompression(binpkg.CompressionZstd) pkg, err := builder.Build()
func NewBinaryPackageBuilder ¶
func NewBinaryPackageBuilder(pkg *state.InstalledPackage, workDir string) (*BinaryPackageBuilder, error)
NewBinaryPackageBuilder creates a new binary package builder.
Parameters:
- pkg: Installed package to build from
- workDir: Temporary directory for building
Returns:
- *BinaryPackageBuilder: Configured builder
- error: If workDir cannot be created
func (*BinaryPackageBuilder) Build ¶
func (b *BinaryPackageBuilder) Build() (*BinaryPackage, error)
Build builds the binary package.
Process:
- Extract files from installed package
- Collect metadata
- Create package archive (GPKG or TBZ2)
- Generate checksums
- Sign package (if signer configured)
- Validate package structure
Returns:
- *BinaryPackage: Built package with path and metadata
- error: If build fails at any step
func (*BinaryPackageBuilder) BuildWithOptions ¶
func (b *BinaryPackageBuilder) BuildWithOptions(opts BuildOptions) (*BinaryPackage, error)
BuildWithOptions builds the binary package with custom options.
func (*BinaryPackageBuilder) SetCompression ¶
func (b *BinaryPackageBuilder) SetCompression(compression CompressionType)
SetCompression sets the compression type.
func (*BinaryPackageBuilder) SetFormat ¶
func (b *BinaryPackageBuilder) SetFormat(format BinaryFormat)
SetFormat sets the binary package format.
func (*BinaryPackageBuilder) SetOutputDir ¶
func (b *BinaryPackageBuilder) SetOutputDir(dir string) error
SetOutputDir sets the output directory for the final package.
func (*BinaryPackageBuilder) SetSigner ¶
func (b *BinaryPackageBuilder) SetSigner(signer PackageSigner)
SetSigner sets the package signer.
type Binhost ¶
type Binhost struct {
// URI is the binhost location
URI string
// Type is the binhost type (local, http, etc)
Type BinhostType
// Packages is the list of available packages
Packages []*BinaryPackage
// LastSync is when the binhost was last synchronized
LastSync time.Time
}
Binhost represents a binary package repository.
A binhost can be:
- Local directory (file:// or absolute path)
- HTTP/HTTPS URL (http://, https://)
- Remote server (rsync://, ssh://)
func NewBinhost ¶
NewBinhost creates a new binhost from URI.
func (*Binhost) Download ¶
func (b *Binhost) Download(binPkg *BinaryPackage, destPath string) error
Download downloads a binary package from the binhost to local path.
func (*Binhost) Find ¶
func (b *Binhost) Find(atom string) []*BinaryPackage
Find searches for packages matching the given atom.
Returns all matching packages, sorted by version (newest first).
type BinhostManager ¶
type BinhostManager struct {
// Root is the binhost root directory
Root string
// Packages is the list of packages in binhost
Packages []*BinaryPackage
// Verbose enables detailed logging
Verbose bool
// IndexFormat is the Packages index format (portage or gentoo)
IndexFormat string
}
BinhostManager manages a local binary package repository (binhost).
Directory structure:
/var/cache/binpkgs/ ├── Packages # Index file ├── category/ │ ├── package-1.0.0.gpkg.tar │ └── package-1.0.0.gpkg.tar.sig └── ...
Example:
manager := binpkg.NewBinhostManager("/var/cache/binpkgs")
err := manager.Add(binaryPackage)
err = manager.GenerateIndex()
func NewBinhostManager ¶
func NewBinhostManager(root string) *BinhostManager
NewBinhostManager creates a new binhost manager.
func (*BinhostManager) Add ¶
func (m *BinhostManager) Add(pkg *BinaryPackage) error
Add adds a binary package to the binhost.
Steps:
- Extract package metadata
- Create category directory
- Copy package file to binhost
- Copy signature if present
- Add to package list
func (*BinhostManager) Clean ¶
func (m *BinhostManager) Clean() error
Clean removes orphaned files and empty directories.
func (*BinhostManager) GenerateIndex ¶
func (m *BinhostManager) GenerateIndex() error
GenerateIndex generates the Packages index file.
Format:
PACKAGES: {package-count}
TIMESTAMP: {unix-timestamp}
CPV: {category/package-version}
SIZE: {bytes}
SHA256: {checksum}
USE: {use-flags}
REPO: gentoo
BUILD_TIME: {unix-timestamp}
PATH: {category/package-version.gpkg.tar}
func (*BinhostManager) Initialize ¶
func (m *BinhostManager) Initialize() error
Initialize initializes the binhost directory structure.
func (*BinhostManager) List ¶
func (m *BinhostManager) List() []*BinaryPackage
List lists all packages in the binhost.
func (*BinhostManager) Remove ¶
func (m *BinhostManager) Remove(category, name, version string) error
Remove removes a package from the binhost.
func (*BinhostManager) Scan ¶
func (m *BinhostManager) Scan() error
Scan scans the binhost directory and loads all packages.
type BinhostType ¶
type BinhostType int
BinhostType represents the type of binhost.
const ( // BinhostLocal is a local directory BinhostLocal BinhostType = iota // BinhostHTTP is an HTTP/HTTPS server BinhostHTTP // BinhostRsync is an rsync server BinhostRsync // BinhostSSH is an SSH server BinhostSSH )
func (BinhostType) String ¶
func (bt BinhostType) String() string
String returns string representation of binhost type.
type BinhostUploader ¶
type BinhostUploader interface {
// Upload uploads a binary package
Upload(pkg *BinaryPackage) error
// UploadFile uploads a single file
UploadFile(localPath, remotePath string) error
// UploadDirectory uploads an entire directory
UploadDirectory(localDir, remoteDir string) error
}
BinhostUploader uploads binary packages to remote binhost.
Supported protocols:
- HTTP/HTTPS (via PUT or POST multipart)
- SSH/SFTP (via scp or sftp command)
Example HTTP:
uploader := binpkg.NewHTTPUploader("https://binhost.example.com")
uploader.SetAuth("username", "password")
err := uploader.Upload(pkg)
Example SSH:
uploader := binpkg.NewSSHUploader("ssh://user@host:/var/binhost")
uploader.SetKeyPath("/home/user/.ssh/id_rsa")
err := uploader.Upload(pkg)
type BuildMetadata ¶
type BuildMetadata struct {
// BuildDate is when the package was built
BuildDate time.Time
// BuildHost is the hostname where it was built
BuildHost string
// CFLAGS are the C compiler flags used
CFLAGS string
// CXXFLAGS are the C++ compiler flags used
CXXFLAGS string
// LDFLAGS are the linker flags used
LDFLAGS string
// USE contains the USE flags used during build
USE []string
// Features contains Portage features enabled during build
Features []string
// EAPI is the EAPI version
EAPI string
// Repository is the repository (e.g., "gentoo")
Repository string
// Size is the installed size in bytes
Size int64
}
BuildMetadata contains information about how the package was built.
func GetGPKGMetadata ¶
func GetGPKGMetadata(path string) (*BuildMetadata, error)
GetGPKGMetadata reads metadata from GPKG package without full extraction.
GPKG metadata is stored in special tar members:
- gpkg-1: Format version marker
- metadata.tar: Package metadata (compressed tar)
- image.tar.{compression}: Installed files
func GetTBZ2Metadata ¶
func GetTBZ2Metadata(path string) (*BuildMetadata, error)
GetTBZ2Metadata reads metadata from TBZ2 package without full extraction.
TBZ2 metadata is stored in XPAK format appended to the tar.bz2 archive.
type BuildOptions ¶
type BuildOptions struct {
// IncludeBuildLog includes build.log in package
IncludeBuildLog bool
// IncludeDebugInfo includes debug symbols
IncludeDebugInfo bool
// StripBinaries strips binaries to reduce size
StripBinaries bool
// VerifyChecksums verifies file checksums before packing
VerifyChecksums bool
// SignPackage enables package signing
SignPackage bool
// SignatureType is GPG or SSH
SignatureType SignatureType
}
BuildOptions configures the build process.
type CompressionType ¶
type CompressionType int
CompressionType represents package compression algorithm.
const ( // CompressionNone - no compression (for testing) CompressionNone CompressionType = iota // CompressionGzip - gzip compression (.gz) CompressionGzip // CompressionBzip2 - bzip2 compression (.bz2) CompressionBzip2 // CompressionXZ - xz compression (.xz) CompressionXZ // CompressionZstd - zstd compression (.zst) - default for GPKG CompressionZstd )
func (CompressionType) Extension ¶
func (c CompressionType) Extension() string
Extension returns file extension for compression type.
func (CompressionType) String ¶
func (c CompressionType) String() string
String returns compression type name.
type GPGSigner ¶
type GPGSigner struct {
// KeyID is the GPG key ID to use for signing
KeyID string
// Passphrase for unlocking private key (optional)
Passphrase string
// GPGPath is path to gpg binary (default: "gpg")
GPGPath string
// Armor enables ASCII armored output
Armor bool
}
GPGSigner signs packages using GPG.
func NewGPGSigner ¶
NewGPGSigner creates a new GPG signer.
type GPKGWriter ¶
type GPKGWriter struct {
// OutputPath is the path for the output .gpkg.tar file
OutputPath string
// Compression is the compression type
Compression CompressionType
// Verbose enables detailed logging
Verbose bool
// contains filtered or unexported fields
}
GPKGWriter writes GPKG format packages.
GPKG format (GLEP 78):
- Tar-based archive structure
- metadata.xml - package metadata
- Manifest - file checksums
- CONTENTS - file list
- image/ - package files
Example:
writer := binpkg.NewGPKGWriter("/tmp/output.gpkg.tar")
writer.SetCompression(binpkg.CompressionZstd)
err := writer.Write(metadata, files)
func NewGPKGWriter ¶
func NewGPKGWriter(outputPath string) *GPKGWriter
NewGPKGWriter creates a new GPKG writer.
func (*GPKGWriter) SetCompression ¶
func (w *GPKGWriter) SetCompression(compression CompressionType)
SetCompression sets the compression type.
func (*GPKGWriter) Write ¶
func (w *GPKGWriter) Write(metadata *BuildMetadata, stagingDir string) error
Write writes a GPKG package.
Parameters:
- metadata: Package build metadata
- stagingDir: Directory containing files to pack (image/)
Returns:
- error: If writing fails
type HTTPUploader ¶
type HTTPUploader struct {
// BaseURL is the binhost base URL (e.g., "https://binhost.example.com")
BaseURL string
// Auth is HTTP authentication
Username string
Password string
// HTTPClient is the underlying HTTP client
HTTPClient *http.Client
// Method is HTTP method (PUT or POST)
Method string
// UseMultipart enables multipart/form-data for POST
UseMultipart bool
// Verbose enables detailed logging
Verbose bool
}
HTTPUploader uploads via HTTP/HTTPS.
func NewHTTPUploader ¶
func NewHTTPUploader(baseURL string) *HTTPUploader
NewHTTPUploader creates a new HTTP uploader.
func (*HTTPUploader) SetAuth ¶
func (u *HTTPUploader) SetAuth(username, password string)
SetAuth sets HTTP authentication.
func (*HTTPUploader) SetTimeout ¶
func (u *HTTPUploader) SetTimeout(timeout time.Duration)
SetTimeout sets HTTP timeout.
func (*HTTPUploader) Upload ¶
func (u *HTTPUploader) Upload(pkg *BinaryPackage) error
Upload uploads a binary package via HTTP.
func (*HTTPUploader) UploadDirectory ¶
func (u *HTTPUploader) UploadDirectory(localDir, remoteDir string) error
UploadDirectory uploads an entire directory via HTTP.
func (*HTTPUploader) UploadFile ¶
func (u *HTTPUploader) UploadFile(localPath, remotePath string) error
UploadFile uploads a single file via HTTP.
type PackageSigner ¶
type PackageSigner interface {
// Sign signs a package file and returns signature
Sign(packagePath string) (*Signature, error)
// Verify verifies a package signature
Verify(packagePath string, signature *Signature) error
}
PackageSigner signs binary packages.
type RSASigner ¶
type RSASigner struct {
// PrivateKey is the RSA private key
PrivateKey *rsa.PrivateKey
// KeyPath is path to RSA private key file (PEM format)
KeyPath string
}
RSASigner signs packages using RSA keys.
func NewRSASigner ¶
NewRSASigner creates a new RSA signer.
type SSHSigner ¶
type SSHSigner struct {
// KeyPath is path to SSH private key
KeyPath string
// Passphrase for encrypted keys (optional)
Passphrase string
// SSHKeygenPath is path to ssh-keygen binary (default: "ssh-keygen")
SSHKeygenPath string
}
SSHSigner signs packages using SSH keys (ed25519).
func NewSSHSigner ¶
NewSSHSigner creates a new SSH signer.
type SSHUploader ¶
type SSHUploader struct {
// Host is the SSH host (e.g., "[email protected]")
Host string
// RemoteDir is the remote binhost directory
RemoteDir string
// KeyPath is path to SSH private key
KeyPath string
// Port is SSH port (default: 22)
Port int
// SCPPath is path to scp binary (default: "scp")
SCPPath string
// Verbose enables detailed logging
Verbose bool
}
SSHUploader uploads via SSH/SCP.
func NewSSHUploader ¶
func NewSSHUploader(sshURL string) (*SSHUploader, error)
NewSSHUploader creates a new SSH uploader.
URL format: ssh://user@host[:port]/path
func (*SSHUploader) SetKeyPath ¶
func (u *SSHUploader) SetKeyPath(keyPath string)
SetKeyPath sets SSH private key path.
func (*SSHUploader) Upload ¶
func (u *SSHUploader) Upload(pkg *BinaryPackage) error
Upload uploads a binary package via SSH/SCP.
func (*SSHUploader) UploadDirectory ¶
func (u *SSHUploader) UploadDirectory(localDir, remoteDir string) error
UploadDirectory uploads an entire directory via SCP.
func (*SSHUploader) UploadFile ¶
func (u *SSHUploader) UploadFile(localPath, remotePath string) error
UploadFile uploads a single file via SCP.
type SelectionResult ¶
type SelectionResult struct {
// UseBinary indicates whether to use binary package
UseBinary bool
// BinaryPackage is the selected binary package (if UseBinary is true)
BinaryPackage *BinaryPackage
// Binhost is the binhost containing the package (if UseBinary is true)
Binhost *Binhost
// Reason explains why this selection was made
Reason string
// Score is the compatibility score (0.0-1.0)
Score float64
}
SelectionResult represents the result of package selection.
type SelectionStrategy ¶
type SelectionStrategy int
SelectionStrategy determines how to choose between binary and source packages.
const ( // StrategyPreferBinary prefers binary packages when available and compatible StrategyPreferBinary SelectionStrategy = iota // StrategyPreferSource prefers building from source StrategyPreferSource // StrategyBinaryOnly only uses binary packages (fails if not available) StrategyBinaryOnly // StrategySourceOnly always builds from source StrategySourceOnly // StrategyAuto automatically decides based on various factors StrategyAuto )
func (SelectionStrategy) String ¶
func (s SelectionStrategy) String() string
String returns string representation of selection strategy.
type Selector ¶
type Selector struct {
// Options configures selection behavior
Options SelectorOptions
// Binhosts is the list of available binhosts
Binhosts []*Binhost
}
Selector selects between binary and source packages.
func NewSelector ¶
func NewSelector(opts SelectorOptions) *Selector
NewSelector creates a new package selector.
func (*Selector) AddBinhost ¶
AddBinhost adds a binhost to the selector.
type SelectorOptions ¶
type SelectorOptions struct {
// Strategy is the selection strategy
Strategy SelectionStrategy
// RequiredUSE are the USE flags that must be present
RequiredUSE []string
// MaxAge is the maximum age for binary packages (0 = no limit)
MaxAge time.Duration
// MinCoverage is minimum USE flag match percentage (0.0-1.0)
// A value of 1.0 means all USE flags must match exactly
MinCoverage float64
// AllowUntrusted allows packages without valid signatures
AllowUntrusted bool
// PreferLocal prefers local binhost over remote
PreferLocal bool
}
SelectorOptions configures package selection behavior.
func DefaultSelectorOptions ¶
func DefaultSelectorOptions() SelectorOptions
DefaultSelectorOptions returns default selector options.
type Signature ¶
type Signature struct {
// Type is the signature type (GPG, SSH, etc)
Type SignatureType
// KeyID is the signing key identifier
KeyID string
// Signature is the actual signature data
Data []byte
// Created is when the signature was created
Created time.Time
}
Signature represents a package signature for verification.
type SignatureType ¶
type SignatureType int
SignatureType represents the type of signature.
const ( // SignatureGPG is a GPG/PGP signature SignatureGPG SignatureType = iota // SignatureSSH is an SSH signature SignatureSSH // SignatureRSA is an RSA signature SignatureRSA // SignatureNone means no signature SignatureNone )
func (SignatureType) String ¶
func (st SignatureType) String() string
String returns string representation of signature type.
type Stats ¶
type Stats struct {
TotalBinhosts int
TotalPackages int
LocalPackages int
RemotePackages int
OldestPackage time.Time
NewestPackage time.Time
AverageAge time.Duration
}
Stats returns statistics about available binary packages.
type TBZ2Writer ¶
type TBZ2Writer struct {
// OutputPath is the path for the output .tbz2 file
OutputPath string
// Verbose enables detailed logging
Verbose bool
}
TBZ2Writer writes TBZ2 format packages.
TBZ2 format (legacy):
- Tar archive with package files
- Bzip2 compressed
- XPAK metadata appended at end
Format: [tar.bz2]XPAK
func NewTBZ2Writer ¶
func NewTBZ2Writer(outputPath string) *TBZ2Writer
NewTBZ2Writer creates a new TBZ2 writer.
func (*TBZ2Writer) Write ¶
func (w *TBZ2Writer) Write(metadata *BuildMetadata, stagingDir string) error
Write writes a TBZ2 package.
Parameters:
- metadata: Package build metadata
- stagingDir: Directory containing files to pack
Returns:
- error: If writing fails
type UploadOptions ¶
type UploadOptions struct {
// ResumeSupport enables resume for interrupted uploads
ResumeSupport bool
// ProgressCallback is called with upload progress (0-100)
ProgressCallback func(percent int)
// Timeout is the upload timeout
Timeout time.Duration
// RetryCount is number of retries on failure
RetryCount int
// VerifyChecksum verifies file checksum after upload
VerifyChecksum bool
}
UploadOptions configures the upload process.
type XPAK ¶
XPAK is the metadata format used in TBZ2 packages.
Format (little-endian):
- Index area: key_len (4) + key + data_len (4) + data_offset (4)
- Data area: concatenated data values
- Footer: "XPAKPACK" + index_len (4) + data_len (4) + xpak_len (4) + "XPAKSTOP"
See: https://wiki.gentoo.org/wiki/XPAK
func ParseXPAK ¶
func ParseXPAK(r io.ReadSeeker) (*XPAK, error)
ParseXPAK parses XPAK metadata from a reader.
The reader should be positioned at the start of XPAK data.