g2

package module
v0.0.99 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2026 License: GPL-2.0 Imports: 37 Imported by: 1

README

g2

A comprehensive, multifaceted command-line toolkit for Gentoo Linux overlays and package management.

Project overview

g2 is a powerful suite of tools built to assist developers and maintainers in working with Gentoo packages, overlays, and metadata efficiently. Designed initially for personal use, it has evolved into a robust project capable of generating static HTML sites representing repository dashboards, indexing packages for rapid client-side search, managing Manifests and checksums automatically, and applying linting checks to ensure code quality within the ebuild ecosystem.

It streamlines workflows by automating repetitive repository administration tasks—like dependency resolution, pkg_desc_index generation, and USE flag documentation parsing.

Installation

go install github.com/arran4/g2/cmd/g2@latest

Quick start

Generate a local static site for your overlay:

g2 overlay site generate -out my_site_dir .
g2 site serve -port 8080 .

Verify ebuild Manifests:

g2 manifest verify .

Modules & Commands

manifest

The manifest command group handles operations related to Manifest files.

Usage:

g2 manifest <subcommand> [flags]

Subcommands:

upsert-from-url

Updates or inserts a Manifest entry for a file downloaded from a URL. This command streams the file, calculates the specified checksums, and updates the Manifest file in the specified directory (or specific file path).

Usage:

g2 manifest [flags] upsert-from-url <url> <filename> <manifestFileOrDir>

Arguments:

  • <url>: The HTTP/HTTPS URL of the file to download.
  • <filename>: The filename to record in the Manifest (typically the distfile name).
  • <manifestFileOrDir>: The path to the Manifest file or the directory containing it (e.g., the ebuild directory).

Flags:

  • -blake2b (default: true): Calculate BLAKE2B checksum.
  • -blake2s (default: false): Calculate BLAKE2S checksum.
  • -md5 (default: false): Calculate MD5 checksum.
  • -rmd160 (default: false): Calculate RMD160 checksum.
  • -sha1 (default: false): Calculate SHA1 checksum.
  • -sha256 (default: false): Calculate SHA256 checksum.
  • -sha3_256 (default: false): Calculate SHA3-256 checksum.
  • -sha3_512 (default: false): Calculate SHA3-512 checksum.
  • -sha512 (default: true): Calculate SHA512 checksum.

Example:

To download a package, calculate SHA256 in addition to defaults, and update the Manifest in the current directory:

g2 manifest -sha256=true upsert-from-url https://example.com/software-1.0.tar.gz software-1.0.tar.gz .
verify

Verifies the Manifest against the actual ebuild files.

Usage:

g2 manifest verify [location]
clean

Cleans up unused entries from the Manifest file.

Usage:

g2 manifest clean [location]
metadata

Commands relating to modifying metadata.xml files.

Usage:

g2 metadata [flags] [location]

Flags:

  • -force: Force overwrite if type mismatches or other errors
  • -l, -longdescription <string>: Set long description
  • -m, -maintainer, -maintainer-add <email[:name[:type]]>: Add/Update maintainer
  • -maintainer-remove <email>: Remove maintainer
  • -u, -upstream-id, -upstream-add <type:id>: Add upstream remote ID
  • -upstream-remove <type:id>: Remove upstream remote ID
  • -use, -use-add <name:description>: Add/Update USE flag
  • -use-remove <name>: Remove USE flag

Example Usage:

Add a maintainer to metadata.xml:

g2 metadata -maintainer-add "dev@example.com:Developer Name:person" .

Add a USE flag description:

g2 metadata -use-add "custom-flag:Enables a custom feature" .
ebuild

Tools for working with .ebuild files.

Usage:

g2 ebuild <subcommand>

Subcommands:

  • init <template_name>: Initialize an ebuild from a template.
  • templates: Manage ebuild templates.
  • sh-parse-to-json <ebuild_file>: Parse an ebuild using the shell parser and output JSON.
  • as-json <ebuild_file>: Parse an ebuild using the native parser and output JSON.
  • explain <ebuild_file>: Output a human-readable summary of an ebuild.
  • check <ebuild_file>: A lightweight structural validator for ebuild files (alias: lint).
  • deps <ebuild_file>: Extract and format dependency fields.
  • query <ebuild_file> --key <key> [--format lines]: Query specific fields from a parsed ebuild.
  • check-exists <ebuildDir> <version>: Determine if any revision of a given version exists, returning exit code 0 if found and 1 if not.
  • next-revision [--inspect <new_ebuild_file>] <ebuildDir> <version>: Generate the next revision name and optionally inspect contents for changes.

Example Usage:

Query a specific field from an ebuild:

g2 ebuild query my-package-1.0.ebuild --key SRC_URI --format lines

Parse an ebuild natively into JSON format:

g2 ebuild as-json my-package-1.0.ebuild

Initialize a new ebuild from the generic template:

g2 ebuild init generic my-new-package-1.0.ebuild
overlay site generate

Generates a static site for a single overlay.

Usage:

g2 overlay site generate [-out <dir>] [-clear] [<location>]

Arguments:

  • <location>: Path to the overlay directory, or a Git URL (defaults to .).

Flags:

  • -out: Output directory for the generated site (default: site_out).
  • -clear: Clear output directory before generation.
  • -fast-git-modtime: Use fast (O(1)) but potentially less reliable go-git file log lookup.
  • -recent-duration: Duration to consider an update 'recent' (e.g., 3mo, 14d, 72h) (default "3mo").

When the overlay contains news items, the generated news dashboard includes RSS 2.0 and Atom feeds at news/index.rss and news/index.atom. Aggregated sites also provide combined feeds there, while each repository has its own feeds under repos/<repository>/news/.

Example:

g2 overlay site generate -out my_site_dir .
overlay ebuild

Tools to modify the overlay with ebuilds.

Usage:

g2 overlay ebuild <subcommand>

Subcommands:

  • move <from> <to>: Record a package move in profiles/updates.
  • slotmove <package> <from> <to>: Record a slot move in profiles/updates.
  • install [-category <string>] <ebuild.ebuild> [overlay_path] [-- <files...>]: Install an ebuild into the overlay, optionally providing a specific category or additional files for the files/ directory. Automatically triggers manifest, cache, use desc, and pkg_desc_index generation.

Example:

Install a package into a specific category with some files:

g2 overlay ebuild install -category sys-apps my-app-1.0.ebuild . -- app.conf app.service
overlays site generate

Generates an aggregated static site for multiple remote repositories from a repositories.xml file.

Usage:

g2 overlays site generate [-out <dir>] [-clear] <repositoriesFile>

Arguments:

  • <repositoriesFile>: Path or URL to a Gentoo repositories.xml file, or - for stdin.
site serve

Serves the generated static site locally for previewing.

Usage:

g2 site serve [-port <int>] [path_to_overlay]

Example:

g2 site serve -port 8080 .
lint

Checks the repository for errors such as ebuild IUSE variables missing in metadata.xml, missing md5-cache files, orphaned Manifest entries, and invalid repository layout.

Usage:

g2 lint [flags] [<location>] [<target_package>...]

Subcommands:

  • g2 lint list: Lists all available lint rules.
  • g2 lint repo [flags] [<location>]: Lints an entire repository.
  • g2 lint package [flags] [<location>] <target_package>...: Lints specific packages or categories.
  • g2 lint query [flags] [<location>] <query>: Lints packages matching a query (e.g. '>=app-misc/foo-v3::guru').

Flags:

  • -enable-layout-lint: Enable repository layout linting (checks for stray files, unlisted categories, honoring .g2ignore).
  • -allow-github-api: Allow fetching upstream Gentoo categories via GitHub API for layout linting.
  • -upstream-repo-path <path>: Path to upstream repository on disk for layout linting (overrides GitHub API).
  • -format <string>: Output format: text, json, or github-actions (default text).
  • -severity <string>: Only show warnings of this severity (error, warning, notice, info).
  • -only-source <string>: Only show warnings from this source (g2, pkgcheck).
  • -only-tag <string>: Only show warnings with this tag.
  • -disable-rule <string>: Comma-separated list of rule IDs to ignore (case-insensitive).
  • -ignore-tag <string>: Comma-separated list of tags to ignore.

Example:

g2 lint /var/db/repos/my-overlay
g2 lint --enable-layout-lint .
g2 lint package . app-misc/foo
g2 lint query '>=app-misc/foo-1.0'
use

Manage and discover USE flags, use.desc, and use.local.desc.

Usage:

g2 use <subcommand>

Subcommands:

  • discover [location]: Discover USE flags from ebuilds and metadata.xml to regenerate use.desc, use.local.desc, and metadata.xml.
  • desc-add <name> <description>: Add a USE flag description to use.desc.
  • desc-remove <name>: Remove a USE flag description from use.desc.
  • desc-edit <name> <description>: Edit a USE flag description in use.desc.
  • desc-list: List all USE flag descriptions from use.desc.
  • local-desc-add <pkg> <name> <description>: Add a USE local flag description to use.local.desc.
  • local-desc-remove <pkg> <name>: Remove a USE local flag description from use.local.desc.
  • local-desc-edit <pkg> <name> <description>: Edit a USE local flag description in use.local.desc.
  • local-desc-list: List all USE local flag descriptions from use.local.desc.

Example Usage:

Discover and populate USE flags automatically:

g2 use discover .

List all local USE descriptions:

g2 use local-desc-list
cache

Manage md5-dict cache files.

Usage:

g2 cache <subcommand>

Subcommands:

  • verify [location]: Verify cache exists for ebuilds.
  • generate [target-packages...]: Generate cache for ebuilds. Optionally specify package atoms to only generate cache for them.
  • set-method <method>: Set the cache method in layout.conf.
  • list-methods: List available cache methods.
  • clean [location]: Clean up unused cache entries.

Example:

Generate the ebuild cache for the current overlay:

g2 cache generate

Generate the ebuild cache for specific packages:

g2 cache generate app-admin/sudoers-emerge app-test/app
pkg-desc-index

Tools relating to generating and verifying pkg_desc_index.

Usage:

g2 pkg-desc-index <subcommand>

Subcommands:

  • generate [location]: Generate pkg_desc_index file from the repository.
  • verify [location]: Verify existing pkg_desc_index file matches the repository.

Example:

Generate the package description index for the current overlay:

g2 pkg-desc-index generate .
package

Commands relating to packages and search indexing.

Usage:

g2 package <subcommand>

Subcommands:

  • search: Search packages.
  • index-overlay: Index a single overlay.
  • index-repositories: Index multiple repositories from an xml file.
  • index: Index local repositories.
  • update: Update the local index from a remote zip file.
  • deprecated: Commands relating to deprecated packages.
  • masked: Commands relating to masked packages within a repository.

Masks Command

The g2 masks command provides tools for inspecting and modifying user-level and repository-level package mask configuration (/etc/portage/package.mask and package.unmask).

  • g2 masks list [<filter>]: List all currently masked and unmasked packages across user config files and repository profiles/package.mask entries. An optional filter (like ::guru or sci-libs/onnxruntime) can be provided.
  • g2 masks mask <package>: Add a package to the user's package.mask configuration. If package.mask is a directory, it creates or appends to a g2.conf file inside it. (e.g. g2 masks mask sci-libs/onnxruntime::guru)
  • g2 masks unmask <package>: Add a package to the user's package.unmask configuration. If package.unmask is a directory, it creates or appends to a g2.conf file inside it. (e.g. g2 masks unmask sci-libs/onnxruntime::guru)
  • g2 masks reset <package>: Remove all mentions of a package from the user's package.mask and package.unmask configurations, sweeping through configuration directories as well.
eclass

Commands relating to eclasses.

Usage:

g2 eclass <subcommand>

Subcommands:

  • list: List available eclasses.
  • install: Install an eclass from gentoo stable.
  • explain: Human-readable summary output of an eclass.
  • remove: Remove an eclass.
arch

Commands relating to architectures.

Usage:

g2 arch <subcommand> [options]

Subcommands:

  • list-add: Add or edit an architecture in arch.list.
  • list-remove: Remove an architecture from arch.list.
  • list-ls: List all architectures in arch.list.
  • desc-add: Add or edit an architecture in arches.desc.
  • desc-remove: Remove an architecture from arches.desc.
  • desc-ls: List all architectures in arches.desc.
profile

Commands relating to profiles.

Usage:

g2 profile <subcommand>

Subcommands:

  • list: List profiles.
  • describe: Describe a profile.
conf

Commands relating to portage configuration.

Usage:

g2 conf all [--repo <path>] [--profile <profile_path>] [--make-conf <make.conf_path>] [--config-root <config_root_path>]

Outputs a complete overview of the system's Portage configuration, parsing variables from make.conf and the active profile's make.defaults cascade.

conf overlay

Manage repository-scoped local Portage policies (masks and unmasks) beneath /etc/portage (or --config-root).

  • g2 conf overlay list [--repos-conf <path>] [--config-root <path>]: List configured, enabled repositories from repos.conf.
  • g2 conf overlay <repo> list [--config-root <path>] [--repos-conf <path>]: List package masks and unmasks scoped to the selected repository across all Portage configuration files.
  • g2 conf overlay <repo> mask <atom> [--config-root <path>] [--repos-conf <path>]: Add a repository-qualified mask to the local Portage configuration (package.mask).
  • g2 conf overlay <repo> unmask <atom> [--config-root <path>] [--repos-conf <path>]: Add a repository-qualified unmask to the local Portage configuration (package.unmask).
  • g2 conf overlay <repo> mask-reset <atom> [--config-root <path>] [--repos-conf <path>]: Remove a repository-scoped mask rule from local Portage configuration.
  • g2 conf overlay <repo> unmask-reset <atom> [--config-root <path>] [--repos-conf <path>]: Remove a repository-scoped unmask rule from local Portage configuration.

GitHub Action

You can use the g2 GitHub Action to integrate g2 into your CI/CD workflows. It automatically downloads and installs g2 for use in your workflow steps.

Example Usage
name: Example workflow
on: [push]

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Install g2
        uses: arran4/g2-action@v1
        with:
          # Optional: specify a version. Defaults to 'latest'
          version: 'latest'

      - name: Use g2
        run: |
          g2 lint .

      - name: Use g2 Action
        uses: arran4/g2-action@v1.2
        with:
          # Optional: specify an action
          action: 'lint .'
          # Optional: skip installation if already installed
          mode: 'run'
Search Features

g2 site features a fully integrated browser-side search accessible from the main dashboard. Search indexes are emitted automatically to search/data. Users can query package names, descriptions, use flags, and numerous field filters (category, license, mask, version, depends, etc.). Advanced queries support boolean logic (AND, OR, NOT), grouping (), and sequence matching ('sequence of words'). Gentoo version ordering is natively supported for range queries like version:>1.2.3.

Flags:

  • -format <string>: Output format: text or json (default text).
  • -severity <string>: Only show warnings of this severity (Error, Warning, Notice, Info).
  • -only-source <string>: Only show warnings from this source (g2, pkgcheck).
  • -only-tag <string>: Only show warnings with this tag (e.g., site-quality, metadata.xml).

Example JSON Output:

g2 lint -format=json /var/db/repos/my-overlay
lint list

Lists all available lint rules.

Usage:

g2 lint list

Agent Skills

g2 supports an agent-skill subcommand system to let users install, inspect, update, remove, and manage AI agent skills that teach coding agents (like Claude, Cursor, Copilot) how to use this CLI correctly.

Installation Syntax

Skills can be installed from a local path:

g2 skill install ./skills/g2
Scopes and Agents

By default, skills are installed into the project scope (the current working directory) under .agents/skills.

You can modify the scope and agent target using flags:

# Install to the global user home directory (~/.agents/skills/g2)
g2 skill install --scope user ./skills/g2

# Install specifically for a given agent tool (e.g. ~/.cursor/skills/g2)
g2 skill install --scope user ./skills/g2 --agent cursor
Managing Skills

List installed skills:

g2 skill list --scope all

Inspect an installed skill's metadata:

g2 skill inspect g2

Update an installed skill (uses source checksums to detect manual modifications):

g2 skill update g2

# Overwrite local modifications
g2 skill update --force g2

Remove a skill:

g2 skill remove g2

Documentation

Index

Constants

View Source
const (
	HashBlake2b  = "BLAKE2B"
	HashBlake2s  = "BLAKE2S"
	HashMd5      = "MD5"
	HashRmd160   = "RMD160"
	HashSha1     = "SHA1"
	HashSha256   = "SHA256"
	HashSha3_256 = "SHA3_256"
	HashSha3_512 = "SHA3_512"
	HashSha512   = "SHA512"
)

Variables

View Source
var (
	ErrUnexpectedEOF = errors.New("unexpected EOF")
	ErrSyntaxError   = errors.New("syntax error")
)

Functions

func AddUserConfigAtom added in v0.0.98

func AddUserConfigAtom(configPath string, atomStr string) (bool, string, error)

AddUserConfigAtom appends atomStr to the appropriate Portage user configuration file under configPath. If the atom already exists anywhere within configPath, no change is made and it returns false, targetFile, nil. If configPath is a directory, it targets configPath/g2.conf. If configPath is an existing file, it targets that file. If configPath does not exist, it creates configPath as a directory containing g2.conf. Returns true, targetFile, nil if successfully added.

func CleanManifest added in v0.0.86

func CleanManifest(sysFS fs.FS, directory string, manifest *Manifest) error

CleanManifest removes unused DIST and EBUILD entries from a Manifest object based on the `.ebuild` files found in the given filesystem directory.

func CompareVersions added in v0.0.20

func CompareVersions(v1, v2 string) int

CompareVersions compares two gentoo versions strictly adhering to PMS. Returns > 0 if v1 > v2, < 0 if v1 < v2, and 0 if equal.

func DeduplicateEbuilds added in v0.0.89

func DeduplicateEbuilds(targets []string) ([]string, error)

DeduplicateEbuilds scans the given targets (directories or files) for ebuilds, groups them by SLOT and version grade, removes duplicates based on content digest (ignoring `# Generated via:` lines), keeps the highest version within each grade, and cleans up empty package directories (including `Manifest`, `metadata.xml`, and `md5-cache` entries). It returns a slice of file paths that were removed.

func ExtractPackageNameFromDep added in v0.0.29

func ExtractPackageNameFromDep(dep string) string

ExtractPackageNameFromDep strips version, slot, and USE flags from a package string using the AST parser PackageAtom to satisfy architectural requirements.

func FetchMainGentooCategories added in v0.0.32

func FetchMainGentooCategories() map[string]bool

func GenerateCache added in v0.0.85

func GenerateCache(repoDir string, targetPkgs []string, genEclasses bool) error

GenerateCache generates the cache for the repository.

func GenerateCacheFS added in v0.0.85

func GenerateCacheFS(cfs CacheFS, repoDir string, targetPkgs []string, genEclasses bool) error

GenerateCacheFS generates the cache for the repository using a custom CacheFS.

func GetLatestMatchingPackageRevision added in v0.0.84

func GetLatestMatchingPackageRevision(overlayFS fs.FS, category, pkgName, version string) (string, error)

GetLatestMatchingPackageRevision finds the highest revision for a given package and base version. It looks for ebuilds in `category/pkgName` directory within the provided `fs.FS`. The version argument is the base version to match against (e.g. "2.17.0"). Returns the full version string (including the highest revision, e.g. "2.17.0-r2").

func PadVersion added in v0.0.78

func PadVersion(ver string) string

PadVersion normalizes a version string so it can be compared strictly as strings.

func PadVersionTokens added in v0.0.24

func PadVersionTokens(v string) string

PadVersionTokens produces a sortable string representation of a gentoo version.

func ParseEbuildVariables

func ParseEbuildVariables(filename string) map[string]string

ParseEbuildVariables extracts PN, PV, P from the ebuild filename.

func ParseEbuildVariablesFromReader added in v0.0.84

func ParseEbuildVariablesFromReader(r io.Reader) map[string]string

ParseEbuildVariablesFromReader parses an ebuild file from a reader and extracts simple variables defined in the top level.

func ParseIUSE added in v0.0.19

func ParseIUSE(iuseStr string) []string

ParseIUSE extracts the actual USE flag names from an IUSE string, stripping prefixes like + and -.

func ParseInfoVars added in v0.0.28

func ParseInfoVars(path string) ([]string, error)

ParseInfoVars parses a profiles/info_vars file from the local filesystem.

func ParseInfoVarsFS added in v0.0.28

func ParseInfoVarsFS(sysFS fs.FS, path string) ([]string, error)

ParseInfoVarsFS parses a profiles/info_vars file from a filesystem.

func ParseLicense added in v0.0.27

func ParseLicense(licenseStr string) []string

ParseLicense extracts individual license names from a LICENSE string, evaluating all conditionals to true to gather all possible licenses.

func ParseLicenseGroups added in v0.0.28

func ParseLicenseGroups(r io.Reader) (map[string][]string, error)

ParseLicenseGroups parses a profiles/license_groups file. It returns a map where the key is the alias/group name, and the value is a list of target licenses that map to it.

func ParseMakeConf added in v0.0.54

func ParseMakeConf(path string) (map[string]string, error)

ParseMakeConf evaluates a make.conf file and extracts its variables.

func ParseMakeConfContent added in v0.0.54

func ParseMakeConfContent(content, filename string) (map[string]string, error)

ParseMakeConfContent parses and evaluates the content of a make.conf file

func ParseMetadata

func ParseMetadata(path string) (interface{}, error)

ParseMetadata parses a metadata.xml file and returns either a PkgMetadata or CatMetadata pointer (as interface{}), or an error.

func ParseMetadataBytes

func ParseMetadataBytes(data []byte) (interface{}, error)

ParseMetadataBytes parses metadata from a byte slice.

func ParseMetadataFromReader

func ParseMetadataFromReader(r io.Reader) (interface{}, error)

ParseMetadataFromReader parses metadata from an io.Reader.

func ParseThirdPartyMirrors added in v0.0.28

func ParseThirdPartyMirrors(path string) (map[string][]string, error)

ParseThirdPartyMirrors parses a thirdpartymirrors file from a path

func ParseThirdPartyMirrorsFS added in v0.0.28

func ParseThirdPartyMirrorsFS(sysFS fs.FS, path string) (map[string][]string, error)

ParseThirdPartyMirrorsFS parses a thirdpartymirrors file from an fs.FS

func ParseThirdPartyMirrorsFromReader added in v0.0.28

func ParseThirdPartyMirrorsFromReader(r io.Reader) (map[string][]string, error)

ParseThirdPartyMirrorsFromReader parses a thirdpartymirrors file from an io.Reader It returns a map of mirror name to a list of mirror URLs.

func ParseUseExpandDescDir added in v0.0.40

func ParseUseExpandDescDir(dir string) (map[string]*UseExpandDesc, error)

func ParseUseExpandDescFS added in v0.0.40

func ParseUseExpandDescFS(sysFS fs.FS, dir string) (map[string]*UseExpandDesc, error)

func ParseUserConfigFile added in v0.0.98

func ParseUserConfigFile(path string) (*UserConfigFile, []UserConfigEntry, error)

ParseUserConfigFile reads and parses a user configuration file (e.g. package.mask, package.unmask). If the file does not exist, it returns nil, nil, nil.

func QualifyAtomForRepo added in v0.0.98

func QualifyAtomForRepo(dep string, targetRepo string) (string, error)

QualifyAtomForRepo validates that the given package atom specification is valid according to Gentoo PMS rules and belongs to targetRepo. If the atom has no repository qualifier, ::targetRepo is appended. If the atom already specifies ::targetRepo, it is accepted. If the atom specifies a conflicting repository qualifier, an error is returned. Repo-wide wildcard atoms (e.g. */*), blockers (!/!!), and USE dependencies ([...]) are rejected.

func RemoveUserConfigAtom added in v0.0.98

func RemoveUserConfigAtom(configPath string, atomStr string) (int, error)

RemoveUserConfigAtom removes all occurrences of atomStr from all files under configPath, preserving untouched bytes (such as CRLF line endings and absence of trailing newlines). Returns the count of removed occurrences and error if any.

func ResolveVariables

func ResolveVariables(text string, variables map[string]string) string

ResolveVariables replaces ${VAR} and $VAR in the text with values from variables map.

func SafeWriteFileAtomic added in v0.0.98

func SafeWriteFileAtomic(targetPath string, content []byte, mode os.FileMode) error

SafeWriteFileAtomic safely writes data to targetPath by writing to a temporary file in the same directory and atomically renaming it into place. Existing permissions are preserved.

func SerializeInfoPkgs added in v0.0.28

func SerializeInfoPkgs(w io.Writer, pkgs []InfoPkg) error

func SerializeInfoVars added in v0.0.28

func SerializeInfoVars(w io.Writer, vars []string) error

SerializeInfoVars writes a list of variables to an io.Writer.

func SerializePackageDeprecated added in v0.0.20

func SerializePackageDeprecated(w io.Writer, deprecated []PackageDeprecated) error

func SerializePackageMasked added in v0.0.41

func SerializePackageMasked(w io.Writer, mask []PackageMasked) error

func SplitInputExpected added in v0.0.85

func SplitInputExpected(ar *txtar.Archive) (input, expected fstest.MapFS)

func SplitVersionOp added in v0.0.78

func SplitVersionOp(queryVersion string) (version string, op string)

SplitVersionOp extracts the operator (>=, <=, >, <, ~, =, ==) and the remaining version string

func StripEmail added in v0.0.30

func StripEmail(s string) string

StripEmail removes the email portion "<email@example.com>" from a string.

func UpsertManifest

func UpsertManifest(manifestPath string, newEntry *ManifestEntry) error

UpsertManifest updates or inserts a manifest entry.

func ValidateRepoName added in v0.0.98

func ValidateRepoName(name string) error

ValidateRepoName validates a repository name according to Gentoo PMS rules. Repository names must: - be non-empty; - contain only [A-Za-z0-9_-]; - not begin with '-'; - not begin with '+' or '.'; - contain no whitespace, CR, LF, NUL, or other delimiters.

func WalkFiles added in v0.0.85

func WalkFiles(root fs.FS, dir string) ([]string, error)

func WriteInfoVarsFile added in v0.0.28

func WriteInfoVarsFile(path string, vars []string) error

WriteInfoVarsFile writes a list of variables to a file on the local filesystem.

func WriteLayoutConf added in v0.0.17

func WriteLayoutConf(lc *LayoutConf, path string) error

WriteLayoutConf writes a LayoutConf back to a file

func WriteMetadata

func WriteMetadata(path string, data interface{}) error

WriteMetadata writes the metadata to a file with proper headers.

func WriteUpdatesFile added in v0.0.20

func WriteUpdatesFile(path string, update *PackageUpdate) error

Types

type AST added in v0.0.35

type AST struct {
	Value string
}

type Affected added in v0.0.15

type Affected struct {
	Packages []Package `xml:"package"`
	Services []Service `xml:"service"`
}

type AggProfile added in v0.0.42

type AggProfile struct {
	Path     string
	IsDesc   bool
	DescArch string
	DescStat string
	Repos    []AggProfileRepo
	Files    map[string]string // Maps filename to its content
}

type AggProfileRepo added in v0.0.42

type AggProfileRepo struct {
	RepoName string
	Profile  ProfileData
}

type ArchList added in v0.0.40

type ArchList struct {
	Arches []string
}

func ParseArchList added in v0.0.40

func ParseArchList(r io.Reader) (*ArchList, error)

func ParseArchListFile added in v0.0.40

func ParseArchListFile(filename string) (*ArchList, error)

type ArchesDesc added in v0.0.40

type ArchesDesc struct {
	Arches      map[string]string
	HeaderLines []string
}

func ParseArchesDesc added in v0.0.40

func ParseArchesDesc(r io.Reader) (*ArchesDesc, error)

func ParseArchesDescFS added in v0.0.95

func ParseArchesDescFS(fsys fs.FS, filename string) (*ArchesDesc, error)

func ParseArchesDescFile added in v0.0.40

func ParseArchesDescFile(filename string) (*ArchesDesc, error)

func (*ArchesDesc) Write added in v0.0.40

func (ad *ArchesDesc) Write(w io.Writer) error

func (*ArchesDesc) WriteFile added in v0.0.40

func (ad *ArchesDesc) WriteFile(filename string) error

type Author added in v0.0.17

type Author struct {
	Name  string
	Email string
	Line  int
}

Author represents an entry in the metadata/AUTHORS file.

func ParseAuthors added in v0.0.17

func ParseAuthors(r io.Reader) ([]Author, error)

ParseAuthors parses the metadata/AUTHORS file format. It ignores blank lines and comments starting with '#'. Expected format: "Name <email@example.com>" or just "Name".

type Background added in v0.0.15

type Background struct {
	Text string `xml:",innerxml"`
}
type Breadcrumb struct {
	Name string
	URL  string
	Path string
}

type CacheFS added in v0.0.85

type CacheFS interface {
	fs.FS
	MkdirAll(path string, perm os.FileMode) error
	Create(name string) (io.WriteCloser, error)
	Remove(name string) error
	Walk(root string, fn fs.WalkDirFunc) error
	Stat(name string) (fs.FileInfo, error)
}

CacheFS interface provides read and write abstraction for testability

type Cat

type Cat struct {
	// Text of the category.
	Text string `xml:",innerxml"`
}

Cat represents a cross-linking category. Note: This struct is not directly used in LongDescription to preserve mixed content via InnerXML, but is provided as part of the model definition.

type CatMetadata

type CatMetadata struct {
	XMLName         xml.Name          `xml:"catmetadata"`
	Comments        MetadataComments  `xml:"comment,omitempty" json:"-"`
	LongDescription []LongDescription `xml:"longdescription"`
}

CatMetadata represents metadata for a category. Source: https://github.com/gentoo-mirror/gentoo/blob/stable/metadata/dtd/metadata.dtd

func (*CatMetadata) String

func (c *CatMetadata) String() string

type CategoryData added in v0.0.19

type CategoryData struct {
	Name     string
	Packages []PackageData
}

type Checksums

type Checksums struct {
	Size   int64
	Hashes map[string]string
}

func DownloadAndChecksum

func DownloadAndChecksum(url string, hashes []string) (*Checksums, error)

type DepAllOf added in v0.0.27

type DepAllOf struct {
	Children []DepNode
}

func (DepAllOf) Evaluate added in v0.0.27

func (d DepAllOf) Evaluate(opts ...any) ([]string, error)

type DepAnyOf added in v0.0.27

type DepAnyOf struct {
	Children []DepNode
}

func (DepAnyOf) Evaluate added in v0.0.27

func (d DepAnyOf) Evaluate(opts ...any) ([]string, error)

type DepNode added in v0.0.27

type DepNode interface {
	Evaluate(opts ...any) ([]string, error)
}

type DepString added in v0.0.27

type DepString string

func (DepString) Evaluate added in v0.0.27

func (d DepString) Evaluate(opts ...any) ([]string, error)

type DepTree added in v0.0.27

type DepTree struct {
	Nodes []DepNode
}

func ParseDepTree added in v0.0.27

func ParseDepTree(s string) DepTree

ParseDepTree parses a dependency string (like DEPEND, RDEPEND, LICENSE) into an AST that can be evaluated with Evaluate().

func (DepTree) Evaluate added in v0.0.27

func (d DepTree) Evaluate(opts ...any) ([]string, error)

type DepUseConditional added in v0.0.27

type DepUseConditional struct {
	Flag      string
	IsNegated bool
	Children  []DepNode
}

func (DepUseConditional) Evaluate added in v0.0.27

func (d DepUseConditional) Evaluate(opts ...any) ([]string, error)

type DescLine added in v0.0.40

type DescLine struct {
	Text string
	Flag string // empty if it's a comment or blank line
}

type Description

type Description struct {
	// Text of the description.
	Text string `xml:",innerxml"`
}

Description represents a description of a maintainer or change.

type Doc

type Doc struct {
	// URL of the documentation.
	URL string `xml:",chardata"`
	// Lang specifies the language of the documentation.
	Lang string `xml:"lang,attr,omitempty"`
}

Doc represents a documentation URL.

type DownloadProgress

type DownloadProgress struct {
	Resp      *http.Response
	TotalSize *int64
	Size      int
	Tick      time.Time
	Start     time.Time
}

func (*DownloadProgress) Write

func (d *DownloadProgress) Write(p []byte) (n int, err error)

type Ebuild

type Ebuild struct {
	Path          string
	Vars          map[string]string
	Functions     map[string]AST
	SrcUri        []URIEntry
	Mode          ParsingMode
	RawText       string
	ParseWarnings []string

	EbuildHeader string
	// contains filtered or unexported fields
}

func BuildEbuild added in v0.0.91

func BuildEbuild(opts ...any) *Ebuild

BuildEbuild constructs an ebuild programmatically using the provided options.

func ParseEbuild

func ParseEbuild(fsys fs.FS, path string, mode ParsingMode) (*Ebuild, error)

ParseEbuild parses an ebuild file with the specified mode.

func (*Ebuild) String

func (e *Ebuild) String() string

type EbuildBDepend added in v0.0.91

type EbuildBDepend string

type EbuildBuilder added in v0.0.91

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

EbuildBuilder provides a fluent interface for generating ebuilds.

func (*EbuildBuilder) AddSrcURI added in v0.0.91

func (b *EbuildBuilder) AddSrcURI(url, filename string) *EbuildBuilder

AddSrcURI adds a source URI entry.

func (*EbuildBuilder) Apply added in v0.0.91

func (b *EbuildBuilder) Apply(opts ...any) *EbuildBuilder

Apply parses and applies a variadic list of options.

func (*EbuildBuilder) Build added in v0.0.91

func (b *EbuildBuilder) Build() *Ebuild

Build returns the constructed Ebuild.

func (*EbuildBuilder) SetFunction added in v0.0.91

func (b *EbuildBuilder) SetFunction(name, body string) *EbuildBuilder

SetFunction adds or updates a function and records its order.

func (*EbuildBuilder) SetVariable added in v0.0.91

func (b *EbuildBuilder) SetVariable(key, value string) *EbuildBuilder

SetVariable adds or updates a variable and records its order.

type EbuildBuilderOption added in v0.0.91

type EbuildBuilderOption interface {
	// contains filtered or unexported methods
}

EbuildBuilderOption represents an option that modifies the ebuild.

type EbuildDepend added in v0.0.91

type EbuildDepend string

type EbuildDescription added in v0.0.91

type EbuildDescription string

type EbuildEAPI added in v0.0.91

type EbuildEAPI string

type EbuildFunc added in v0.0.91

type EbuildFunc struct{ Name, Body string }

type EbuildHeader added in v0.0.91

type EbuildHeader string

type EbuildHomepage added in v0.0.91

type EbuildHomepage string

type EbuildIUse added in v0.0.91

type EbuildIUse []string

type EbuildInherit added in v0.0.91

type EbuildInherit []string

type EbuildKeywords added in v0.0.91

type EbuildKeywords []string

type EbuildLicense added in v0.0.91

type EbuildLicense string

type EbuildPDepend added in v0.0.91

type EbuildPDepend string

type EbuildParser added in v0.0.19

type EbuildParser struct {
	Warnings []string
	// contains filtered or unexported fields
}

EbuildParser implements a recursive descent parser for Gentoo ebuild files.

func NewEbuildParser added in v0.0.19

func NewEbuildParser(ctx context.Context, reader io.Reader) *EbuildParser

func (*EbuildParser) Parse added in v0.0.19

func (p *EbuildParser) Parse() (ParsedEbuild, error)

Parse extracts variables and functions from the ebuild using a recursive descent approach tailored specifically for ebuilds, bypassing full bash posix rules.

type EbuildRDepend added in v0.0.91

type EbuildRDepend string

type EbuildRequiredUse added in v0.0.91

type EbuildRequiredUse string

type EbuildRestrict added in v0.0.91

type EbuildRestrict []string

type EbuildSlot added in v0.0.91

type EbuildSlot string

type EbuildSrcURI added in v0.0.91

type EbuildSrcURI struct{ URL, Filename string }

type EbuildSrcURIRaw added in v0.0.91

type EbuildSrcURIRaw string

type EbuildVar added in v0.0.91

type EbuildVar struct{ Key, Value string }

type EclassData added in v0.0.46

type EclassData struct {
	Name string
}

type Email

type Email struct {
	// Text of the email address.
	Text string `xml:",innerxml"`
}

Email represents an email address.

type EvaluateConfig added in v0.0.27

type EvaluateConfig struct {
	UseFlags       map[string]bool
	IgnoreUseFlags bool
}

type Familyname added in v0.0.15

type Familyname struct {
	Text string `xml:",innerxml"`
	Sort string `xml:"sort,attr,omitempty"`
}

type Feed added in v0.0.19

type Feed struct {
	ID            string
	Title         string
	Link          string
	Description   string
	LastBuildDate string
	Updated       string
	Items         []FeedItem
}

type FeedItem added in v0.0.19

type FeedItem struct {
	ID          string
	Title       string
	Link        string
	Description string
	PubDate     string
	Updated     string
}

type FileData added in v0.0.19

type FileData struct {
	Name   string
	Path   string
	RawURL string
}

type Flag

type Flag struct {
	// Name of the USE flag.
	Name string `xml:"name,attr"`
	// Text of the flag.
	Text string `xml:",innerxml"`
	// Restrict specifies restrictions on the applicability of the flag.
	Restrict string `xml:"restrict,attr,omitempty"`
}

Flag represents a USE flag.

type GLSA added in v0.0.15

type GLSA struct {
	XMLName     xml.Name        `xml:"glsa"`
	ID          string          `xml:"id,attr"`
	Title       string          `xml:"title"`
	Synopsis    string          `xml:"synopsis"`
	Product     Product         `xml:"product"`
	Announced   string          `xml:"announced"`
	Revised     Revised         `xml:"revised"`
	Bugs        []string        `xml:"bug"`
	Access      string          `xml:"access,omitempty"`
	Affected    Affected        `xml:"affected"`
	Background  *Background     `xml:"background"`
	Description GLSADescription `xml:"description"`
	Impact      Impact          `xml:"impact"`
	Workaround  Workaround      `xml:"workaround"`
	Resolution  Resolution      `xml:"resolution"`
	References  References      `xml:"references"`
	License     *License        `xml:"license"`
	Metadata    []GLSAMetadata  `xml:"metadata"`
}

GLSA represents a Gentoo Linux Security Advisory. Source: https://github.com/gentoo-mirror/gentoo/blob/stable/metadata/dtd/glsa.dtd

func ParseGLSA added in v0.0.15

func ParseGLSA(path string) (*GLSA, error)

ParseGLSA parses a glsa.xml file and returns a GLSA pointer, or an error.

func ParseGLSABytes added in v0.0.15

func ParseGLSABytes(data []byte) (*GLSA, error)

ParseGLSABytes parses GLSA from a byte slice.

func ParseGLSAFromReader added in v0.0.15

func ParseGLSAFromReader(r io.Reader) (*GLSA, error)

ParseGLSAFromReader parses GLSA from an io.Reader.

type GLSADescription added in v0.0.15

type GLSADescription struct {
	Text string `xml:",innerxml"`
}

type GLSAMetadata added in v0.0.15

type GLSAMetadata struct {
	Text      string `xml:",innerxml"`
	Tag       string `xml:"tag,attr"`
	Revision  string `xml:"revision,attr,omitempty"`
	Author    string `xml:"author,attr,omitempty"`
	Timestamp string `xml:"timestamp,attr,omitempty"`
}

type GentooSuffix added in v0.0.88

type GentooSuffix struct {
	Name     string
	Value    int
	ValueStr string
}

GentooVersion represents a parsed Gentoo package version strictly adhering to PMS rules.

type GentooVersion added in v0.0.23

type GentooVersion struct {
	Nums     []int
	NumStrs  []string
	Letter   string
	Suffixes []GentooSuffix
	Revision int
	IsValid  bool
}

func ParseGentooVersion added in v0.0.23

func ParseGentooVersion(v string) GentooVersion

ParseGentooVersion parses a gentoo version into parts

func (*GentooVersion) IncrementPart added in v0.0.23

func (gv *GentooVersion) IncrementPart(parts ...any)

IncrementPart allows incrementing specific parts of the version string based on common bump operations. Supports variadic Part arguments to increment multiple parts sequentially.

func (*GentooVersion) IncrementRevision added in v0.0.23

func (gv *GentooVersion) IncrementRevision()

IncrementRevision increments the Gentoo version revision number (e.g., -r1 -> -r2).

func (*GentooVersion) String added in v0.0.23

func (gv *GentooVersion) String() string

String reassembles and serializes the parsed GentooVersion back into a string.

type Hash

type Hash struct {
	Type  string
	Value string
}

type IgnoreUseFlags added in v0.0.27

type IgnoreUseFlags bool

type Impact added in v0.0.15

type Impact struct {
	Text string `xml:",innerxml"`
	Type string `xml:"type,attr"`
}

type InfoPkg added in v0.0.28

type InfoPkg struct {
	PackageAtom string
}

func ParseInfoPkgs added in v0.0.28

func ParseInfoPkgs(path string) ([]InfoPkg, error)

func ParseInfoPkgsFS added in v0.0.28

func ParseInfoPkgsFS(sysFS fs.FS, path string) ([]InfoPkg, error)

type LayoutConf added in v0.0.17

type LayoutConf struct {
	Entries []LayoutConfEntry
}

LayoutConf represents the contents of a metadata/layout.conf file

func ParseLayoutConf added in v0.0.17

func ParseLayoutConf(path string) (*LayoutConf, error)

ParseLayoutConf parses a metadata/layout.conf file

func ParseLayoutConfFromReader added in v0.0.19

func ParseLayoutConfFromReader(r io.Reader) (*LayoutConf, error)

ParseLayoutConfFromReader parses a layout.conf from an io.Reader

func (*LayoutConf) Aliases added in v0.0.98

func (lc *LayoutConf) Aliases() []string

Aliases returns the list of alternative names for the repository.

func (*LayoutConf) CacheFormats added in v0.0.98

func (lc *LayoutConf) CacheFormats() []string

CacheFormats returns the cache formats used by the repository.

func (*LayoutConf) EapisBanned added in v0.0.98

func (lc *LayoutConf) EapisBanned() []string

EapisBanned returns the list of banned EAPIs for ebuilds.

func (*LayoutConf) EapisDeprecated added in v0.0.98

func (lc *LayoutConf) EapisDeprecated() []string

EapisDeprecated returns the list of deprecated EAPIs for ebuilds.

func (*LayoutConf) EapisTesting added in v0.0.98

func (lc *LayoutConf) EapisTesting() []string

EapisTesting returns the list of testing EAPIs for ebuilds.

func (*LayoutConf) GetValue added in v0.0.17

func (lc *LayoutConf) GetValue(key string) string

GetValue returns the value for a specific key

func (*LayoutConf) GetValuesAsSlice added in v0.0.17

func (lc *LayoutConf) GetValuesAsSlice(key string) []string

GetValuesAsSlice returns the value for a specific key split by spaces

func (*LayoutConf) HasKey added in v0.0.94

func (lc *LayoutConf) HasKey(key string) bool

HasKey returns true if a specific key exists

func (*LayoutConf) ManifestHashes added in v0.0.98

func (lc *LayoutConf) ManifestHashes() []string

ManifestHashes returns the list of allowed manifest hashes.

func (*LayoutConf) ManifestRequiredHashes added in v0.0.98

func (lc *LayoutConf) ManifestRequiredHashes() []string

ManifestRequiredHashes returns the list of required manifest hashes.

func (*LayoutConf) Masters added in v0.0.98

func (lc *LayoutConf) Masters() []string

Masters returns the list of master repositories.

func (*LayoutConf) ProfileEapisBanned added in v0.0.98

func (lc *LayoutConf) ProfileEapisBanned() []string

ProfileEapisBanned returns the list of banned EAPIs for profiles.

func (*LayoutConf) ProfileEapisDeprecated added in v0.0.98

func (lc *LayoutConf) ProfileEapisDeprecated() []string

ProfileEapisDeprecated returns the list of deprecated EAPIs for profiles.

func (*LayoutConf) ProfileFormats added in v0.0.98

func (lc *LayoutConf) ProfileFormats() []string

ProfileFormats returns the formats used by profiles.

func (*LayoutConf) PropertiesAllowed added in v0.0.98

func (lc *LayoutConf) PropertiesAllowed() []string

PropertiesAllowed returns the list of properties permitted in ebuilds.

func (*LayoutConf) RepoName added in v0.0.98

func (lc *LayoutConf) RepoName() string

RepoName returns the specified repository name.

func (*LayoutConf) RestrictAllowed added in v0.0.98

func (lc *LayoutConf) RestrictAllowed() []string

RestrictAllowed returns the list of restrict tokens permitted in ebuilds.

func (*LayoutConf) SetValue added in v0.0.17

func (lc *LayoutConf) SetValue(key, value string)

SetValue sets the value for a specific key, updating it if it exists or appending if it doesn't

func (*LayoutConf) SignCommits added in v0.0.98

func (lc *LayoutConf) SignCommits() bool

SignCommits indicates whether git commits should be signed.

func (*LayoutConf) SignManifests added in v0.0.98

func (lc *LayoutConf) SignManifests() bool

SignManifests indicates whether individual package manifests should be signed.

func (*LayoutConf) ThinManifests added in v0.0.98

func (lc *LayoutConf) ThinManifests() bool

ThinManifests indicates whether thin manifests are used.

func (*LayoutConf) UnsetValue added in v0.0.17

func (lc *LayoutConf) UnsetValue(key string)

UnsetValue removes a specific key

func (*LayoutConf) UpdateChangelog added in v0.0.98

func (lc *LayoutConf) UpdateChangelog() bool

UpdateChangelog indicates whether development tools should write ChangeLog files.

func (*LayoutConf) UseManifests added in v0.0.98

func (lc *LayoutConf) UseManifests() string

UseManifests returns the policy for creating and using Manifest files (e.g., strict, true, false).

type LayoutConfEntry added in v0.0.17

type LayoutConfEntry struct {
	Comments []string
	Key      string
	Value    string
}

LayoutConfEntry represents a single key-value entry with its preceding comments

type License added in v0.0.15

type License struct {
	Text string `xml:",innerxml"`
}

type LicenseData added in v0.0.19

type LicenseData struct {
	Name     string
	Count    int
	Packages []PackageData
}

type Location added in v0.0.15

type Location struct {
	Text      string `xml:",innerxml"`
	Latitude  string `xml:"latitude,attr,omitempty"`
	Longitude string `xml:"longitude,attr,omitempty"`
}

type LongDescription

type LongDescription struct {
	// Body contains the inner XML of the long description.
	// We use InnerXML to preserve mixed content (text + <pkg>/<cat> tags) and ensure circularity.
	Body string `xml:",innerxml"`
	// Lang specifies the language of the description.
	Lang string `xml:"lang,attr,omitempty"`
	// Restrict specifies restrictions on the applicability of the description.
	Restrict string `xml:"restrict,attr,omitempty"`
}

LongDescription represents a long description of a package or category.

type Maintainer

type Maintainer struct {
	// Email of the maintainer.
	Email string `xml:"email"`
	// Name of the maintainer.
	Name string `xml:"name,omitempty"`
	// Description of the maintainer.
	Description string `xml:"description,omitempty"`
	// Type of the maintainer: person, project, or unknown.
	Type string `xml:"type,attr,omitempty"`
	// Proxied indicates whether the maintainer is proxied: yes, no, or proxy.
	Proxied string `xml:"proxied,attr,omitempty"`
	// Status of the upstream maintainer: active, inactive, or unknown.
	Status string `xml:"status,attr,omitempty"`
	// Restrict specifies restrictions on the applicability of the maintainer.
	Restrict string `xml:"restrict,attr,omitempty"`
}

Maintainer represents a maintainer of a package.

type Manifest

type Manifest struct {
	Entries []*ManifestEntry
}

func ParseManifest

func ParseManifest(path string) (*Manifest, error)

func ParseManifestContent

func ParseManifestContent(content string) (*Manifest, error)

func ParseManifestFromReader added in v0.0.19

func ParseManifestFromReader(r io.Reader) (*Manifest, error)

ParseManifestFromReader parses a Manifest file from an io.Reader

func (*Manifest) AddOrReplace

func (m *Manifest) AddOrReplace(entry *ManifestEntry)

func (*Manifest) GetEntry

func (m *Manifest) GetEntry(filename string) *ManifestEntry

GetEntry returns the entry for a filename if it exists

func (*Manifest) Remove

func (m *Manifest) Remove(filename string)

func (*Manifest) Sort

func (m *Manifest) Sort()

Sort sorts the manifest entries by type then filename

func (*Manifest) String

func (m *Manifest) String() string

type ManifestEntry

type ManifestEntry struct {
	Type     string
	Filename string
	Size     int64
	Hashes   []Hash
}

func NewManifestEntry

func NewManifestEntry(typeStr, filename string, size int64, hashes ...Hash) *ManifestEntry

func ParseManifestEntry

func ParseManifestEntry(line string) (*ManifestEntry, error)

func (*ManifestEntry) AddHash

func (e *ManifestEntry) AddHash(hType, hValue string)

func (*ManifestEntry) GetHash

func (e *ManifestEntry) GetHash(hType string) string

func (*ManifestEntry) String

func (e *ManifestEntry) String() string

type ManifestEntryData added in v0.0.46

type ManifestEntryData struct {
	Entry        *ManifestEntry
	Versions     []string
	URLs         []string
	ResolvedURLs []string
}

type Member added in v0.0.15

type Member struct {
	IsLead string `xml:"is-lead,attr,omitempty"` // 0|1
	Email  string `xml:"email"`
	Name   string `xml:"name,omitempty"`
	Role   string `xml:"role,omitempty"`
}

type MetadataComments added in v0.0.90

type MetadataComments []string

MetadataComments represents a list of XML comments.

func (MetadataComments) MarshalXML added in v0.0.90

func (c MetadataComments) MarshalXML(e *xml.Encoder, start xml.StartElement) error

MarshalXML implements the xml.Marshaler interface to emit XML comments.

type Mirror added in v0.0.15

type Mirror struct {
	City        string      `xml:"city,attr,omitempty"`
	Coordinates string      `xml:"coordinates,attr,omitempty"`
	GentooBug   string      `xml:"gentoo-bug,attr,omitempty"`
	Name        string      `xml:"name"`
	URIs        []MirrorURI `xml:"uri"`
}

type MirrorGroup added in v0.0.15

type MirrorGroup struct {
	Region      string   `xml:"region,attr"`
	Country     string   `xml:"country,attr"`
	CountryName string   `xml:"countryname,attr,omitempty"`
	Mirrors     []Mirror `xml:"mirror"`
}

type MirrorURI added in v0.0.15

type MirrorURI struct {
	Text     string `xml:",innerxml"`
	IPv4     string `xml:"ipv4,attr,omitempty"`     // Y|y|N|n
	IPv6     string `xml:"ipv6,attr,omitempty"`     // Y|y|N|n
	Partial  string `xml:"partial,attr,omitempty"`  // Y|y|N|n
	Protocol string `xml:"protocol,attr,omitempty"` // http|ftp|rsync
}

type Mirrors added in v0.0.15

type Mirrors struct {
	XMLName      xml.Name      `xml:"mirrors"`
	MirrorGroups []MirrorGroup `xml:"mirrorgroup"`
}

Mirrors represents a set of mirror groups. Source: https://github.com/gentoo-mirror/gentoo/blob/stable/metadata/dtd/mirrors.dtd

func ParseMirrors added in v0.0.15

func ParseMirrors(path string) (*Mirrors, error)

ParseMirrors parses a mirrors.xml file and returns a Mirrors pointer, or an error.

func ParseMirrorsBytes added in v0.0.15

func ParseMirrorsBytes(data []byte) (*Mirrors, error)

ParseMirrorsBytes parses Mirrors from a byte slice.

func ParseMirrorsFromReader added in v0.0.15

func ParseMirrorsFromReader(r io.Reader) (*Mirrors, error)

ParseMirrorsFromReader parses Mirrors from an io.Reader.

type Name

type Name struct {
	// Text of the name.
	Text string `xml:",innerxml"`
}

Name represents a name of a person or maintainer.

type NewsItem added in v0.0.30

type NewsItem struct {
	Title              string
	Author             string
	Translator         []string
	Posted             time.Time
	Revision           string
	NewsItemFormat     string
	DisplayIfInstalled []string
	DisplayIfKeyword   []string
	DisplayIfProfile   []string
	Body               string
	BodyAST            []NewsNode
	DirName            string
	FileName           string
}

NewsItem represents a parsed Gentoo News Item (GLEP 42).

func ParseNewsItem added in v0.0.30

func ParseNewsItem(content string) NewsItem

ParseNewsItem parses the content of a Gentoo news file into a NewsItem structure.

func (NewsItem) ToHTML added in v0.0.30

func (n NewsItem) ToHTML() string

ToHTML is here for template interface compatibility

func (NewsItem) ToHTMLTemplate added in v0.0.30

func (n NewsItem) ToHTMLTemplate() template.HTML

ToHTMLTemplate converts the NewsItem body into an HTML template representation.

func (NewsItem) ToText added in v0.0.30

func (n NewsItem) ToText(compliant ...bool) string

ToText returns the plain text body of the NewsItem. It will reconstruct it from the AST for 2.0 format to demonstrate serialization.

type NewsNode added in v0.0.30

type NewsNode struct {
	Type  NewsNodeType
	Lines []string // Contains the text for text/code, or list items
}

NewsNode represents a single abstract syntax tree element in a news item body.

type NewsNodeType added in v0.0.30

type NewsNodeType int

NewsNodeType identifies the type of an AST node in a news item body.

const (
	NewsNodeText NewsNodeType = iota
	NewsNodeList
	NewsNodeCode
)

type OsCacheFS added in v0.0.85

type OsCacheFS struct {
	fs.FS
	// contains filtered or unexported fields
}

OsCacheFS is a CacheFS implementation that interacts with the real OS filesystem

func NewOsCacheFS added in v0.0.85

func NewOsCacheFS(base string) *OsCacheFS

func (*OsCacheFS) Create added in v0.0.85

func (o *OsCacheFS) Create(name string) (io.WriteCloser, error)

func (*OsCacheFS) MkdirAll added in v0.0.85

func (o *OsCacheFS) MkdirAll(path string, perm os.FileMode) error

func (*OsCacheFS) Remove added in v0.0.85

func (o *OsCacheFS) Remove(name string) error

func (*OsCacheFS) Stat added in v0.0.85

func (o *OsCacheFS) Stat(name string) (fs.FileInfo, error)

func (*OsCacheFS) Walk added in v0.0.85

func (o *OsCacheFS) Walk(root string, fn fs.WalkDirFunc) error

type Package added in v0.0.15

type Package struct {
	Name       string       `xml:"name,attr"`
	Auto       string       `xml:"auto,attr"` // yes|no
	Arch       string       `xml:"arch,attr"`
	Vulnerable []Vulnerable `xml:"vulnerable"`
	Unaffected []Unaffected `xml:"unaffected"`
}

type PackageAtom added in v0.0.29

type PackageAtom struct {
	Operator string // e.g. ">=", "~", "!", "!!", ""
	Category string // e.g. "dev-lang"
	Name     string // e.g. "python"
	Version  string // e.g. "3.10.4-r1"
	Slot     string // e.g. "0/3.10"
	Repo     string // e.g. "arrans-overlay"
	UseFlags string // e.g. "sqlite,xml"
}

PackageAtom represents a parsed Gentoo package dependency specification.

func ParsePackageAtom added in v0.0.29

func ParsePackageAtom(dep string) PackageAtom

ParsePackageAtom parses a raw dependency string into its constituent parts.

func (PackageAtom) String added in v0.0.98

func (a PackageAtom) String() string

String returns the Gentoo package atom specification as a string.

type PackageData added in v0.0.19

type PackageData struct {
	Name                  string
	Category              string
	Versions              []VersionData
	Metadata              *PkgMetadata
	MetadataError         error
	Manifest              *Manifest
	ManifestData          []ManifestEntryData
	Files                 []FileData
	HighestStableVersion  []VersionGroup
	HighestTestingVersion []VersionGroup
	SnapshotVersion       string
	EbuildCount           int
	DominantDescription   string
	DominantHomepage      string
	DominantLicense       string

	// Git info
	MetadataRawURL string
	ModTime        time.Time // Changed from time.Time to break cycle or keep as int64 if needed, wait time is standard

	// Processed Uses (per package)
	PkgUseFlags []PkgUseFlag

	// Lint Info
	LintWarnings []string

	// Deprecation
	Masked     *PackageMasked
	Deprecated *PackageDeprecated

	// InfoPkg matching
	IsInfoPkg bool

	ReverseVirtuals []string
	Equivalents     []string
	VirtualDeps     []string
}

type PackageDeprecated added in v0.0.20

type PackageDeprecated struct {
	Reason      string
	Date        string
	Author      string
	AuthorEmail string
	Entries     []PackageDeprecatedEntry
}

PackageDeprecated represents a block of deprecation entries grouped by author and reason.

func ParsePackageDeprecated added in v0.0.20

func ParsePackageDeprecated(path string) ([]PackageDeprecated, error)

func ParsePackageDeprecatedFS added in v0.0.20

func ParsePackageDeprecatedFS(sysFS fs.FS, path string) ([]PackageDeprecated, error)

type PackageDeprecatedEntry added in v0.0.41

type PackageDeprecatedEntry struct {
	Package string
}

PackageDeprecatedEntry represents a single deprecation entry from profiles/package.deprecated.

type PackageMasked added in v0.0.41

type PackageMasked struct {
	Reason      string
	Date        string
	Author      string
	AuthorEmail string
	Entries     []PackageMaskedEntry
}

PackageMasked represents a block of deprecation entries grouped by author and reason.

func ParsePackageMasked added in v0.0.41

func ParsePackageMasked(path string) ([]PackageMasked, error)

func ParsePackageMaskedFS added in v0.0.41

func ParsePackageMaskedFS(sysFS fs.FS, path string) ([]PackageMasked, error)

type PackageMaskedEntry added in v0.0.41

type PackageMaskedEntry struct {
	Package string
}

PackageMaskedEntry represents a single deprecation entry from profiles/package.mask.

type PackageMove added in v0.0.17

type PackageMove struct {
	Old string
	New string
}

type PackageSlotMove added in v0.0.20

type PackageSlotMove struct {
	Package string
	Old     string
	New     string
}

type PackageUpdate added in v0.0.17

type PackageUpdate struct {
	Moves     []PackageMove
	SlotMoves []PackageSlotMove
}

func ParseUpdatesDir added in v0.0.17

func ParseUpdatesDir(dir string) (*PackageUpdate, error)

func ParseUpdatesDirFS added in v0.0.19

func ParseUpdatesDirFS(sysFS fs.FS, dir string) (*PackageUpdate, error)

type ParseError added in v0.0.19

type ParseError struct {
	Pos Position
	Err error
}

func (*ParseError) Error added in v0.0.19

func (e *ParseError) Error() string

func (*ParseError) Unwrap added in v0.0.19

func (e *ParseError) Unwrap() error

type ParsedEbuild added in v0.0.35

type ParsedEbuild struct {
	Variables    map[string]string
	Functions    map[string]AST
	Order        []string
	EbuildHeader string
	Warnings     []string
}

ParsedEbuild contains the results of parsing an ebuild

type ParsingMode

type ParsingMode uint
const (
	ParseMetadataOnly ParsingMode = iota + 1 // Parse only filename-based metadata (PN, PV, etc.)
	ParseVariables                           // Parse variable definitions in the file
	ParseFull                                // Parse everything (e.g. SRC_URI)
)

func (ParsingMode) String

func (m ParsingMode) String() string

type Part added in v0.0.23

type Part string

Part represents a specific component of a Gentoo version.

const (
	MajorPart    Part = "major"
	MinorPart    Part = "minor"
	PatchPart    Part = "patch"
	SuffixPart   Part = "suffix"
	RevisionPart Part = "revision"
)

type Pkg

type Pkg struct {
	// Text of the package.
	Text string `xml:",innerxml"`
}

Pkg represents a cross-linking package. Note: This struct is not directly used in LongDescription to preserve mixed content via InnerXML, but is provided as part of the model definition.

type PkgDescIndex added in v0.0.19

type PkgDescIndex struct {
	Entries []PkgDescIndexEntry
}

PkgDescIndex represents the parsed content of a pkg_desc_index file.

func ParsePkgDescIndex added in v0.0.19

func ParsePkgDescIndex(r io.Reader) (*PkgDescIndex, error)

ParsePkgDescIndex reads and parses the pkg_desc_index file from an io.Reader.

func ParsePkgDescIndexFile added in v0.0.19

func ParsePkgDescIndexFile(path string, opts ...any) (*PkgDescIndex, error)

ParsePkgDescIndexFile reads and parses a pkg_desc_index file. It optionally accepts an fs.FS to read from via type-switched variadic args. If no fs.FS is provided, it falls back to os.Open.

func (*PkgDescIndex) Save added in v0.0.19

func (idx *PkgDescIndex) Save(path string) error

Save serializes the PkgDescIndex and writes it to the specified file path.

func (*PkgDescIndex) Serialize added in v0.0.19

func (idx *PkgDescIndex) Serialize(w io.Writer) error

Serialize formats the PkgDescIndex into the expected text format.

func (*PkgDescIndex) Sort added in v0.0.19

func (idx *PkgDescIndex) Sort()

Sort sorts the entries alphabetically by category and package.

type PkgDescIndexEntry added in v0.0.19

type PkgDescIndexEntry struct {
	Category    string
	Package     string
	Versions    []string
	Description string
}

PkgDescIndexEntry represents a single entry in the pkg_desc_index file.

type PkgMetadata

type PkgMetadata struct {
	XMLName            xml.Name            `xml:"pkgmetadata"`
	Comments           MetadataComments    `xml:"comment,omitempty" json:"-"`
	Maintainers        []Maintainer        `xml:"maintainer"`
	LongDescription    []LongDescription   `xml:"longdescription"`
	Slots              *Slots              `xml:"slots"`
	StabilizeAllArches *StabilizeAllArches `xml:"stabilize-allarches"`
	StraightToStable   *StraightToStable   `xml:"straight-to-stable"`
	Use                []Use               `xml:"use"`
	Upstream           *Upstream           `xml:"upstream"`
}

func (*PkgMetadata) String

func (p *PkgMetadata) String() string

type PkgUseFlag added in v0.0.46

type PkgUseFlag struct {
	Name     string
	Desc     string
	Source   string
	Versions map[string]string // Version -> Unicode symbol representing state
}

type Position added in v0.0.19

type Position struct {
	Line   int
	Column int
}

func (Position) String added in v0.0.19

func (p Position) String() string

type Product added in v0.0.15

type Product struct {
	Text string `xml:",innerxml"`
	Type string `xml:"type,attr"` // ebuild|infrastructure|informational
}

type ProfileData added in v0.0.42

type ProfileData struct {
	Path     string
	IsDesc   bool
	DescArch string
	DescStat string
	Parents  []string
	Children []string
	Files    map[string]string // Maps filename to its content
}

type ProfileDescEntry added in v0.0.42

type ProfileDescEntry struct {
	Arch   string
	Path   string
	Status string
}

type Project added in v0.0.15

type Project struct {
	Email       string       `xml:"email"`
	Name        string       `xml:"name"`
	URL         string       `xml:"url,omitempty"`
	Description string       `xml:"description,omitempty"`
	Subprojects []Subproject `xml:"subproject"`
	Members     []Member     `xml:"member"`
}

type Projects added in v0.0.15

type Projects struct {
	XMLName  xml.Name  `xml:"projects"`
	Projects []Project `xml:"project"`
}

Projects represents a list of projects. Source: https://github.com/gentoo-mirror/gentoo/blob/stable/metadata/dtd/projects.dtd

func ParseProjects added in v0.0.15

func ParseProjects(path string) (*Projects, error)

ParseProjects parses a projects.xml file and returns a Projects pointer, or an error.

func ParseProjectsBytes added in v0.0.15

func ParseProjectsBytes(data []byte) (*Projects, error)

ParseProjectsBytes parses Projects from a byte slice.

func ParseProjectsFromReader added in v0.0.15

func ParseProjectsFromReader(r io.Reader) (*Projects, error)

ParseProjectsFromReader parses Projects from an io.Reader.

type QAPolicy added in v0.0.19

type QAPolicy struct {
	Policies map[string]string
}

func ParseQAPolicy added in v0.0.19

func ParseQAPolicy(path string) (*QAPolicy, error)

func ParseQAPolicyFromReader added in v0.0.19

func ParseQAPolicyFromReader(r io.Reader) (*QAPolicy, error)

type Reader added in v0.0.19

type Reader struct {
	Pos Position
	// contains filtered or unexported fields
}

Wrapper for tracking position

func NewReader added in v0.0.19

func NewReader(r io.Reader) *Reader

func (*Reader) ReadRune added in v0.0.19

func (r *Reader) ReadRune() (rune, int, error)

func (*Reader) UnreadRune added in v0.0.19

func (r *Reader) UnreadRune() error

type Realname added in v0.0.15

type Realname struct {
	Fullname   string     `xml:"fullname,attr,omitempty"`
	Firstname  string     `xml:"firstname"`
	Familyname Familyname `xml:"familyname"`
}

type References added in v0.0.15

type References struct {
	URIs []URI `xml:"uri"`
}

type RemoteID

type RemoteID struct {
	// Text of the remote identifier.
	Text string `xml:",innerxml"`
	// Type of the remote identifier.
	Type string `xml:"type,attr"`
}

RemoteID represents a remote identifier for a package. Supported types: bitbucket, codeberg, cpan, cpan-module, cpe, cran, ctan, freedesktop-gitlab, gentoo, github, gitlab, gnome-gitlab, google-code, hackage, heptapod, kde-invent, launchpad, osdn, pear, pecl, pypi, rubygems, savannah, savannah-nongnu, sourceforge, sourcehut, vim

type RepoInfo added in v0.0.98

type RepoInfo struct {
	Name       string // Section name in repos.conf
	RepoName   string // Actual repository identity (from profiles/repo_name if present, else section name)
	Location   string // Repository location directory
	Disabled   bool   // True if disabled in repos.conf
	ConfigFile string // Path to repos.conf file containing this section
}

RepoInfo describes a configured repository found in repos.conf.

func ListConfiguredRepos added in v0.0.98

func ListConfiguredRepos(location string) ([]*RepoInfo, error)

ListConfiguredRepos returns all active (enabled) repositories from repos.conf at location.

func ResolveRepo added in v0.0.98

func ResolveRepo(repoName string, reposConfPath string) (*RepoInfo, error)

ResolveRepo finds a single configured repository by section name or Portage repository identity.

type ReposConf added in v0.0.43

type ReposConf struct {
	Path  string
	IsDir bool
	Files []*ReposConfFile
}

func ParseReposConf added in v0.0.43

func ParseReposConf(path string) (*ReposConf, error)

type ReposConfFile added in v0.0.43

type ReposConfFile struct {
	Path        string
	HeaderLines []string
	Sections    []*ReposConfSection
}

func ParseReposConfFile added in v0.0.43

func ParseReposConfFile(path string) (*ReposConfFile, error)

func (*ReposConfFile) Disable added in v0.0.43

func (f *ReposConfFile) Disable() error

func (*ReposConfFile) Enable added in v0.0.43

func (f *ReposConfFile) Enable() error

func (*ReposConfFile) Write added in v0.0.43

func (f *ReposConfFile) Write() error

type ReposConfSection added in v0.0.43

type ReposConfSection struct {
	Name     string
	Disabled bool
	Lines    []string
}

func (*ReposConfSection) Disable added in v0.0.43

func (s *ReposConfSection) Disable()

func (*ReposConfSection) Enable added in v0.0.43

func (s *ReposConfSection) Enable()

func (*ReposConfSection) Get added in v0.0.43

func (s *ReposConfSection) Get(key string) string

func (*ReposConfSection) Set added in v0.0.43

func (s *ReposConfSection) Set(key, value string)

func (*ReposConfSection) Unset added in v0.0.43

func (s *ReposConfSection) Unset(key string)

type Repositories added in v0.0.15

type Repositories struct {
	XMLName      xml.Name     `xml:"repositories"`
	Version      string       `xml:"version,attr"`
	Repositories []Repository `xml:"repo"`
}

Repositories represents a list of Gentoo repositories. Source: https://github.com/gentoo-mirror/gentoo/blob/stable/metadata/dtd/repositories.dtd

func ParseRepositories added in v0.0.15

func ParseRepositories(path string) (*Repositories, error)

ParseRepositories parses a repositories.xml file and returns a Repositories pointer, or an error.

func ParseRepositoriesBytes added in v0.0.15

func ParseRepositoriesBytes(data []byte) (*Repositories, error)

ParseRepositoriesBytes parses Repositories from a byte slice.

func ParseRepositoriesFromReader added in v0.0.15

func ParseRepositoriesFromReader(r io.Reader) (*Repositories, error)

ParseRepositoriesFromReader parses Repositories from an io.Reader.

type Repository added in v0.0.15

type Repository struct {
	Priority         string                  `xml:"priority,attr,omitempty"`
	Quality          string                  `xml:"quality,attr"` // core|stable|testing|experimental|graveyard
	Status           string                  `xml:"status,attr"`  // official|unofficial
	Name             string                  `xml:"name"`
	Descriptions     []RepositoryDescription `xml:"description"`
	LongDescriptions []RepositoryDescription `xml:"longdescription"`
	Homepage         string                  `xml:"homepage,omitempty"`
	Owners           []RepositoryOwner       `xml:"owner"`
	Sources          []RepositorySource      `xml:"source"`
	Feeds            []string                `xml:"feed"`
}

type RepositoryDescription added in v0.0.15

type RepositoryDescription struct {
	Text string `xml:",innerxml"`
	Lang string `xml:"lang,attr,omitempty"`
}

type RepositoryOwner added in v0.0.15

type RepositoryOwner struct {
	Type  string `xml:"type,attr,omitempty"` // project|person
	Email string `xml:"email"`
	Name  string `xml:"name,omitempty"`
}

type RepositorySource added in v0.0.15

type RepositorySource struct {
	Text string `xml:",innerxml"`
	Type string `xml:"type,attr"` // bzr|cvs|darcs|git|mercurial|rsync|svn|tar
}

type RequiredUseAllOf added in v0.0.20

type RequiredUseAllOf struct {
	Nodes []RequiredUseNode
}

RequiredUseAllOf represents a list of requirements, ALL of which must be met.

func (RequiredUseAllOf) Evaluate added in v0.0.20

func (a RequiredUseAllOf) Evaluate(context map[string]bool) bool

func (RequiredUseAllOf) String added in v0.0.20

func (a RequiredUseAllOf) String() string

type RequiredUseAnyOf added in v0.0.20

type RequiredUseAnyOf struct {
	Nodes []RequiredUseNode
}

RequiredUseAnyOf represents a list of requirements, ANY of which must be met (||).

func (RequiredUseAnyOf) Evaluate added in v0.0.20

func (a RequiredUseAnyOf) Evaluate(context map[string]bool) bool

func (RequiredUseAnyOf) String added in v0.0.20

func (a RequiredUseAnyOf) String() string

type RequiredUseAtMostOneOf added in v0.0.20

type RequiredUseAtMostOneOf struct {
	Nodes []RequiredUseNode
}

RequiredUseAtMostOneOf represents a list of requirements, AT MOST ONE of which must be met (??).

func (RequiredUseAtMostOneOf) Evaluate added in v0.0.20

func (a RequiredUseAtMostOneOf) Evaluate(context map[string]bool) bool

func (RequiredUseAtMostOneOf) String added in v0.0.20

func (a RequiredUseAtMostOneOf) String() string

type RequiredUseConditional added in v0.0.20

type RequiredUseConditional struct {
	Condition string
	Nodes     RequiredUseAllOf
}

RequiredUseConditional represents a conditional requirement (flag? ( ... ) or !flag? ( ... )).

func (RequiredUseConditional) Evaluate added in v0.0.20

func (c RequiredUseConditional) Evaluate(context map[string]bool) bool

func (RequiredUseConditional) String added in v0.0.20

func (c RequiredUseConditional) String() string

type RequiredUseConfig added in v0.0.20

type RequiredUseConfig struct {
}

type RequiredUseExactlyOneOf added in v0.0.20

type RequiredUseExactlyOneOf struct {
	Nodes []RequiredUseNode
}

RequiredUseExactlyOneOf represents a list of requirements, EXACTLY ONE of which must be met (^^).

func (RequiredUseExactlyOneOf) Evaluate added in v0.0.20

func (e RequiredUseExactlyOneOf) Evaluate(context map[string]bool) bool

func (RequiredUseExactlyOneOf) String added in v0.0.20

func (e RequiredUseExactlyOneOf) String() string

type RequiredUseFlag added in v0.0.20

type RequiredUseFlag struct {
	Name string
}

RequiredUseFlag represents a single USE flag.

func (RequiredUseFlag) Evaluate added in v0.0.20

func (f RequiredUseFlag) Evaluate(context map[string]bool) bool

func (RequiredUseFlag) String added in v0.0.20

func (f RequiredUseFlag) String() string

type RequiredUseNode added in v0.0.20

type RequiredUseNode interface {
	String() string
	Evaluate(context map[string]bool) bool
}

RequiredUseNode represents a node in the REQUIRED_USE AST.

func ParseRequiredUse added in v0.0.20

func ParseRequiredUse(input string, opts ...any) (RequiredUseNode, error)

ParseRequiredUse parses a REQUIRED_USE string into an AST.

type RequiredUseOption added in v0.0.20

type RequiredUseOption interface {
	Apply(*RequiredUseConfig)
}

type Resolution added in v0.0.15

type Resolution struct {
	Text string `xml:",innerxml"`
}

type ResolveBashOption added in v0.0.67

type ResolveBashOption func(*ResolveBashOptions)

func WithFastPath added in v0.0.67

func WithFastPath() ResolveBashOption

func WithInterpOption added in v0.0.67

func WithInterpOption(opt interp.RunnerOption) ResolveBashOption

func WithVars added in v0.0.67

func WithVars(vars map[string]string) ResolveBashOption

type ResolveBashOptions added in v0.0.67

type ResolveBashOptions struct {
	InterpOptions []interp.RunnerOption
	FastPath      bool
	Variables     map[string]string
}

type Revised added in v0.0.15

type Revised struct {
	Text  string `xml:",innerxml"`
	Count string `xml:"count,attr"`
}

type Service added in v0.0.15

type Service struct {
	Text  string `xml:",innerxml"`
	Type  string `xml:"type,attr"`            // rsync|web|mirror
	Fixed string `xml:"fixed,attr,omitempty"` // yes|no
}

type SiteData added in v0.0.19

type SiteData struct {
	Title             string
	RepoName          string
	RemoteURL         string
	Repository        *Repository
	EAPI              string
	Projects          *Projects
	Categories        []CategoryData
	Profiles          []ProfileData
	DefinedEclasses   []EclassData
	AggEclasses       any // To break cycle, keep CLI specific type as any or redefine
	Authors           []Author
	AuthorsURL        string
	Moves             []PackageMove
	SlotMoves         []PackageSlotMove
	News              []NewsItem
	LayoutConf        *LayoutConf
	LicenseMapping    map[string][]string
	ProvidedLicenses  []string
	AggLicenses       any // To break cycle, keep CLI specific type as any or redefine
	QAPolicy          *QAPolicy
	UseDesc           *UseDesc
	UseLocalDesc      *UseLocalDesc
	UseExpandDescs    map[string]*UseExpandDesc
	ValidUseExpands   map[string]bool
	ArchList          *ArchList
	ArchesDesc        *ArchesDesc
	InfoPkgs          []InfoPkg
	Masked            []PackageMasked
	Deprecated        []PackageDeprecated
	ParsedEclasses    []*Ebuild
	Eclasses          []*Ebuild
	PackageCount      int
	AggUseFlags       any // To break cycle
	ThirdPartyMirrors map[string][]string
	InfoVars          []string
	GitSize           string
	CheckoutTime      string
	ProcessTime       string
	SourceURL         string
}

type Slot

type Slot struct {
	// Name of the SLOT.
	Name string `xml:"name,attr"`
	// Text of the slot.
	Text string `xml:",innerxml"`
}

Slot represents a particular SLOT.

type Slots

type Slots struct {
	// Slot elements.
	Slot []Slot `xml:"slot"`
	// Subslots of the package.
	Subslots string `xml:"subslots,omitempty"`
	// Lang specifies the language of the slots.
	Lang string `xml:"lang,attr,omitempty"`
}

Slots represents the description of a package's SLOTs.

type StabilizeAllArches added in v0.0.20

type StabilizeAllArches struct {
	Restrict string `xml:"restrict,attr,omitempty"`
}

PkgMetadata represents metadata for a package. Source: https://github.com/gentoo-mirror/gentoo/blob/stable/metadata/dtd/metadata.dtd

func (*StabilizeAllArches) MarshalXML added in v0.0.20

func (s *StabilizeAllArches) MarshalXML(e *xml.Encoder, start xml.StartElement) error

type StraightToStable added in v0.0.98

type StraightToStable struct {
	Restrict string `xml:"restrict,attr,omitempty"`
}

func (*StraightToStable) MarshalXML added in v0.0.98

func (s *StraightToStable) MarshalXML(e *xml.Encoder, start xml.StartElement) error

type Subproject added in v0.0.15

type Subproject struct {
	Text           string `xml:",innerxml"`
	InheritMembers string `xml:"inherit-members,attr,omitempty"` // 0|1
	Ref            string `xml:"ref,attr"`
}

type URI added in v0.0.15

type URI struct {
	Text string `xml:",innerxml"`
	Link string `xml:"link,attr,omitempty"`
}

type URIEntry

type URIEntry struct {
	URL      string
	Filename string
}

func ExtractURIs

func ExtractURIs(content string, variables map[string]string) ([]URIEntry, error)

ExtractURIs parses the ebuild content and extracts SRC_URI entries.

type Unaffected added in v0.0.15

type Unaffected struct {
	Text  string `xml:",innerxml"`
	Range string `xml:"range,attr"`
	Slot  string `xml:"slot,attr"`
	Name  string `xml:"name,attr,omitempty"`
}

type Upstream

type Upstream struct {
	// Maintainers of the upstream.
	Maintainers []Maintainer `xml:"maintainer"`
	// URL of the upstream changelog.
	Changelog string `xml:"changelog,omitempty"`
	// Documentation URL of the upstream.
	Doc []Doc `xml:"doc"`
	// URL or email address to report bugs.
	BugsTo string `xml:"bugs-to,omitempty"`
	// Remote identifiers for the package.
	RemoteID []RemoteID `xml:"remote-id"`
}

Upstream represents upstream metadata information.

type Use

type Use struct {
	// Flags representing the USE flags.
	Flags []Flag `xml:"flag"`
	// Lang specifies the language of the USE description.
	Lang string `xml:"lang,attr,omitempty"`
}

Use represents the description of USE flags for a package.

type UseDesc added in v0.0.19

type UseDesc struct {
	Flags       map[string]string
	HeaderLines []string
}

func ParseUseDesc added in v0.0.19

func ParseUseDesc(r io.Reader) (*UseDesc, error)

func ParseUseDescFile added in v0.0.19

func ParseUseDescFile(filename string) (*UseDesc, error)

func (*UseDesc) Write added in v0.0.19

func (ud *UseDesc) Write(w io.Writer) error

func (*UseDesc) WriteFile added in v0.0.19

func (ud *UseDesc) WriteFile(filename string) error

type UseExpandDesc added in v0.0.40

type UseExpandDesc struct {
	Name  string
	Flags map[string]string
	Lines []DescLine // ordered list of lines
}

func ParseUseExpandDesc added in v0.0.40

func ParseUseExpandDesc(r io.Reader, name string) (*UseExpandDesc, error)

func ParseUseExpandDescFile added in v0.0.40

func ParseUseExpandDescFile(filename string, name string) (*UseExpandDesc, error)

func (*UseExpandDesc) Write added in v0.0.40

func (ud *UseExpandDesc) Write(w io.Writer) error

func (*UseExpandDesc) WriteFile added in v0.0.40

func (ud *UseExpandDesc) WriteFile(filename string) error

type UseFlag added in v0.0.27

type UseFlag string

type UseFlags added in v0.0.27

type UseFlags []string

type UseLocalDesc added in v0.0.19

type UseLocalDesc struct {
	Flags       map[string]map[string]string // pkg -> flag -> desc
	HeaderLines []string
}

func ParseUseLocalDesc added in v0.0.19

func ParseUseLocalDesc(r io.Reader) (*UseLocalDesc, error)

func ParseUseLocalDescFile added in v0.0.19

func ParseUseLocalDescFile(filename string) (*UseLocalDesc, error)

func (*UseLocalDesc) Write added in v0.0.19

func (ud *UseLocalDesc) Write(w io.Writer) error

func (*UseLocalDesc) WriteFile added in v0.0.19

func (ud *UseLocalDesc) WriteFile(filename string) error

type User added in v0.0.15

type User struct {
	Username string    `xml:"username,attr"`
	Realname Realname  `xml:"realname"`
	PGPKeys  []string  `xml:"pgpkey"`
	Aliases  []string  `xml:"alias"`
	Emails   []string  `xml:"email"`
	Joined   []string  `xml:"joined"`
	Retired  []string  `xml:"retired"`
	Status   string    `xml:"status,omitempty"`
	Roles    string    `xml:"roles,omitempty"`
	Location *Location `xml:"location"`
}

type UserConfigEntry added in v0.0.98

type UserConfigEntry struct {
	RawLine    string
	AtomString string
	Atom       PackageAtom
	FilePath   string
	LineNumber int
}

UserConfigEntry represents a single configuration rule parsed from a Portage user config file.

func ReadUserConfigEntries added in v0.0.98

func ReadUserConfigEntries(path string) ([]UserConfigEntry, error)

ReadUserConfigEntries reads and parses all entries from a Portage configuration target (either a single file or a directory of files). Non-existent targets return an empty slice and nil error.

type UserConfigFile added in v0.0.98

type UserConfigFile struct {
	Path  string
	Lines []string
	Mode  os.FileMode
}

UserConfigFile represents a parsed Portage user config file.

type UserList added in v0.0.15

type UserList struct {
	XMLName xml.Name `xml:"userlist"`
	Users   []User   `xml:"user"`
}

UserList represents a list of users. Source: https://github.com/gentoo-mirror/gentoo/blob/stable/metadata/dtd/userinfo.dtd

func ParseUserInfo added in v0.0.15

func ParseUserInfo(path string) (*UserList, error)

ParseUserInfo parses a userinfo.xml file and returns a UserList pointer, or an error.

func ParseUserInfoBytes added in v0.0.15

func ParseUserInfoBytes(data []byte) (*UserList, error)

ParseUserInfoBytes parses UserList from a byte slice.

func ParseUserInfoFromReader added in v0.0.15

func ParseUserInfoFromReader(r io.Reader) (*UserList, error)

ParseUserInfoFromReader parses UserList from an io.Reader.

type VersionData added in v0.0.19

type VersionData struct {
	Version string
	Ebuild  *Ebuild

	// Git info
	EbuildRawURL string
	ModTime      time.Time

	// Deprecation
	Deprecated *PackageDeprecated
	Masked     *PackageMasked

	// Moves
	MovedToSlot string

	ResolvedDepsJSON string
	// Mirrors
	ApplicableMirrors map[string][]string
}

type VersionGroup added in v0.0.65

type VersionGroup struct {
	Version string
	Archs   string
}

type Vulnerable added in v0.0.15

type Vulnerable struct {
	Text  string `xml:",innerxml"`
	Range string `xml:"range,attr"`
	Slot  string `xml:"slot,attr"`
}

type Workaround added in v0.0.15

type Workaround struct {
	Text string `xml:",innerxml"`
}

Directories

Path Synopsis
cmd
g2 command
skills
g2

Jump to

Keyboard shortcuts

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