goolib

package
v2.13.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2018 License: Apache-2.0 Imports: 20 Imported by: 16

Documentation

Overview

Package goolib contains common functions useful when working with GooGet.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Checksum

func Checksum(r io.Reader) string

Checksum retuns the SHA256 checksum of the provided file.

func Compare

func Compare(v1, v2 string) (int, error)

Compare compares string versions of packages v1 to v2: -1 == v1 is less than v2 0 == v1 is equal to v2 1 == v1 is greater than v2

func ContainsInt

func ContainsInt(a int, slice []int) bool

ContainsInt checks if a is in slice.

func ContainsString

func ContainsString(a string, slice []string) bool

ContainsString checks if a is in slice.

func Exec

func Exec(s string, args []string, ec []int, w io.Writer) error

Exec execs a script or binary on either Windows or Linux using the provided args. The process is successful if the exit code matches any of those provided or '0'. stdout and stderr are sent to the writer.

func MarshalPackageSpec

func MarshalPackageSpec(spec *PkgSpec) ([]byte, error)

MarshalPackageSpec encodes the given PkgSpec.

func Run

func Run(c *exec.Cmd, ec []int, w io.Writer) error

Run runs a command. The process is successful if the exit code matches any of those provided or '0'. stdout and stderr are sent to the writer and to this process's stdout and stderr.

func SortVersions

func SortVersions(versions []string) []string

SortVersions sorts a list of goospec string versions.

func WritePackageSpec

func WritePackageSpec(tw *tar.Writer, spec *PkgSpec) error

WritePackageSpec takes a PkgSpec and writes it as a JSON file using the provided tar writer.

Types

type ExecFile

type ExecFile struct {
	Path      string   `json:",omitempty"`
	Args      []string `json:",omitempty"`
	ExitCodes []int    `json:",omitempty"`
}

ExecFile contains info involved in running a script or binary file.

type GooSpec

type GooSpec struct {
	Build       build
	Sources     []PkgSources
	PackageSpec *PkgSpec
}

GooSpec is the build specification for a package.

func ReadGooSpec

func ReadGooSpec(cf string) (GooSpec, error)

ReadGooSpec unmarshalls and verifies a goospec file into the GooSpec struct.

func (GooSpec) Ver

func (gs GooSpec) Ver() (Version, error)

Ver returns the goospec version.

type PackageInfo

type PackageInfo struct {
	Name, Arch, Ver string
}

PackageInfo describes the name arch and version of a package.

func PkgNameSplit

func PkgNameSplit(pn string) PackageInfo

PkgNameSplit returns the PackageInfo from a package name. If the package name does not contain arch or version an empty string will be returned.

func (PackageInfo) PkgName

func (pi PackageInfo) PkgName() string

PkgName returns the proper goo package name.

func (PackageInfo) String

func (pi PackageInfo) String() string

type PkgSources

type PkgSources struct {
	Include, Exclude []string
	Target, Root     string
}

PkgSources is a list of includes, excludes and their target in the package.

type PkgSpec

type PkgSpec struct {
	Name            string
	Version         string
	Arch            string
	ReleaseNotes    []string          `json:",omitempty"`
	Description     string            `json:",omitempty"`
	License         string            `json:",omitempty"`
	Authors         string            `json:",omitempty"`
	Owners          string            `json:",omitempty"`
	Tags            map[string][]byte `json:",omitempty"`
	PkgDependencies map[string]string `json:",omitempty"`
	Replaces        []string
	Conflicts       []string
	Install         ExecFile
	Uninstall       ExecFile
	Files           map[string]string `json:",omitempty"`
}

PkgSpec is an individual package specification.

func ExtractPkgSpec

func ExtractPkgSpec(r io.Reader) (*PkgSpec, error)

ExtractPkgSpec pulls and unmarshals the package spec file from a reader.

func ReadPackageSpec

func ReadPackageSpec(r io.Reader) (*PkgSpec, error)

ReadPackageSpec reads a PkgSpec from the given reader, which is expected to contain an uncompressed tar archive.

func UnmarshalPackageSpec

func UnmarshalPackageSpec(data []byte) (*PkgSpec, error)

UnmarshalPackageSpec parses data and returns a PkgSpec, if it finds one.

type RepoSpec

type RepoSpec struct {
	Checksum, Source string
	PackageSpec      *PkgSpec
}

RepoSpec is the repository specification of a package.

func (*RepoSpec) Marshal

func (rs *RepoSpec) Marshal() ([]byte, error)

Marshal returns the formatted RepoSpec.

type Version

type Version struct {
	Semver semver.Version
	GsVer  int
}

Version contains the semver version as well as the GsVer. Semver is semantic versioning version. GsVer is a GooSpec version number (usually version of installer).

func ParseVersion

func ParseVersion(ver string) (Version, error)

ParseVersion parses the string version into goospec.Version. ParseVersion attempts to fix non-compliant Semver strings by removing leading zeros from components, and replacing any missing components with zero values after using existing components for the least significant components first (i.e. "1" will become "0.0.1", not "1.0.0").

type Versions

type Versions []string

Versions contains a list of goospec string versions.

func (Versions) Len

func (s Versions) Len() int

func (Versions) Less

func (s Versions) Less(i, j int) bool

func (Versions) Swap

func (s Versions) Swap(i, j int)

Jump to

Keyboard shortcuts

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