Documentation
¶
Overview ¶
Package placement decides where zip items may be written: the write roots compiled into the build, and the checks every placement path passes before sofcat writes under it. It is portable and holds no service state, so the service and a per-user helper share it.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrRefused = errors.New("placement refused")
ErrRefused wraps every refusal of a placement path. The item then fails with report.CodePlacementRefused.
Functions ¶
func BinaryDirs ¶
BinaryDirs returns the directories holding sofcat's binaries: the running executable's, and on macOS /Library/Application Support/<Name>/bin.
Types ¶
type Guard ¶
type Guard struct {
// GOOS picks the harness paths and roots: harness.Darwin or
// harness.Windows. Paths compare case-insensitively for both.
GOOS string
Roots Roots
// DataDir is sofcat's data directory; nothing is placed inside it.
DataDir string
// BinaryDirs hold sofcat's executables; no placement may be inside one,
// equal one, or contain one.
BinaryDirs []string
// Vars holds values only the caller knows, such as USERPROFILE for a
// user-scope placement. The service has no user and leaves it empty.
Vars map[string]string
}
Guard checks placement paths against the write roots and the directories sofcat must never write into.
func MachineGuard ¶
MachineGuard is the service's guard: this OS, the compiled-in roots, the data directory, and the directories holding this build's binaries.
type Roots ¶
type Roots struct {
// Darwin and Windows are the machine-scope roots on each OS. Windows
// roots may use ${ProgramFiles} and ${ProgramData}.
Darwin []string `yaml:"darwin"`
Windows []string `yaml:"windows"`
// WindowsUser are the user-scope roots on Windows, relative to the user's
// profile: either starting with ${USERPROFILE} or a relative path.
WindowsUser []string `yaml:"windows_user"`
}
Roots are the directories a build may place trees under. They come from the build only (a brand's write-roots.yaml, or the stock defaults), never from runtime config or the harness table.
func ParseRoots ¶
ParseRoots decodes write-roots.yaml, rejecting unknown fields.
func StockRoots ¶
func StockRoots() Roots
StockRoots are the roots of a build without write-roots.yaml: the directory holding its config and Data for machine scope (${ProgramData}\<Name> on Windows, /Library/Application Support/<Name> on macOS), and no user roots. Data itself and the executables' directory stay refused (Guard.Check).