wrappers

package
v0.0.0-...-9e584df Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2021 License: GPL-3.0 Imports: 31 Imported by: 0

Documentation

Overview

Package wrappers is used to generate wrappers and service units and also desktop files for snap applications.

Index

Constants

View Source
const SnapdToolingMountUnit = "usr-lib-snapd.mount"

snapdToolingMountUnit is the name of the mount unit that makes the

Variables

This section is empty.

Functions

func AddSnapBinaries

func AddSnapBinaries(s *snap.Info) (err error)

AddSnapBinaries writes the wrapper binaries for the applications from the snap which aren't services.

func AddSnapDBusActivationFiles

func AddSnapDBusActivationFiles(s *snap.Info) error

func AddSnapDesktopFiles

func AddSnapDesktopFiles(s *snap.Info) (err error)

AddSnapDesktopFiles puts in place the desktop files for the applications from the snap.

func AddSnapIcons

func AddSnapIcons(s *snap.Info) error

func AddSnapServices

func AddSnapServices(s *snap.Info, opts *AddSnapServicesOptions, inter interacter) error

AddSnapServices adds service units for the applications from the snap which are services. The services do not get enabled or started.

func AddSnapdSnapServices

func AddSnapdSnapServices(s *snap.Info, inter interacter) error

AddSnapdSnapServices sets up the services based on a given snapd snap in the system.

func DeriveSnapdDBusConfig

func DeriveSnapdDBusConfig(s *snap.Info) (sessionContent, systemContent map[string]osutil.FileState, err error)

func EnsureSnapServices

func EnsureSnapServices(snaps map[*snap.Info]*SnapServiceOptions, opts *EnsureSnapServicesOptions, observeChange ObserveChangeCallback, inter interacter) (err error)

EnsureSnapServices will ensure that the specified snap services' file states are up to date with the specified options and infos. It will add new services if those units don't already exist, but it does not delete existing service units that are not present in the snap's Info structures. There are two sets of options; there are global options which apply to the entire transaction and to every snap service that is ensured, and options which are per-snap service and specified in the map argument. If any errors are encountered trying to update systemd units, then all changes performed up to that point are rolled back, meaning newly written units are deleted and modified units are attempted to be restored to their previous state. To observe which units were added or modified a ObserveChangeCallback calllback can be provided. The callback is invoked while processing the changes. Because of that it should not produce immediate side-effects, as the changes are in effect only if the function did not return an error. This function is idempotent.

func QueryDisabledServices

func QueryDisabledServices(info *snap.Info, pb progress.Meter) ([]string, error)

QueryDisabledServices returns a list of all currently disabled snap services in the snap.

func RemoveQuotaGroup

func RemoveQuotaGroup(grp *quota.Group, inter interacter) error

RemoveQuotaGroup ensures that the slice file for a quota group is removed. It assumes that the slice corresponding to the group is not in use anymore by any services or sub-groups of the group when it is invoked. To remove a group with sub-groups, one must remove all the sub-groups first. This function is idempotent, if the slice file doesn't exist no error is returned.

func RemoveSnapBinaries

func RemoveSnapBinaries(s *snap.Info) error

RemoveSnapBinaries removes the wrapper binaries for the applications from the snap which aren't services from.

func RemoveSnapDBusActivationFiles

func RemoveSnapDBusActivationFiles(s *snap.Info) error

func RemoveSnapDesktopFiles

func RemoveSnapDesktopFiles(s *snap.Info) error

RemoveSnapDesktopFiles removes the added desktop files for the applications in the snap.

func RemoveSnapIcons

func RemoveSnapIcons(s *snap.Info) error

func RemoveSnapServices

func RemoveSnapServices(s *snap.Info, inter interacter) error

RemoveSnapServices disables and removes service units for the applications from the snap which are services. The optional flag indicates whether services are removed as part of undoing of first install of a given snap.

func RemoveSnapdSnapServicesOnCore

func RemoveSnapdSnapServicesOnCore(s *snap.Info, inter interacter) error

RemoveSnapdSnapServicesOnCore removes the snapd services generated by a prior call to AddSnapdSnapServices. The core snap is used as the reference for restoring the system state, making this undo helper suitable for use when reverting the first installation of the snapd snap on a core device.

func RestartServices

func RestartServices(svcs []*snap.AppInfo, explicitServices []string,
	flags *RestartServicesFlags, inter interacter, tm timings.Measurer) error

Restart or reload active services in `svcs`. If reload flag is set then "systemctl reload-or-restart" is attempted. The services mentioned in `explicitServices` should be a subset of the services in svcs. The services included in explicitServices are always restarted, regardless of their state. The services in the `svcs` argument are only restarted if they are active, so if a service is meant to be restarted no matter it's state, it should be included in the explicitServices list. The list of explicitServices needs to use systemd unit names. TODO: change explicitServices format to be less unusual, more consistent (introduce AppRef?)

func ServicesEnableState

func ServicesEnableState(s *snap.Info, inter interacter) (map[string]bool, error)

ServicesEnableState returns a map of service names from the given snap, together with their enable/disable status.

func StartServices

func StartServices(apps []*snap.AppInfo, disabledSvcs []string, flags *StartServicesFlags, inter interacter, tm timings.Measurer) (err error)

StartServices starts service units for the applications from the snap which are services. Service units will be started in the order provided by the caller.

func StopServices

func StopServices(apps []*snap.AppInfo, flags *StopServicesFlags, reason snap.ServiceStopReason, inter interacter, tm timings.Measurer) error

StopServices stops and optionally disables service units for the applications from the snap which are services.

Types

type AddSnapServicesOptions

type AddSnapServicesOptions struct {
	// VitalityRank is the rank of all services in the specified snap used by
	// the OOM killer when OOM conditions are reached.
	VitalityRank int

	// QuotaGroup is the quota group for all services in the specified snap.
	QuotaGroup *quota.Group

	// RequireMountedSnapdSnap is whether the generated units should depend on
	// the snapd snap being mounted, this is specific to systems like UC18 and
	// UC20 which have the snapd snap and need to have units generated
	RequireMountedSnapdSnap bool

	// Preseeding is whether the system is currently being preseeded, in which
	// case there is not a running systemd for EnsureSnapServicesOptions to
	// issue commands like systemctl daemon-reload to.
	Preseeding bool
}

AddSnapServicesOptions is a struct for controlling the generated service definition for a snap service.

type EnsureSnapServicesOptions

type EnsureSnapServicesOptions struct {
	// Preseeding is whether the system is currently being preseeded, in which
	// case there is not a running systemd for EnsureSnapServicesOptions to
	// issue commands like systemctl daemon-reload to.
	Preseeding bool

	// RequireMountedSnapdSnap is whether the generated units should depend on
	// the snapd snap being mounted, this is specific to systems like UC18 and
	// UC20 which have the snapd snap and need to have units generated
	RequireMountedSnapdSnap bool
}

EnsureSnapServicesOptions is the set of options applying to the EnsureSnapServices operation. It does not include per-snap specific options such as VitalityRank or RequireMountedSnapdSnap from AddSnapServiceOptions, since those are expected to be provided in the snaps argument.

type ObserveChangeCallback

type ObserveChangeCallback func(app *snap.AppInfo, grp *quota.Group, unitType string, name, old, new string)

ObserveChangeCallback can be invoked by EnsureSnapServices to observe the previous content of a unit and the new on a change. unitType can be "service", "socket", "timer". name is empty for a timer.

type RestartServicesFlags

type RestartServicesFlags struct {
	Reload bool
}

type SnapServiceOptions

type SnapServiceOptions struct {
	// VitalityRank is the rank of all services in the specified snap used by
	// the OOM killer when OOM conditions are reached.
	VitalityRank int

	// QuotaGroup is the quota group for all services in the specified snap.
	QuotaGroup *quota.Group
}

type StartServicesFlags

type StartServicesFlags struct {
	Enable bool
}

StartServicesFlags carries extra flags for StartServices.

type StopServicesFlags

type StopServicesFlags struct {
	Disable bool
}

StopServicesFlags carries extra flags for StopServices.

Jump to

Keyboard shortcuts

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