packages

package
v0.72.3 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2025 License: Apache-2.0 Imports: 28 Imported by: 0

README

Package installation hooks

All the packaging tools we use (dpkg, rpm, the installer) allow package-specific code to execute at various stages of the package lifecycle.

Regular installation / removal / upgrade

The following is valid for deb, rpm, and oci packages.

Installation

Install Hooks Source

  1. v1's files are written to disk.
  2. v1's PostInstall hook is executed.
Removal

Remove Hooks Source

  1. v1's PreRemove hook is executed.
  2. v1's files are removed from disk.
Upgrade

Upgrade Hooks Source

  1. v1's PreRemove hook is executed. Note that we inform the hook that the package is being upgraded.
  2. v2's files are written to disk and v1's files are removed.
  3. v2's PostInstall hook is executed. Note that we inform the hook that the package is being upgraded.

Experiment upgrades

The following is only valid for oci packages.

The installer supports a safer upgrade path for oci packages called "experiments".

Package upgrade

Package Upgrade Source

Start experiment
  1. v1's PreStartExperiment hook is executed.
  2. v2's files are written to disk. v1's files are kept intact.
  3. v2's PostStartExperiment hook is executed.
Stop experiment
  1. v2's PreStopExperiment hook is executed.
  2. v2's files are removed from disk. v1's files are kept intact.
  3. v1's PostStopExperiment hook is executed.
Promote experiment
  1. v2's PrePromoteExperiment hook is executed.
  2. v1's files are removed from disk. v2's files are kept intact.
  3. v1's PostPromoteExperiment hook is executed.

Documentation

Overview

Package packages contains the install/upgrades/uninstall logic for packages

Index

Constants

This section is empty.

Variables

View Source
var (

	// AsyncPreRemoveHooks is called before a package is removed from the disk.
	// It can block the removal of the package files until a condition is met without blocking
	// the rest of the uninstall or upgrade process.
	// Today this is only useful for the dotnet tracer on windows and generally *SHOULD BE AVOIDED*.
	AsyncPreRemoveHooks = map[string]repository.PreRemoveHook{}
)

Functions

func InstrumentAPMInjector

func InstrumentAPMInjector(ctx context.Context, method string) (err error)

InstrumentAPMInjector instruments the APM injector

func RunHook added in v0.66.0

func RunHook(ctx HookContext) (err error)

RunHook executes a hook for a package

func RunPackageCommand added in v0.68.0

func RunPackageCommand(ctx context.Context, packageName string, command string) (err error)

RunPackageCommand runs a package-specific command

func UninstrumentAPMInjector

func UninstrumentAPMInjector(ctx context.Context, method string) (err error)

UninstrumentAPMInjector uninstruments the APM injector

Types

type HookContext added in v0.66.0

type HookContext struct {
	context.Context `json:"-"`
	Package         string      `json:"package"`
	PackageType     PackageType `json:"package_type"`
	PackagePath     string      `json:"package_path"`
	Hook            string      `json:"hook"`
	Upgrade         bool        `json:"upgrade"`
	WindowsArgs     []string    `json:"windows_args"`
}

HookContext is the context passed to hooks during install/upgrade/uninstall.

func (HookContext) StartSpan added in v0.66.0

func (c HookContext) StartSpan(operationName string) (*telemetry.Span, HookContext)

StartSpan starts a new span with the given operation name.

type Hooks added in v0.66.0

type Hooks interface {
	PreInstall(ctx context.Context, pkg string, pkgType PackageType, upgrade bool) error
	PreRemove(ctx context.Context, pkg string, pkgType PackageType, upgrade bool) error
	PostInstall(ctx context.Context, pkg string, pkgType PackageType, upgrade bool, winArgs []string) error

	PreStartExperiment(ctx context.Context, pkg string) error
	PostStartExperiment(ctx context.Context, pkg string) error
	PreStopExperiment(ctx context.Context, pkg string) error
	PostStopExperiment(ctx context.Context, pkg string) error
	PrePromoteExperiment(ctx context.Context, pkg string) error
	PostPromoteExperiment(ctx context.Context, pkg string) error

	PostStartConfigExperiment(ctx context.Context, pkg string) error
	PreStopConfigExperiment(ctx context.Context, pkg string) error
	PostPromoteConfigExperiment(ctx context.Context, pkg string) error
}

Hooks is the interface for the hooks.

func NewHooks added in v0.66.0

func NewHooks(env *env.Env, packages *repository.Repositories) Hooks

NewHooks creates a new Hooks instance that will execute hooks via the CLI.

type PackageCommandHandler added in v0.68.0

type PackageCommandHandler func(ctx context.Context, command string) error

PackageCommandHandler is a function that handles the execution of a package-specific command.

Implement this function and add it to the packagesCommands map to enable package-specific commands for a given package. Package commands are currently intended to be used internally by package hooks and not exposed to the user. For example, the Agent Windows package hooks must start some background worker processes.

The content of the command string is entirely defined by the individual package. Do NOT include private information in the command string, use environment variables instead.

type PackageType added in v0.66.0

type PackageType string

PackageType is the type of package.

const (
	// PackageTypeOCI is the type for OCI packages.
	PackageTypeOCI PackageType = "oci"
	// PackageTypeDEB is the type for DEB packages.
	PackageTypeDEB PackageType = "deb"
	// PackageTypeRPM is the type for RPM packages.
	PackageTypeRPM PackageType = "rpm"
)

Directories

Path Synopsis
Package apminject implements the apm injector installer
Package apminject implements the apm injector installer
Package embedded provides embedded files for the installer.
Package embedded provides embedded files for the installer.
templates command
Package main generates the templates for the installer.
Package main generates the templates for the installer.
Package exec provides wrappers to external executables
Package exec provides wrappers to external executables
Package fapolicyd offers an interface to set agent's fapolicyd permissions.
Package fapolicyd offers an interface to set agent's fapolicyd permissions.
Package file offers filesystem utils geared towards idempotent operations.
Package file offers filesystem utils geared towards idempotent operations.
Package integrations contains packaging logic for python integrations
Package integrations contains packaging logic for python integrations
Package packagemanager provides an interface over the OS package manager
Package packagemanager provides an interface over the OS package manager
Package selinux offers an interface to set agent's SELinux permissions.
Package selinux offers an interface to set agent's SELinux permissions.
Package service provides service manager utilities
Package service provides service manager utilities
systemd
Package systemd provides a set of functions to manage systemd units
Package systemd provides a set of functions to manage systemd units
sysvinit
Package sysvinit provides a set of functions to manage sysvinit services
Package sysvinit provides a set of functions to manage sysvinit services
upstart
Package upstart provides a set of functions to manage upstart services
Package upstart provides a set of functions to manage upstart services
windows
Package windows provides a set of functions to manage Windows services.
Package windows provides a set of functions to manage Windows services.
Package ssi adds methods to check the status of the APM Single Step Instrumentation
Package ssi adds methods to check the status of the APM Single Step Instrumentation
Package user offers an interface over user and group management
Package user offers an interface over user and group management
windows
Package windowsuser offers an interface over user management on Windows
Package windowsuser offers an interface over user management on Windows

Jump to

Keyboard shortcuts

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