Documentation
¶
Overview ¶
How icebath came onto a computer and what marks it: the stamp an installer writes into the folder it made for the program, the package managers, images and source checkouts that own a program instead, and the PATH lines and the Windows environment an install sets
Index ¶
- Constants
- Variables
- func AddShellLine(rc, line string) (bool, error)
- func AddUserPath(string) (bool, error)
- func Apps(string) bool
- func Archive(version, goos, goarch string) string
- func Aside(program string) []string
- func Bin(system bool) string
- func Cache() string
- func Checked() string
- func ChecksumOf(body []byte, name string) string
- func Commands(name string, path []string) []string
- func Compare(a, b string) int
- func Contained() bool
- func ID() string
- func IDOf(exe string) string
- func Installer() string
- func Keyed() bool
- func Leads(cmd string) string
- func LineFolder(line, home string) string
- func LoginShell() string
- func MarkedPath(rc, dir, home string) bool
- func OnlyMarked(rc string) bool
- func PathLine(s Shell, dir, home string) string
- func ProgramName(goos string) string
- func Publish(program, bin string) (bool, error)
- func RemoveApps(string) (bool, error)
- func RemoveShellLine(rc, line string) (bool, error)
- func RemoveUserPath([]string) ([]string, error)
- func RemoveUserVar(string) (bool, error)
- func Replace(staged, program string) (string, error)
- func SetsPath(rc, dir, home string) bool
- func ShellFiles(home string) []string
- func ShellLines(rc string) []string
- func Stable(tag string) bool
- func Staged(program string) string
- func StripShellLines(rc string) (int, error)
- func Sweep(program string) []string
- func Tree(system bool) string
- func Unpack(archive, dir, goos string) (string, error)
- func UserPath() []string
- func UserVar(string) (string, bool)
- func Valid(version string) bool
- func Verify(what string, data, signature []byte, published time.Time) error
- func Versions(body []byte) []string
- func WriteStamp(tree string, stamp Stamp) error
- type Ack
- type Announce
- type Ask
- type Asked
- func (a *Asked) Ack(p Process) (Ack, bool)
- func (a *Asked) Acks() []Ack
- func (a *Asked) Close() error
- func (a *Asked) Go(words string) error
- func (a *Asked) Gone() []Process
- func (a *Asked) Off(words string) error
- func (a *Asked) Processes() []Process
- func (a *Asked) Wait(ctx context.Context) []Ack
- func (a *Asked) Want(p Process) Want
- type Build
- type Completion
- type Found
- type Held
- type Install
- func (i Install) Held() (Held, bool)
- func (i Install) Owed(settings, part string) bool
- func (i Install) Owned() bool
- func (i Install) Removal() string
- func (i Install) Said() string
- func (i Install) Settle(ctx context.Context, settings, part string) error
- func (i Install) System() bool
- func (i Install) Updating() string
- type Key
- type Method
- type Presence
- type Process
- type Provenance
- type Purpose
- type Reason
- type Shell
- type Stamp
- type Startup
- type Supervisor
- type Told
- type Want
Constants ¶
const ( // Something is under way, which Doing names Busy = "busy" // Nothing is under way, or the process only waits to be told Ready = "ready" // The process ends now, as the asker said Go Ending = "ending" // The process was told the words of Go, or that the ask was called off Noticed = "noticed" )
States of an answer
const ( Systemd = "systemd" Launchd = "launchd" // The service manager of Windows Service = "service" // runit's runsv, which termux-services runs services with on Termux, and Void Linux and many containers on Linux Runit = "runit" )
Programs that run a process
const Checksums = "checksums.txt"
Asset of every release listing the sha256 and the name of each other asset, two spaces between
const ProfileScript = "/etc/profile.d/icebath.sh"
Startup script the install script makes for an install for everyone of a computer whose PATH lacks /usr/local/bin, holding the marked line that puts it there
const (
PyPIName = "icebath-cli"
)
Name icebath is published under on PyPI, and the name its files carry in a Python environment
const Repository = "https://github.com/nickheyer/icebath"
Where the releases of icebath are published
const SettledName = "settled.json"
File of the settings folder that says, by install and by part of icebath, which install the first start settled there: what the first start after an install owes is owed again once an installer runs again or a package manager puts another version in place
const ShellMarker = "# added by icebath"
Comment line a line icebath adds to a shell startup file carries directly above it, such as the one that puts its command on the PATH, which an uninstall finds and strips with the line under it
const SignatureSuffix = ".sig"
Suffix of the file beside a signed file that holds its signature
const StampName = ".icebath-install"
File an installer writes last into the folder it made for the program, which marks that folder as one an installer made: lines of name=value, read as data and never sourced, a name given again for each value of a list
const WinGetID = "nickheyer.icebath"
Identifier icebath is published under in the WinGet community repository, which names its package folder and its Apps and Features entry
Variables ¶
Every family, in the order a report lists them
Functions ¶
func AddShellLine ¶
Adds the line under the marker at the end of the startup file, after a blank line, unless the file has that line already: whether it added it
func AddUserPath ¶
func Archive ¶
Name of the release archive of a version for an OS and architecture: icebath_1.4.2_linux_amd64.tar.gz, a zip on Windows
func Aside ¶
Programs an update moved aside beside the program, oldest first, which processes started before it may still run
func Bin ¶
Folder of the commands icebath puts on the user's PATH, the icebath command and the shell commands of profiles: ~/.local/bin, or /usr/local/bin for an install for everyone of the computer, or in Termux its own bin folder, the user's and on the PATH of every shell there. Empty when the system names no home
func Cache ¶
func Cache() string
Folder of what every icebath of this user shares whatever settings folder each uses: the user's cache folder, otherwise one of the system's temporary folder of this user's own
func ChecksumOf ¶
sha256 a checksums file gives the name, in lower case. Empty when it lists no such name
func Commands ¶
Every program by the name of the command in the folders of the PATH, in the order a shell looks, the first being the one it runs; on Windows with the endings PATHEXT gives commands
func Compare ¶
Order of two versions by the precedence of semantic versioning, a leading v optional: negative when a comes first, positive when b does, zero for the same precedence. Text that is no version comes before every version, and two such by their text
func Contained ¶
func Contained() bool
Whether this process runs inside a container, as Docker and Podman mark one
func ID ¶
func ID() string
Id of the install of this process, which every record of an install is named by
func IDOf ¶
Id of the install of the program at the path: twelve hex digits of the digest of the folder the program is in, its links followed and, where the file system ignores case as on Windows and macOS, in lower case
func Installer ¶
func Installer() string
Command a user runs to install icebath with the install script on this computer
func Keyed ¶
func Keyed() bool
Whether this build carries a key to check the signature of a release with. Without one a release is checked by its digests alone
func Leads ¶
Program a command runs: where its links lead, or the program a small script of icebath runs with exec. The command itself otherwise
func LineFolder ¶
Folder a marked PATH line icebath wrote puts on PATH, empty for a line of another kind
func LoginShell ¶
func LoginShell() string
Login shell of the user: SHELL, otherwise the one the system's record of accounts names for this user. Empty on Windows and when neither says
func MarkedPath ¶
Whether a line icebath marked in the startup file puts the folder on PATH
func OnlyMarked ¶
Whether the startup file holds nothing but the lines icebath marked, their markers and blank lines, as a file icebath made itself does
func PathLine ¶
PathLine returns the line that puts the folder first on the PATH for a shell in the family, only once however often the file is read. It returns an empty line when the folder name contains a character that some shell can't accept unquoted, such as a quote, a dollar or a colon
func Publish ¶
Makes the command icebath of the folder of commands lead to the program: a link made beside it and renamed over it, so a shell never finds none. A command there already that leads nowhere, to another program of icebath, or is a copy of one is replaced; another program's is never touched. Whether it changed anything. Linux and macOS only: on Windows the program's folder goes on the user PATH
func RemoveApps ¶
func RemoveShellLine ¶
Removes one line icebath added to the startup file, with its marker and the blank line AddShellLine put above it, as when the folder the line puts on PATH is gone: whether it was there
func RemoveUserPath ¶
func RemoveUserVar ¶
func Replace ¶
Puts the staged program in place of the program, both in one folder: one rename where the system lets a running program be replaced, and on Windows, which keeps a running program's file, the program renamed aside first and put back when the staged one can't follow. Where the old program went, empty when it went nowhere
func SetsPath ¶
Whether a line of the startup file that is no comment puts the folder on the PATH: one that sets a PATH and names the folder, as written, through $HOME, ${HOME} or ~, marked by icebath or written by the user or their system, such as Fedora's .bashrc
func ShellFiles ¶
Startup files of every family of shells under the home folder, where icebath may have marked lines: those of bash, zsh (in the home and in ZDOTDIR), sh, fish, nushell, csh and PowerShell, the files of fish and PowerShell in ~/.config and in XDG_CONFIG_HOME both
func ShellLines ¶
The lines the marker stands above in the startup file
func Staged ¶
Where a new program waits beside the program until it is put in place: in its folder, so putting it there is one rename
func StripShellLines ¶
Removes each marker in the startup file with the line under it, and the blank line AddShellLine put above it: how many lines it removed of what icebath added
func Sweep ¶
Removes the programs moved aside beside the program that no process runs any more, which the system then lets go. Those removed
func Tree ¶
Folder the install script makes for the program and its stamp: the user's data folder's icebath on Linux and macOS (${XDG_DATA_HOME:-~/.local/share}/icebath) and Programs\icebath of the user's local application data on Windows, or /usr/local/lib/icebath for an install for everyone of the computer, as the script makes when it runs as root. Empty when the system names no home
func Unpack ¶
Unpacks the program of a release archive for the OS into the folder, the archive's other files left in it: the program at the archive's root or inside its one top folder, a regular file and nothing else. The path of the program unpacked
func UserPath ¶
func UserPath() []string
The user PATH and variables of the Windows registry, which no other system has
func Valid ¶
Whether the text is a version by the rules of semantic versioning, a leading v optional
func Verify ¶
Checks the signature of data, published at the time: base64 as cosign writes it, of ECDSA P-256 over the SHA-256 of the data or of Ed25519 over the data, made by a key this build trusts that was not retired by then. An error a user reads when no such key made it
func Versions ¶
Versions the release archives a checksums file lists hold, each once in the order first listed: one for the checksums of one release
func WriteStamp ¶
Writes the stamp into the folder whole, as an installer or an update of the program keeps it
Types ¶
type Ack ¶
type Ack struct {
PID int `json:"pid"`
Start int64 `json:"start,omitempty"`
Want Want `json:"want"`
State string `json:"state"`
// What is under way that the process finishes first, while Busy
Doing string `json:"doing,omitempty"`
At time.Time `json:"at"`
}
How one process answered an ask
type Announce ¶
type Announce struct {
// Key of the record, the same as the key of the process's record in its settings folder. One is made when empty
Key string
Purpose Purpose
Settings string
Profile string
// Start time of a process as the system reads it, false when it can't be read
Started func(pid int) (int64, bool)
}
What a process announces of itself
type Ask ¶
type Ask struct {
Reason Reason
Install string
Settings string
// What every process asked wants, but those Wants names by their pid
Want Want
Wants map[int]Want
// Deadline of the work under way that an ask to end waits for
Until time.Time
// What the processes asked say while they wait, such as that icebath is updating to 1.5.0
Coming string
}
One ask of the icebath processes of an install and of a settings folder, either empty for any, the asker always spared
type Asked ¶
type Asked struct {
// contains filtered or unexported fields
}
An ask this process made of others, which it follows and settles
func (*Asked) Go ¶
Says the change was made: those asked to end end saying the words, the others are told them
func (*Asked) Off ¶
Calls the ask off, nothing changed: every process goes on, told the words where it was told something
type Build ¶
type Build struct {
// As the build names it: v1.4.2, a prerelease such as v1.5.0-main.4, a pseudo version such as v1.4.3-0.20261201120000-abcdef123456,
// empty for a build that names none
Version string
// Commit it was built from, 40 hex digits, empty when the build names none
Commit string
// Time of that commit, zero when unknown
Time time.Time
// Built from a tree with changes not committed
Modified bool
OS, Arch string
// Go toolchain it was built with
Go string
// Tags, Flags and CGO are the build tags, linker flags and CGO_ENABLED given to go build, which a checkout rebuild passes again. A
// build with -trimpath does not record linker flags, so Flags is empty for that build and Trimmed is true
Tags, Flags, CGO string
Trimmed bool
// State its stores write, 0 for a program that carries no mark of it
Epoch int
}
What a program of icebath was built from, read from the build info of the program file without running it
func Read ¶
Build of a program file, read without running it. An error a user reads for a file that is no program of icebath
func (Build) Line ¶
One line naming the build whole: version, commit, OS and architecture, toolchain
func (Build) Published ¶
A clean build of a tag a release was published under, a stable or a prerelease one, never a pseudo version
type Completion ¶
type Completion struct {
Shell Shell
// Shell as the completion command names it: bash, zsh, fish or powershell
Script string
Path string
// Startup files the line goes into, and the line, none for a shell that loads the file by itself, as bash-completion and fish do
RC []string
Line string
}
Where the completion script of icebath goes for a family of shells, and the line of a startup file that loads it where the shell does not load scripts of that place by itself
func Completions ¶
func Completions(home string) []Completion
Completions of icebath for the families of shells the user uses, as the user's own files: bash through the folder bash-completion reads, zsh through ~/.zfunc and a line of .zshrc that loads it once the completion system runs, fish through its completions folder, PowerShell through a script beside its profiles and a line of each profile there is (on Windows, of those already there, since an execution policy may keep a profile from running)
type Found ¶
type Found struct {
Shell Shell
// The PATH the shell starts with holds the folder already
Inherited bool
// Files the family's lines go into that put the folder on PATH, those that do not, and of the first those whose line icebath marked
Setting, Lacking, Marked []string
}
How a new shell of a family finds a folder on its PATH
type Held ¶
type Held struct {
// Who keeps it, as Steward names it
By string
// Folder it keeps the program in, such as the package folder of WinGet
Folder string
// Version it records as installed, empty when it records none to read
Version string
// Installed for every user of the computer, so updated and removed by an administrator
Machine bool
// Command on the PATH it runs the program by, empty when none leads to the program
Command string
// Where it keeps its record of the program, such as the key of an Apps and Features entry. Empty when it keeps none to read
Record string
// Its record of the program is gone, so it no longer knows the program is there and passes it by when it updates
Lost bool
// What makes it know the program again, whole sentences with the command
Repair string
// Why it can't update or remove the program now, such as the Python its environment was made with gone. Empty when it can
Unusable string
}
What the package manager holding the program keeps of it, read from its own records
type Install ¶
type Install struct {
// The running program, links followed, empty when the system can't say, and the id of its install
Program, ID string
// Folder an installer made for the program and stamped, the program's or the one above it. Empty for none
Tree string
Stamp Stamp
// How it came here: the stamp's, otherwise what owns the program, otherwise a checkout, otherwise a loose program
Method Method
// Who owns the program when icebath does not, as a user names it, such as Homebrew or a Debian package. Empty when icebath owns it
Steward string
// Package the system's package manager holds the program in, for the words of its removal. Empty for none
Package string
// Source checkout of icebath the program was built in, empty for none
Checkout string
}
The install of this process: its program, and how it came onto this computer
func (Install) Held ¶
What the package manager holding the program keeps of it, false for a program none holds or one whose records icebath does not read
func (Install) Owed ¶
Whether the first start after the install owes the part something in the settings folder: an installer finished, or a package manager put this version in place, and no start of this settings folder settled it for the part yet
func (Install) Owned ¶
Whether icebath removes its own program, which a package manager, an image or a checkout keeps for itself
func (Install) Removal ¶
Removal returns why an uninstall keeps the program, as one statement of 5 to 10 words that ends with the command that removes it. It is empty when icebath removes the program itself.
func (Install) Said ¶
How the program came onto this computer, as a user reads it at the start of a line
func (Install) Settle ¶
Records that the part settled what the install owed it in the settings folder, until an installer finishes again
type Key ¶
type Key struct {
// Day it was added, and the day after which a release signed by it alone is refused, zero while it is in use
Added, Retired time.Time
// The key as PKIX PEM, as cosign public-key prints it: ECDSA P-256 or Ed25519
PEM string
}
A public key the releases of icebath are signed with
type Method ¶
type Method string
How icebath came onto this computer
const ( // The install script, which makes a folder of its own for the program Script Method = "script" WinGet Method = "winget" Scoop Method = "scoop" Homebrew Method = "homebrew" Chocolatey Method = "chocolatey" Nix Method = "nix" Deb Method = "dpkg" RPM Method = "rpm" Pacman Method = "pacman" APK Method = "apk" Pip Method = "pip" // A container image built from icebath's Dockerfile Image Method = "image" // Built in a source checkout of icebath Checkout Method = "checkout" // A build of one commit a developer gave out, which never updates Pinned Method = "pinned" // A program file nothing placed, such as one built and copied, or one go install put down Loose Method = "" )
type Presence ¶
type Presence struct {
// contains filtered or unexported fields
}
This process in the record of the icebath processes, and the asks it answers
func Present ¶
Announces this process in the record of the icebath processes of this user for as long as it runs, and answers the asks made of it: busy says what is under way in this process that an ask to end waits for, empty when nothing. End ends this process as a stop signal ends it, after which Close says why. Never nil: a record that can't be written leaves the process unseen by the others, which the error says
func (*Presence) Asking ¶
Asks the processes the ask names, every one but this process, and those it spares left out
func (*Presence) Close ¶
Takes this process out of the record and says why it ended when an ask ended it. Nothing for a process that never announced itself
func (*Presence) Heard ¶
What asks of others told this process last, and a channel closed once they tell it more
func (*Presence) SetProfile ¶
Rewrites the record with the profile the process's window is on now
type Process ¶
type Process struct {
PID int `json:"pid"`
// Start time as the system reads it, which tells this process from a later one given the same pid
Start int64 `json:"start,omitempty"`
Purpose Purpose `json:"purpose"`
// Install of its program, as ID names it, and the program, links followed
Install string `json:"install"`
Program string `json:"program"`
Build Build `json:"build"`
// Settings folder it uses and the profile it works on
Settings string `json:"settings"`
Profile string `json:"profile"`
Supervisor Supervisor `json:"supervisor"`
Since time.Time `json:"since"`
// contains filtered or unexported fields
}
One icebath process of this user as it announced itself
func OfSettings ¶
The processes of the settings folder, compared with links followed and case folded where the system folds it
type Provenance ¶
type Provenance struct {
Schema int `json:"schema"`
// Image it was published as, such as ghcr.io/nickheyer/icebath
Image string `json:"image"`
// Version and commit of the program it was built with, the version without its v. Empty when the build named none
Version string `json:"version"`
Revision string `json:"revision"`
// Program that runs its containers as the image was built for, docker unless the marker names another
Manager string `json:"manager"`
// The program of icebath the image carries, which the marker describes and no other. Empty in a marker that names none
Program string `json:"program"`
}
What the container image of icebath says of itself in its provenance marker, written when the image is built
func Marker ¶
func Marker() (Provenance, bool, error)
Provenance marker of the container image this process runs in: whether there is one, and why the one there does not read
func (Provenance) Describes ¶
func (p Provenance) Describes(exe string) bool
Whether the marker describes the program at the path: the program it names, links followed, or any program for a marker that names none
func (Provenance) Tag ¶
func (p Provenance) Tag() string
Tag of the image a pull of a newer one of the same kind names: latest for a release, main for a build of main, the channel for a build of another channel
type Shell ¶
type Shell string
A family of shells that read the same startup files and take the same lines
const ( // bash, which reads .bashrc when it is interactive and the first of .bash_profile, .bash_login and .profile at sign-in Bash Shell = "bash" // zsh, which reads its files in ZDOTDIR when that names a folder, otherwise in the home Zsh Shell = "zsh" // The POSIX shells sh, dash, ash and ksh, which read .profile at sign-in, as display managers do Sh Shell = "sh" Fish Shell = "fish" Nu Shell = "nu" // csh and tcsh Csh Shell = "csh" // PowerShell on Linux and macOS. On Windows the user PATH of the registry stands for every shell Pwsh Shell = "pwsh" )
func ShellOf ¶
Family of a shell program by its name, such as bash of /bin/bash or -zsh of a login shell. Empty for a program that is no shell icebath knows
func (Shell) Finds ¶
How a new shell of the family finds the folder: through the PATH it starts with, the base, otherwise through the lines of the files the family's lines go into, a login file of bash that reads .bashrc taking what .bashrc does
type Stamp ¶
type Stamp struct {
Method Method
// Version installed, the 40 hex digit commit it was built from, the repository it came from and the channel of its updates, the first
// two kept current by an update that put a new program in place
Version, Commit, Repository, Channel string
// When the install finished, zero for one that never did
Completed time.Time
// Commands it put on the PATH, shell startup files it added the marked PATH line to, Windows user PATH entries it added and user
// variables it set, and completion files it wrote
Launchers, RCFiles, UserPath, UserVars, Completions []string
// Programs the user left out of those the first start of the program installs, such as chromium
Without []string
// Key of the Apps and Features entry it registered on Windows, under the current user's Uninstall key
Apps string
// Package a package manager holds the program in, as the stamp its package installs names it, such as icebath-bin
Package string
}
What an installer recorded of an install in its stamp
type Startup ¶
type Startup struct {
Path string
// Read by a login shell, such as the first one of a session or of a terminal of macOS, and by an interactive shell that is no login
Login, Interactive bool
// Read only when no earlier file of the shell marked First is there, as bash reads the first of its login files
First bool
}
A startup file of a shell and when the shell reads it
type Supervisor ¶
type Supervisor struct {
Kind string `json:"kind,omitempty"`
// The unit, the label, the name of the Windows service, or the service folder of runit
Name string `json:"name,omitempty"`
// systemd: user or system; launchd: the domain, such as gui/501 or system; runit: the folder of its services
Scope string `json:"scope,omitempty"`
}
How a process runs under a program that starts it, and starts it again, empty Kind for none
func Supervised ¶
func Supervised() Supervisor
How this process runs, empty Kind when nothing runs it
func (Supervisor) Said ¶
func (s Supervisor) Said() string
The supervisor in words a user reads, such as the systemd user unit icebath.service. Empty for none
type Told ¶
type Told struct {
Reason Reason
Want Want
// What the ask said while it waited, then the words of Go or Off
Words string
Until time.Time
// The asker said Go, or called the ask off when Off
Done, Off bool
}
What asks of others told a process, for its windows
type Want ¶
type Want string
What an ask wants of one process
const ( // Finish what is under way within the deadline, answer ready, and end once the asker says Go End Want = "end" // Go on running, told the words once the asker says Go Notice Want = "notice" // Nothing: the asker, a window the asker spares, a server its service manager restarts Spare Want = "spare" )