Documentation ¶
Overview ¶
Package backend implements the low-level primitives to manage the snaps and their installation on disk.
Index ¶
- func OpenSnapFile(snapPath string, sideInfo *snap.SideInfo) (*snap.Info, snap.Container, error)
- type Alias
- type Backend
- func (b Backend) Candidate(*snap.SideInfo)
- func (b Backend) ClearTrashedData(oldSnap *snap.Info)
- func (b Backend) CopySnapData(newSnap, oldSnap *snap.Info, meter progress.Meter) error
- func (b Backend) CurrentInfo(*snap.Info)
- func (b Backend) DiscardSnapNamespace(snapName string) error
- func (b Backend) LinkSnap(info *snap.Info, dev boot.Device, linkCtx LinkContext, tm timings.Measurer) (rebootRequired bool, e error)
- func (b Backend) QueryDisabledServices(info *snap.Info, pb progress.Meter) ([]string, error)
- func (b Backend) RemoveSnapAliases(snapName string) error
- func (b Backend) RemoveSnapCommonData(snap *snap.Info) error
- func (b Backend) RemoveSnapData(snap *snap.Info) error
- func (b Backend) RemoveSnapDataDir(info *snap.Info, hasOtherInstances bool) error
- func (b Backend) RemoveSnapDir(s snap.PlaceInfo, hasOtherInstances bool) error
- func (b Backend) RemoveSnapFiles(s snap.PlaceInfo, typ snap.Type, installRecord *InstallRecord, dev boot.Device, ...) error
- func (b Backend) ServicesEnableState(info *snap.Info, meter progress.Meter) (map[string]bool, error)
- func (b Backend) SetupSnap(snapFilePath, instanceName string, sideInfo *snap.SideInfo, dev boot.Device, ...) (snapType snap.Type, installRecord *InstallRecord, err error)
- func (b Backend) StartServices(apps []*snap.AppInfo, meter progress.Meter, tm timings.Measurer) error
- func (b Backend) StopServices(apps []*snap.AppInfo, reason snap.ServiceStopReason, meter progress.Meter, ...) error
- func (b Backend) UndoCopySnapData(newInfo *snap.Info, oldInfo *snap.Info, meter progress.Meter) error
- func (b Backend) UndoSetupSnap(s snap.PlaceInfo, typ snap.Type, installRecord *InstallRecord, dev boot.Device, ...) error
- func (b Backend) UnlinkSnap(info *snap.Info, linkCtx LinkContext, meter progress.Meter) error
- func (b Backend) UpdateAliases(add []*Alias, remove []*Alias) error
- type InstallRecord
- type LinkContext
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func OpenSnapFile ¶
OpenSnapFile opens a snap blob returning both a snap.Info completed with sideInfo (if not nil) and a corresponding snap.Container. Assumes the file was verified beforehand or the user asked for --dangerous.
Types ¶
type Backend ¶
type Backend struct {
// contains filtered or unexported fields
}
Backend exposes all the low-level primitives to manage snaps and their installation on disk.
func NewForPreseedMode ¶
func NewForPreseedMode() Backend
func (Backend) ClearTrashedData ¶
ClearTrashedData removes the trash. It returns no errors on the assumption that it is called very late in the game.
func (Backend) CopySnapData ¶
CopySnapData makes a copy of oldSnap data for newSnap in its data directories.
func (Backend) DiscardSnapNamespace ¶
Discard the mount namespace of a given snap.
func (Backend) LinkSnap ¶
func (b Backend) LinkSnap(info *snap.Info, dev boot.Device, linkCtx LinkContext, tm timings.Measurer) (rebootRequired bool, e error)
LinkSnap makes the snap available by generating wrappers and setting the current symlinks.
func (Backend) QueryDisabledServices ¶
func (Backend) RemoveSnapAliases ¶
RemoveSnapAliases removes all the aliases targeting the given snap.
func (Backend) RemoveSnapCommonData ¶
RemoveSnapCommonData removes the data common between versions of the given snap.
func (Backend) RemoveSnapData ¶
RemoveSnapData removes the data for the given version of the given snap.
func (Backend) RemoveSnapDataDir ¶
RemoveSnapDataDir removes base snap data directory
func (Backend) RemoveSnapDir ¶
func (Backend) RemoveSnapFiles ¶
func (b Backend) RemoveSnapFiles(s snap.PlaceInfo, typ snap.Type, installRecord *InstallRecord, dev boot.Device, meter progress.Meter) error
RemoveSnapFiles removes the snap files from the disk after unmounting the snap.
func (Backend) ServicesEnableState ¶
func (b Backend) ServicesEnableState(info *snap.Info, meter progress.Meter) (map[string]bool, error)
ServicesEnableState returns the current enabled/disabled states of a snap's services, primarily for committing before snap removal/disable/revert.
func (Backend) SetupSnap ¶
func (b Backend) SetupSnap(snapFilePath, instanceName string, sideInfo *snap.SideInfo, dev boot.Device, meter progress.Meter) (snapType snap.Type, installRecord *InstallRecord, err error)
SetupSnap does prepare and mount the snap for further processing.
func (Backend) StartServices ¶
func (Backend) StopServices ¶
func (Backend) UndoCopySnapData ¶
func (b Backend) UndoCopySnapData(newInfo *snap.Info, oldInfo *snap.Info, meter progress.Meter) error
UndoCopySnapData removes the copy that may have been done for newInfo snap of oldInfo snap data and also the data directories that may have been created for newInfo snap.
func (Backend) UndoSetupSnap ¶
func (b Backend) UndoSetupSnap(s snap.PlaceInfo, typ snap.Type, installRecord *InstallRecord, dev boot.Device, meter progress.Meter) error
UndoSetupSnap undoes the work of SetupSnap using RemoveSnapFiles.
func (Backend) UnlinkSnap ¶
UnlinkSnap makes the snap unavailable to the system removing wrappers and symlinks. The firstInstallUndo is true when undoing the first installation of the snap.
type InstallRecord ¶
type InstallRecord struct { // TargetSnapExisted indicates that the target .snap file under /var/lib/snapd/snap already existed when the // backend attempted SetupSnap() through squashfs Install() and should be kept. TargetSnapExisted bool `json:"target-snap-existed,omitempty"` }
InstallRecord keeps a record of what installation effectively did as hints about what needs to be undone in case of failure.
type LinkContext ¶
type LinkContext struct { // FirstInstall indicates whether this is the first time given snap is // installed FirstInstall bool // PrevDisabledServices is a list snap services that were manually // disable in the previous revisions of this snap PrevDisabledServices []string // VitalityRank is used to hint how much the services should be // protected from the OOM killer VitalityRank int }
LinkContext carries additional information about the current or the previous state of the snap