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 ¶
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 ¶
NewArchesFromString splits a list of arches in individual components.
type Fix ¶
func (*Fix) UnmarshalYAML ¶ added in v0.8.0
type FixedVersion ¶
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 ¶
NewPackageFromString takes a single token from a dependency list, and parses it in each individual component.
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 ¶
Source represents an entry in the sources list.
sources="filename.tar.gz::https://domain.org/file.tar.gz"
type SourceHash ¶
SourceHash represents a single entry in the checksum list.
sha512sums="32de73bec5e2a522b0bb22dda723f31aabee6ed3cb3bab9646f7b598662732d5f9579441bf04607187b99eb054f33db78220176b0fc0cb7a7ee3ce70917f28ff filename.tar.gz"
type Subpackage ¶
Subpackage represents an entry in the subpackage list.
subpackages="subpkgname:splitfunc:arch"
type Trigger ¶
Trigger represents a single trigger, with the scriptname and paths parsed.
scriptname.trigger=path/a:path/b
func NewTriggerFromString ¶
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 ¶
NewTriggersFromString takes a triggers string and returns a list of Trigger objects.