osplan

package
v0.4.120 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2026 License: Apache-2.0 Imports: 29 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package osplan answers, for the machine it runs on, "if I upgraded now, what exactly would happen?", and changes nothing of the machine to say it. It rewrites the box's apt sources to the next release in a temporary tree, has apt plan the upgrade against that tree in a sandbox (the real mirror metadata, a simulated transaction), parses and judges what apt said (what is removed, what is kept back, which protected packages are touched, how much disk and download it takes), gives the plan an id, and writes from it the runbook for doing the hop by hand.

The package is pure: it decides every rule and touches nothing. It sees the machine through two seams, each as small as it can be (seam.go): Files, which only reads and is the Probe of the readiness report itself, and Sandbox, which is the only thing that writes and runs, and runs only what AllowedSandboxArgv accepts. The service that wires them to the machine (service/) adds the job, the clock and the HTTP shape; it decides nothing that is a rule.

What this rung does not do: run the hop (that is the button of the next rungs), plan any hop but Debian 11 to 12 (planHops is the one table of them), read deb822 (.sources) files for a hop that does not say Deb822, or keep a plan anywhere but in memory.

Index

Constants

View Source
const (
	// ConfNotSimple: a line that is not "NAME "VALUE";" or a "//" comment (a brace block, a comment between "/*" and "*/", a
	// statement that is cut, or followed by another or by a comment, a value that is not printable ASCII), or a file that is
	// not text.
	ConfNotSimple = "not_simple"
	// ConfHasDirective: a line that starts with "#" ("#include" and "#clear" change what apt reads).
	ConfHasDirective = "has_directive"
	// ConfNotAllowedSetting: a plain statement of a setting that is not on the short list that the sandbox keeps
	// (sandboxAptSettings): any other setting of apt, and in Acquire:: any that a box does not need to say, those that make
	// apt's helpers run or write something (Acquire::gpgv::Options, Acquire::<method>::Options and the like) included.
	ConfNotAllowedSetting = "not_allowed_setting"
	// ConfTooLarge: more than maxAptFragmentBytes, or one of the files beyond the first maxAptFragments.
	ConfTooLarge = "too_large"
	// ConfNotRegular: a symbolic link, a directory, a device: only a regular file is read.
	ConfNotRegular = "not_regular"
	// ConfProxyAutoDetect: Acquire::...::Proxy-Auto-Detect runs the program it names.
	ConfProxyAutoDetect = "proxy_auto_detect"
)

The reasons a file of the box's apt configuration is left out of the sandbox (AptConfLeftOut.Reason).

View Source
const (
	DataConfLeftOut          = "apt_conf_left_out"
	DataConfLeftOutTruncated = "apt_conf_left_out_truncated"
)

The keys of the data of a failure that say what the sandbox did not get of the box's apt configuration.

View Source
const (
	// WarningInitrdSmall: the initrd of the new kernel is under the 5 MiB of a usual one.
	WarningInitrdSmall = "initrd_small"
	// WarningNoGrubConfig: there is no /boot/grub/grub.cfg to see whether the boot loader names the new kernel.
	WarningNoGrubConfig = "grub_cfg_missing"
)

The words that block 7 of the unit writes in the file "warnings" of the backup folder, one on a line, for each WARNING it prints: the core shows them beside the restart, and the judge reports them after it.

View Source
const (
	CodeNotRoot             = "not_root"
	CodeHopNotPlanned       = "hop_not_planned"
	CodeIdentityUnsupported = "identity_unsupported"
	CodeBusy                = "busy"
	CodeNoRoom              = "no_room"
	CodeSourcesFormat       = "sources_format"
	CodeSourcesAlias        = "sources_alias"
	CodeSourcesTarget       = "sources_target"
	CodeSourcesMixedFile    = "sources_mixed_file"
	CodeSourcesCDROM        = "sources_cdrom"
	// CodeNotOffered is a hop of Ubuntu that Canonical does not offer (MetaReleaseLTS), or whose offer could not be read (Data["unknown"]).
	CodeNotOffered          = "not_offered"
	CodeSandboxUpdateFailed = "sandbox_update_failed"
	CodeSandboxSolverFailed = "sandbox_solver_failed"
	CodePlanUnparsed        = "plan_unparsed"
	CodeTimeout             = "timeout"
	CodeCanceled            = "canceled"
	CodeInternal            = "internal"
)

The codes of a plan that could not be made, as the job says them in its error (BINDING: the page and the CI report use them). The four first are also what the POST answers at once, with a 409, before a job starts.

View Source
const (
	KindNoPubkey      = "no_pubkey"
	KindNotFound      = "not_found"
	KindNetwork       = "network"
	KindReleaseChange = "release_change"
	KindOther         = "other"
)

The kinds of a failed update of the sandbox (Failure.Data["kind"] of sandbox_update_failed), decided from apt's fixed messages.

View Source
const (
	VerdictOK              = "ok"
	VerdictNeedsAcceptance = "needs_acceptance"
	VerdictBlocked         = "blocked"
)

The verdicts of a plan.

View Source
const (
	SeverityBlocked    = "blocked"
	SeverityAcceptance = "needs_acceptance"
	SeverityInfo       = "info"
)

The severities of a problem: blocked (the verdict is blocked), needs_acceptance (the owner must accept it), info.

View Source
const (
	ProblemRemovalProtected = "removal_protected" // {name, pattern}: blocked
	ProblemRemovalEssential = "removal_essential" // {name}: blocked
	ProblemRemovalManual    = "removal_manual"    // {name, version}: needs_acceptance
	ProblemDistKeptBack     = "dist_kept_back"    // {names}, and {unlisted: n} when apt counts packages that it does not name: blocked (names has the ones that only the minimal upgrade named, see leftBehind)
	ProblemDiskShort        = "disk_short"        // {path, need, free} or, when the room could not be read, {path, need, unknown: true}: blocked
	ProblemDowngrade        = "downgrade"         // {names}: blocked (apt would downgrade them, and the hop's -y refuses to)
	ProblemDockerHeld       = "docker_held"       // {names}: info
)

The problems of a plan, by code (BINDING: the page and the CI use them).

View Source
const (
	ActionRewritten = "rewritten"
	ActionPaused    = "paused"
	ActionUnchanged = "unchanged"
)

The actions on a file of sources.

View Source
const (
	// SandboxParent is the directory the sandbox directories are made in.
	SandboxParent = "/var/tmp"
	// SandboxPrefix starts the name of a sandbox directory.
	SandboxPrefix = "casaos-os-plan."
	// StaleAfter is how old a sandbox directory is before a sweep removes it as left behind (SweepStale): the core's at its
	// start, and the one a plan of a module makes before its own directory. Both callers make their directories with the one
	// prefix, so it is longer than either lives: the job of the plan of an upgrade has 20 minutes, a plan of a module two
	// simulations of SolverTimeout.
	StaleAfter = time.Hour
)

The sandbox directory, where it is, and how it is named: the name pattern is strict and part of the allow-list.

View Source
const (
	// MaxOutputBytes is the most of a command's output that is kept (8 MiB): more is a plan that cannot be parsed.
	MaxOutputBytes = 8 << 20
	// MinFreeBytes is what /var/tmp must have free to make a plan: the measured sandbox of the Debian 11 to 12 plan was
	// 214 MiB (the lists of the target, with deb-src). A decision, to be re-tared by the CI numbers.
	MinFreeBytes = 640 << 20
	// PlanLifetime is how long a plan is good for, from the time it was made.
	PlanLifetime = 24 * time.Hour
)

The bounds of a plan.

View Source
const (
	PhaseSources     = "sources"
	PhaseUpdate      = "update"
	PhaseUpgrade     = "upgrade"
	PhaseDistUpgrade = "dist-upgrade"
	PhaseEstimate    = "estimate"
	PhaseParse       = "parse"
)

The phases of a plan, in order: each is a named phase in the job's state and a time in the result.

View Source
const (
	UpdateTimeout = 10 * time.Minute
	SolverTimeout = 2 * time.Minute
)

How long each command of the sandbox has: it is killed as a group at the end of its time.

View Source
const DiskNoteEstimatesUnknown = "estimates_unknown"

DiskNoteEstimatesUnknown is the DiskNote of a plan whose sizes apt did not say in a form that is known.

View Source
const MaxLeftOut = 200

MaxLeftOut is the most files that the plan, and a failure, name as left out of the sandbox: the fragments beyond the 200th are left out without being read, and named, so a box with thousands of them would put some 200 KB in every answer of GET plan.

View Source
const MaxListed = 600

MaxListed is the most names of a list of the plan.

View Source
const MaxRunbookBytes = 256 << 10

MaxRunbookBytes is the most a runbook is: what the page accepts (262144 characters).

View Source
const MetaReleaseLTS = "https://changelogs.ubuntu.com/meta-release-lts"

MetaReleaseLTS is where Canonical says which upgrades between its LTS releases it offers: the URI_LTS of /etc/update-manager/meta-release, which do-release-upgrade reads. A hop of Ubuntu is planned only when the stanza of its target is there and says Supported: 1. Canonical opens an upgrade with the first point release of the target, and holds one back by taking its stanza out (from 22.04 to 24.04, from 2 to 9 September 2024: LP #2078895).

View Source
const RefreshFolderPrefix = "/var/backups/casaos-os-upgrade-refresh-"

RefreshFolderPrefix is the start of the name of the backup folder of a refresh; the id of the run ends it.

View Source
const SandboxDirMode fs.FileMode = 0o711

SandboxDirMode is the mode of the sandbox directory and of the directories made above a file in it. apt gives the directories it downloads into (lists/partial) to its own user (_apt), which has to walk down to them: it may search every directory above them, and list none. Nothing in the sandbox is private by its mode but the files, which are 0600: the sources and the configuration of apt, in which a proxy's password may be.

View Source
const SandboxTmp = "tmp"

SandboxTmp is the directory of the sandbox that TMPDIR names.

View Source
const SecurityArchiveGapWords = "" /* 285-byte string literal not displayed */

SecurityArchiveGapWords begins the line of the stop of R2 for a 404 from the security mirror; $sechost is the host that apt named (security.debian.org, deb.debian.org or one of its aliases such as cdn-fastly.deb.debian.org). osrun.HintOf reads the hint SecurityArchiveGap from it, and the class is network.

View Source
const WhySecurityArchive = "security_archive"

WhySecurityArchive is the Why of a line of a refresh that was moved to the security archive of Debian 11.

Variables

View Source
var (
	// ErrNoRunbook: the plan has none (it is blocked, or is not for a hop that has a runbook, or has no tree).
	ErrNoRunbook = errors.New("there is no runbook for this plan")
	// ErrRunbookUnsafe: a line of a file of the box has the word that ends a heredoc, or the marker of a block: the text could
	// not be told from its own structure.
	ErrRunbookUnsafe = errors.New("a line of the sources would end a part of the runbook early")
	// ErrRunbookTooLarge: the text is more than 256 KiB. The fixed text is some 100 KB, which leaves some 150 KB for the lines of the sources and for the
	// third-party files that are put aside: this is for a tree of hundreds of comment lines, and its message says what to cut.
	ErrRunbookTooLarge = errors.New("the runbook is larger than it may be: shorten the comments of the sources and the number of third-party files")
)

The reasons there is no runbook for a plan.

View Source
var ErrAutoDrift = errors.New("the auto text has a STOP line that no class covers, or a hook that did not apply exactly once")

ErrAutoDrift: a STOP line that no class covers, or a hook that did not apply exactly once, or a part of a heredoc that the class pass changed. The owner's text was changed, or this package was, in a way that the unit's text has not been made to follow.

ErrorCodes are all the codes a plan can fail with.

Phases are the phases of a plan, in order.

ProblemCodes are the codes of the problems of a plan.

View Source
var ProtectedNames = []string{
	"docker-ce", "docker-ce-cli", "containerd.io", "docker-*-plugin", "docker.io",
	"samba*", "cifs-utils", "mergerfs", "ntfs-3g", "udevil", "smartmontools", "parted", "net-tools",
	"wget", "curl", "unzip", "git", "openssh-*", "sudo",
	"systemd*", "dbus", "ifupdown", "network-manager", "netplan.io", "dhcpcd", "ca-certificates",
	"linux-image*", "grub*", "shim*", "initramfs-tools",
	"apt", "dpkg", "libc6",
}

ProtectedNames are the patterns of the names of the packages whose removal blocks the plan. The alphabet is a-z, 0-9, "." "+" "-" and "*" (a test enforces it): a pattern means the same to a Go matcher, to path.Match and to a POSIX shell's case. A star stands for any run of characters, none included, wherever it is.

Functions

func AllowedModuleArgv added in v0.4.75

func AllowedModuleArgv(argv []string, dir string) bool

AllowedModuleArgv says whether argv is one of the two commands of a module for the sandbox directory dir, and nothing else: the head is pinned word for word, and every word after it is a package that is valid. AllowedSandboxArgv does not take these, nor this the commands of the plan of the upgrade.

func AllowedSandboxArgv

func AllowedSandboxArgv(argv []string, dir string) bool

AllowedSandboxArgv says whether argv is one of the four commands this rung runs, for the sandbox directory dir, and nothing else: the verb is pinned, so are the options, their order and their paths. A directory that is not a sandbox directory (ValidSandboxDir) has no allowed command.

func AptConfigText

func AptConfigText(dir string) string

AptConfigText is the file that APT_CONFIG names, whole: three statements, read by apt before anything else. The parts and the main file of the sandbox, in place of the box's; and no log of the planner: apt writes the "eipp" log of every simulation to /var/log/apt/eipp.log.xz, and that is the log of the last REAL transaction of the box (apt 2.2.4 and 2.6.1 both write it for -s upgrade and -s dist-upgrade, and neither writes anything when Dir::Log::Planner is empty).

func DistUpgradeArgv

func DistUpgradeArgv(dir string) []string

DistUpgradeArgv is the simulation of the full upgrade.

func EstimateArgv

func EstimateArgv(dir string) []string

EstimateArgv reads the sizes. Whenever the transaction has an operation to do (a package to upgrade, to install, to remove or to downgrade) or dpkg has work pending (a package half configured), apt stops at its prompt step with "E: Trivial Only specified but this is not a trivial operation." (exit status 100, its normal end here) before it fetches or installs anything, having printed "Need to get ..." and "After this operation ..." that "-s" does not print. When the file system of the sandbox's cache has less room than the download it ends, with the same status, on "E: You don't have enough free space in <dir>/cache/archives/." instead (ParseEstimate reads both). When there is nothing to do at all (0 upgraded, 0 newly installed, 0 to remove) apt has no operation to stop at: it ends with status 0, no error and no sizes, after a real dist-upgrade of nothing, which changes nothing (testdata/real/chroot-d11-nothing-size.txt; the status file of dpkg is as it was afterwards), and ParseEstimate reads that end as sizes that are known to be zero. Trivial-Only is allowed with this verb and no other. This was run for real on apt 2.2.4 and on apt 2.6.1, in Debian 11 and Debian 12 chroots: the status 100 and the text are as said (the Debian 11 one, taken to bookworm with the real lists of the mirror, is testdata/real/chroot-d11-12-size.txt, and with a small tmpfs on the archives testdata/real/chroot-d11-12-lowroom-size.txt). The guest of the measurement of the hop was not asked it.

func InsideSandbox

func InsideSandbox(dir, p string) bool

InsideSandbox says whether a path is strictly inside the sandbox directory dir (a clean path, no step up): what Sandbox.WriteFile of the service checks before it writes.

func IsSandboxDirName

func IsSandboxDirName(name string) bool

IsSandboxDirName says whether the name of an entry of SandboxParent is that of a sandbox directory.

func ModuleEstimateArgv added in v0.4.75

func ModuleEstimateArgv(dir string, packages []string) ([]string, error)

ModuleEstimateArgv is the same transaction with --print-uris: apt says what it downloads and what it uses, prints the addresses of the archives and ends, installing nothing and fetching nothing. It is how the sizes are read (ParseURIEstimate).

func ModuleEstimateArgvNoUpgrade added in v0.4.78

func ModuleEstimateArgvNoUpgrade(dir string, packages []string) ([]string, error)

func ModuleSimArgv added in v0.4.75

func ModuleSimArgv(dir string, packages []string) ([]string, error)

ModuleSimArgv is "apt-get -s install --no-install-recommends" of the packages, in the sandbox directory dir.

func ModuleSimArgvNoUpgrade added in v0.4.78

func ModuleSimArgvNoUpgrade(dir string, packages []string) ([]string, error)

ModuleSimArgvNoUpgrade and ModuleEstimateArgvNoUpgrade are the same commands for the update of a module, which upgrades no package that is installed.

func ModuleStatesFile added in v0.4.75

func ModuleStatesFile(dir string) string

ModuleStatesFile is the file in the sandbox directory dir that the commands of a module are told to keep apt's list of the automatically installed packages in. It is made empty before they run: every package of the sandbox is installed by hand, and none is marked, so that nothing is written but in the sandbox.

func ParseModuleSimulation added in v0.4.75

func ParseModuleSimulation(sim, estimate Output, packages []string) osmodule.AptResult

ParseModuleSimulation reads the outputs of ModuleSimArgv (sim) and ModuleEstimateArgv (estimate) for the packages that were asked about, as what the plan of a module needs of apt: the packages to install and to upgrade, those it would remove or downgrade or finds held, and the sizes. It reads the simulation with ParseSolver, which it shares with the plan of the upgrade, and the sizes with ParseURIEstimate: anything that is not understood is a Failure of the result, never a partial answer. The sizes are Known only if the estimate is the same transaction as the simulation. The text of apt is English (SandboxEnv sets LC_ALL=C); a translated one is not understood and is a failure.

Every package that was asked about must be in the answer under the name it was asked for: an Inst line of that name, or the line that says it is already the newest version. apt reads a name with a "." or a "+" in it as a regular expression when no package has the name (mod.lean selects modclean), and a name that a package provides as that package; the simulation of such a name is the simulation of something else, and is RefusedPackageNotExact.

func ParseSolver

func ParseSolver(out Output) (*SolverRun, *Failure)

ParseSolver reads the output of "apt-get -s upgrade" or "apt-get -s dist-upgrade". An exit status that is not 0, or an E: line anywhere, is sandbox_solver_failed. The sections, the summary and the Inst, Remv and Purg lines must agree with each other: a count that is not the number of names, a section that appears twice, a name that is not a package's, a line of a shape that is not known (the line is said), a missing summary: plan_unparsed, never a partial answer.

The one count that may be more than its list is the not-upgraded one: apt counts a package that is on hold and whose candidate is a downgrade (a pin of a priority over 1000) as not upgraded and does not name it among the kept back ones (measured, apt 2.2.4, testdata/real/chroot-d11-downgrade-held-*). It is never less.

func PlanID

func PlanID(p Plan) string

PlanID is the id of a plan as Assemble gives it: a function of the hop, of the sources as they are and as they are rewritten, of what is paused, held and removed, of the verdict and the codes of the problems, and of Docker.

func Plannable

func Plannable(ctx context.Context, files Files) (HopSpec, *Failure)

Plannable says whether a plan can be made for this box, from what the report says of who it is and from nothing that takes time: it runs as root; it is strictly the Debian that the table knows (a box that is unsupported, on the latest release or a variant is identity_unsupported); and the hop it would take is one that planHops has (hop_not_planned otherwise). It asks no apt, takes no lock and writes nothing.

func Preflight

func Preflight(ctx context.Context, files Files) (HopSpec, *Failure)

Preflight is what is refused at once, before a job starts: Plannable, then busy, then room in /var/tmp for the sandbox.

func Protected

func Protected(name string) (pattern string, ok bool)

Protected says whether the removal of a package blocks the plan, and which pattern says so. The name is a package's as apt prints it, with the architecture it has when it is not the native one ("libc6:i386"): the architecture does not make another package of it.

func RemoveSandboxDir added in v0.4.82

func RemoveSandboxDir(parent, name string) error

RemoveSandboxDir removes a sandbox directory of parent, by its name: only a name that is one (IsSandboxDirName), and only after Lstat says it is a directory and not a link, whatever is in it. One that is not there is removed already.

func Run

func Run(ctx context.Context, files Files, sb Sandbox, opts Options) (plan *Plan, failure *Failure)

Run makes the plan of the box: the whole of this rung, in its phases, from the sources to the verdict. Nothing of the box is changed: what is written is the sandbox directory, which is removed on every way out of Run (it ends, fails, times out, is canceled or panics). A failure is the code and the phase it was in; a panic is recovered as internal.

func SandboxEnv

func SandboxEnv(dir string) []string

SandboxEnv is the whole environment of a command of the sandbox: a clean PATH, English, no questions, the temporary files in the sandbox's tmp directory (the one directory of it that apt's own user may write in: apt falls back to /tmp for a user that cannot use TMPDIR), and apt's own configuration file, which keeps the hooks of /etc/apt/apt.conf.d from running (see AptConfig). Everything else of the core's environment is unset.

func SanitizeLine added in v0.4.74

func SanitizeLine(l string) string

SanitizeLine is sanitizeLine for the packages that say what a unit or apt printed: a line as it may be shown, printable ASCII, a URL reduced to its scheme and host, and cut.

func ShellCase

func ShellCase() string

ShellCase is the patterns as the pattern list of a POSIX shell's case, ")" included, so that a runbook can write

case "$name" in <ShellCase()> echo STOP;; esac

A test makes a shell say the same as Protected of every name that it is given.

func SweepStale added in v0.4.82

func SweepStale(parent string, now time.Time, olderThan time.Duration, leftAlone func(dir, why string)) ([]string, error)

SweepStale removes the sandbox directories of parent that are older than olderThan, whichever of the two callers made them: a plan that was killed, or a core that did not live to remove its own, left them. Only a directory (never a link) with the name of one that the sandbox's user owns, that nobody else may write in and that is on the file system of its parent (notOurs); one that is not is left alone and said to leftAlone, when it is set. What it removed is returned, and the first error with it. Both callers sweep with StaleAfter, which is longer than either of them lives, so that neither removes the directory of a plan of the other that is still at work.

func UnmetNames added in v0.4.75

func UnmetNames(text string) []string

UnmetNames are the names that the block of unmet dependencies of a simulation that apt could not solve has in it, in the order they come and each once: the package that cannot be installed, what it needs, what it conflicts with (the version of an architecture is the name: "libc6:i386" is "libc6"). Whether one of them is a package that is held is not something apt says in words: it says "you have held broken packages" for a dependency that is not installable at all as well, and the box is asked which of these names are held.

func UpdateArgv

func UpdateArgv(dir string) []string

UpdateArgv is "apt-get update" of the sandbox: it fetches the metadata of the target release into the sandbox's lists.

func UpgradeArgv

func UpgradeArgv(dir string) []string

UpgradeArgv is the simulation of the minimal upgrade.

func ValidPlanID

func ValidPlanID(id string) bool

ValidPlanID says whether a string is shaped as the id of a plan.

func ValidSandboxDir

func ValidSandboxDir(dir string) bool

ValidSandboxDir says whether a path is the path of a sandbox directory: absolute, under SandboxParent, named as SandboxPrefix and a short alphanumeric suffix make a name. It is the one pattern: the allow-list, the removal of the directory and the sweep of the stale ones use it.

Types

type AptConfLeftOut

type AptConfLeftOut struct {
	File   string `json:"file"`
	Reason string `json:"reason"`
}

AptConfLeftOut is a file of the box's apt configuration that the sandbox did not get: its name ("99proxy", or "apt.conf" for /etc/apt/apt.conf), and why.

type AptConfig

type AptConfig struct {
	Fragments []TreeFile
	Main      string
	HasMain   bool
	LeftOut   []AptConfLeftOut
}

AptConfig is the configuration of apt the sandbox gets: Fragments, with their path in the sandbox directory ("apt.conf.d/99proxy"), Main (the content of apt.conf, when the box has one and something of it is kept), and what the box has and the sandbox does not.

func ReadAptConfig

func ReadAptConfig(ctx context.Context, files Files) (AptConfig, error)

ReadAptConfig reads the configuration of apt that the sandbox keeps, through the Probe: the files of /etc/apt/apt.conf.d that apt reads (at most maxAptFragments of them, the others are left out and named), and /etc/apt/apt.conf, each through canonicalAptConf: kept again in its canonical form, or left out whole with its reason.

type AutoBlock added in v0.4.74

type AutoBlock struct {
	ID, Title string
	// Text is LF only, ends with a newline, has no carriage return, and starts with the line "# casaos-os-upgrade <id> <run id>".
	Text string
}

An AutoBlock is the text of one block, as the driver runs it from a file of its own.

type AutoParams added in v0.4.74

type AutoParams struct {
	// RunID is the id of the run, a UUID. The unit sets it in the environment of the blocks, and the gate of each block compares it.
	RunID string
	// Hostname is the name of the machine, checked by the core (^[A-Za-z0-9]([A-Za-z0-9.-]{0,251}[A-Za-z0-9])?$, and the one os.Hostname gives).
	Hostname string
	// CgroupFile is the file that the gate reads to see that the block runs in the unit: "" is /proc/self/cgroup. Only tests set it.
	CgroupFile string
}

AutoParams is what the core knows when it writes the text for a run.

type AutoRunbook added in v0.4.74

type AutoRunbook struct {
	RunID, PlanID string
	Blocks        []AutoBlock
	Forward       AutoBlock
}

An AutoRunbook is the text of a run: the nine blocks of the hop in their order, and the block that mends what a hop that stopped after its point of no return left half done.

func BuildAuto added in v0.4.74

func BuildAuto(p Plan, a AutoParams) (*AutoRunbook, error)

BuildAuto writes the text that the unit runs for a plan. It refuses what BuildRunbook refuses (ErrNoRunbook, ErrRunbookUnsafe, ErrRunbookTooLarge), a run id that is no UUID, a hostname that is no hostname and a file of cgroups that is no path (ErrRunbookUnsafe: the text could not carry it), and ErrAutoDrift.

func BuildRefresh added in v0.4.74

func BuildRefresh(in RefreshInputs) (*AutoRunbook, error)

BuildRefresh writes the text that the unit runs for a refresh: the four blocks, and the block that mends what dpkg left half done, which the unwind of a refresh runs. It refuses a hop that is not a refresh (ErrNoRunbook: its tree is not the one that this text is for), sources with no tree (ErrNoRunbook), a run id, a name of the machine or a file of cgroups that the text could not carry, and a tree that would end a part of the text early (ErrRunbookUnsafe), a text that is too large (ErrRunbookTooLarge), and ErrAutoDrift.

type Count

type Count struct {
	Upgraded int `json:"upgraded"`
	New      int `json:"new"`
	Removed  int `json:"removed"`
	KeptBack int `json:"kept_back"`
}

A Count is what apt says it would do, as numbers.

type Counts

type Counts struct {
	DistUpgrade Count `json:"dist_upgrade"`
	Upgrade     Count `json:"upgrade"`
}

Counts are the numbers of the full upgrade (dist-upgrade) and of the first, minimal one (upgrade). They drift by a few between two reads of the same mirror, and are not part of the id of the plan.

type Decider

type Decider interface {
	Suite(ctx context.Context, uri, suite string) (distro, decided bool, err error)
}

Decider says whether a suite of a source is the distribution's own: *osreadiness.DistroDecider is the one that answers for the box.

type DirSandbox added in v0.4.82

type DirSandbox struct {
	// Log, when set, is told what went wrong with the removal of the directory: the first failure, which is tried again after a moment, and the second, which leaves it.
	Log func(msg, dir string, err error)
	// contains filtered or unexported fields
}

DirSandbox makes, writes and removes the directory of a Sandbox; the zero value is ready, and makes one directory.

func (*DirSandbox) Dir added in v0.4.82

func (s *DirSandbox) Dir() string

Dir is the directory MakeDir made, "" before it did.

func (*DirSandbox) LeftBehind added in v0.4.82

func (s *DirSandbox) LeftBehind() string

LeftBehind is the directory that the sandbox could not remove, "" when it removed it, or has not yet.

func (*DirSandbox) MakeDir added in v0.4.82

func (s *DirSandbox) MakeDir() (string, func(), error)

MakeDir makes the directory (os.MkdirTemp: 0700, owned by the user that runs, which is root) and opens it to be searched, as SandboxDirMode says. The function it gives back removes it, once and whatever is in it, and does nothing the second time.

func (*DirSandbox) WriteFile added in v0.4.82

func (s *DirSandbox) WriteFile(p string, content []byte, mode fs.FileMode) error

WriteFile writes a file in the sandbox's directory, and makes the directories above it (SandboxDirMode); a mode that says directory makes the directory, with the permissions of the mode (and its sticky bit). A path that is not inside the directory is refused (InsideSandbox), and so is one that goes through a link or over a file: the files of a plan are written once each, and the directories are the ones this made.

type DiskRow

type DiskRow struct {
	Path string `json:"path"`
	Need uint64 `json:"need"`
	Free uint64 `json:"free"`
	OK   bool   `json:"ok"`
	// Unknown says that the free room could not be read: it is taken for none.
	Unknown bool `json:"unknown,omitempty"`
}

A DiskRow is room that the hop needs on a file system, and what there is.

type DockerState

type DockerState struct {
	Present      bool     `json:"present"`
	SourcePaused bool     `json:"source_paused"`
	PackagesHeld []string `json:"packages_held"`
}

DockerState is what the plan knows of Docker: whether there is one, whether its source is put aside for the hop, and which of its packages are on hold.

type Estimates

type Estimates struct {
	Known bool `json:"known"`
	// DownloadBytes is the size of the archives of the transaction, whole (apt says "0 B/140 MB" for what is still to fetch
	// and what there is in all: the whole is the safe one). ExtraBytes is the disk it takes, negative when it is freed.
	DownloadBytes *int64 `json:"download_bytes,omitempty"`
	ExtraBytes    *int64 `json:"extra_bytes,omitempty"`
}

Estimates are what the plan can say of the download and of the disk. The sizes are apt's own words, but for a transaction with nothing to do: apt prints none for it, and they are known to be zero (ParseEstimate). When the text is none of the ends that are known there are no sizes, and Known is false: never a guess.

func ParseEstimate

func ParseEstimate(out Output, simulated Summary, dir string) Estimates

ParseEstimate reads the output of the sandbox's "apt-get -o APT::Get::Trivial-Only=true dist-upgrade" run in the sandbox directory dir. It has three normal ends. Two have exit status 100 and come after "Need to get ..." and "After this operation ...": the line "E: Trivial Only specified but this is not a trivial operation." and, when the file system of the sandbox's cache has less room than the download (apt checks it before it stops at the trivial operation: measured in a Debian 11 chroot with apt 2.2.4 and a small tmpfs, testdata/real/chroot-d11-12-lowroom-size.txt), the line "E: You don't have enough free space in <dir>/cache/archives/." That second line is the sandbox's own cache and no other directory (an other E: line is not ended normally and the sizes are not known), and it does not make the sizes any less true: they are printed above it. It must be the same transaction as the simulation's (the same summary): anything else, an other shape of the sentences, a cut output, is Known false, and no number. The third end is that of a box with nothing to do (testdata/real/chroot-d11-nothing-size.txt): apt has no operation to stop at, ends with status 0 and prints its summary of zeros and neither error nor sizes; it did a real dist-upgrade of nothing, and the sizes are known, and zero. That end is decided by the summary and by what must not be in the text, and not by every line being one that is classified here: exactly one summary, the same as the simulation's, with nothing upgraded, installed, removed or downgraded, and no error, no "Need to get", no "After this operation" and no pending work of dpkg (that one apt stops at, with its error). The other lines are not looked at on purpose: above that summary apt prints the section of the packages that are no longer required (testdata/real/chroot-d11-autoremove-one-nothing-size.txt, the usual text of a box with nothing to upgrade), the packages that are kept back, or a warning, and none of them is an operation. A status 0 with another summary, or with one of the lines that must not be there, is Known false.

func ParseURIEstimate added in v0.4.75

func ParseURIEstimate(out Output, simulated Summary) Estimates

ParseURIEstimate reads the output of the sandbox's "apt-get --print-uris install ..." of the packages of a module, whose transaction is the one that the simulation next to it has the summary of. That command installs nothing and downloads nothing: it says "Need to get ..." and "After this operation ...", prints the address of each archive and ends with status 0 (testdata/realmodule, apt 2.2.4 and 2.6.1), so a status 0 is its normal end, and a transaction that has work in it ends so; and a transaction with nothing to do ends so with its summary of zeros and neither of the two lines, as the estimate of the upgrade does. The rest is as in ParseEstimate, the sizes only for the same transaction as the simulation's and nothing for an output that is cut or not understood, with these differences: any E: line is a command that did not end as it should (this command has no end that is an error, and does not look at the room of the cache), the lines that name the addresses are not read, and a package that dpkg left half done is not a thing to size.

type Failure

type Failure struct {
	Code   string         `json:"code"`
	Phase  string         `json:"phase,omitempty"`
	Detail string         `json:"detail,omitempty"`
	Data   map[string]any `json:"data,omitempty"`
	// Cause is what really went wrong when the failure is internal: an error of the machine, or a recovered panic with its stack.
	// It is for the log of the core and is never said to the page (Detail is generic): it is not in the JSON.
	Cause error `json:"-"`
}

A Failure is why a plan could not be made: a code, the phase it was in, a few words of English for whoever reads the raw answer (the page says it by code), and the data that makes the code precise. It is an error.

func ParseUpdate

func ParseUpdate(out Output) *Failure

ParseUpdate judges the output of the sandbox's "apt-get update --error-on=any": it passes when it ended with 0 and said nothing of E: or W:. A failure is sandbox_update_failed, with at most six lines of apt's, sanitised, and the kind of what went wrong; an output that was cut is plan_unparsed.

func (*Failure) Error

func (f *Failure) Error() string

type FileChange

type FileChange struct {
	File   string       `json:"file"`
	Action string       `json:"action"`
	Lines  []LineChange `json:"lines"`
}

A FileChange is what became of one file apt reads: File is its name ("sources.list", "docker.list").

type Files

type Files = osreadiness.Probe

Files is what the plan reads of the machine: the Probe of the readiness report (ReadFile, ReadDir, Lstat, FreeBytes, Now, and the few reading commands its allow-list has), and no second way to read the box. The plan runs its commands through osreadiness.Guard, so the allow-list of the report holds for it too.

type FreeRead

type FreeRead struct {
	Bytes uint64
	Known bool
}

FreeRead is the room found on a path; Known is false when it could not be read.

type HopSpec

type HopSpec struct {
	ID osreadiness.HopID
	// Distro is the distribution of both releases, as the texts of the blocks name it ("Debian", "Ubuntu").
	Distro string
	// From and To are the codenames of the releases ("bullseye", "bookworm").
	From, To string
	// FromVersion and ToVersion are the numbers of the releases ("11", "12"), which the texts of the blocks name them by.
	FromVersion, ToVersion string
	// Later are the codenames of the releases after To: a source that names one is already past the target.
	Later []string
	// Firmware says that the target has the component non-free-firmware, which is put beside non-free.
	Firmware bool
	// Deb822 says that the plan reads the .sources files (deb822) of the box: without it, a box that has one is refused.
	Deb822 bool
	// SimBroken are the packages whose "E: Conf Broken" ends apt's simulation of the full upgrade (status 100) when the real upgrade goes through: the order that apt's simulator
	// takes for them is not the one dpkg takes. Each was seen both ways, simulated and run, on the release that is left (withoutSimBroken, and sim_ok in the texts).
	SimBroken []string
	// OneStep says that block 5 runs the whole upgrade (dist-upgrade) and not a minimal one first, as do-release-upgrade does: a minimal upgrade leaves the init system of the release
	// that is left under packages of the next one (firstStep).
	OneStep bool
	// RequiredRenames are the packages of priority required that the hop removes, each with the package that takes its place in the same upgrade ("" when none does). The
	// plan and the guard of the blocks let such a removal through only so: when the one that takes its place is not installed, it stops as the removal of any other
	// required package does (requiredRenamed, renameCases).
	RequiredRenames map[string]string
	// Refresh says that the sources are written for bringing the release that is left up to its last state, and not for the next one: the lines of that release are kept as they are
	// (its suite, its host, its components, its backports), and what is not the distribution's is put aside as it is for a hop. Only ForRefresh sets it.
	Refresh bool
}

HopSpec is a hop that a plan can be made for: the release left, the one reached, and what the sources have to say about them.

func PlannedHop

func PlannedHop(id osreadiness.HopID) (HopSpec, bool)

PlannedHop is the hop of a box's identity, when a plan can be made for it.

func (HopSpec) ForRefresh added in v0.4.74

func (h HopSpec) ForRefresh() HopSpec

ForRefresh is the hop as the refresh of the release that is left reads the sources: the same refusals, the same third-party sources put aside, and no line moved to the next release. What Firmware says is of no use to it (it adds a component of the next release): Refresh is what rewriteDistro looks at first.

func (HopSpec) FromName added in v0.4.94

func (h HopSpec) FromName() string

FromName and ToName are the releases as the texts of the blocks say them: "Debian 11", "Ubuntu 24.04".

func (HopSpec) ToName added in v0.4.94

func (h HopSpec) ToName() string

type Inputs

type Inputs struct {
	Hop       HopSpec
	Rewritten *Rewritten
	// AptConfLeftOut are the files of the configuration of apt that the sandbox did not get.
	AptConfLeftOut []AptConfLeftOut
	// Dist and Upgrade are what apt said of the full and of the minimal upgrade.
	Dist, Upgrade *SolverRun
	Estimates     Estimates
	// Held are the packages on hold; DockerHeld are the Docker engine's among them.
	Held, DockerHeld []string
	DockerPresent    bool
	// Facts are what dpkg says of the packages that are removed, by name.
	Facts map[string]PackageFacts
	// AutoInstalled are the packages apt installed by itself, by the name that apt prints for them (a foreign architecture has
	// it after a colon); AutoKnown is false when the file that says it could not be read, and every package is then a manual one.
	AutoInstalled map[string]bool
	AutoKnown     bool
	// Free is the room on the file systems, read before the sandbox was written: what the sandbox takes is not in it.
	Free         map[string]FreeRead
	Now          time.Time
	SandboxBytes int64
	Seconds      map[string]float64
}

Inputs are all that the plan is made of: what the pure steps made of the sources and of apt's words, and what was read of the box. Assemble decides everything else.

type InstLine

type InstLine struct {
	Name, From, To, Tag string
}

An InstLine is an "Inst" line of a simulation: the package, the version it is at ("" when it is new), the one it goes to, and the repository tag ("Debian:12.15/oldstable").

type LineChange

type LineChange struct {
	N      int    `json:"n"`
	Before string `json:"before"`
	After  string `json:"after"`
	Why    string `json:"why"`
}

A LineChange is one line of a file that the rewrite changed, as it is shown: Before and After are text, bounded, with the user and the query of a URL replaced by ***. Why is what was done, in a fixed vocabulary, comma-separated: suite, host, firmware (a line that was rewritten), security_archive (a line of a refresh moved to archive.debian.org), dropped (a backports or proposed-updates line, commented), paused (a line that is not the distribution's, commented, or in a file that is put aside).

type Options

type Options struct {
	// Progress is told the phase that begins, from a goroutine that is Run's own.
	Progress func(phase string)
	Timeouts Timeouts
	// MetaRelease reads Canonical's list of the upgrades it offers, for a hop of Ubuntu; nil is a GET of MetaReleaseLTS.
	MetaRelease func(ctx context.Context) ([]byte, error)
}

Options are the knobs of Run; the zero value is what the service uses.

type Output

type Output = osreadiness.Output

Output is what a command printed (its standard output and its error output, in English, cut to MaxOutputBytes), and how it ended. A command that ran and failed is not an error: it is an ExitCode that is not 0.

type PackageFacts

type PackageFacts struct {
	Version   string
	Essential bool
	Priority  string
}

PackageFacts are what dpkg says of a package that is on the box.

type Paused

type Paused struct {
	File   string   `json:"file"`
	Line   int      `json:"line,omitempty"`
	Hosts  []string `json:"hosts"`
	Docker bool     `json:"docker"`
}

Paused is a source that the hop puts aside: a file of sources.list.d (File is its name, Line is 0), or a line of sources.list (Line is its number). Hosts are scheme and host only. Docker says that every line of it is Docker's own package source (download.docker.com).

type Plan

type Plan struct {
	PlanID    string    `json:"plan_id"`
	Hop       string    `json:"hop"`
	MadeAt    time.Time `json:"made_at"`
	ExpiresAt time.Time `json:"expires_at"`
	Verdict   string    `json:"verdict"`
	Problems  []Problem `json:"problems"`
	Counts    Counts    `json:"counts"`
	Removals  []Removal `json:"removals"`
	// NewPackages are at most MaxListed names, sorted; NewTruncated says there were more. The same for the others.
	NewPackages            []string    `json:"new_packages"`
	NewTruncated           bool        `json:"new_truncated,omitempty"`
	KeptBack               []string    `json:"kept_back"`
	KeptBackTruncated      bool        `json:"kept_back_truncated,omitempty"`
	Autoremovable          []string    `json:"autoremovable"`
	AutoremovableTruncated bool        `json:"autoremovable_truncated,omitempty"`
	Sources                SourcesPlan `json:"sources"`
	Paused                 []Paused    `json:"paused"`
	// Holds are all the packages on hold, sorted.
	Holds     []string    `json:"holds"`
	Docker    DockerState `json:"docker"`
	Estimates Estimates   `json:"estimates"`
	Disk      []DiskRow   `json:"disk"`
	// DiskNote says why Disk is empty when it is: DiskNoteEstimatesUnknown, the sizes that the floors are made of were not read
	// from apt, and the plan has no floor to measure the disk by (the verdict is not blocked for it).
	DiskNote string      `json:"disk_note,omitempty"`
	Sandbox  SandboxInfo `json:"sandbox"`
	// AptConfLeftOut are the files of the box's apt configuration that the sandbox did not get, with the reason of each: at most MaxLeftOut, in the order of
	// compareLeftOut; AptConfLeftOutTruncated says there were more.
	AptConfLeftOut          []AptConfLeftOut `json:"apt_conf_left_out"`
	AptConfLeftOutTruncated bool             `json:"apt_conf_left_out_truncated,omitempty"`
}

A Plan is what would happen if the box were upgraded now.

func Assemble

func Assemble(in Inputs) Plan

Assemble judges what was read and makes the plan of it: the removals, with what the guard says of each, the problems and the verdict, the disk, and the id.

func (*Plan) Expired

func (p *Plan) Expired(now time.Time) bool

Expired says whether the plan is no longer good: it lives PlanLifetime from the time it was made.

func (Plan) WithoutTree

func (p Plan) WithoutTree() Plan

WithoutTree is the plan as the plan endpoint says it: the tree of the sources is the runbook's.

type Problem

type Problem struct {
	Code     string         `json:"code"`
	Severity string         `json:"severity"`
	Data     map[string]any `json:"data"`
}

A Problem is something about the plan that the owner must know: a code, how much it weighs, and the data that makes it precise.

type RefreshInputs added in v0.4.74

type RefreshInputs struct {
	// Hop is the hop whose old release is brought up to date, as HopSpec.ForRefresh says it: Rewritten was made with it.
	Hop HopSpec
	// Rewritten is the sources of the machine as the refresh writes them (RewriteSources with Hop): the files of apt that are left, and what is put aside.
	Rewritten *Rewritten
	// AcceptReleaseInfo adds the one option that lets apt take a repository whose release information changed ("stable" becoming "oldstable" is the usual one), to the update of
	// R1: the owner said that the change is wanted. Without it apt refuses, and the block says so in words that the page turns into the question.
	AcceptReleaseInfo bool
	// RunID is the id of the run, a UUID, and Hostname the name of the machine, checked by the core: as in AutoParams.
	RunID, Hostname string
	// CgroupFile is the file that the gate reads, as in AutoParams: only tests set it.
	CgroupFile string
}

RefreshInputs is what the text of a refresh is written from.

type Removal

type Removal struct {
	Name    string `json:"name"`
	Version string `json:"version"`
	// Manual: the owner installed it (or the file that says it was installed by itself cannot be read: nothing is assumed).
	Manual    bool   `json:"manual"`
	Protected bool   `json:"protected"`
	Pattern   string `json:"pattern,omitempty"`
	// Essential: dpkg says it is Essential: yes, or its Priority is required, or apt warned that it removes an essential package
	// of this name.
	Essential bool `json:"essential"`
}

A Removal is a package the full upgrade removes.

type Rewritten

type Rewritten struct {
	Files  []FileChange
	Tree   []TreeFile
	Paused []Paused
	// DroppedBackports is how many lines were dropped (backports, proposed-updates).
	DroppedBackports int
	// FirmwareAdded is how many lines got the component non-free-firmware.
	FirmwareAdded int
	// SecurityArchive is how many lines of a refresh were moved to the security archive of Debian 11 (WhySecurityArchive).
	SecurityArchive int
	// HashCurrent is the hash of the files as they are (their names and bytes, sorted), and HashGenerated that of the tree.
	HashCurrent, HashGenerated string
}

Rewritten is the sources of the box as the hop leaves them, and what changed.

func RewriteSources

func RewriteSources(ctx context.Context, hop HopSpec, files []osreadiness.SourceFile, decider Decider) (*Rewritten, error)

RewriteSources rewrites the sources of the box to the target release, in memory: the tree the sandbox reads (and the hop writes), and what changed. It refuses, with a *Failure (sources_format, sources_alias, sources_target, sources_mixed_file, sources_cdrom) naming the file and the line, anything it does not read: it never guesses, and never leaves as it is a line it did not understand. An error that is not a *Failure is the end of the time.

type Runbook

type Runbook struct {
	PlanID string         `json:"plan_id"`
	Hop    string         `json:"hop"`
	Text   string         `json:"text"`
	Blocks []RunbookBlock `json:"blocks"`
}

A Runbook is the text for a plan, and its blocks.

func BuildRunbook

func BuildRunbook(p Plan) (*Runbook, error)

BuildRunbook writes the runbook of a plan. It is refused (ErrNoRunbook) for a plan that is blocked, which has no runbook (its problems say why), and ErrRunbookUnsafe when a line of the tree has the word that ends a heredoc.

type RunbookBlock

type RunbookBlock struct {
	ID    string `json:"id"`
	Title string `json:"title"`
	// Reboot: the machine is to be restarted by the owner after this block.
	Reboot bool `json:"reboot"`
	// PointOfNoReturn: from this block on, nothing is undone by going back.
	PointOfNoReturn bool `json:"point_of_no_return"`
}

A RunbookBlock is a block of the text, as the page lists them.

type Sandbox

type Sandbox interface {
	// MakeDir makes the private directory of this plan (owned by the user the core runs as; os.MkdirTemp makes it 0700, and it
	// is opened to be searched, 0711, and no more: apt drops to its own user, _apt, to fetch, and that user has to walk down to
	// the directories apt gives it, which the measurement of the hop did with 0755) under SandboxParent, named SandboxPrefix
	// and an alphanumeric suffix, and gives its path and the function that removes it.
	// remove is called once, on every exit (success, failure, timeout, cancellation, panic), and is safe to call more than
	// once. It removes the directory only after its Lstat says it is a directory (not a symbolic link) whose name matches.
	MakeDir() (path string, remove func(), err error)
	// WriteFile writes a file inside the directory MakeDir made, and makes the directories above it (mode 0711, as the
	// directory itself is) when they are not there. A mode with fs.ModeDir set makes the directory with the permissions of
	// the mode (the sticky bit too), whatever the umask is, and content is ignored. It refuses a path that is not inside that
	// directory, one that goes through a link, and a file that is there already.
	WriteFile(path string, content []byte, mode fs.FileMode) error
	// Run runs argv, which the caller has checked with AllowedSandboxArgv and which the implementation checks again: no
	// shell, the standard input from /dev/null, the environment SandboxEnv(dir) and nothing else, in a process group that
	// is killed as a group when ctx ends, its output bounded to MaxOutputBytes (Output.Truncated says it was cut). A
	// command that ends with a status is an Output; one that could not be started, or was killed with ctx, is an error.
	Run(ctx context.Context, argv []string) (Output, error)
}

Sandbox is the only thing the plan writes with and runs commands with. Its production implementations are DirSandbox with the Run of service/ (the plan of an upgrade) or of pkg/modulecmd/ (the plan of a module). It owes the rules below, and the fake of the tests records that they are kept.

type SandboxFile

type SandboxFile struct {
	Path    string
	Content []byte
	Mode    fs.FileMode
}

A SandboxFile is something to write in the sandbox directory: a file, or (Mode has fs.ModeDir) a directory.

func SandboxFiles

func SandboxFiles(dir string, tree []TreeFile, cfg AptConfig) []SandboxFile

SandboxFiles are all that is written in the sandbox directory dir before apt runs, in the order of writing: the directories (apt makes the ones it needs too, as root, but the measured recipe made them first), the tree of the sources, the copies of the configuration, and apt-config, which the environment names. Every path is inside dir.

type SandboxInfo

type SandboxInfo struct {
	Bytes          int64              `json:"bytes"`
	SecondsByPhase map[string]float64 `json:"seconds_by_phase"`
}

SandboxInfo is what the plan cost: the size of the sandbox directory at the end, and the seconds of each phase.

type SolverRun

type SolverRun struct {
	Upgraded, New, Removed, KeptBack, AutoRemovable []string
	// Downgraded are the packages that apt would downgrade: a package that is installed at a version above the one that a
	// pin of a priority over 1000 asks for. The hop would stop at them (apt refuses a downgrade that -y has not been told to
	// allow).
	Downgraded []string
	// Essential are the packages that apt warns it is about to remove although they are essential ("WARNING: The following
	// essential packages will be removed."), by the names the list of the removed has. All of them are removed ones.
	Essential []string
	Summary   Summary
	Inst      []InstLine
}

A SolverRun is what apt said of a simulated upgrade.

func (*SolverRun) Removals

func (r *SolverRun) Removals() []string

Removals are the packages the transaction removes: the names of the REMOVED list, which is the authority (a Remv line of a package that is installed again by a later Inst line is apt ordering a replacement, and is not one), checked against the Remv and Purg lines and the summary, which parse already did.

type SourcesPlan

type SourcesPlan struct {
	Files            []FileChange `json:"files"`
	Tree             []TreeFile   `json:"tree,omitempty"`
	HashCurrent      string       `json:"hash_current"`
	HashGenerated    string       `json:"hash_generated"`
	DroppedBackports int          `json:"dropped_backports"`
	FirmwareAdded    int          `json:"firmware_added"`
}

SourcesPlan is what the plan did to the sources. Tree is the generated files, with the content of the box's own files that the machine needs: the plan endpoint leaves it out (WithoutTree) and the runbook has it.

type Summary

type Summary struct {
	Upgraded, New, Remove, NotUpgraded, Downgraded int
}

A Summary is the line apt prints at the end of its list: "384 upgraded, 75 newly installed, 2 to remove and 0 not upgraded." Downgraded is the count that apt adds, between the new and the removed, when it has packages to downgrade: "0 upgraded, 0 newly installed, 1 downgraded, 0 to remove and 0 not upgraded."

type Timeouts

type Timeouts struct {
	Update, Solver time.Duration
}

Timeouts are the times the commands have; the zero value is what the service uses, and a test shortens them.

type TreeFile

type TreeFile struct {
	Path    string `json:"path"`
	Content string `json:"content"`
}

The tree: the files the sandbox reads (and the runbook writes to /etc/apt), as their path in the tree and their content.

Directories

Path Synopsis
Package boxtest is the machine that the tests of the blocks of the upgrade run them on: a folder with the commands of a Debian 11 box replaced by small ones that answer what a test says (they are first in the PATH of the shell), the files that the blocks read at the places the folder gives them, and the way to point the text of a block at them.
Package boxtest is the machine that the tests of the blocks of the upgrade run them on: a folder with the commands of a Debian 11 box replaced by small ones that answer what a test says (they are first in the PATH of the shell), the files that the blocks read at the places the folder gives them, and the way to point the text of a block at them.

Jump to

Keyboard shortcuts

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