#!/bin/bash # pm_apk.sh - APK package manager implementation for Alpine Linux systems # # To add a new package manager, create a file named pm_.sh with: # - pm__detect: Returns 0 if this PM is available, 1 otherwise # - pm__get_missing_deps: Prints space-separated list of missing packages # - pm__install_missing_deps: Installs the missing packages # Package names required by USM APK_DEPS="vala meson ninja pkgconf gcc musl-dev glib-dev libsodium-dev json-glib-dev libarchive-dev libgee-dev xz gobject-introspection gobject-introspection-dev" # Check if this package manager is available pm_apk_detect() { command -v apk &>/dev/null } # Get list of missing dependencies pm_apk_get_missing_deps() { local -a missing=() for pkg in $APK_DEPS; do if ! apk info -e "$pkg" &>/dev/null; then missing+=("$pkg") fi done echo "${missing[*]}" } # Install missing dependencies pm_apk_install_missing_deps() { local missing=$(pm_apk_get_missing_deps) if [[ -z "$missing" ]]; then log_info "All dependencies are already installed" return 0 fi log_step "Installing packages via apk: ${missing}" local sudo="" if ! is_root; then sudo=$(get_sudo) fi local apk_opts="--quiet" if [[ "$ASSUME_YES" == "true" ]]; then apk_opts="--quiet --force" fi if [[ -n "$sudo" ]]; then $sudo apk update $sudo apk add $apk_opts $missing else apk update apk add $apk_opts $missing fi }