Help us shape the future of Go! Take the 2026 Go Developer Survey

ebuild

package
v0.37.1 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package ebuild parses ebuild paths into category, package and version, and compares Gentoo versions (suffixes such as _rc and _p, and -r revisions) the way Portage orders them.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidEbuildPath = errors.New("invalid ebuild path format")
)

Functions

func CompareVersions

func CompareVersions(v1, v2 string) int

CompareVersions compares two Gentoo-style version strings by the ordering of PMS section 3.3 and returns -1 if v1 < v2, 0 if v1 == v2, 1 if v1 > v2.

Every number is compared as an unbounded integer, so no component, suffix number or revision can overflow. PMS equality is not text identity: 1.0 and 1.0-r0 compare equal, and so do 1.010 and 1.01.

The comparison is total on any two strings. A valid version is compared in its trimmed form, the form IsValidVersion accepts. A string IsValidVersion rejects orders below every valid version, and two invalid strings order byte-wise on their untrimmed text, so two distinct invalid strings never compare equal.

func IsValidVersion

func IsValidVersion(v string) bool

IsValidVersion reports whether v, once surrounding whitespace is trimmed, is a well-formed Gentoo-style version string that CompareVersions orders by PMS.

A string it rejects — "INKSCAPE_1_4_4", "latest", a still-prefixed "v6.6.91" — is not an error to CompareVersions: it orders below every valid version. That is a deterministic answer, not a meaningful one, so callers that compare an upstream value against the current ebuild version should reject non-comparable inputs up front rather than treat them as "no update available".

Types

type Ebuild

type Ebuild struct {
	Category string // e.g., "app-misc"
	Package  string // e.g., "hello"
	Name     string // e.g., "hello" (same as Package for simple cases)
	Version  string // e.g., "1.0", "1.0_rc1", "1.0-r1"
}

Ebuild represents a parsed ebuild file path

func ParsePath

func ParsePath(path string) (*Ebuild, error)

ParsePath parses an ebuild path and extracts category, package, name, and version Expected format: category/package/package-version.ebuild

func (*Ebuild) FullName

func (e *Ebuild) FullName() string

FullName returns the category/package format

func (*Ebuild) String

func (e *Ebuild) String() string

String returns the full ebuild path format: category/package/package-version.ebuild

Jump to

Keyboard shortcuts

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