pkgen

package
v0.0.0-...-531a4e7 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2018 License: MIT Imports: 21 Imported by: 3

Documentation

Overview

Package pkgen processes Panux .pkgen packaging files

Index

Constants

This section is empty.

Variables

View Source
var DefaultVars = MakeVars{
	SrcTar:    "SRCTAR",
	TarOut:    "TAROUT",
	HostArch:  "HOSTARCH",
	BuildArch: "BUILDARCH",
}

DefaultVars is the default MakeVars.

View Source
var ErrExceedsMaxBuffer = errors.New("resource exceeds maximum buffer size")

ErrExceedsMaxBuffer is an error returned by Loader.Get if the resource is too big to be buffered.

View Source
var ErrMissingHash = errors.New("insecure resource does not have hash")

ErrMissingHash is an error returned by Loader.Get if the resource is being loaded over an insecure protocol and does not have a hash.

View Source
var ErrUnsupportedArch = errors.New("unsupported arch")

ErrUnsupportedArch is an error for an architecture that is not recognized.

View Source
var ErrUnsupportedBuilder = errors.New("builder not supported")

ErrUnsupportedBuilder is an error indicating that the Builder is not supported

View Source
var ErrUnsupportedProtocol = errors.New("unsupported protocol")

ErrUnsupportedProtocol is returned by Loader.Get if the protocol of the URL is unsupported.

View Source
var SupportedArch = ArchSet{"x86_64", "x86"}

SupportedArch is the set of supported Arch.

Functions

This section is empty.

Types

type Arch

type Arch string

Arch is an architecture.

const (
	Archx86_64 Arch = "x86_64"
	Archx86    Arch = "x86"
)

Arch constants.

func GetHostArch

func GetHostArch() (Arch, error)

GetHostArch returns the arch on the host system.

func (Arch) AutoTools

func (a Arch) AutoTools() string

AutoTools returns the name used by autotools for the Arch.

func (Arch) Convert

func (a Arch) Convert() string

Convert implements the makefile.Text interface.

func (Arch) GoArch

func (a Arch) GoArch() string

GoArch returns the name of an arch used by Go/Kubernetes.

func (Arch) RunsOn

func (a Arch) RunsOn() []Arch

RunsOn returns what Arch's code from this arch will run on. Why: 32-bit code can be built on 64-bit systems (e.g. x86 can build on x86_64).

func (Arch) String

func (a Arch) String() string

func (Arch) Supported

func (a Arch) Supported() bool

Supported checks if an Arch is recognized and will be processed correctly.

type ArchSet

type ArchSet []Arch

ArchSet is a set of supported Arch's. A nil value indicates that all Arch's are supported.

func (ArchSet) Supports

func (a ArchSet) Supports(arch Arch) bool

Supports checks if the ArchSet supports arch.

type Builder

type Builder string

Builder is a package builder type

const (
	BuilderDefault   Builder = "default"
	BuilderDocker    Builder = "docker"
	BuilderBootstrap Builder = "bootstrap"
)

Buiilder constants

func ParseBuilder

func ParseBuilder(str string) (Builder, error)

ParseBuilder parses a Builder from a string. An empty string is interpreted as BuilderDefault.

func (Builder) IsBootstrap

func (b Builder) IsBootstrap() bool

IsBootstrap checks if the builder is BuilderBootstrap.

type Loader

type Loader interface {
	// SupportedProtocols gets a list of protocols supported by the Loader.
	// These protocols are used as URL schemes.
	SupportedProtocols() ([]string, error)

	// Get retrieves a source with the given URL.
	// Implementations may optionally use the context with cancellation.
	// The caller must cancel the context at some point in time.
	// The returned io.ReadCloser contains the content, and the caller must close this.
	// The int64 is the length of the source. Lengths less than 0 indicate that the length is unknown.
	// If the protocol is unsupported,  Get should return ErrUnsupportedProtocol.
	Get(context.Context, *url.URL) (int64, io.ReadCloser, error)
}

Loader is an interface for source loaders.

func BufferLoader

func BufferLoader(loader Loader, maxBuffer int64) Loader

BufferLoader returns a Loader that will always provide a length. If no length is provided by the underlying Loader, it will buffer the data in memory. If the data is buffered and size exceeds maxBuffer, it will return ErrExceedsMaxBuffer. If loader is already a BufferLoader, loader will be returned.

func FileLoader

func FileLoader(fs vfs.FileSystem) Loader

FileLoader returns a Loader which loads files from the given VFS.

func HTTPLoader

func HTTPLoader(client *http.Client, maxbuf int64) Loader

HTTPLoader returns a new Loader which loads content over HTTP. client is the HTTP client to use to make the requests. if client is nil, it will use http.DefaultClient. maxbuf is the maximum number of bytes to buffer in memory when necessary. data will only be buffered in memory when there is an attached hash.

func MultiLoader

func MultiLoader(loaders ...Loader) (Loader, error)

MultiLoader returns a Loader which uses the input loaders. SupportedProtocols is the union of the SupportedProtocols sets from loaders. If multiple loaders support the same protocol, the last one will be used. If no loaders are input, MultiLoader will return nil.

type MakeVars

type MakeVars struct {
	SrcTar    makefile.MakeVar // variable with path to source tarball
	TarOut    makefile.MakeVar // variable with path to the tar output directory
	HostArch  makefile.MakeVar // variable with host arch
	BuildArch makefile.MakeVar // variable with build arch
}

MakeVars is a set of makefile.MakeVar to use for generated makefiles.

type Package

type Package struct {
	// Dependencies is the set of dependencies the package will have.
	Dependencies []string
}

Package is a package entry in a pkgen.

type PackageGenerator

type PackageGenerator struct {
	// Package is a list of packages generated and their dependencies.
	// Required.
	Packages map[string]Package `json:"packages"`

	// Arch is a list of supported architectures.
	// Optional. Defualts to nil.
	Arch ArchSet `json:"arch"`

	// HostArch is the Arch which the package will be compiled on.
	// Required.
	HostArch Arch `json:"hostArch"`

	// BuildArch is the Arch which the package will be compiled for.
	// Required.
	BuildArch Arch `json:"buildArch"`

	// Version is the version of the package built.
	// Required.
	Version string `json:"version"`

	// Sources is a list of URLs for sources.
	// Optional.
	Sources []*url.URL `json:"sources,omitempty"`

	// Script is the script for building the package.
	// Optional.
	Script []string `json:"script,omitempty"`

	// BuildDependencies is a set of packages required for compilation.
	// Optional.
	BuildDependencies []string `json:"buildDependencies,omitempty"`

	// Builder is the builder to be used to compile the package.
	// Required.
	Builder Builder `json:"builder"`

	// Cross is whether or not the package may be cross compiled.
	// Not supported. Reserved for future use.
	Cross bool `json:"cross,omitempty"`

	// NoBootstrap is an option to force-unbootstrap a dependency.
	// Format: {"python":true}
	NoBootstrap map[string]bool `json:"nobootstrap"`
}

PackageGenerator is the preprocessed pkgen.

func (*PackageGenerator) GenFullMakefile

func (pg *PackageGenerator) GenFullMakefile(mv MakeVars) *makefile.Builder

GenFullMakefile creates an entire Makefile.

func (*PackageGenerator) GenMake

func (pg *PackageGenerator) GenMake(mv MakeVars, b *makefile.Builder)

GenMake adds the PackageGenerator script to a Makefile.

func (*PackageGenerator) GenMakeInfoComment

func (pg *PackageGenerator) GenMakeInfoComment(b *makefile.Builder)

GenMakeInfoComment generates a Makefile comment with pretty-printed info.

func (*PackageGenerator) InitializeVars

func (pg *PackageGenerator) InitializeVars(mv MakeVars, b *makefile.Builder)

InitializeVars adds variable initialization of MakeVars to a Makefile.

func (*PackageGenerator) ListPackages

func (pg *PackageGenerator) ListPackages() []string

ListPackages returns a sorted list of packages.

func (*PackageGenerator) PackageInfos

func (pg *PackageGenerator) PackageInfos() []PkgInfo

PackageInfos returns a set of PkgInfo for the PackageGenerator.

func (*PackageGenerator) WriteSourceTar

func (pg *PackageGenerator) WriteSourceTar(ctx context.Context, path string, tw *tar.Writer, loader Loader, maxbuf int64) (err error)

WriteSourceTar creates a tar file containing all of the source files necessary for building a package. Also includes the Makefile in the tar. May buffer files of unknown size up to maxbuf bytes in memory. Context may be used for cancellation of internal steps. Closing of the underlying io.Writer is necessary to garuntee cancellation.

type PkgInfo

type PkgInfo struct {
	Name         string
	Version      string
	Dependencies []string
}

PkgInfo is a container with the data in a .pkginfo.

func (PkgInfo) WriteTo

func (pki PkgInfo) WriteTo(w io.Writer) (int64, error)

WriteTo writes a PkgInfo (implements io.WriterTo).

type RawPackageGenerator

type RawPackageGenerator struct {
	// Packages is the list of packages generated by this pkgen.
	// Required.
	Packages map[string]Package

	// Arch is the set of supported architectures.
	// Optional.
	Arch ArchSet

	// Version is the version of the package.
	// Required.
	Version string

	// Build is the build number (added to end of version).
	// Optional.
	Build uint

	// Sources is a list of source URLs.
	// These will be preprocessed using "text/template".
	// Optional.
	Sources []string

	// Script is the script used for building the package.
	// This will be preprocessed using "text/template".
	// Required.
	Script []string

	// BuildDependencies is the set of build dependencies.
	// Required.
	BuildDependencies []string

	// Builder is the system used to build the pkgen.
	// Possible builders are: "bootstrap", "docker", or "default".
	// Optional. Defaults to "default".
	Builder string

	// Cross indicates whether or not the package can be cross-compiled.
	// Optional. Defaults to false.
	Cross bool

	// Data is a set of user-defined data.
	Data map[string]interface{}

	// NoBootstrap is an option to force-unbootstrap a dependency.
	// Format: {"python":true}
	NoBootstrap map[string]bool
}

RawPackageGenerator is the package generator in raw form (after YAML unmarshalling).

func UnmarshalPkgen

func UnmarshalPkgen(r io.Reader) (*RawPackageGenerator, error)

UnmarshalPkgen unmarshals a raw pkgen from YAML.

func (*RawPackageGenerator) Preprocess

func (rpg *RawPackageGenerator) Preprocess(hostarch Arch, buildarch Arch, bootstrap bool) (*PackageGenerator, error)

Preprocess preprocesses a RawPackageGenerator into a PackageGenerator.

Directories

Path Synopsis
Package buildlog implements a logging system for build operations.
Package buildlog implements a logging system for build operations.

Jump to

Keyboard shortcuts

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