From aed911c7e9f9f62b6eeab6c1d197209e6ef809a8 Mon Sep 17 00:00:00 2001 From: Jens Nistler Date: Tue, 13 Jan 2026 18:07:48 +0100 Subject: [PATCH 1/2] install ruff from github releases instead of pipx --- src/ruff/README.md | 2 +- src/ruff/devcontainer-feature.json | 9 ++-- src/ruff/install.sh | 9 ++-- src/ruff/library_scripts.sh | 71 +++++++++++++++--------------- 4 files changed, 43 insertions(+), 48 deletions(-) diff --git a/src/ruff/README.md b/src/ruff/README.md index 6c052cea7..03c1e3fc8 100644 --- a/src/ruff/README.md +++ b/src/ruff/README.md @@ -1,5 +1,5 @@ -# Ruff (via pipx) (ruff) +# Ruff (via Github Releases) Ruff is an extremely fast Python linter, written in Rust. diff --git a/src/ruff/devcontainer-feature.json b/src/ruff/devcontainer-feature.json index 4df2188f7..dabdc6702 100644 --- a/src/ruff/devcontainer-feature.json +++ b/src/ruff/devcontainer-feature.json @@ -1,7 +1,7 @@ { "id": "ruff", - "version": "1.1.1", - "name": "Ruff (via pipx)", + "version": "2.0.0", + "name": "Ruff (via Github Releases)", "documentationURL": "http://github.com/devcontainers-extra/features/tree/main/src/ruff", "description": "Ruff is an extremely fast Python linter, written in Rust.", "options": { @@ -21,8 +21,5 @@ ] } }, - "installsAfter": [ - "ghcr.io/devcontainers-extra/features/pipx-package", - "ghcr.io/devcontainers/features/python" - ] + "installsAfter": [] } diff --git a/src/ruff/install.sh b/src/ruff/install.sh index 1c344caae..0f12357b8 100755 --- a/src/ruff/install.sh +++ b/src/ruff/install.sh @@ -8,16 +8,13 @@ set -e # `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.0" +ensure_nanolayer nanolayer_location "v0.5.6" $nanolayer_location \ install \ devcontainer-feature \ - "ghcr.io/devcontainers-extra/features/pipx-package:1.1.8" \ - --option package='ruff' --option version="$VERSION" - - + "ghcr.io/devcontainers-extra/features/gh-release:1" \ + --option repo='astral-sh/ruff' --option binaryNames='ruff' --option version="$VERSION" echo 'Done!' - diff --git a/src/ruff/library_scripts.sh b/src/ruff/library_scripts.sh index 9e1072eca..f6d0760d7 100644 --- a/src/ruff/library_scripts.sh +++ b/src/ruff/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 } - - From 40513914abc022dd1eb3cd41698e823637d811eb Mon Sep 17 00:00:00 2001 From: Jens Nistler Date: Wed, 14 Jan 2026 09:45:10 +0100 Subject: [PATCH 2/2] align with install script from ty --- src/ruff/install.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/ruff/install.sh b/src/ruff/install.sh index 0f12357b8..87b3ec2af 100755 --- a/src/ruff/install.sh +++ b/src/ruff/install.sh @@ -1,7 +1,8 @@ +#!/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 @@ -10,7 +11,7 @@ set -e # of the script ensure_nanolayer nanolayer_location "v0.5.6" - +# Example nanolayer installation via devcontainer-feature $nanolayer_location \ install \ devcontainer-feature \