apkbuild

package
v0.0.0-...-289873c Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// A poor mans set
	OfficialVariables = map[string]bool{
		"HOSTCC":            true,
		"arch":              true,
		"builddir":          true,
		"checkdepends":      true,
		"depends":           true,
		"depends_dev":       true,
		"depends_doc":       true,
		"depends_libs":      true,
		"depends_openrc":    true,
		"depends_static":    true,
		"giturl":            true,
		"install":           true,
		"install_if":        true,
		"langdir":           true,
		"ldpath":            true,
		"license":           true,
		"linguas":           true,
		"makedepends":       true,
		"makedepends_build": true,
		"makedepends_host":  true,
		"md5sums":           true,
		"options":           true,
		"patch_args":        true,
		"pcprefix":          true,
		"pkgdesc":           true,
		"pkgdir":            true,
		"pkggroups":         true,
		"pkgname":           true,
		"pkgrel":            true,
		"pkgusers":          true,
		"pkgver":            true,
		"provider_priority": true,
		"provides":          true,
		"replaces":          true,
		"replaces_priority": true,
		"sha256sums":        true,
		"sha512sums":        true,
		"somask":            true,
		"sonameprefix":      true,
		"source":            true,
		"srcdir":            true,
		"startdir":          true,
		"subpackages":       true,
		"subpkgdir":         true,
		"triggers":          true,
		"url":               true,
	}

	DeprecatedVariables = map[string]struct{}{
		"cpandepends":      {},
		"cpanmakedepends":  {},
		"cpancheckdepends": {},
	}

	Options = map[string]struct{}{
		"!archcheck":       {},
		"!check":           {},
		"!dbg":             {},
		"!fhs":             {},
		"!spdx":            {},
		"!strip":           {},
		"!tracedeps":       {},
		"bigdocs":          {},
		"charset.alias":    {},
		"checkroot":        {},
		"chmod-clean":      {},
		"ldpath-recursive": {},
		"lib64":            {},
		"libtool":          {},
		"net":              {},
		"setcap":           {},
		"sover-namecheck":  {},
		"suid":             {},
		"textrels":         {},
		"toolchain":        {},
	}

	Arches = map[string]struct{}{
		"x86_64":  {},
		"x86":     {},
		"aarch64": {},
		"armv7":   {},
		"armhf":   {},
		"ppc64le": {},
		"s390x":   {},
		"riscv64": {},
		"mips":    {},
		"mips64":  {},
	}
)

Functions

func HasCustomVariablePrefix

func HasCustomVariablePrefix(name string) bool

func IsDeprecatedVariable

func IsDeprecatedVariable(name string) (exists bool)

func IsOfficialVariable

func IsOfficialVariable(name string) bool

func IsValidArch

func IsValidArch(arch string) bool

func IsValidOption

func IsValidOption(option string) bool

func MakeFile

func MakeFile(program string) (f io.Reader)

func ParseHeredocs

func ParseHeredocs(stmts []*syntax.Stmt) (heredocs []*syntax.Word)

Types

type Apkbuild

type Apkbuild struct {
	File            *syntax.File
	GlobalVariables VariableScope
	Functions       []Function
	Lines           []string
	Heredocs        []*syntax.Word
}

func Parse

func Parse(f io.Reader, filename string) (apkbuild *Apkbuild, err error)

func (*Apkbuild) AssignsIterator

func (a *Apkbuild) AssignsIterator() iterator.Iterator[Variable]

func (*Apkbuild) FuncIterator

func (a *Apkbuild) FuncIterator() *iterator.SliceIterator[[]Function, Function]

func (Apkbuild) GetGlobal

func (a Apkbuild) GetGlobal(name string) string

func (*Apkbuild) IterAssigns

func (a *Apkbuild) IterAssigns(iterFunc func(Variable))

IterAssigns will call the provided function for each assignment in the file, both in the global scope, as in each function.

type Call

type Call struct {
	Command string
	Args    []string
	Expr    *syntax.CallExpr
}

func ParseCallExpr

func ParseCallExpr(expr *syntax.CallExpr) (call Call)

type Environ

type Environ struct {
	VariableScope
}

func (Environ) Each

func (e Environ) Each(f func(name string, vr expand.Variable) bool)

func (Environ) Get

func (e Environ) Get(name string) (vr expand.Variable)

type Function

type Function struct {
	Name      string
	FuncDecl  *syntax.FuncDecl
	Stmts     []*syntax.Stmt
	Variables VariableScope
}

func (Function) StmtsIterator

func (f Function) StmtsIterator() iterator.Iterator[*syntax.Stmt]

StmtsIterator returns an Iterator that returns each top-level statements in this function.

type Variable

type Variable struct {
	Assignment     *syntax.Assign
	Name           string
	Value          string
	EvaluatedValue string
	Exported       bool
	Local          bool
	CommandSubst   []*syntax.CmdSubst
}

type VariableScope

type VariableScope []Variable

func (VariableScope) Get

func (v VariableScope) Get(name string) optional.Option[Variable]

func (VariableScope) GetValue

func (v VariableScope) GetValue(name string) string

func (VariableScope) Iter

func (v VariableScope) Iter(f func(Variable))

Iter calls the provided function for each variable and provides the variable to the function. If the function returns false, the iteration will stop.

func (VariableScope) IterVar

func (v VariableScope) IterVar(name string, f func(Variable))

IterVar calls the provided function for each variable where the name matches provided name and provides the variable to the function. If the function returns false, the iteration will stop.

Jump to

Keyboard shortcuts

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