Documentation ¶
Overview ¶
Package v1 defines data types for v1 of the formulae.brew.sh JSON API and some utility functions for working with the data.
Index ¶
- Constants
- Variables
- func Names(formulae []*Info) []string
- type Bottle
- type BottleFile
- type FormulaDeprecateReason
- type FormulaDisableReason
- type FormulaURL
- type HeadDependencies
- type Index
- type Info
- type InstalledInfo
- type KegOnlyConfig
- type KegOnlyReason
- type MacOSBounds
- type PlatformInfo
- type ProcessType
- type Requirement
- type RuntimeDependency
- type Service
- type ServiceRunType
- type Variation
- type Versions
Constants ¶
const ( PourBottleConditionDefaultPrefix = "default_prefix" // pour bottle condition requiring the default prefix PourBottleConditionCLTInstalled = "clt_installed" // pour bottle condition requiring the macOS command line tools )
const ( CellarAny = ":any" // Signifies bottle is safe to install in the Cellar. CellarAnySkipRelocation = ":any_skip_relocation" // Signifies bottle is safe to install in the Cellar without relocation. )
const ( ProcessTypeInteractive = "interactive" // value for interactive process ProcessTypeBackground = "background" // value for background process )
const (
// RubySourceChecksumSha256 is the key for the sha256 checksum of a Formula's Ruby source.
RubySourceChecksumSha256 = "sha256"
)
const (
Stable = "stable" // Key used for stable bottles
)
Variables ¶
var FormulaDeprecateDisableReasons = map[string]string{
"does_not_build": "does not build",
"no_license": "has no license",
"repo_archived": "has an archived upstream repository",
"repo_removed": "has a removed upstream repository",
"unmaintained": "is not maintained upstream",
"unsupported": "is not supported upstream",
"deprecated_upstream": "is deprecated upstream",
"versioned_formula": "is a versioned formula",
"checksum_mismatch": heredoc.Doc(`
was built with an initially released source file that had
a different checksum than the current one.
Upstream's repository might have been compromised.
We can re-package this once upstream has confirmed that they retagged their release`),
}
FormulaDeprecateDisableReasons contains known deprecation and disabling reasons.
https://github.com/Homebrew/brew/blob/master/Library/Homebrew/deprecate_disable.rb
Functions ¶
Types ¶
type Bottle ¶
type Bottle struct { Rebuild int `json:"rebuild"` RootURL string `json:"root_url"` Files map[platform.Platform]*BottleFile `json:"files"` }
Bottle represents the bottle section.
type BottleFile ¶
type BottleFile struct { Cellar string `json:"cellar"` URL string `json:"url"` Sha256 string `json:"sha256"` }
BottleFile defines a bottle.files entry.
func (*BottleFile) Relocatable ¶
func (file *BottleFile) Relocatable() bool
Relocatable reports if the bottle is relocatable.
type FormulaDeprecateReason ¶
type FormulaDeprecateReason string
FormulaDeprecateReason describes why a formula was deprecated.
func (FormulaDeprecateReason) MarshalJSON ¶
func (r FormulaDeprecateReason) MarshalJSON() ([]byte, error)
MarshalJSON implements json.Marshaler.
func (*FormulaDeprecateReason) UnmarshalJSON ¶
func (r *FormulaDeprecateReason) UnmarshalJSON(b []byte) error
UnmarshalJSON implements json.Unmarshaler.
type FormulaDisableReason ¶
type FormulaDisableReason string
FormulaDisableReason describes why a formula was disabled.
func (FormulaDisableReason) MarshalJSON ¶
func (r FormulaDisableReason) MarshalJSON() ([]byte, error)
MarshalJSON implements json.Marshaler.
func (*FormulaDisableReason) UnmarshalJSON ¶
func (r *FormulaDisableReason) UnmarshalJSON(b []byte) error
UnmarshalJSON implements json.Unmarshaler.
type FormulaURL ¶
type FormulaURL struct { URL string `json:"url"` Branch string `json:"branch,omitempty"` Tag string `json:"tag,omitempty"` Revision string `json:"revision,omitempty"` Using string `json:"using,omitempty"` Checksum string `json:"checksum,omitempty"` }
FormulaURL represents the urls block.
type HeadDependencies ¶
type HeadDependencies struct { BuildDependencies []string `json:"build_dependencies"` Dependencies []string `json:"dependencies"` TestDependencies []string `json:"test_dependencies"` RecommendedDependencies []string `json:"recommended_dependencies"` OptionalDependencies []string `json:"optional_dependencies"` UsesFromMacOS []any `json:"uses_from_macos"` UsesFromMacOSBounds []*MacOSBounds `json:"uses_from_macos_bounds"` }
HeadDependencies represents the head_dependencies field.
type Info ¶
type Info struct { PlatformInfo `json:",inline"` Variations map[platform.Platform]*PlatformInfo `json:"variations"` }
Info represents Homebrew API information for a formula.
func (*Info) ForPlatform ¶
func (info *Info) ForPlatform(plat platform.Platform) (*PlatformInfo, error)
ForPlatform produces the "compiled" metadata for the given platform by evaluating its variations.
type InstalledInfo ¶
type InstalledInfo struct { Version string `json:"version"` UsedOptions []any `json:"used_options"` BuiltAsBottle bool `json:"built_as_bottle"` PouredFromBottle bool `json:"poured_from_bottle"` Time int `json:"time"` RuntimeDependencies []*RuntimeDependency `json:"runtime_dependencies"` InstalledAsDependency bool `json:"installed_as_dependency"` InstalledOnRequest bool `json:"installed_on_request"` }
InstalledInfo represents the installed block.
type KegOnlyConfig ¶
type KegOnlyConfig struct { Reason KegOnlyReason `json:"reason"` Explanation string `json:"explanation"` }
KegOnlyConfig represents the keg_only_reason section.
type KegOnlyReason ¶
type KegOnlyReason string
KegOnlyReason is used for the reason field in keg_only_reason.
func (KegOnlyReason) MarshalJSON ¶
func (r KegOnlyReason) MarshalJSON() ([]byte, error)
MarshalJSON implements json.Marshaler.
func (*KegOnlyReason) UnmarshalJSON ¶
func (r *KegOnlyReason) UnmarshalJSON(b []byte) error
UnmarshalJSON implements json.Unmarshaler.
type MacOSBounds ¶
type MacOSBounds struct {
Since string `json:"since"`
}
MacOSBounds represents the uses_from_macos_bounds entries.
type PlatformInfo ¶
type PlatformInfo struct { Name string `json:"name"` FullName string `json:"full_name"` // Deprecated: Evaluate from Tap/Name Tap string `json:"tap"` OldName string `json:"oldname"` // Deprecated: Use OldNames list OldNames []string `json:"oldnames"` Aliases []string `json:"aliases"` VersionedFormulae []string `json:"versioned_formulae"` Desc string `json:"desc"` License string `json:"license"` Homepage string `json:"homepage"` Versions Versions `json:"versions"` URLs map[string]FormulaURL `json:"urls"` Revision int `json:"revision"` VersionScheme int `json:"version_scheme"` Bottle map[string]*Bottle `json:"bottle"` PourBottleOnlyIf *string `json:"pour_bottle_only_if"` KegOnly bool `json:"keg_only"` KegOnlyReason KegOnlyConfig `json:"keg_only_reason"` Options []any `json:"options"` BuildDependencies []string `json:"build_dependencies"` Dependencies []string `json:"dependencies"` TestDependencies []string `json:"test_dependencies"` RecommendedDependencies []string `json:"recommended_dependencies"` OptionalDependencies []string `json:"optional_dependencies"` UsesFromMacOS []any `json:"uses_from_macos"` UsesFromMacOSBounds []*MacOSBounds `json:"uses_from_macos_bounds"` Requirements []*Requirement `json:"requirements"` ConflictsWith []string `json:"conflicts_with"` ConflictsWithReasons []string `json:"conflicts_with_reasons"` LinkOverwrite []string `json:"link_overwrite"` Caveats *string `json:"caveats"` Installed []InstalledInfo `json:"installed"` LinkedKeg string `json:"linked_keg"` Pinned bool `json:"pinned"` Outdated bool `json:"outdated"` Deprecated bool `json:"deprecated"` DeprecationDate *string `json:"deprecation_date"` DeprecationReason *string `json:"deprecation_reason"` Disabled bool `json:"disabled"` DisabledDate *string `json:"disable_date"` DisabledReason *string `json:"disable_reason"` PostInstallDefined bool `json:"post_install_defined"` Service *Service `json:"service"` TapGitHead string `json:"tap_git_head"` RubySourcePath string `json:"ruby_source_path"` RubySourceChecksum map[string]string `json:"ruby_source_checksum"` HeadDependencies *HeadDependencies `json:"head_dependencies,omitempty"` }
Info represents Homebrew API information for a formula.
func (*PlatformInfo) ManifestTag ¶
func (info *PlatformInfo) ManifestTag(key string) (string, error)
ManifestTag produces the tag of the formula's manifest.
func (*PlatformInfo) PossibleNames ¶
func (info *PlatformInfo) PossibleNames() []string
PossibleNames returns all possible names for the formula. This is a combination of the current name, old names, and any aliases.
func (*PlatformInfo) Version ¶
func (info *PlatformInfo) Version() string
Version returns the version of the formula according to Homebrew.
Pattern:
VERSION[_REVISION]
This version will vary from the formula project's version when the "revision" field is set in the formula, which signals the formula was updated without changing the version being installed.
type Requirement ¶
type Requirement struct { Name string `json:"name"` Cask any `json:"cask"` Download any `json:"download"` Version string `json:"version"` Contexts []string `json:"contexts"` Specs []string `json:"specs"` }
Requirement represents a requirement.
type RuntimeDependency ¶
type RuntimeDependency struct { FullName string `json:"full_name"` Version string `json:"version"` Revision int `json:"revision"` PkgVersionValue string `json:"pkg_version"` DeclaredDirectly bool `json:"declared_directly"` }
RuntimeDependency represents a required dependency.
func (*RuntimeDependency) PkgVersion ¶
func (rd *RuntimeDependency) PkgVersion() string
PkgVersion returns the package version.
func (*RuntimeDependency) Repo ¶
func (rd *RuntimeDependency) Repo() string
Repo implements the same name formatting as other bottle parsing functions.
func (*RuntimeDependency) Tag ¶
func (rd *RuntimeDependency) Tag() string
Tag implements the same tag naming logic as other bottle parsing functions.
type Service ¶
type Service struct { Name *struct { MacOS string `json:"macos,omitempty"` } `json:"name,omitempty"` Run any `json:"run"` RunType ServiceRunType `json:"run_type"` EnvironmentVariables map[string]string `json:"environment_variables,omitempty"` Interval time.Duration `json:"interval,omitempty"` Cron string `json:"cron,omitempty"` RequireRoot bool `json:"require_root,omitempty"` KeepAlive struct { Always bool `json:"always,omitempty"` SuccessfulExit bool `json:"successful_exit,omitempty"` Crashed bool `json:"crashed,omitempty"` // 1 example } `json:"keep_alive,omitempty"` WorkingDir string `json:"working_dir,omitempty"` InputPath string `json:"input_path,omitempty"` // 2 examples LogPath string `json:"log_path,omitempty"` ErrorLogPath string `json:"error_log_path,omitempty"` Sockets string `json:"sockets,omitempty"` // 3 examples ProcessType ProcessType `json:"process_type,omitempty"` // seen: background|interactive MacOSLegacyTimers bool `json:"macos_legacy_timers,omitempty"` // literally only used on the gitlab-runners formula }
Service represents the service block.
type ServiceRunType ¶
type ServiceRunType string
ServiceRunType represents a run type for a service.
const ( RunTypeImmediate ServiceRunType = "immediate" // immediate run type RunTypeInterval ServiceRunType = "interval" // interval run type RunTypeCron ServiceRunType = "cron" // cron run type )