pkgbuild

package
v2.0.0-alpha.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 30, 2026 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// PackageMagic is the magic number for .ipk files (4 bytes: "IPK1")
	PackageMagic = "\x49\x50\x4b\x31" // "IPK1"
)
View Source
const (
	SpecFileName = "ipk.toml"
)

Variables

View Source
var (
	// NameRegex validates package names (lowercase, alphanumeric, hyphens, underscores)
	NameRegex = regexp.MustCompile(`^[a-z][a-z0-9_-]*$`)
)
View Source
var SpecFileSearchOrder = []string{
	SpecFileName,
	filepath.Join(".ipk", SpecFileName),
	filepath.Join("misc", "ipk", SpecFileName),
}

SpecFileSearchOrder defines the order to search for spec files

View Source
var ValidArch = map[string]bool{
	"amd64": true,
	"arm64": true,
	"src":   true,
}

ValidArch defines the supported CPU architectures

View Source
var ValidOS = map[string]bool{
	"linux":   true,
	"freebsd": true,
	"darwin":  true,
	"all":     true,
}

ValidOS defines the supported operating systems

Functions

func Extract

func Extract(ipkPath, targetDir string) error

Extract reads an .ipk package file and writes its contents into targetDir.

IPK file format (mirrors Builder.writeIPK):

  • Magic Number (4 bytes): "IPK1"
  • Header Length (4 bytes): uint32, little-endian
  • Header Block (JSON): inapi.Package
  • Data Block: compressed tarball (xz/gzip/none)

The compression format is taken from the header's Release.Compress. Directory modes, regular files and symlinks are preserved. Entries that escape targetDir (path traversal) are rejected.

func MetadataValidate

func MetadataValidate(meta *inapi.PackageMetadata) error

MetadataValidate validates package metadata

func MinifyCSS

func MinifyCSS(src, dst string) error

MinifyCSS minifies a CSS file

func MinifyHTML

func MinifyHTML(src, dst string) error

MinifyHTML minifies an HTML file

func MinifyJS

func MinifyJS(src, dst string) error

MinifyJS minifies a JavaScript file

func OptimizePNG

func OptimizePNG(src, dst string) error

OptimizePNG optimizes a PNG file using optipng

func ReleaseValidate

func ReleaseValidate(release *inapi.PackageRelease) error

ReleaseValidate validates package release info

func SpecFind

func SpecFind(packDir string, specOverride string) (string, *inapi.PackageSpec, error)

SpecFind locates a spec file in the search order

func SpecParse

func SpecParse(path string) (*inapi.PackageSpec, error)

SpecParse parses a package spec from a TOML file

func SpecValidate

func SpecValidate(spec *inapi.PackageSpec) error

SpecValidate validates a package spec

Types

type Builder

type Builder struct {
	// contains filtered or unexported fields
}

Builder handles package building

func NewBuilder

func NewBuilder(cfg Config) *Builder

NewBuilder creates a new Builder instance

func (*Builder) Build

func (b *Builder) Build() error

Build executes the package build process

type Config

type Config struct {
	// Dir is the package source directory
	Dir string
	// OutputDir is the output directory for the package
	OutputDir string
	// SpecFile is the spec file path (optional, auto-detect if empty)
	SpecFile string
	// Version is the full version with optional pre-release and build metadata
	// If empty, uses Metadata.Version (core version only)
	// Example: "1.0.0-beta.1+build.123"
	Version string
	// Os is the operating system target (linux, freebsd, all)
	Os string
	// Arch is the architecture target (amd64, arm64, src)
	Arch string
	// Compress is the compression format (xz, gzip)
	Compress string
	// NoCompress skips final compression (for debugging)
	NoCompress bool
	// ShowBuild prints the build script before execution
	ShowBuild bool
	// BuildDir is the build temp directory (for debugging)
	BuildDir string
	// Quiet suppresses non-error output
	Quiet bool
}

Config holds the build configuration

type ProcessFunc

type ProcessFunc func(src, dst string) error

ProcessFunc is a function that processes a file

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL