Documentation ¶
Overview ¶
Package wrappers is used to generate wrappers and service units and also desktop files for snap applications.
Index ¶
- Constants
- func AddSnapBinaries(s *snap.Info) (err error)
- func AddSnapDBusActivationFiles(s *snap.Info) error
- func AddSnapDesktopFiles(s *snap.Info) (err error)
- func AddSnapIcons(s *snap.Info) error
- func AddSnapServices(s *snap.Info, opts *AddSnapServicesOptions, inter interacter) error
- func AddSnapdSnapServices(s *snap.Info, inter interacter) error
- func DeriveSnapdDBusConfig(s *snap.Info) (sessionContent, systemContent map[string]osutil.FileState, err error)
- func EnsureSnapServices(snaps map[*snap.Info]*SnapServiceOptions, opts *EnsureSnapServicesOptions, ...) (err error)
- func QueryDisabledServices(info *snap.Info, pb progress.Meter) ([]string, error)
- func RemoveQuotaGroup(grp *quota.Group, inter interacter) error
- func RemoveSnapBinaries(s *snap.Info) error
- func RemoveSnapDBusActivationFiles(s *snap.Info) error
- func RemoveSnapDesktopFiles(s *snap.Info) error
- func RemoveSnapIcons(s *snap.Info) error
- func RemoveSnapServices(s *snap.Info, inter interacter) error
- func RemoveSnapdSnapServicesOnCore(s *snap.Info, inter interacter) error
- func RestartServices(svcs []*snap.AppInfo, explicitServices []string, flags *RestartServicesFlags, ...) error
- func ServicesEnableState(s *snap.Info, inter interacter) (map[string]bool, error)
- func StartServices(apps []*snap.AppInfo, disabledSvcs []string, flags *StartServicesFlags, ...) (err error)
- func StopServices(apps []*snap.AppInfo, flags *StopServicesFlags, reason snap.ServiceStopReason, ...) error
- type AddSnapServicesOptions
- type EnsureSnapServicesOptions
- type ObserveChangeCallback
- type RestartServicesFlags
- type SnapServiceOptions
- type StartServicesFlags
- type StopServicesFlags
Constants ¶
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 ¶
AddSnapBinaries writes the wrapper binaries for the applications from the snap which aren't services.
func AddSnapDesktopFiles ¶
AddSnapDesktopFiles puts in place the desktop files for the applications from the snap.
func AddSnapIcons ¶
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 ¶
AddSnapdSnapServices sets up the services based on a given snapd snap in the system.
func DeriveSnapdDBusConfig ¶
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 ¶
QueryDisabledServices returns a list of all currently disabled snap services in the snap.
func RemoveQuotaGroup ¶
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 ¶
RemoveSnapBinaries removes the wrapper binaries for the applications from the snap which aren't services from.
func RemoveSnapDesktopFiles ¶
RemoveSnapDesktopFiles removes the added desktop files for the applications in the snap.
func RemoveSnapIcons ¶
func RemoveSnapServices ¶
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 ¶
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 ¶
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 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.