A package may be declared absent, and an uninstalled front end is retired for good (hq ADR 0175)
absent: true on a package has the host remove it through the machine's own package manager when it is installed and leave alone a machine that never had it; read back either way. Undeclaring a package still removes nothing. A found firewall whose command is gone is recorded as removed, said once, and asked nothing of.
This commit is contained in:
@@ -1407,6 +1407,25 @@ func applyPackage(ctx context.Context, sys system.System, r *declaration.Package
|
||||
if err != nil {
|
||||
return out, err
|
||||
}
|
||||
if r.Absent {
|
||||
// Declared absent (novox/hq ADR 0175): removed when it is here, left alone when it is not.
|
||||
if !installed {
|
||||
out.Action = "unchanged"
|
||||
out.Detail = "not installed, as declared"
|
||||
return out, nil
|
||||
}
|
||||
if err := sys.RemovePackage(ctx, run, r.Package); err != nil {
|
||||
return out, fmt.Errorf("removing %s: %w", r.Package, err)
|
||||
}
|
||||
if still, err := sys.PackageInstalled(ctx, run, r.Package); err != nil {
|
||||
return out, err
|
||||
} else if still {
|
||||
return out, fmt.Errorf("%s was removed without error and the package database still has it", r.Package)
|
||||
}
|
||||
out.Action = "removed"
|
||||
out.Detail = "declared absent; its configuration is left where the package manager leaves it"
|
||||
return out, nil
|
||||
}
|
||||
if installed {
|
||||
out.Action = "unchanged"
|
||||
out.Detail = "already installed"
|
||||
|
||||
Reference in New Issue
Block a user