Skip to content

Support Alpine Linux in main install.sh script with proper package manager detection #45

@xtetsuji

Description

@xtetsuji

Problem

Currently, the main install.sh script is hardcoded to use apt-get for package installation, which causes failures on Alpine Linux and other non-Debian/Ubuntu systems. While we have a separate alpine/install_alpine.sh, the main installation script should handle different Linux distributions gracefully.

When install.sh is executed automatically by GitHub (e.g., in Actions or Codespaces), it fails on Alpine Linux because:

  1. apt-get is not available (Alpine uses apk)
  2. No fallback mechanism exists for different package managers
  3. The script assumes Debian/Ubuntu environment

Current State

  • alpine/install_alpine.sh exists as a separate solution
  • ❌ Main install.sh doesn't detect Alpine Linux
  • ❌ No package manager abstraction layer
  • ❌ Fails when executed automatically on Alpine systems

Proposed Solution

1. Add distribution detection in install.sh

function detect-distro {
    if [ -f /etc/alpine-release ]; then
        echo "alpine"
    elif command -v apt-get >/dev/null 2>&1; then
        echo "debian"
    else
        echo "unknown"
    fi
}

2. Add package manager abstraction

function install-packages {
    local distro=$(detect-distro)
    case "$distro" in
        alpine)
            if command -v apk >/dev/null 2>&1; then
                sudo apk add --no-cache "${INSTALL_PACKAGES_ALPINE[@]}"
            else
                echo "Warning: apk not available, skipping package installation"
            fi
            ;;
        debian)
            sudo apt-get update && sudo apt-get install -y "${INSTALL_DEB_PACKAGES_IN_CODESPACES[@]}"
            ;;
        *)
            echo "Warning: Unknown distribution, skipping package installation"
            ;;
    esac
}

3. Define Alpine package equivalents

declare -a INSTALL_PACKAGES_ALPINE=(
    tig
    bat
    # Note: rcm might not be available, need alternative approach
)

Package Mapping Strategy

Debian/Ubuntu Alpine Notes
tig tig ✅ Available
bat bat ✅ Available
rcm Need alternative or skip

For rcm (dotfiles manager), we could:

  • Option A: Skip rcm installation and use manual symlink approach
  • Option B: Implement basic rcm-like functionality in the script
  • Option C: Check if rcm can be installed from edge/testing repos

Benefits

  • ✅ Single install.sh works across distributions
  • ✅ Graceful degradation when packages unavailable
  • ✅ No breaking changes to existing functionality
  • ✅ Better CI/CD compatibility

Out of Scope

  • RedHat/CentOS support (as requested)
  • Complex package manager features
  • Perfect feature parity across distributions

Implementation Notes

The goal is to make install.sh resilient rather than feature-complete. If Alpine-specific packages aren't available, the script should warn and continue rather than fail.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions