Expand description
General utility functions.
Functions§
- ask_
for_ confirmation - Prompts the user for confirmation (y/N) unless the
yesflag is set. - build_
blocking_ http_ client - Builds a blocking HTTP client with a custom timeout.
- check_
license - Validates a package license against SPDX and organizational policies.
- command_
exists - Checks if a command exists in the system’s PATH.
- confirm_
untrusted_ source - Prompts the user to confirm installation from an untrusted (non-official) source.
- copy_
dir_ all - Recursively copies all files and subdirectories from source to destination.
- expand_
placeholders - Expands standard Zoi path placeholders (e.g.
${pkgstore},${usrhome}) in a string. - expand_
tilde - Expands the
~character to the user’s home directory. - format_
bytes - Formats a byte count into a human-readable string (e.g. “1.24 MiB”).
- format_
size_ diff - Formats a size difference into a signed human-readable string (e.g. “+50 B”).
- generate_
package_ id - Generates a unique, origin-aware ID for a package.
- generate_
versioned_ package_ id - Generates a unique ID for a package including its version.
- get_
all_ available_ package_ managers - Scans the system for all supported package managers.
- get_
cpu_ info - Returns a short description of the system’s CPU.
- get_
current_ shell - Detects and returns the current shell being used.
- get_
db_ base_ dir - Returns the root directory of the package database for a given scope.
- get_
db_ root - Returns the root directory for the package database.
- get_
desktop_ environment - Returns the name of the current desktop environment (e.g. “gnome”, “kde”).
- get_
display_ server - Returns the name of the current display server (e.g. “wayland”, “x11”).
- get_
distro_ version - Returns the version of the current distribution.
- get_
git_ base_ dir - Returns the root directory for Git repositories for a given scope.
- get_
gpu_ info - Returns a short description of the system’s GPU.
- get_
http_ client - Creates an HTTP client with Zoi’s default configuration.
- get_
init_ system - Returns the name of the system’s init system (e.g. “systemd”, “openrc”).
- get_
kernel_ version - Returns the version of the operating system kernel.
- get_
linux_ distribution - Returns the ID of the current Linux distribution (e.g. “debian”, “fedora”).
- get_
linux_ distribution_ info - Retrieves information about the current Linux distribution from /etc/os-release.
- get_
linux_ distro_ family - Detects the general family of a Linux distribution (e.g. “debian”, “arch”, “fedora”).
- get_
native_ package_ manager - Identifies the primary package manager for the current operating system.
- get_
package_ dir_ name - Creates the directory name for the package in the store.
Format:
{hash}-{name} - get_
platform - Returns a standard Zoi platform identifier (e.g. “linux-amd64”, “windows-arm64”).
- get_
privilege_ escalator - Returns the name of the available privilege escalation tool (e.g. “sudo”, “doas”).
- get_
store_ base_ dir - Returns the root directory of the package store for a given scope.
- get_
user_ home - Returns the home directory of the current user, or the original user if run via sudo or doas.
- is_
admin - Checks if the current process has administrative privileges.
- is_
mini_ mode - Returns true if Zoi is running in “Mini” mode (lightweight, zero-sync).
- is_
platform_ compatible - Checks if a target platform is compatible with a list of allowed platforms.
- is_
safe_ path - Verifies that a given path is “Safe” and doesn’t attempt to escape the base directory.
- is_
zoios - Returns true if the current system is a ZoiOS-based distribution (like Parlex).
- resolve_
fallback_ scope - Resolves the default installation scope based on the current environment.
- retry_
backoff_ sleep - Performs a jittered exponential backoff sleep.
- run_
shell_ command - Executes a shell command and returns an error if it fails.
- run_
shell_ command_ quietly - Executes a shell command quietly (suppressing output) and returns an error if it fails.
- set_
path_ owner - Sets the owner and group for a file or directory (Unix only).
- set_
path_ read_ only - Recursively sets a directory and its contents to be read-only.
- set_
path_ writable - Recursively ensures a directory and its contents are writable.
- symlink_
dir - Creates a symbolic link for a directory, handling platform-specific requirements.
- symlink_
file - Creates a symbolic link for a file, handling platform-specific requirements.