bottle

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateCompletions added in v0.2.0

func GenerateCompletions(ctx context.Context, binaryPath string, command []string, dir string) (map[string]string, error)

GenerateCompletions runs `<binaryPath> <command...> <shell>` for bash, zsh and fish, writes each captured script under dir, and returns keg-relative archive path -> local path entries suitable for BuildOptions.ExtraFiles. Any shell failing to generate is an error: shipping partial completions silently is worse than failing the build.

Types

type BinaryInstall added in v0.2.0

type BinaryInstall struct {
	Name        string
	InstallPath string
}

BinaryInstall names a binary and the keg-relative directory it installs into (empty means "bin").

type Bottle

type Bottle struct {
	Formula            string            // e.g., "myapp"
	Version            string            // e.g., "1.2.3"
	Platform           platform.Platform // The Homebrew platform
	SHA256             string            // SHA256 of the bottle tarball (formula sha256 == OCI layer digest)
	UncompressedSHA256 string            // SHA256 of the raw tar stream (OCI diff_id)
	UncompressedSize   int64             // raw tar size in bytes (installed_size basis)
	Path               string            // Local path to bottle file
	Binaries           []string          // Binaries included
	Cellar             string            // e.g., ":any_skip_relocation"
	Rebuild            int               // Rebuild number (usually 0)
	Tab                *Tab              // INSTALL_RECEIPT content (also pushed as sh.brew.tab)
}

Bottle represents a built Homebrew bottle

func (*Bottle) BottleName

func (b *Bottle) BottleName() string

BottleName returns the local bottle filename, matching brew's convention: formula--version.platform.bottle[.rebuild].tar.gz

func (*Bottle) FileSize

func (b *Bottle) FileSize() (int64, error)

FileSize returns the size of the bottle tarball in bytes.

func (*Bottle) RefName

func (b *Bottle) RefName() string

RefName returns the org.opencontainers.image.ref.name annotation value: "version.platform_tag" or "version.platform_tag.rebuild".

func (*Bottle) VersionRebuild

func (b *Bottle) VersionRebuild() string

VersionRebuild returns the OCI tag for this bottle's version: "version" or "version-rebuild" (GitHubPackages.version_rebuild).

type BuildOptions

type BuildOptions struct {
	Formula      string
	Version      string
	Platform     platform.Platform
	ArtifactPath string          // Path to archive containing the binaries
	Binaries     []BinaryInstall // Binaries to include
	Cellar       string
	Rebuild      int
	Tap          string            // Tap name for INSTALL_RECEIPT.json (e.g., "user/homebrew-tap")
	FormulaRb    string            // Rendered formula source (sans bottle block) for .brew/<formula>.rb
	ExtraFiles   map[string]string // Keg-relative archive path -> local path (e.g. completions)
	SourceDate   time.Time
	OutputDir    string // Where to write the bottle (default: builder temp dir, removed on Close)
}

BuildOptions contains the parameters for building a bottle

type Builder

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

Builder transforms build artifacts into Homebrew bottles

func NewBuilder

func NewBuilder() (*Builder, error)

NewBuilder creates a new bottle builder with a temp work directory

func (*Builder) Build

func (b *Builder) Build(ctx context.Context, opts BuildOptions) (*Bottle, error)

Build creates a bottle from an artifact archive containing the binaries at its root. The output tarball is fully deterministic for identical inputs.

func (*Builder) Close

func (b *Builder) Close() error

Close cleans up the work directory

type RuntimeDependency

type RuntimeDependency struct {
	FullName         string `json:"full_name"`
	Version          string `json:"version"`
	Revision         int    `json:"revision,omitempty"`
	PkgVersion       string `json:"pkg_version"`
	DeclaredDirectly bool   `json:"declared_directly"`
}

RuntimeDependency represents a runtime dependency in the tab

type Tab

type Tab struct {
	HomebrewVersion       string              `json:"homebrew_version"`
	UsedOptions           []string            `json:"used_options"`
	UnusedOptions         []string            `json:"unused_options"`
	BuiltAsBottle         bool                `json:"built_as_bottle"`
	PouredFromBottle      bool                `json:"poured_from_bottle"`
	InstalledAsDependency bool                `json:"installed_as_dependency"`
	InstalledOnRequest    bool                `json:"installed_on_request"`
	ChangedFiles          []string            `json:"changed_files"`
	Time                  int64               `json:"time"`
	SourceModifiedTime    int64               `json:"source_modified_time"`
	Compiler              string              `json:"compiler"`
	Stdlib                *string             `json:"stdlib"`
	Aliases               []string            `json:"aliases"`
	RuntimeDependencies   []RuntimeDependency `json:"runtime_dependencies"`
	Source                TabSource           `json:"source"`
	Arch                  string              `json:"arch"`
	BuiltOn               TabBuiltOn          `json:"built_on"`
}

Tab represents the INSTALL_RECEIPT.json structure used by Homebrew to track bottle metadata and installation information.

func NewTab

func NewTab(opts TabOptions) *Tab

NewTab creates a new Tab with the given options

func (*Tab) Marshal

func (t *Tab) Marshal() ([]byte, error)

Marshal returns the compact JSON representation of the Tab, used both for the INSTALL_RECEIPT.json inside the bottle and the sh.brew.tab manifest annotation.

type TabBuiltOn

type TabBuiltOn struct {
	OS            string `json:"os"`
	OSVersion     string `json:"os_version"`
	CPUFamily     string `json:"cpu_family"`
	Xcode         string `json:"xcode,omitempty"`
	CLT           string `json:"clt,omitempty"`
	PreferredPerl string `json:"preferred_perl,omitempty"`
}

TabBuiltOn contains build environment information

type TabOptions

type TabOptions struct {
	// Formula name
	Formula string

	// Version string
	Version string

	// Architecture (arm64 or x86_64)
	Arch string

	// OS (darwin or linux)
	OS string

	// OS version (e.g., "15.0" for macOS Sequoia)
	OSVersion string

	// Tap name (e.g., "user/homebrew-tap")
	Tap string

	// Compiler used (default: "go" for Go-built bottles)
	Compiler string

	// Time overrides the build timestamp (for reproducible bottles).
	// Falls back to SOURCE_DATE_EPOCH, then the Unix epoch — never
	// time.Now(), so identical inputs marshal identically.
	Time time.Time
}

TabOptions contains options for creating a new Tab

type TabSource

type TabSource struct {
	Spec       string      `json:"spec"`
	Versions   TabVersions `json:"versions"`
	Path       string      `json:"path,omitempty"`
	Tap        string      `json:"tap,omitempty"`
	TapGitHead string      `json:"tap_git_head,omitempty"`
}

TabSource contains source information for the formula

type TabVersions

type TabVersions struct {
	Stable        string  `json:"stable"`
	Head          *string `json:"head"`
	VersionScheme int     `json:"version_scheme"`
}

TabVersions contains version information

Jump to

Keyboard shortcuts

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