From df9bc98a435536ba85a85bc7057835328fbe1947 Mon Sep 17 00:00:00 2001 From: patrickcrocker Date: Sun, 2 Nov 2025 21:55:57 +0000 Subject: [PATCH 1/3] fix(btm): improved arch detection and filter out nightly builds - Add dynamic architecture and C library type detection (musl vs gnu) - Add release tag regex to exclude nightly prereleases (fixed downloading latest version) - Update nanolayer version from v0.5.4 to v0.5.6 - Update gh-release dependency from 1.0.25 to 1.0.26 - Update install.sh and library_scripts.sh with latest template folder versions - Add test scenario for specific version (0.11.0) - Bump feature version to 1.0.17 Fixes #15 --- archive/src/btm/devcontainer-feature.json | 2 +- archive/src/btm/install.sh | 35 +++++++++-- archive/src/btm/library_scripts.sh | 71 ++++++++++++----------- archive/test/btm/scenarios.json | 8 +++ archive/test/btm/test_specific_version.sh | 9 +++ 5 files changed, 84 insertions(+), 41 deletions(-) create mode 100644 archive/test/btm/test_specific_version.sh diff --git a/archive/src/btm/devcontainer-feature.json b/archive/src/btm/devcontainer-feature.json index 8e9048345..e384107bd 100644 --- a/archive/src/btm/devcontainer-feature.json +++ b/archive/src/btm/devcontainer-feature.json @@ -1,6 +1,6 @@ { "id": "btm", - "version": "1.0.16", + "version": "1.0.17", "name": "bottom (via Github Releases)", "documentationURL": "http://github.com/devcontainers-extra/features/tree/main/src/btm", "description": "bottom is a customizable cross-platform graphical process/system monitor for the terminal.", diff --git a/archive/src/btm/install.sh b/archive/src/btm/install.sh index 56871f3ba..081aac365 100755 --- a/archive/src/btm/install.sh +++ b/archive/src/btm/install.sh @@ -1,21 +1,46 @@ +#!/usr/bin/env bash set -e -. ./library_scripts.sh +source ./library_scripts.sh # nanolayer is a cli utility which keeps container layers as small as possible # source code: https://github.com/devcontainers-extra/nanolayer # `ensure_nanolayer` is a bash function that will find any existing nanolayer installations, # and if missing - will download a temporary copy that automatically get deleted at the end # of the script -ensure_nanolayer nanolayer_location "v0.5.4" - +ensure_nanolayer nanolayer_location "v0.5.6" + +# Detect C library type +if [ -f "/lib/ld-musl-x86_64.so.1" ] || [ -f "/lib/ld-musl-aarch64.so.1" ]; then + clib_type=musl +else + clib_type=gnu +fi + +# Detect architecture +architecture="$(uname -m)" +case $architecture in + arm64) + arch="aarch64" + ;; + armv7) + clib_type="${clib_type}eabihf" + ;; + *) + arch="$architecture" + ;; +esac +asset_regex="^bottom_${arch}-unknown-linux-${clib_type}\\.tar\\.gz$" + +# Exclude nightly prereleases, only match semantic version tags +release_tag_regex="^(?!.*nightly)[0-9]+\\.[0-9]+\\.[0-9]+$" $nanolayer_location \ install \ devcontainer-feature \ - "ghcr.io/devcontainers-extra/features/gh-release:1.0.25" \ - --option repo='ClementTsang/bottom' --option binaryNames='btm' --option version="$VERSION" --option assetRegex='^(?!.*(2-17))' + "ghcr.io/devcontainers-extra/features/gh-release:1" \ + --option repo='ClementTsang/bottom' --option binaryNames='btm' --option version="$VERSION" --option assetRegex="$asset_regex" --option releaseTagRegex="$release_tag_regex" diff --git a/archive/src/btm/library_scripts.sh b/archive/src/btm/library_scripts.sh index 9e1072eca..f6d0760d7 100644 --- a/archive/src/btm/library_scripts.sh +++ b/archive/src/btm/library_scripts.sh @@ -1,4 +1,4 @@ - +#!/usr/bin/env bash clean_download() { # The purpose of this function is to download a file with minimal impact on container layer size @@ -15,7 +15,7 @@ clean_download() { tempdir=$(mktemp -d) downloader_installed="" - _apt_get_install() { + function _apt_get_install() { tempdir=$1 # copy current state of apt list - in order to revert back later (minimize contianer layer size) @@ -24,7 +24,7 @@ clean_download() { apt-get -y install --no-install-recommends wget ca-certificates } - _apt_get_cleanup() { + function _apt_get_cleanup() { tempdir=$1 echo "removing wget" @@ -35,15 +35,15 @@ clean_download() { rm -r /var/lib/apt/lists && mv $tempdir/lists /var/lib/apt/lists } - _apk_install() { + function _apk_install() { tempdir=$1 # copy current state of apk cache - in order to revert back later (minimize contianer layer size) cp -p -R /var/cache/apk $tempdir - apk add --no-cache wget + apk add --no-cache wget } - _apk_cleanup() { + function _apk_cleanup() { tempdir=$1 echo "removing wget" @@ -59,10 +59,10 @@ clean_download() { fi # in case none of them is installed, install wget temporarly - if [ -z $downloader ] ; then - if [ -x "/usr/bin/apt-get" ] ; then + if [ -z $downloader ]; then + if [ -x "/usr/bin/apt-get" ]; then _apt_get_install $tempdir - elif [ -x "/sbin/apk" ] ; then + elif [ -x "/sbin/apk" ]; then _apk_install $tempdir else echo "distro not supported" @@ -72,7 +72,7 @@ clean_download() { downloader_installed="true" fi - if [ $downloader = "wget" ] ; then + if [ $downloader = "wget" ]; then wget -q $url -O $output_location else curl -sfL $url -o $output_location @@ -80,10 +80,10 @@ clean_download() { # NOTE: the cleanup procedure was not implemented using `trap X RETURN` only because # alpine lack bash, and RETURN is not a valid signal under sh shell - if ! [ -z $downloader_installed ] ; then - if [ -x "/usr/bin/apt-get" ] ; then + if ! [ -z $downloader_installed ]; then + if [ -x "/usr/bin/apt-get" ]; then _apt_get_cleanup $tempdir - elif [ -x "/sbin/apk" ] ; then + elif [ -x "/sbin/apk" ]; then _apk_cleanup $tempdir else echo "distro not supported" @@ -93,56 +93,60 @@ clean_download() { } - ensure_nanolayer() { # Ensure existance of the nanolayer cli program local variable_name=$1 local required_version=$2 + # normalize version + if ! [[ $required_version == v* ]]; then + required_version=v$required_version + fi - local __nanolayer_location="" + local nanolayer_location="" # If possible - try to use an already installed nanolayer - if [ -z "${NANOLAYER_FORCE_CLI_INSTALLATION}" ]; then - if [ -z "${NANOLAYER_CLI_LOCATION}" ]; then + if [[ -z "${NANOLAYER_FORCE_CLI_INSTALLATION}" ]]; then + if [[ -z "${NANOLAYER_CLI_LOCATION}" ]]; then if type nanolayer >/dev/null 2>&1; then echo "Found a pre-existing nanolayer in PATH" - __nanolayer_location=nanolayer + nanolayer_location=nanolayer fi - elif [ -f "${NANOLAYER_CLI_LOCATION}" ] && [ -x "${NANOLAYER_CLI_LOCATION}" ] ; then - __nanolayer_location=${NANOLAYER_CLI_LOCATION} - echo "Found a pre-existing nanolayer which were given in env variable: $__nanolayer_location" + elif [ -f "${NANOLAYER_CLI_LOCATION}" ] && [ -x "${NANOLAYER_CLI_LOCATION}" ]; then + nanolayer_location=${NANOLAYER_CLI_LOCATION} + echo "Found a pre-existing nanolayer which were given in env variable: $nanolayer_location" fi # make sure its of the required version - if ! [ -z "${__nanolayer_location}" ]; then + if ! [[ -z "${nanolayer_location}" ]]; then local current_version - current_version=$($__nanolayer_location --version) - + current_version=$($nanolayer_location --version) + if ! [[ $current_version == v* ]]; then + current_version=v$current_version + fi if ! [ $current_version == $required_version ]; then echo "skipping usage of pre-existing nanolayer. (required version $required_version does not match existing version $current_version)" - __nanolayer_location="" + nanolayer_location="" fi fi fi # If not previuse installation found, download it temporarly and delete at the end of the script - if [ -z "${__nanolayer_location}" ]; then + if [[ -z "${nanolayer_location}" ]]; then - if [ "$(uname -sm)" = 'Linux x86_64' ] || [ "$(uname -sm)" = "Linux aarch64" ]; then + if [ "$(uname -sm)" == "Linux x86_64" ] || [ "$(uname -sm)" == "Linux aarch64" ]; then tmp_dir=$(mktemp -d -t nanolayer-XXXXXXXXXX) - clean_up () { + clean_up() { ARG=$? rm -rf $tmp_dir exit $ARG } trap clean_up EXIT - - if [ -x "/sbin/apk" ] ; then + if [ -x "/sbin/apk" ]; then clib_type=musl else clib_type=gnu @@ -155,8 +159,7 @@ ensure_nanolayer() { tar xfzv $tmp_dir/$tar_filename -C "$tmp_dir" chmod a+x $tmp_dir/nanolayer - __nanolayer_location=$tmp_dir/nanolayer - + nanolayer_location=$tmp_dir/nanolayer else echo "No binaries compiled for non-x86-linux architectures yet: $(uname -m)" @@ -165,8 +168,6 @@ ensure_nanolayer() { fi # Expose outside the resolved location - export ${variable_name}=$__nanolayer_location + declare -g ${variable_name}=$nanolayer_location } - - diff --git a/archive/test/btm/scenarios.json b/archive/test/btm/scenarios.json index 56389dc03..88b24d836 100644 --- a/archive/test/btm/scenarios.json +++ b/archive/test/btm/scenarios.json @@ -4,5 +4,13 @@ "features": { "btm": {} } + }, + "test_specific_version": { + "image": "mcr.microsoft.com/devcontainers/base:debian", + "features": { + "btm": { + "version": "0.11.0" + } + } } } \ No newline at end of file diff --git a/archive/test/btm/test_specific_version.sh b/archive/test/btm/test_specific_version.sh new file mode 100644 index 000000000..2476ea3a8 --- /dev/null +++ b/archive/test/btm/test_specific_version.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env bash + +set -e + +source dev-container-features-test-lib + +check "btm version is equal to 0.11.0" sh -c "btm --version | grep '0.11.0'" + +reportResults From 0122ed86c7a2b748482416f9475ffe5622eb490a Mon Sep 17 00:00:00 2001 From: patrickcrocker Date: Sun, 2 Nov 2025 21:58:34 +0000 Subject: [PATCH 2/3] fix(btm): pin gh-release feature to version 1.0.26 Fixes #15 --- archive/src/btm/install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/archive/src/btm/install.sh b/archive/src/btm/install.sh index 081aac365..b6cc158ad 100755 --- a/archive/src/btm/install.sh +++ b/archive/src/btm/install.sh @@ -39,7 +39,7 @@ release_tag_regex="^(?!.*nightly)[0-9]+\\.[0-9]+\\.[0-9]+$" $nanolayer_location \ install \ devcontainer-feature \ - "ghcr.io/devcontainers-extra/features/gh-release:1" \ + "ghcr.io/devcontainers-extra/features/gh-release:1.0.26" \ --option repo='ClementTsang/bottom' --option binaryNames='btm' --option version="$VERSION" --option assetRegex="$asset_regex" --option releaseTagRegex="$release_tag_regex" From 456e220c40d4d7e44202609eb6c726a54e0a7c95 Mon Sep 17 00:00:00 2001 From: patrickcrocker Date: Fri, 7 Nov 2025 15:26:59 +0000 Subject: [PATCH 3/3] fix(btm): unarchived btm feature Fixes #15 --- {archive/src => src}/btm/README.md | 0 {archive/src => src}/btm/devcontainer-feature.json | 0 {archive/src => src}/btm/install.sh | 0 {archive/src => src}/btm/library_scripts.sh | 0 {archive/test => test}/btm/scenarios.json | 0 {archive/test => test}/btm/test_defaults_debian.sh | 0 {archive/test => test}/btm/test_specific_version.sh | 0 7 files changed, 0 insertions(+), 0 deletions(-) rename {archive/src => src}/btm/README.md (100%) rename {archive/src => src}/btm/devcontainer-feature.json (100%) rename {archive/src => src}/btm/install.sh (100%) rename {archive/src => src}/btm/library_scripts.sh (100%) rename {archive/test => test}/btm/scenarios.json (100%) rename {archive/test => test}/btm/test_defaults_debian.sh (100%) rename {archive/test => test}/btm/test_specific_version.sh (100%) diff --git a/archive/src/btm/README.md b/src/btm/README.md similarity index 100% rename from archive/src/btm/README.md rename to src/btm/README.md diff --git a/archive/src/btm/devcontainer-feature.json b/src/btm/devcontainer-feature.json similarity index 100% rename from archive/src/btm/devcontainer-feature.json rename to src/btm/devcontainer-feature.json diff --git a/archive/src/btm/install.sh b/src/btm/install.sh similarity index 100% rename from archive/src/btm/install.sh rename to src/btm/install.sh diff --git a/archive/src/btm/library_scripts.sh b/src/btm/library_scripts.sh similarity index 100% rename from archive/src/btm/library_scripts.sh rename to src/btm/library_scripts.sh diff --git a/archive/test/btm/scenarios.json b/test/btm/scenarios.json similarity index 100% rename from archive/test/btm/scenarios.json rename to test/btm/scenarios.json diff --git a/archive/test/btm/test_defaults_debian.sh b/test/btm/test_defaults_debian.sh similarity index 100% rename from archive/test/btm/test_defaults_debian.sh rename to test/btm/test_defaults_debian.sh diff --git a/archive/test/btm/test_specific_version.sh b/test/btm/test_specific_version.sh similarity index 100% rename from archive/test/btm/test_specific_version.sh rename to test/btm/test_specific_version.sh