apkbuild

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2024 License: MIT Imports: 12 Imported by: 4

Documentation

Overview

Package apkbuild provides functions to get metadata from APKBUILD files. The main function Parse() interprets an APKBUILD file to obtain the package metadata.

ParseSecfixes() can be used to get the secfixes present in the comments of an APKBUILD file.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Apkbuild

type Apkbuild struct {
	Pkgname          string
	Pkgver           string
	Pkgrel           string
	Pkgdesc          string
	Url              string
	License          string
	Options          Options
	Arch             Arches
	Depends          PackageSpecs
	DependsDev       PackageSpecs
	Makedepends      PackageSpecs
	MakedependsBuild PackageSpecs
	MakedependsHost  PackageSpecs
	Checkdepends     PackageSpecs
	Install          []string
	Pkgusers         []string
	Pkggroups        []string
	Triggers         Triggers
	Subpackages      []Subpackage
	Source           []Source
	Replaces         []PkgSpec
	Provides         []PkgSpec
	ProviderPriority string
	Builddir         string
	Sha512sums       []SourceHash
	Funcs            map[string]*syntax.Stmt
}

Apkbuild contains all the metadata for a single package.

func Parse

func Parse(file ApkbuildFile, env expand.Environ) (apkbuild Apkbuild, err error)

Parse the given file and return an Apkbuild struct with the parsed information. This is done by interpreting the code and then extracting variables from the interpreter, like if the APKBUILD file was sourced in a shell.

The interpreter does not execute any external commands (no fork/exec), but logs a warning in case a non built-in command is encountered. Subshells are supported (as long as they don't invoke external commands).

Environment variables can be provided through the expand.Environ interface. Use expand.ListEnviron(os.Environ()...) to use the system's environment variables.

Example
pkgContents := strings.NewReader(heredoc.Doc(`
		pkgname="example-package"
		pkgver="1.2.0"
	`))

apkbuildFile := apkbuild.ApkbuildFile{
	PackageName: "example-package",
	Content:     pkgContents,
}

pkg, err := apkbuild.Parse(apkbuildFile, expand.ListEnviron())

if err != nil {
	panic(err)
}

fmt.Println(pkg.Pkgver)
Output:

1.2.0

type ApkbuildFile

type ApkbuildFile struct {
	PackageName string
	Content     io.Reader
}

An APKBUILD file together with a package name used for reporting

func NewApkbuildFile

func NewApkbuildFile(pkgname string, content io.Reader) ApkbuildFile

type Arches

type Arches []string

Arches is list of supported arches.

arches="all !armhf"

func NewArchesFromString

func NewArchesFromString(arches string) Arches

NewArchesFromString splits a list of arches in individual components.

func (Arches) Enabled

func (a Arches) Enabled(arch string) bool

Enabled returns whether this package is enabled on a given arch. All arches satisfy 'all' and 'nooarch', unless the arch has specifically been disabled.

type Fix

type Fix struct {
	Identifiers []string
	LineNr      uint
}

func (*Fix) UnmarshalYAML added in v0.8.0

func (f *Fix) UnmarshalYAML(node *yaml.Node) error

type FixedVersion

type FixedVersion struct {
	Version string
	Fixes   []Fix
	LineNr  uint
}

type Options

type Options []string

Options is a list of enabled options.

options="net"

func (Options) Has

func (o Options) Has(wanted string) bool

Has returns whether a specific option is present in the options list.

type PackageSpecs

type PackageSpecs []PkgSpec

PackageSpecs represents list of dependencies.

makedepends="dep1 dep2"

type PkgSpec

type PkgSpec struct {
	Pkgname    string
	Constraint string
	Version    string
	RepoPin    string
	Conflicts  bool
}

PkgSpec represents a single dependency with its modifiers.

depends="lib>2.0"

func NewPkgSpecFromString

func NewPkgSpecFromString(pkg string) (pkgspec PkgSpec)

NewPackageFromString takes a single token from a dependency list, and parses it in each individual component.

func (PkgSpec) String

func (ps PkgSpec) String() string

String returns the PkgSpec as a string as it would be present in a dependency list.

type Secfixes

type Secfixes []FixedVersion

func ParseSecfixes

func ParseSecfixes(apkbuild io.ReadCloser) (secfixes Secfixes, err error)

func (Secfixes) Get

func (s Secfixes) Get(version string) *FixedVersion

type Source

type Source struct {
	Filename string
	Location string
}

Source represents an entry in the sources list.

sources="filename.tar.gz::https://domain.org/file.tar.gz"

func (Source) IsRemote added in v0.6.0

func (s Source) IsRemote() bool

IsRemote returns whether source location is remote (http, https, ftp).

type SourceHash

type SourceHash struct {
	Source string
	Hash   string
}

SourceHash represents a single entry in the checksum list.

sha512sums="32de73bec5e2a522b0bb22dda723f31aabee6ed3cb3bab9646f7b598662732d5f9579441bf04607187b99eb054f33db78220176b0fc0cb7a7ee3ce70917f28ff  filename.tar.gz"

type Subpackage

type Subpackage struct {
	Subpkgname string
	SplitFunc  string
	Arch       string
}

Subpackage represents an entry in the subpackage list.

subpackages="subpkgname:splitfunc:arch"

type Trigger

type Trigger struct {
	Scriptname string
	Paths      []string
}

Trigger represents a single trigger, with the scriptname and paths parsed.

scriptname.trigger=path/a:path/b

func NewTriggerFromString

func NewTriggerFromString(rawTrigger string) (trigger Trigger)

NewTriggerFromString takes a single element of a triggers string, parses it, an returns a Trigger.

type Triggers

type Triggers []Trigger

Triggers represents a list of triggers.

triggers="scriptname.trigger=path/a:path/b otherscript.trigger=path/c:path/e"

func NewTriggersFromString

func NewTriggersFromString(rawTriggers string) (triggers Triggers)

NewTriggersFromString takes a triggers string and returns a list of Trigger objects.

Jump to

Keyboard shortcuts

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