Documentation ¶
Overview ¶
Package pkgen processes Panux .pkgen packaging files
Index ¶
- Variables
- type Arch
- type ArchSet
- type Builder
- type Loader
- type MakeVars
- type Package
- type PackageGenerator
- func (pg *PackageGenerator) GenFullMakefile(mv MakeVars) *makefile.Builder
- func (pg *PackageGenerator) GenMake(mv MakeVars, b *makefile.Builder)
- func (pg *PackageGenerator) GenMakeInfoComment(b *makefile.Builder)
- func (pg *PackageGenerator) InitializeVars(mv MakeVars, b *makefile.Builder)
- func (pg *PackageGenerator) ListPackages() []string
- func (pg *PackageGenerator) PackageInfos() []PkgInfo
- func (pg *PackageGenerator) WriteSourceTar(ctx context.Context, path string, tw *tar.Writer, loader Loader, maxbuf int64) (err error)
- type PkgInfo
- type RawPackageGenerator
Constants ¶
This section is empty.
Variables ¶
var DefaultVars = MakeVars{
SrcTar: "SRCTAR",
TarOut: "TAROUT",
HostArch: "HOSTARCH",
BuildArch: "BUILDARCH",
}
DefaultVars is the default MakeVars.
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.
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.
var ErrUnsupportedArch = errors.New("unsupported arch")
ErrUnsupportedArch is an error for an architecture that is not recognized.
var ErrUnsupportedBuilder = errors.New("builder not supported")
ErrUnsupportedBuilder is an error indicating that the Builder is not supported
var ErrUnsupportedProtocol = errors.New("unsupported protocol")
ErrUnsupportedProtocol is returned by Loader.Get if the protocol of the URL is unsupported.
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.
func GetHostArch ¶
GetHostArch returns the arch on the host system.
type ArchSet ¶
type ArchSet []Arch
ArchSet is a set of supported Arch's. A nil value indicates that all Arch's are supported.
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 ¶
ParseBuilder parses a Builder from a string. An empty string is interpreted as BuilderDefault.
func (Builder) IsBootstrap ¶
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 ¶
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 ¶
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 ¶
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 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.