In Development Package, API may change between versions.

import "github.com/egdaemon/eg/runtime/x/wasi/egflatpak"

Package egflatpak provides utilities for build and publishing software using flatpak.

func Build

func Build(ctx context.Context, runtime shell.Command, b *Builder) error

Build the flatpak, requires that the container is run with --privileged option. due to kernel/bwrap issues. e.g.)

func main() {
	ctx, done := context.WithTimeout(context.Background(), egenv.TTL())
	defer done()
	err := eg.Perform(
		ctx,
		// note: eg.DefaultModule() does not have flatpak installed by default, you'll
		// have to provide a container with flatpak installed.
		eg.Build(eg.DefaultModule()),
		eg.Module(
			ctx, eg.DefaultModule().OptionLiteral("--privileged"),
		),
	)
	if err != nil {
		log.Fatalln(err)
	}
}

func BuildOp

func BuildOp(runtime shell.Command, b *Builder) eg.OpFn

eg op for running flatpka-builder

func ManifestOp

func ManifestOp(path string, b *Builder) eg.OpFn

write the manifest to the specified path.

type Builder

type Builder struct {
    Manifest
}

func New

func New(id string, command string, options ...option) *Builder

configure the manifest for building the flatpak, but default it'll copy everything in the current directory in an rsync like manner.

type Manifest

Manifests describe how to build the application. see https://docs.flatpak.org/en/latest/manifests.html

type Manifest struct {
    ID         string `yaml:"id"`
    Runtime    `yaml:",inline"`
    SDK        `yaml:",inline"`
    Command    string   `yaml:"command"`
    Modules    []Module `yaml:"modules"`
    FinishArgs []string `yaml:"finish-args"`
}

type Module

type Module struct {
    Name          string   `yaml:"name"`
    BuildSystem   string   `yaml:"buildsystem,omitempty"`
    SubDirectory  string   `yaml:"subdir,omitempty"` // build inside the specified sub directory.
    ConfigOptions []string `yaml:"config-opts,omitempty"`
    Cleanup       []string `yaml:"cleanup,omitempty"`      // files/directories to remove once done.
    PostInstall   []string `yaml:"post-install,omitempty"` // commands to execute post installation.
    Commands      []string `yaml:"build-commands,omitempty"`
    Sources       []Source `yaml:"sources,omitempty"`
}

func ModuleCopy

func ModuleCopy(dir string) Module

Not recommended, here for testing: build a module directly from a directory.

func ModuleTarball

func ModuleTarball(url, sha256d string) Module

build a module from a binary tarball.

func NewModule

func NewModule(name, system string, options ...moption) Module

type Runtime

type Runtime struct {
    ID      string `yaml:"runtime"`
    Version string `yaml:"runtime-version"`
}

type SDK

type SDK struct {
    ID      string `yaml:"sdk"`
    Version string `yaml:"-"`
}

type Source

type Source struct {
    Type            string   `yaml:"type"`
    Directory       string   `yaml:"dest,omitempty"`             // used by archive source(s).
    Destination     string   `yaml:"dest-filename,omitempty"`    // used by archive source(s).
    Path            string   `yaml:"path,omitempty"`             // used by directory source.
    URL             string   `yaml:"url,omitempty"`              // used by archive source.
    SHA256          string   `yaml:"sha256,omitempty"`           // used by archive source(s).
    StripComponents int      `yaml:"strip-components,omitempty"` // used by archive source(s).
    Tag             string   `yaml:"tag,omitempty"`              // used by git sources(s).
    Commit          string   `yaml:"commit,omitempty"`           // used by git source(s).
    Mirrors         []string `yaml:"mirror-urls,omitempty"`      // used by git source(s).
    Architectures   []string `yaml:"only-arches,omitempty"`      // used by archive source(s).
    Commands        []string `yaml:"commands,omitempty"`
}

func SourceDir

func SourceDir(dir string, options ...soption) Source

func SourceFile

func SourceFile(url string, options ...soption) Source

func SourceGit

func SourceGit(url, commit string, options ...soption) Source

func SourcePatch

func SourcePatch(path string, options ...soption) Source

func SourceShell

func SourceShell(options ...soption) Source

func SourceTarball

func SourceTarball(url, sha256d string, options ...soption) Source