Documentation ¶
Overview ¶
Package srcinfo is a parser for srcinfo files. Typically generated by makepkg, part of the pacman package manager.
Split packages and architecture dependent fields are fully supported.
This Package aims to parse srcinfos but not interpret them in any way. All values are fundamentally strings, other tools should be used for things such as dependency parsing, validity checking etc.
Example (Parse_file) ¶
info, err := srcinfo.ParseFile(SRCINFO) if err != nil { fmt.Println(err) return } fmt.Println(info)
Output:
Example (Parse_string) ¶
info, err := srcinfo.Parse(str) if err != nil { fmt.Println(err) return } fmt.Println(info)
Output:
Example (Show_architecture_dependant_sources) ¶
info, err := srcinfo.ParseFile(SRCINFO) if err != nil { fmt.Println(err) return } for _, source := range info.Source { if source.Arch == "" { fmt.Printf("This source is for %s: %s\n", "any", source.Value) } else { fmt.Printf("This source is for %s: %s\n", source.Arch, source.Value) } }
Output:
Example (Show_split_packages) ¶
info, err := srcinfo.ParseFile(SRCINFO) if err != nil { fmt.Println(err) return } for _, pkg := range info.SplitPackages() { fmt.Printf("%s-%s: %s\n", pkg.Pkgname, info.Version(), pkg.Pkgdesc) }
Output:
Index ¶
Examples ¶
Constants ¶
const EmptyOverride = "\x00"
EmptyOverride is used to signal when a value has been overridden with an empty value. An empty ovrride is when a value is defined in the pkgbuild but then overridden inside the package function to be empty.
For example "pkgdesc=”" is an empty override on the pkgdesc which would lead to the line "pkgdesc=" in the srcinfo.
This value is used internally to store empty overrides, mainly to avoid using string pointers. It is possible to check for empty overrides using the Packages slice in Packagebase.
During normal use with the SplitPackage function this value will be converted back to an empty string, or removed entirely for slice values. This means the this value can be completley ignored unless you are explicitly looking for empty overrides.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ArchDistroString ¶
type ArchDistroString struct { Arch string // Architecture name Distro string // Distribution Value string // Value }
ArchDistroString describes string values that may be architecture dependent. For Example depends_x86_64. If Arch is an empty string then the field is not architecture dependent.
type LineError ¶
type LineError struct { LineNumber int // The line number at which the error occurred Line string // The line that caused the error ErrorStr string // An error string }
LineError is an error type that stores the line number at which an error occurred as well the full Line that cased the error and an error string.
type Package ¶
type Package struct { Pkgname string Pkgdesc string URL string Priority string Arch []string License []string Gives []ArchDistroString Depends []ArchDistroString CheckDepends []ArchDistroString OptDepends []ArchDistroString Pacdeps []ArchDistroString CheckConflicts []ArchDistroString Conflicts []ArchDistroString Provides []ArchDistroString Breaks []ArchDistroString Replaces []ArchDistroString Enhances []ArchDistroString Recommends []ArchDistroString Suggests []ArchDistroString Backup []string Repology []string }
Package describes the fields of a pkgbuild that may be overwritten by in build_<pkgname> function.
type PackageBase ¶
type PackageBase struct { Pkgbase string Pkgver string Pkgrel string Epoch string Mask []string Compatible []string Incompatible []string Maintainer []string Source []ArchDistroString NoExtract []string NoSubmodules []string MD5Sums []ArchDistroString SHA1Sums []ArchDistroString SHA224Sums []ArchDistroString SHA256Sums []ArchDistroString SHA384Sums []ArchDistroString SHA512Sums []ArchDistroString B2Sums []ArchDistroString MakeDepends []ArchDistroString MakeConflicts []ArchDistroString }
PackageBase describes the fields of a pkgbuild that may not be overwritten in package_<pkgname> function.
type Srcinfo ¶
type Srcinfo struct { PackageBase // Fields that only apply to the package base Package // Fields that apply to the package globally Packages []Package // Fields for each package this package base contains }
Srcinfo represents a full srcinfo. All global fields are defined here while fields overwritten in the package_<pkgname> function are defined in the Packages field.
Note: The Packages field only contains the values that each package overrides, global fields will be missing. A Package containing both global and overwritten fields can be generated using the SplitPackage function.
func Parse ¶
Parse parses a srcinfo in string form. Parsing will fail if:
A srcinfo does not contain all required fields The same pkgname is specified more then once arch is missing pkgver is mising pkgrel is missing An architecture specific field is defined for an architecture that does not exist An unknown key is specified An empty value is specified
Required fields are:
pkgbase pkname arch pkgrel pkgver
func (*Srcinfo) SplitPackage ¶
SplitPackage generates a Package that contains all fields that the specified pkgname has. But will fall back on global fields if they are not defined in the Package.
Note slice values will be passed by reference, it is not recommended you modify this struct after it is returned.
func (*Srcinfo) SplitPackages ¶
SplitPackages generates a splice of all packages that are part of this srcinfo. This is equivalent to calling SplitPackage on every pkgname.
func (*Srcinfo) String ¶
String generates a string that should be similar to the srcinfo data used to create this Srcinfo struct. Fields will be printed in order and with the same whitespace rules that `makepkg --printsrcinfo` uses.
The order of each global field is as follows:
pkgdesc pkgver pkgrel epoch url install changelog arch groups license checkdepends makedepends depends optdepends provides conflicts replaces noextract options backup source validpgpkeys md5suns sha1sums sha224sums sha256sums sha384sums sha512sums
The order of each overwritten field is as follows:
pkgdesc url install changelog arch groups license checkdepends depends optdepends provides conflicts replaces options backup