aptinstall

package
v2.1.4 Latest Latest
Warning

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

Go to latest
Published: May 26, 2026 License: GPL-3.0 Imports: 25 Imported by: 0

Documentation

Overview

Package aptinstall installs Debian packages into a target root.

It runs the dpkg install pipeline: transitive dep resolution against pkg/aptcache, .deb download via grab, ar/control.tar/data.tar extraction, maintainer scriptlets via /bin/sh, atomic /var/lib/dpkg/status + /var/lib/dpkg/info/<pkg>.* updates, conffile-preserving extraction, and a single ldconfig at the end of the transaction. Failures surface as errors; nothing falls back to a distro install subprocess.

Scriptlets run as real /bin/sh child processes (not in-process via mvdan.cc/sh) because debconf's confmodule re-execs the script via Perl IPC::Open2, and update-alternatives/dpkg-trigger/etc. expect real exec semantics.

The caller is responsible for refreshing apt indexes (pkg/aptrepo) before Install — trust of every downloaded .deb is bounded by the SHA-256 in the apt-index manifest, which itself is only as trustworthy as the InRelease PGP verification that produced it.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Install

func Install(ctx context.Context, names []string) error

Install performs a full apt-get install equivalent with default options.

Default policy: when running on a privileged host (uid 0 — the expected case inside a yap build container) `AllowRootInstall` is implicitly enabled. On a developer workstation running as a regular user, the safety guard still trips and refuses to clobber the host filesystem.

Callers needing explicit control (sandboxed RootDir, suppressed ldconfig, etc.) should call InstallWithOptions directly.

func InstallWithOptions

func InstallWithOptions(ctx context.Context, names []string, opts Options) error

InstallWithOptions is the explicit-options variant of Install.

func RefreshLDCache

func RefreshLDCache()

RefreshLDCache runs ldconfig to refresh the dynamic linker cache. Non-fatal: if ldconfig is not found or fails, we log a warning but continue.

Types

type Options

type Options struct {
	RootDir          string
	AllowRootInstall bool
	RunLDConfig      bool
	WriteDpkgStatus  bool
}

Options controls Install's runtime behaviour.

RootDir is the filesystem root the installation writes into.

  • "" / "/" → install into the live system root. Refused unless AllowRootInstall is true: the typical caller is yap running inside a build container, but on a developer workstation accidentally invoking Install would clobber the host filesystem.
  • Any other value → install into that directory (fakeroot use). dpkg status / lock files are still rooted at /var/lib/dpkg under it.

RunLDConfig defaults to true; set false in fakeroot scenarios where the ld.so.cache would be meaningless.

WriteDpkgStatus defaults to false. When false, installed packages are recorded in YAP's internal state database (pkg/yapdb) only. When true, packages are ALSO written to /var/lib/dpkg/status (legacy behavior). Rationale: YAP runs in ephemeral build containers where dpkg is not the source of truth.

Jump to

Keyboard shortcuts

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