snapdtool

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2022 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package snapdtool exposes version and related information, supports re-execution and inter-tool lookup/execution across all snapd tools.

Index

Constants

This section is empty.

Variables

View Source
var Version = "unknown"

Version will be overwritten at build-time via mkversion.sh

Functions

func CommandFromSystemSnap

func CommandFromSystemSnap(name string, cmdArgs ...string) (*exec.Cmd, error)

CommandFromSystemSnap runs a command from the snapd/core snap using the proper interpreter and library paths.

At the moment it can only run ELF files, expects a standard ld.so interpreter, and can't handle RPATH.

func ExecInSnapdOrCoreSnap

func ExecInSnapdOrCoreSnap()

ExecInSnapdOrCoreSnap makes sure you're executing the binary that ships in the snapd/core snap.

func InternalToolPath

func InternalToolPath(tool string) (string, error)

InternalToolPath returns the path of an internal snapd tool. The tool *must* be located inside the same tree as the current binary.

The return value is either the path of the tool in the current distribution or in the core/snapd snap (or the ubuntu-core snap) if the current binary is ran from that location.

func IsReexecd

func IsReexecd() (bool, error)

IsReexecd returns true when the current process binary is running from a snap.

func MockOsReadlink(f func(string) (string, error)) func()

MockOsReadlink is for use in tests

func MockVersion

func MockVersion(version string) (restore func())

func SnapdVersionFromInfoFile

func SnapdVersionFromInfoFile(dir string) (version string, flags map[string]string, err error)

SnapdVersionFromInfoFile returns the snapd version read from the info file in the given dir, as well as any other key/value pairs/flags in the file. The format of the "info" file are lines with "KEY=VALUE" with the typical key being just VERSION. The file is produced by mkversion.sh and normally installed along snapd binary in /usr/lib/snapd. Other typical keys in this file include SNAPD_APPARMOR_REEXEC, which indicates whether or not the snapd-apparmor binary installed via the traditional linux package of snapd supports re-exec into the version in the snapd or core snaps.

Types

This section is empty.

Jump to

Keyboard shortcuts

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