| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- #!/bin/bash
- # pm_pacman.sh - pacman package manager implementation for Arch systems
- #
- # To add a new package manager, create a file named pm_<name>.sh with:
- # - pm_<name>_detect: Returns 0 if this PM is available, 1 otherwise
- # - pm_<name>_get_missing_deps: Prints space-separated list of missing packages
- # - pm_<name>_install_missing_deps: Installs the missing packages
- #
- # Arch notes:
- # - PACMAN_DEPS mirror the dnf/apt dependency sets. Arch carries no
- # -dev split: glib2, json-glib, libgee, gobject-introspection ship
- # headers, pkg-config, .gir/.typelib and .vapi artifacts themselves,
- # and glibc already bundles the crt objects gcc needs, so no
- # companion package (musl-dev style) is required.
- # Package names required by USM
- PACMAN_DEPS="vala meson ninja pkgconf gcc glib2 libsodium json-glib libarchive libgee xz gobject-introspection"
- # Check if this package manager is available
- pm_pacman_detect() {
- command -v pacman &>/dev/null
- }
- # Get list of missing dependencies
- pm_pacman_get_missing_deps() {
- local -a missing=()
- for pkg in $PACMAN_DEPS; do
- if ! pacman -Q "$pkg" &>/dev/null; then
- missing+=("$pkg")
- fi
- done
- echo "${missing[*]}"
- }
- # Install missing dependencies
- pm_pacman_install_missing_deps() {
- local missing=$(pm_pacman_get_missing_deps)
- if [[ -z "$missing" ]]; then
- log_info "All dependencies are already installed"
- return 0
- fi
- log_step "Installing packages via pacman: ${missing}"
- local sudo=""
- if ! is_root; then
- sudo=$(get_sudo)
- fi
- local pacman_opts="--needed --noconfirm"
- if [[ -n "$sudo" ]]; then
- $sudo pacman -Sy $pacman_opts $missing
- else
- pacman -Sy $pacman_opts $missing
- fi
- }
|