Bladeren bron

feat(installer): add Alpine Linux support and fix missing dependencies

- Add apk (Alpine) package manager support with new pm_apk.sh module
- Create Alpine container configuration in containers/alpine/
- Add missing dependencies to apt and dnf package lists:
  - libjson-glib, libarchive, libgee, xz-utils, gobject-introspection
- Reorder installation to check system dependencies before extracting sources
- Simplify Debian/Ubuntu Dockerfiles by removing redundant steps
clanker 4 dagen geleden
bovenliggende
commit
40a46e676d

+ 17 - 0
containers/alpine/Dockerfile

@@ -0,0 +1,17 @@
+FROM alpine:latest
+
+# Install bash first (Alpine uses ash by default)
+RUN apk add --no-cache bash
+
+# Copy the installer
+COPY install-builddir/install-usm.sh /tmp/install-usm.sh
+RUN chmod +x /tmp/install-usm.sh
+
+# Run the installer non-interactively
+RUN /tmp/install-usm.sh -y
+
+# Clean up installer
+RUN rm /tmp/install-usm.sh
+
+# Default command
+CMD ["/usr/bin/usm"]

+ 0 - 6
containers/debian/Dockerfile

@@ -1,8 +1,5 @@
 FROM debian:latest
 
-# Install basic dependencies that might be needed
-RUN apt-get update && apt-get -y upgrade && apt-get clean
-
 # Copy the installer
 COPY install-builddir/install-usm.sh /tmp/install-usm.sh
 RUN chmod +x /tmp/install-usm.sh
@@ -10,9 +7,6 @@ RUN chmod +x /tmp/install-usm.sh
 # Run the installer non-interactively
 RUN /tmp/install-usm.sh -y
 
-# Verify installation
-RUN /usr/bin/usm --help
-
 # Clean up installer
 RUN rm /tmp/install-usm.sh
 

+ 0 - 6
containers/ubuntu/Dockerfile

@@ -1,8 +1,5 @@
 FROM ubuntu:latest
 
-# Install basic dependencies that might be needed
-RUN apt-get update && apt-get -y upgrade && apt-get clean
-
 # Copy the installer
 COPY install-builddir/install-usm.sh /tmp/install-usm.sh
 RUN chmod +x /tmp/install-usm.sh
@@ -10,9 +7,6 @@ RUN chmod +x /tmp/install-usm.sh
 # Run the installer non-interactively
 RUN /tmp/install-usm.sh -y
 
-# Verify installation
-RUN /usr/bin/usm --help
-
 # Clean up installer
 RUN rm /tmp/install-usm.sh
 

+ 6 - 6
installer/main.sh

@@ -115,6 +115,12 @@ check_existing_installation() {
 
 # Main installation function
 run_installation() {
+    # Install system dependencies first (before extracting sources)
+    log_step "Checking system dependencies..."
+    if ! pm_install_missing_deps; then
+        show_error_and_exit "Failed to install system dependencies. Installation halted."
+    fi
+    
     # Set up temporary directory
     setup_temp_dir
     local extract_dir="$TEMP_DIR/sources"
@@ -126,12 +132,6 @@ run_installation() {
         show_error_and_exit "Failed to extract bundled sources"
     fi
     
-    # Install system dependencies
-    log_step "Checking system dependencies..."
-    if ! pm_install_missing_deps; then
-        show_error_and_exit "Failed to install system dependencies. Installation halted."
-    fi
-    
     # Build and install all components
     log_step "Building and installing components..."
     if ! build_all "$extract_dir" "$TARGET_DIR"; then

+ 58 - 0
installer/pm_apk.sh

@@ -0,0 +1,58 @@
+#!/bin/bash
+# pm_apk.sh - APK package manager implementation for Alpine Linux 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
+
+# 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
+}

+ 1 - 1
installer/pm_apt.sh

@@ -7,7 +7,7 @@
 #   - pm_<name>_install_missing_deps: Installs the missing packages
 
 # Package names required by USM
-APT_DEPS="valac meson ninja-build git pkg-config gcc libglib2.0-dev libsodium-dev"
+APT_DEPS="valac meson ninja-build pkg-config gcc libglib2.0-dev libsodium-dev libjson-glib-dev libarchive-dev libgee-0.8-dev xz-utils gobject-introspection"
 
 # Check if this package manager is available
 pm_apt_detect() {

+ 2 - 0
installer/pm_base.sh

@@ -29,6 +29,7 @@ detect_package_manager() {
 # Get missing dependencies using the detected package manager
 pm_get_missing_deps() {
     case "$PM_TYPE" in
+        apk) pm_apk_get_missing_deps "$@" ;;
         apt) pm_apt_get_missing_deps "$@" ;;
         dnf) pm_dnf_get_missing_deps "$@" ;;
         *)
@@ -41,6 +42,7 @@ pm_get_missing_deps() {
 # Install missing dependencies using the detected package manager
 pm_install_missing_deps() {
     case "$PM_TYPE" in
+        apk) pm_apk_install_missing_deps "$@" ;;
         apt) pm_apt_install_missing_deps "$@" ;;
         dnf) pm_dnf_install_missing_deps "$@" ;;
         *)

+ 1 - 1
installer/pm_dnf.sh

@@ -7,7 +7,7 @@
 #   - pm_<name>_install_missing_deps: Installs the missing packages
 
 # Package names required by USM
-DNF_DEPS="vala meson ninja-build pkgconf-pkg-config gcc glib2-devel libsodium-devel json-glib-devel libarchive-devel libgee-devel"
+DNF_DEPS="vala meson ninja-build pkgconf-pkg-config gcc glib2-devel libsodium-devel json-glib-devel libarchive-devel libgee-devel xz gobject-introspection"
 
 # Check if this package manager is available
 pm_dnf_detect() {