Documentation
¶
Overview ¶
Package nativeapps prepares a private native graphical stack without changing system packages. Callers own user consent, authorization, and application launch.
Index ¶
- Variables
- func SelfTest(context.Context, string) error
- func WriteApplicationLauncher(directory string) (string, error)
- func WriteBundle(ctx context.Context, pkg Package, cacheRoot string, output io.Writer, ...) error
- func XpraApplicationLifetimeArgs() []string
- func XpraNoAudioArgs() []string
- type Artifact
- type Manager
- func (m *Manager) Cancel(owner, id string) (Status, error)
- func (m *Manager) Close()
- func (m *Manager) CompleteUpload(owner, id string) (Status, error)
- func (m *Manager) Directory() (string, error)
- func (m *Manager) Package() Package
- func (m *Manager) Snapshot(owner string) Status
- func (m *Manager) Start(owner, requestID, source string, uploadSize int64) (Status, error)
- func (m *Manager) Watch() (<-chan struct{}, func())
- func (m *Manager) WriteChunk(owner, id string, offset int64, data []byte) (Status, error)
- type Package
- type ProcessIdentity
- type Status
- type Tools
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var ErrBusy = errors.New("native preparation is already running")
var ErrForbidden = errors.New("native preparation belongs to another caller")
var ErrInvalid = errors.New("invalid native preparation request")
var ErrUnsupported = errors.New("native graphical components are unavailable for this platform")
Functions ¶
func WriteApplicationLauncher ¶ added in v0.3.0
WriteApplicationLauncher installs the Linux GIO launcher in a consumer-owned private directory. Invoke it with the tools' Python, an absolute .desktop file and an absolute receipt path. The atomic receipt reports running, exited or failed. A running receipt confirms process launch, not window/pixel readiness. The launcher restores the host application environment and reaps descendants; closing a window or losing a viewer never terminates the application.
func WriteBundle ¶
func WriteBundle(ctx context.Context, pkg Package, cacheRoot string, output io.Writer, progress func(int64)) error
WriteBundle acquires the exact catalog archives for an offline host. It neither extracts nor executes them; the destination host verifies every original byte. Callers must publish the output only after this function returns successfully.
func XpraApplicationLifetimeArgs ¶ added in v0.3.0
func XpraApplicationLifetimeArgs() []string
XpraApplicationLifetimeArgs binds an Xpra server to a monitored application child, independently of its viewers and windows. Use a --start-child command that remains alive until the application and its descendants have exited. Consumers still own application authorization, persistence and session policy.
func XpraNoAudioArgs ¶ added in v0.2.1
func XpraNoAudioArgs() []string
XpraNoAudioArgs disables audio support for a silent Xpra 6.x graphics session. Muting the speaker and microphone with "off" still initializes audio codecs; a missing audio backend can then delay every server inventory request. Session ownership, transport, and all other feature choices remain with the host.
Types ¶
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
func New ¶
New requires a private state root. Creating a manager never downloads or starts native processes. The optional validator is useful for host-owned qualification; production callers use the built-in graphical self-check by passing nil.
Example ¶
This example compiles in source checks but performs no network operations in tests. A service should retain its manager for the service's entire lifetime.
package main
import (
"context"
"fmt"
"log"
"os"
"path/filepath"
"time"
nativeapps "github.com/floegence/floe-native-apps"
)
func main() {
prepare := func(ctx context.Context, stateRoot, owner, requestID string) (nativeapps.Tools, error) {
pkg, err := nativeapps.NativePackage()
if err != nil {
return nativeapps.Tools{}, err
}
manager, err := nativeapps.New(stateRoot, pkg, nil)
if err != nil {
return nativeapps.Tools{}, err
}
defer manager.Close()
changes, stop := manager.Watch()
defer stop()
if _, err := manager.Start(owner, requestID, "download", 0); err != nil {
return nativeapps.Tools{}, err
}
for {
status := manager.Snapshot(owner)
if status.State == "ready" {
root, err := manager.Directory()
if err != nil {
return nativeapps.Tools{}, err
}
return nativeapps.ResolveTools(root)
}
if !status.Active() {
return nativeapps.Tools{}, fmt.Errorf("preparation %s: %s", status.State, status.ErrorCode)
}
select {
case <-ctx.Done():
return nativeapps.Tools{}, ctx.Err()
case <-changes:
}
}
}
cache, err := os.UserCacheDir()
if err != nil {
log.Fatal(err)
}
ctx, cancel := context.WithTimeout(context.Background(), 20*time.Minute)
defer cancel()
// A real product supplies an authenticated owner and a stable request ID.
tools, err := prepare(ctx, filepath.Join(cache, "floe-native-apps"), "local-user", "prepare-1")
if err != nil {
log.Fatal(err)
}
fmt.Println(tools.Xpra)
}
Output:
type Package ¶
type Package struct {
ID string `json:"id"`
Architecture string `json:"architecture"`
SizeBytes int64 `json:"size_bytes"`
InstalledBytes int64 `json:"installed_bytes"`
Artifacts []Artifact `json:"artifacts"`
}
func ForPlatform ¶
func NativePackage ¶
type ProcessIdentity ¶ added in v0.3.0
type ProcessIdentity struct {
PID int `json:"pid"`
Boot string `json:"boot"`
Started string `json:"started"`
}
ProcessIdentity is an observation of one Linux process generation. Persisting it allows a host to distinguish a surviving native backend from a reused PID after restart. It grants no authorization and must never be used alone to select an application or issue a signal.
func ObserveProcess ¶ added in v0.3.0
func ObserveProcess(_ int) (ProcessIdentity, error)
func (ProcessIdentity) Alive ¶ added in v0.3.0
func (p ProcessIdentity) Alive() bool
type Status ¶
type Tools ¶
type Tools struct{ Root, Xpra, Python, Xvfb, Xauth, DBus, HTML string }
func ResolveTools ¶
func (Tools) Environment ¶
Environment scopes support-tool overrides. The GIO launcher must restore this small saved map on its AppLaunchContext before starting the user's program. Display and D-Bus addresses are deliberately not restored: those belong to the caller's private graphical session.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package artifactcache acquires pinned publisher archives into a private, content-addressed cache.
|
Package artifactcache acquires pinned publisher archives into a private, content-addressed cache. |
|
cmd
|
|
|
floe-native-apps
command
floe-native-apps is an explicit qualification and offline acquisition tool.
|
floe-native-apps is an explicit qualification and offline acquisition tool. |