fix: handle sudo absence in fresh Debian containers
Debian containers run as root without sudo installed by default. The script was trying to use sudo to install packages (including sudo itself), which failed with "sudo: command not found". Changes: - Check if running as root ($EUID -eq 0) before using sudo - If root: use package managers directly (apt-get, pacman) - If not root: use sudo as before Applied to: - Basic prerequisites installation (lines 108-113) - Arch prerequisites installation (lines 131-135) - System dependencies installation (lines 215-221) - Arch system dependencies (lines 228-232) This fixes installation in: - Fresh Debian containers (root, no sudo) - Fresh Ubuntu containers (root, has sudo but not needed) - User Debian/Ubuntu systems (not root, uses sudo) - User Arch systems (not root, uses sudo) Fixes Debian 12 CI failure: "sudo: command not found" 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
00bad9c706
commit
da05e9c602
1 changed files with 28 additions and 6 deletions
34
install.sh
34
install.sh
|
|
@ -104,8 +104,14 @@ if command -v apt-get &> /dev/null; then
|
|||
|
||||
if [ ${#MISSING_PACKAGES[@]} -gt 0 ]; then
|
||||
print_info "Installing basic prerequisites: ${MISSING_PACKAGES[*]}"
|
||||
sudo apt-get update -qq
|
||||
sudo apt-get install -y -q ${MISSING_PACKAGES[*]}
|
||||
# Use sudo only if not running as root (Debian containers run as root without sudo)
|
||||
if [ "$EUID" -eq 0 ]; then
|
||||
apt-get update -qq
|
||||
apt-get install -y -q ${MISSING_PACKAGES[*]}
|
||||
else
|
||||
sudo apt-get update -qq
|
||||
sudo apt-get install -y -q ${MISSING_PACKAGES[*]}
|
||||
fi
|
||||
print_success "Basic prerequisites installed"
|
||||
else
|
||||
print_success "Basic prerequisites already installed"
|
||||
|
|
@ -121,7 +127,12 @@ elif command -v pacman &> /dev/null; then
|
|||
|
||||
if [ ${#MISSING_PACKAGES[@]} -gt 0 ]; then
|
||||
print_info "Installing basic prerequisites: ${MISSING_PACKAGES[*]}"
|
||||
sudo pacman -S --noconfirm ${MISSING_PACKAGES[*]}
|
||||
# Use sudo only if not running as root
|
||||
if [ "$EUID" -eq 0 ]; then
|
||||
pacman -S --noconfirm ${MISSING_PACKAGES[*]}
|
||||
else
|
||||
sudo pacman -S --noconfirm ${MISSING_PACKAGES[*]}
|
||||
fi
|
||||
print_success "Basic prerequisites installed"
|
||||
else
|
||||
print_success "Basic prerequisites already installed"
|
||||
|
|
@ -200,14 +211,25 @@ if command -v apt-get &> /dev/null; then
|
|||
# Debian/Ubuntu/Raspberry Pi OS
|
||||
print_info "Detected Debian/Ubuntu-based system"
|
||||
echo "Installing: python3-pip python3-gi python3-dbus python3-cairo bluez"
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y python3-pip python3-gi python3-dbus python3-cairo bluez
|
||||
# Use sudo only if not running as root
|
||||
if [ "$EUID" -eq 0 ]; then
|
||||
apt-get update
|
||||
apt-get install -y python3-pip python3-gi python3-dbus python3-cairo bluez
|
||||
else
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y python3-pip python3-gi python3-dbus python3-cairo bluez
|
||||
fi
|
||||
print_success "System dependencies installed (using pre-compiled system packages)"
|
||||
elif command -v pacman &> /dev/null; then
|
||||
# Arch Linux
|
||||
print_info "Detected Arch Linux"
|
||||
echo "Installing: python-pip python-gobject python-dbus python-cairo bluez bluez-utils"
|
||||
sudo pacman -S --noconfirm python-pip python-gobject python-dbus python-cairo bluez bluez-utils
|
||||
# Use sudo only if not running as root
|
||||
if [ "$EUID" -eq 0 ]; then
|
||||
pacman -S --noconfirm python-pip python-gobject python-dbus python-cairo bluez bluez-utils
|
||||
else
|
||||
sudo pacman -S --noconfirm python-pip python-gobject python-dbus python-cairo bluez bluez-utils
|
||||
fi
|
||||
print_success "System dependencies installed (using pre-compiled system packages)"
|
||||
else
|
||||
print_warning "Could not detect package manager"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue