duck.cli.commands.sync.platform_utils¶
Detects the current operating system and the package manager it favors.
Module Contents¶
Functions¶
Picks the best matching system package manager for this machine. |
|
Classifies the host machine into a coarse OS family. |
|
Checks whether the current process is already running as root. |
|
Checks whether Duck Sync is running inside Termux on Android. |
|
Reads the distro id from /etc/os-release. |
Data¶
API¶
- duck.cli.commands.sync.platform_utils.LINUX_BACKEND_PRIORITY¶
[‘apt’, ‘dnf’, ‘pacman’, ‘zypper’, ‘apk’]
- duck.cli.commands.sync.platform_utils.detect_backend_name() str[source]¶
Picks the best matching system package manager for this machine.
- Returns:
A backend identifier such as “apt”, “brew”, “dnf”, “pacman”, “choco”, or “termux” that
backends.get_backendunderstands.- Raises:
UnsupportedPlatformError – If no known package manager is found.
- duck.cli.commands.sync.platform_utils.detect_os_family(raise_for_unknown: bool = True) str[source]¶
Classifies the host machine into a coarse OS family.
- Returns:
One of “linux”, “macos”, “windows”.
- Raises:
UnsupportedPlatformError – If the platform cannot be classified (only is raise_for_uknown=True).
- duck.cli.commands.sync.platform_utils.is_root() bool[source]¶
Checks whether the current process is already running as root.
Used to skip prefixing install commands with sudo, since sudo is unavailable or unnecessary inside most containers that already run as root.
- Returns:
True on POSIX systems running as uid 0. Always False on Windows, since sudo does not apply there.
- duck.cli.commands.sync.platform_utils.is_termux() bool[source]¶
Checks whether Duck Sync is running inside Termux on Android.
Termux reports itself as a normal Linux uname, so it needs its own check rather than falling through the generic Linux package manager detection. It also has no root and no sudo binary.
- Returns:
True when the Termux environment and pkg command are both present.