Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/desktop-lite/devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"id": "desktop-lite",
"version": "1.2.9",
"version": "1.2.10",
"name": "Light-weight Desktop",
"documentationURL": "https://github.com/devcontainers/features/tree/main/src/desktop-lite",
"description": "Adds a lightweight Fluxbox based desktop to the container that can be accessed using a VNC viewer or the web. GUI-based commands executed from the built-in VS code terminal will open on the desktop automatically.",
Expand Down
26 changes: 18 additions & 8 deletions src/desktop-lite/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,19 @@ check_packages() {
fi
}

find_available_package() {
local candidate
local package_name
for package_name in "$@"; do
candidate="$(apt-cache policy "${package_name}" | awk '/Candidate:/ {print $2}')"
if [ -n "${candidate}" ] && [ "${candidate}" != "(none)" ]; then
echo "${package_name}"
return 0
fi
done
return 1
}

##########################
# Install starts here #
##########################
Expand Down Expand Up @@ -199,15 +212,12 @@ fi
# Install X11, fluxbox and VS Code dependencies
check_packages ${package_list}

# if Ubuntu-24.04, noble(numbat) / Debian-13, trixie found, then will install libasound2-dev instead of libasound2.
# this change is temporary, https://packages.ubuntu.com/noble/libasound2 will switch to libasound2 once it is available for Ubuntu-24.04, noble(numbat)
. /etc/os-release
if { [ "${ID}" = "ubuntu" ] && [ "${VERSION_CODENAME}" = "noble" ]; } || { [ "${ID}" = "debian" ] && [ "${VERSION_CODENAME}" = "trixie" ]; }; then
echo "Detected Noble (Ubuntu 24.04) or Trixie (Debian). Installing libasound2-dev package..."
check_packages "libasound2-dev"
else
check_packages "libasound2"
if ! alsa_package="$(find_available_package libasound2t64 libasound2 libasound2-dev)"; then
echo "(!) No supported ALSA package found. Tried: libasound2, libasound2t64, libasound2-dev." >&2
exit 1
fi
echo "Installing ${alsa_package} package..."
check_packages "${alsa_package}"

# On newer versions of Ubuntu (22.04),
# we need an additional package that isn't provided in earlier versions
Expand Down
33 changes: 33 additions & 0 deletions test/desktop-lite/check_asound_package.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
checkOSPackage() {
PACKAGE_NAME=$1
# Check if the package exists and retrieve its exact version
if [ "$(dpkg-query -W -f='${Status}' "$PACKAGE_NAME" 2>/dev/null | grep -c "ok installed")" -eq 1 ]; then
echo "✅ Package '$PACKAGE_NAME' is installed."
return 0
else
echo "❌ Package '$PACKAGE_NAME' is not installed."
return 1
fi
}

findAvailableOSPackage() {
local candidate
local package_name
for package_name in "$@"; do
candidate="$(apt-cache policy "${package_name}" | awk '/Candidate:/ {print $2}')"
if [ -n "${candidate}" ] && [ "${candidate}" != "(none)" ]; then
echo "${package_name}"
return 0
fi
done
return 1
}

checkAsoundPackage() {
local alsa_package
if ! alsa_package="$(findAvailableOSPackage libasound2 libasound2t64 libasound2-dev)"; then
echo "No supported ALSA package found in apt indexes." >&2
exit 1
fi
check "alsa-package-installed-${alsa_package}" checkOSPackage "${alsa_package}"
}
12 changes: 12 additions & 0 deletions test/desktop-lite/scenarios.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,18 @@
"desktop-lite": {}
}
},
"test_asound_package_ubuntu_2204": {
"image": "ubuntu:22.04",
"features": {
"desktop-lite": {}
}
},
"test_asound_package_ubuntu_2604": {
"image": "ubuntu:26.04",
"features": {
"desktop-lite": {}
}
},
"test_desktop_init_exec_passthrough": {
"image": "ubuntu:noble",
"features": {
Expand Down
22 changes: 3 additions & 19 deletions test/desktop-lite/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,30 +10,14 @@ echoStderr()
echo "$@" 1>&2
}

checkOSPackage() {
LABEL=$1
PACKAGE_NAME=$2
echo -e "\n🧪 Testing $LABEL"
# Check if the package exists and retrieve its exact version
if [ "$(dpkg-query -W -f='${Status}' "$PACKAGE_NAME" 2>/dev/null | grep -c "ok installed")" -eq 1 ]; then
echo "✅ Package '$PACKAGE_NAME' is installed."
exit 0
else
echo "❌ Package '$PACKAGE_NAME' is not installed."
exit 1
fi
}
script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "${script_dir}/check_asound_package.sh"

check "desktop-init-exists" bash -c "ls /usr/local/share/desktop-init.sh"
check "log-exists" bash -c "ls /tmp/container-init.log"
check "fluxbox-exists" bash -c "ls -la ~/.fluxbox"

. /etc/os-release
if [ "${VERSION_CODENAME}" = "noble" ] || [ "${VERSION_CODENAME}" = "trixie" ]; then
checkOSPackage "if libasound2-dev exists !" "libasound2-dev"
else
checkOSPackage "if libasound2 exists !" "libasound2"
fi
checkAsoundPackage

# Report result
reportResults
14 changes: 14 additions & 0 deletions test/desktop-lite/test_asound_package_ubuntu_2204.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash
Comment thread
abdurriq marked this conversation as resolved.
Outdated

set -e

# Optional: Import test library
source dev-container-features-test-lib

script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "${script_dir}/check_asound_package.sh"

checkAsoundPackage

# Report result
reportResults
14 changes: 14 additions & 0 deletions test/desktop-lite/test_asound_package_ubuntu_2604.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash

set -e

# Optional: Import test library
source dev-container-features-test-lib

script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "${script_dir}/check_asound_package.sh"

checkAsoundPackage

# Report result
reportResults
Loading