diff --git a/.rwx/mint-utils.sh b/.rwx/mint-utils.sh deleted file mode 100755 index 97d280c..0000000 --- a/.rwx/mint-utils.sh +++ /dev/null @@ -1,115 +0,0 @@ -#!/usr/bin/env bash -# mint-utils version 1.0.4 - -detected_os="" -detected_os_version="" -detected_os_codename="" -detected_arch="" -detected_package_manager="" - -function mint__detect_os_arch { - if [ -f /etc/os-release ]; then - . /etc/os-release - - detected_os="$ID" - detected_os_version="$VERSION_ID" - detected_os_codename="$VERSION_CODENAME" - - case "$ID" in - ubuntu|debian) - detected_package_manager="apt" - ;; - esac - fi - - detected_arch=$(uname -m) -} - -function mint_os_name { - if [ -z "$detected_os" ]; then - mint__detect_os_arch - fi - echo "$detected_os" -} - -function mint_os_version { - if [ -z "$detected_os_version" ]; then - mint__detect_os_arch - fi - echo "$detected_os_version" -} - -# Output the name and version of the operating system as expected by Mint's `base.os` field. -function mint_os_name_version { - echo "$(mint_os_name) $(mint_os_version)" -} - -function mint_os_codename { - if [ -z "$detected_os_codename" ]; then - mint__detect_os_arch - fi - echo "$detected_os_codename" -} - -function mint_arch { - if [ -z "$detected_arch" ]; then - mint__detect_os_arch - fi - echo "$detected_arch" -} - -function mint_arch_amd { - local arch - arch="$(mint_arch)" - if [ "$arch" = "x86_64" ]; then - echo "amd64" - else - echo "$arch" - fi -} - -function mint_os_package_manager { - if [ -z "$detected_package_manager" ]; then - mint__detect_os_arch - fi - echo "$detected_package_manager" -} - -function mint_os_version_gte { - local compare_version="$1" - printf '%s\n' "$compare_version" "$(mint_os_version)" | sort -Vsc >/dev/null 2>&1 -} - -function mint_os_version_lte { - local compare_version="$1" - printf '%s\n' "$compare_version" "$(mint_os_version)" | sort -Vsc -r >/dev/null 2>&1 -} - -# Convert a string something usable as a Mint key. -# -# Replaces all non-alphanumeric characters with hyphens, compressing multiple hyphens into one. -function mint_keyify { - echo -n "$*" | tr -c -s '[:alnum:]' '-' -} - -# Check if an array contains a given element. -# -# Usage: mint_contains two one two three -function mint_contains { - local needle="$1" - local elements=("${@:2}") - for item in "${elements[@]}"; do - if [ "$item" = "$needle" ]; then - return 0 - fi - done - return 1 -} - -function mint_os_name_in { - mint_contains "$(mint_os_name)" "$@" -} - -function mint_os_package_manager_in { - mint_contains "$(mint_os_package_manager)" "$@" -} diff --git a/aws/install-cli/README.md b/aws/install-cli/README.md index c3061c7..34d836d 100644 --- a/aws/install-cli/README.md +++ b/aws/install-cli/README.md @@ -5,7 +5,7 @@ To install the latest version of the AWS CLI: ```yaml tasks: - key: aws-cli - call: aws/install-cli 1.0.8 + call: aws/install-cli 1.0.9 ``` To install a specific version of the AWS CLI (only v2 of the AWS CLI is supported): @@ -13,7 +13,7 @@ To install a specific version of the AWS CLI (only v2 of the AWS CLI is supporte ```yaml tasks: - key: aws-cli - call: aws/install-cli 1.0.8 + call: aws/install-cli 1.0.9 with: cli-version: "2.15.13" ``` diff --git a/aws/install-cli/mint-utils.sh b/aws/install-cli/mint-utils.sh deleted file mode 100755 index 725ee83..0000000 --- a/aws/install-cli/mint-utils.sh +++ /dev/null @@ -1,111 +0,0 @@ -#!/usr/bin/env bash -# mint-utils version 1.0.3 - -detected_os="" -detected_os_version="" -detected_os_codename="" -detected_arch="" -detected_package_manager="" - -function mint__detect_os_arch { - if [ -f /etc/os-release ]; then - . /etc/os-release - - detected_os="$ID" - detected_os_version="$VERSION_ID" - detected_os_codename="$VERSION_CODENAME" - - case "$ID" in - ubuntu|debian) - detected_package_manager="apt" - ;; - esac - fi - - detected_arch=$(uname -m) -} - -function mint_os_name { - if [ -z "$detected_os" ]; then - mint__detect_os_arch - fi - echo "$detected_os" -} - -function mint_os_version { - if [ -z "$detected_os_version" ]; then - mint__detect_os_arch - fi - echo "$detected_os_version" -} - -# Output the name and version of the operating system as expected by Mint's `base.os` field. -function mint_os_name_version { - echo "$(mint_os_name) $(mint_os_version)" -} - -function mint_os_codename { - if [ -z "$detected_os_codename" ]; then - mint__detect_os_arch - fi - echo "$detected_os_codename" -} - -function mint_arch { - if [ -z "$detected_arch" ]; then - mint__detect_os_arch - fi - echo "$detected_arch" -} - -function mint_arch_amd { - local arch - arch="$(mint_arch)" - if [ "$arch" = "x86_64" ]; then - echo "amd64" - else - echo "$arch" - fi -} - -function mint_os_package_manager { - if [ -z "$detected_package_manager" ]; then - mint__detect_os_arch - fi - echo "$detected_package_manager" -} - -function mint_os_version_gte { - local compare_version="$1" - printf '%s\n' "$compare_version" "$(mint_os_version)" | sort -Vsc >/dev/null 2>&1 -} - -function mint_os_version_lte { - local compare_version="$1" - printf '%s\n' "$compare_version" "$(mint_os_version)" | sort -Vsc -r >/dev/null 2>&1 -} - -# Convert a string something usable as a Mint key. -# -# Replaces all non-alphanumeric characters with hyphens, compressing multiple hyphens into one. -function mint_keyify { - echo -n "$*" | tr -c -s '[:alnum:]' '-' -} - -# Check if an array contains a given element. -# -# Usage: mint_contains two one two three -function mint_contains { - local needle="$1" - local elements=("${@:2}") - for item in "${elements[@]}"; do - if [ "$item" = "$needle" ]; then - return 0 - fi - done - return 1 -} - -function mint_os_package_manager_in { - mint_contains "$(mint_os_package_manager)" "$@" -} diff --git a/aws/install-cli/rwx-package.yml b/aws/install-cli/rwx-package.yml index 9e3426e..4f49d87 100644 --- a/aws/install-cli/rwx-package.yml +++ b/aws/install-cli/rwx-package.yml @@ -1,5 +1,5 @@ name: aws/install-cli -version: 1.0.8 +version: 1.0.9 description: Install the AWS CLI source_code_url: https://github.com/rwx-cloud/packages/tree/main/aws/install-cli issue_tracker_url: https://github.com/rwx-cloud/packages/issues @@ -13,9 +13,9 @@ tasks: - key: install-unzip-if-necessary run: | if ! command -v unzip &> /dev/null; then - source "$RWX_PACKAGE_PATH/mint-utils.sh" - if ! mint_os_package_manager_in apt; then - echo "Unsupported operating system or package manager \`$(mint_os_package_manager)\`" > "$(mktemp "$RWX_ERRORS/error-XXXX")" + source "$RWX_PACKAGE_PATH/rwx-utils.sh" + if ! rwx_os_package_manager_in apt; then + echo "Unsupported operating system or package manager \`$(rwx_os_package_manager)\`" > "$(mktemp "$RWX_ERRORS/error-XXXX")" exit 1 fi @@ -27,9 +27,9 @@ tasks: - key: install-gpg-if-necessary run: | if ! command -v gpg &> /dev/null; then - source "$RWX_PACKAGE_PATH/mint-utils.sh" - if ! mint_os_package_manager_in apt; then - echo "Unsupported operating system or package manager \`$(mint_os_package_manager)\`" > "$(mktemp "$RWX_ERRORS/error-XXXX")" + source "$RWX_PACKAGE_PATH/rwx-utils.sh" + if ! rwx_os_package_manager_in apt; then + echo "Unsupported operating system or package manager \`$(rwx_os_package_manager)\`" > "$(mktemp "$RWX_ERRORS/error-XXXX")" exit 1 fi diff --git a/aws/install-cli/rwx-utils.sh b/aws/install-cli/rwx-utils.sh new file mode 100755 index 0000000..7e906ff --- /dev/null +++ b/aws/install-cli/rwx-utils.sh @@ -0,0 +1,137 @@ +#!/bin/sh +# rwx-utils version 2.0.1 + +detected_os="" +detected_os_version="" +detected_os_codename="" +detected_arch="" +detected_package_manager="" + +rwx__detect_os_arch() { + if [ -f /etc/os-release ]; then + . /etc/os-release + + detected_os="$ID" + detected_os_version="$VERSION_ID" + detected_os_codename="$VERSION_CODENAME" + + case "$ID" in + ubuntu|debian) + detected_package_manager="apt" + ;; + alpine) + detected_package_manager="apk" + ;; + esac + fi + + detected_arch=$(uname -m) +} + +rwx_os_name() { + if [ -z "$detected_os" ]; then + rwx__detect_os_arch + fi + printf '%s\n' "$detected_os" +} + +rwx_os_version() { + if [ -z "$detected_os_version" ]; then + rwx__detect_os_arch + fi + printf '%s\n' "$detected_os_version" +} + +# Output the name and version of the operating system as expected by RWX's `base.os` field. +rwx_os_name_version() { + printf '%s %s\n' "$(rwx_os_name)" "$(rwx_os_version)" +} + +rwx_os_codename() { + if [ -z "$detected_os_codename" ]; then + rwx__detect_os_arch + fi + printf '%s\n' "$detected_os_codename" +} + +rwx_arch() { + if [ -z "$detected_arch" ]; then + rwx__detect_os_arch + fi + printf '%s\n' "$detected_arch" +} + +rwx_arch_amd() { + arch="$(rwx_arch)" + if [ "$arch" = "x86_64" ]; then + printf '%s\n' "amd64" + else + printf '%s\n' "$arch" + fi +} + +rwx_os_package_manager() { + if [ -z "$detected_package_manager" ]; then + rwx__detect_os_arch + fi + printf '%s\n' "$detected_package_manager" +} + +rwx_os_version_gte() { + compare_version="$1" + printf '%s\n' "$compare_version" "$(rwx_os_version)" | sed 's/\([0-9.]*\).*/\1/' | sort -c -t. -k1,1n -k2,2n -k3,3n >/dev/null 2>&1 +} + +rwx_os_version_lte() { + compare_version="$1" + printf '%s\n' "$(rwx_os_version)" "$compare_version" | sed 's/\([0-9.]*\).*/\1/' | sort -c -t. -k1,1n -k2,2n -k3,3n >/dev/null 2>&1 +} + +# Convert a string something usable as a RWX key. +# +# Replaces all non-alphanumeric characters with hyphens, compressing multiple hyphens into one. +rwx_keyify() { + printf '%s' "$*" | tr -c -s '[:alnum:]' '-' +} + +# Check if the provided list contains a given element. +# +# Usage: rwx_contains two one two three +rwx_contains() { + if [ "$#" -eq 0 ]; then + return 1 + fi + + needle=$1 + shift + + for item do + if [ "$item" = "$needle" ]; then + return 0 + fi + done + + return 1 +} + +rwx_os_name_in() { + rwx_contains "$(rwx_os_name)" "$@" +} + +rwx_os_package_manager_in() { + rwx_contains "$(rwx_os_package_manager)" "$@" +} + +rwx_maybe_sudo() { + if [ "$(id -u)" -eq 0 ]; then + "$@" + else + # If sudo is available, use it + if command -v sudo >/dev/null 2>&1; then + sudo "$@" + else + echo "Error: need root privileges but 'sudo' not found" >&2 + return 1 + fi + fi +} diff --git a/azure/install-cli/README.md b/azure/install-cli/README.md index 87186a3..556d468 100644 --- a/azure/install-cli/README.md +++ b/azure/install-cli/README.md @@ -5,7 +5,7 @@ To install the latest version of the Azure CLI: ```yaml tasks: - key: azure-cli - call: azure/install-cli 1.0.8 + call: azure/install-cli 1.0.9 ``` To install a specific version of the Azure CLI: @@ -13,7 +13,7 @@ To install a specific version of the Azure CLI: ```yaml tasks: - key: azure-cli - call: azure/install-cli 1.0.8 + call: azure/install-cli 1.0.9 with: version: "2.65.0" ``` diff --git a/azure/install-cli/mint-utils.sh b/azure/install-cli/mint-utils.sh deleted file mode 100755 index 725ee83..0000000 --- a/azure/install-cli/mint-utils.sh +++ /dev/null @@ -1,111 +0,0 @@ -#!/usr/bin/env bash -# mint-utils version 1.0.3 - -detected_os="" -detected_os_version="" -detected_os_codename="" -detected_arch="" -detected_package_manager="" - -function mint__detect_os_arch { - if [ -f /etc/os-release ]; then - . /etc/os-release - - detected_os="$ID" - detected_os_version="$VERSION_ID" - detected_os_codename="$VERSION_CODENAME" - - case "$ID" in - ubuntu|debian) - detected_package_manager="apt" - ;; - esac - fi - - detected_arch=$(uname -m) -} - -function mint_os_name { - if [ -z "$detected_os" ]; then - mint__detect_os_arch - fi - echo "$detected_os" -} - -function mint_os_version { - if [ -z "$detected_os_version" ]; then - mint__detect_os_arch - fi - echo "$detected_os_version" -} - -# Output the name and version of the operating system as expected by Mint's `base.os` field. -function mint_os_name_version { - echo "$(mint_os_name) $(mint_os_version)" -} - -function mint_os_codename { - if [ -z "$detected_os_codename" ]; then - mint__detect_os_arch - fi - echo "$detected_os_codename" -} - -function mint_arch { - if [ -z "$detected_arch" ]; then - mint__detect_os_arch - fi - echo "$detected_arch" -} - -function mint_arch_amd { - local arch - arch="$(mint_arch)" - if [ "$arch" = "x86_64" ]; then - echo "amd64" - else - echo "$arch" - fi -} - -function mint_os_package_manager { - if [ -z "$detected_package_manager" ]; then - mint__detect_os_arch - fi - echo "$detected_package_manager" -} - -function mint_os_version_gte { - local compare_version="$1" - printf '%s\n' "$compare_version" "$(mint_os_version)" | sort -Vsc >/dev/null 2>&1 -} - -function mint_os_version_lte { - local compare_version="$1" - printf '%s\n' "$compare_version" "$(mint_os_version)" | sort -Vsc -r >/dev/null 2>&1 -} - -# Convert a string something usable as a Mint key. -# -# Replaces all non-alphanumeric characters with hyphens, compressing multiple hyphens into one. -function mint_keyify { - echo -n "$*" | tr -c -s '[:alnum:]' '-' -} - -# Check if an array contains a given element. -# -# Usage: mint_contains two one two three -function mint_contains { - local needle="$1" - local elements=("${@:2}") - for item in "${elements[@]}"; do - if [ "$item" = "$needle" ]; then - return 0 - fi - done - return 1 -} - -function mint_os_package_manager_in { - mint_contains "$(mint_os_package_manager)" "$@" -} diff --git a/azure/install-cli/rwx-package.yml b/azure/install-cli/rwx-package.yml index d013671..b94e672 100644 --- a/azure/install-cli/rwx-package.yml +++ b/azure/install-cli/rwx-package.yml @@ -1,5 +1,5 @@ name: azure/install-cli -version: 1.0.8 +version: 1.0.9 description: Install the Azure CLI source_code_url: https://github.com/rwx-cloud/packages/tree/main/azure/install-cli issue_tracker_url: https://github.com/rwx-cloud/packages/issues @@ -14,9 +14,9 @@ tasks: run: | # https://learn.microsoft.com/en-us/cli/azure/install-azure-cli-linux?pivots=apt#option-2-step-by-step-installation-instructions - source "$RWX_PACKAGE_PATH/mint-utils.sh" - if ! mint_os_package_manager_in apt; then - echo "Unsupported operating system or package manager \`$(mint_os_package_manager)\`" > "$(mktemp "$RWX_ERRORS/error-XXXX")" + source "$RWX_PACKAGE_PATH/rwx-utils.sh" + if ! rwx_os_package_manager_in apt; then + echo "Unsupported operating system or package manager \`$(rwx_os_package_manager)\`" > "$(mktemp "$RWX_ERRORS/error-XXXX")" exit 1 fi diff --git a/azure/install-cli/rwx-utils.sh b/azure/install-cli/rwx-utils.sh new file mode 100755 index 0000000..7e906ff --- /dev/null +++ b/azure/install-cli/rwx-utils.sh @@ -0,0 +1,137 @@ +#!/bin/sh +# rwx-utils version 2.0.1 + +detected_os="" +detected_os_version="" +detected_os_codename="" +detected_arch="" +detected_package_manager="" + +rwx__detect_os_arch() { + if [ -f /etc/os-release ]; then + . /etc/os-release + + detected_os="$ID" + detected_os_version="$VERSION_ID" + detected_os_codename="$VERSION_CODENAME" + + case "$ID" in + ubuntu|debian) + detected_package_manager="apt" + ;; + alpine) + detected_package_manager="apk" + ;; + esac + fi + + detected_arch=$(uname -m) +} + +rwx_os_name() { + if [ -z "$detected_os" ]; then + rwx__detect_os_arch + fi + printf '%s\n' "$detected_os" +} + +rwx_os_version() { + if [ -z "$detected_os_version" ]; then + rwx__detect_os_arch + fi + printf '%s\n' "$detected_os_version" +} + +# Output the name and version of the operating system as expected by RWX's `base.os` field. +rwx_os_name_version() { + printf '%s %s\n' "$(rwx_os_name)" "$(rwx_os_version)" +} + +rwx_os_codename() { + if [ -z "$detected_os_codename" ]; then + rwx__detect_os_arch + fi + printf '%s\n' "$detected_os_codename" +} + +rwx_arch() { + if [ -z "$detected_arch" ]; then + rwx__detect_os_arch + fi + printf '%s\n' "$detected_arch" +} + +rwx_arch_amd() { + arch="$(rwx_arch)" + if [ "$arch" = "x86_64" ]; then + printf '%s\n' "amd64" + else + printf '%s\n' "$arch" + fi +} + +rwx_os_package_manager() { + if [ -z "$detected_package_manager" ]; then + rwx__detect_os_arch + fi + printf '%s\n' "$detected_package_manager" +} + +rwx_os_version_gte() { + compare_version="$1" + printf '%s\n' "$compare_version" "$(rwx_os_version)" | sed 's/\([0-9.]*\).*/\1/' | sort -c -t. -k1,1n -k2,2n -k3,3n >/dev/null 2>&1 +} + +rwx_os_version_lte() { + compare_version="$1" + printf '%s\n' "$(rwx_os_version)" "$compare_version" | sed 's/\([0-9.]*\).*/\1/' | sort -c -t. -k1,1n -k2,2n -k3,3n >/dev/null 2>&1 +} + +# Convert a string something usable as a RWX key. +# +# Replaces all non-alphanumeric characters with hyphens, compressing multiple hyphens into one. +rwx_keyify() { + printf '%s' "$*" | tr -c -s '[:alnum:]' '-' +} + +# Check if the provided list contains a given element. +# +# Usage: rwx_contains two one two three +rwx_contains() { + if [ "$#" -eq 0 ]; then + return 1 + fi + + needle=$1 + shift + + for item do + if [ "$item" = "$needle" ]; then + return 0 + fi + done + + return 1 +} + +rwx_os_name_in() { + rwx_contains "$(rwx_os_name)" "$@" +} + +rwx_os_package_manager_in() { + rwx_contains "$(rwx_os_package_manager)" "$@" +} + +rwx_maybe_sudo() { + if [ "$(id -u)" -eq 0 ]; then + "$@" + else + # If sudo is available, use it + if command -v sudo >/dev/null 2>&1; then + sudo "$@" + else + echo "Error: need root privileges but 'sudo' not found" >&2 + return 1 + fi + fi +} diff --git a/erlang/install/README.md b/erlang/install/README.md index a647565..8dbd71b 100644 --- a/erlang/install/README.md +++ b/erlang/install/README.md @@ -5,7 +5,7 @@ To install Erlang: ```yaml tasks: - key: erlang - call: erlang/install 1.1.1 + call: erlang/install 1.1.2 with: erlang-version: 28.1 ``` diff --git a/erlang/install/mint-utils.sh b/erlang/install/mint-utils.sh deleted file mode 100755 index 725ee83..0000000 --- a/erlang/install/mint-utils.sh +++ /dev/null @@ -1,111 +0,0 @@ -#!/usr/bin/env bash -# mint-utils version 1.0.3 - -detected_os="" -detected_os_version="" -detected_os_codename="" -detected_arch="" -detected_package_manager="" - -function mint__detect_os_arch { - if [ -f /etc/os-release ]; then - . /etc/os-release - - detected_os="$ID" - detected_os_version="$VERSION_ID" - detected_os_codename="$VERSION_CODENAME" - - case "$ID" in - ubuntu|debian) - detected_package_manager="apt" - ;; - esac - fi - - detected_arch=$(uname -m) -} - -function mint_os_name { - if [ -z "$detected_os" ]; then - mint__detect_os_arch - fi - echo "$detected_os" -} - -function mint_os_version { - if [ -z "$detected_os_version" ]; then - mint__detect_os_arch - fi - echo "$detected_os_version" -} - -# Output the name and version of the operating system as expected by Mint's `base.os` field. -function mint_os_name_version { - echo "$(mint_os_name) $(mint_os_version)" -} - -function mint_os_codename { - if [ -z "$detected_os_codename" ]; then - mint__detect_os_arch - fi - echo "$detected_os_codename" -} - -function mint_arch { - if [ -z "$detected_arch" ]; then - mint__detect_os_arch - fi - echo "$detected_arch" -} - -function mint_arch_amd { - local arch - arch="$(mint_arch)" - if [ "$arch" = "x86_64" ]; then - echo "amd64" - else - echo "$arch" - fi -} - -function mint_os_package_manager { - if [ -z "$detected_package_manager" ]; then - mint__detect_os_arch - fi - echo "$detected_package_manager" -} - -function mint_os_version_gte { - local compare_version="$1" - printf '%s\n' "$compare_version" "$(mint_os_version)" | sort -Vsc >/dev/null 2>&1 -} - -function mint_os_version_lte { - local compare_version="$1" - printf '%s\n' "$compare_version" "$(mint_os_version)" | sort -Vsc -r >/dev/null 2>&1 -} - -# Convert a string something usable as a Mint key. -# -# Replaces all non-alphanumeric characters with hyphens, compressing multiple hyphens into one. -function mint_keyify { - echo -n "$*" | tr -c -s '[:alnum:]' '-' -} - -# Check if an array contains a given element. -# -# Usage: mint_contains two one two three -function mint_contains { - local needle="$1" - local elements=("${@:2}") - for item in "${elements[@]}"; do - if [ "$item" = "$needle" ]; then - return 0 - fi - done - return 1 -} - -function mint_os_package_manager_in { - mint_contains "$(mint_os_package_manager)" "$@" -} diff --git a/erlang/install/rwx-package.yml b/erlang/install/rwx-package.yml index af749ff..96f859a 100644 --- a/erlang/install/rwx-package.yml +++ b/erlang/install/rwx-package.yml @@ -1,5 +1,5 @@ name: erlang/install -version: 1.1.1 +version: 1.1.2 description: Install Erlang, a programming language used to build massively scalable soft real-time systems with requirements on high availability source_code_url: https://github.com/rwx-cloud/packages/tree/main/erlang/install issue_tracker_url: https://github.com/rwx-cloud/packages/issues @@ -12,13 +12,13 @@ parameters: tasks: - key: install run: | - source "$RWX_PACKAGE_PATH/mint-utils.sh" - if [ "$(mint_os_name)" != "ubuntu" ]; then - echo "Unsupported operating system \`$(mint_os_name)\`" | tee "$(mktemp "$RWX_ERRORS/error-XXXX")" + source "$RWX_PACKAGE_PATH/rwx-utils.sh" + if [ "$(rwx_os_name)" != "ubuntu" ]; then + echo "Unsupported operating system \`$(rwx_os_name)\`" | tee "$(mktemp "$RWX_ERRORS/error-XXXX")" exit 1 fi - if mint_os_version_gte 24.04; then + if rwx_os_version_gte 24.04; then ncurses_package="libncurses6" else ncurses_package="libncurses5" @@ -28,9 +28,9 @@ tasks: sudo apt-get install libsctp1 "$ncurses_package" sudo apt-get clean - OTP_OS=$(mint_os_name) - OTP_OS_VERSION=$(mint_os_version) - OTP_ARCH=$(mint_arch_amd) + OTP_OS=$(rwx_os_name) + OTP_OS_VERSION=$(rwx_os_version) + OTP_ARCH=$(rwx_arch_amd) if [ "$OTP_ARCH" == "aarch64" ]; then OTP_ARCH="arm64" fi diff --git a/erlang/install/rwx-utils.sh b/erlang/install/rwx-utils.sh new file mode 100755 index 0000000..7e906ff --- /dev/null +++ b/erlang/install/rwx-utils.sh @@ -0,0 +1,137 @@ +#!/bin/sh +# rwx-utils version 2.0.1 + +detected_os="" +detected_os_version="" +detected_os_codename="" +detected_arch="" +detected_package_manager="" + +rwx__detect_os_arch() { + if [ -f /etc/os-release ]; then + . /etc/os-release + + detected_os="$ID" + detected_os_version="$VERSION_ID" + detected_os_codename="$VERSION_CODENAME" + + case "$ID" in + ubuntu|debian) + detected_package_manager="apt" + ;; + alpine) + detected_package_manager="apk" + ;; + esac + fi + + detected_arch=$(uname -m) +} + +rwx_os_name() { + if [ -z "$detected_os" ]; then + rwx__detect_os_arch + fi + printf '%s\n' "$detected_os" +} + +rwx_os_version() { + if [ -z "$detected_os_version" ]; then + rwx__detect_os_arch + fi + printf '%s\n' "$detected_os_version" +} + +# Output the name and version of the operating system as expected by RWX's `base.os` field. +rwx_os_name_version() { + printf '%s %s\n' "$(rwx_os_name)" "$(rwx_os_version)" +} + +rwx_os_codename() { + if [ -z "$detected_os_codename" ]; then + rwx__detect_os_arch + fi + printf '%s\n' "$detected_os_codename" +} + +rwx_arch() { + if [ -z "$detected_arch" ]; then + rwx__detect_os_arch + fi + printf '%s\n' "$detected_arch" +} + +rwx_arch_amd() { + arch="$(rwx_arch)" + if [ "$arch" = "x86_64" ]; then + printf '%s\n' "amd64" + else + printf '%s\n' "$arch" + fi +} + +rwx_os_package_manager() { + if [ -z "$detected_package_manager" ]; then + rwx__detect_os_arch + fi + printf '%s\n' "$detected_package_manager" +} + +rwx_os_version_gte() { + compare_version="$1" + printf '%s\n' "$compare_version" "$(rwx_os_version)" | sed 's/\([0-9.]*\).*/\1/' | sort -c -t. -k1,1n -k2,2n -k3,3n >/dev/null 2>&1 +} + +rwx_os_version_lte() { + compare_version="$1" + printf '%s\n' "$(rwx_os_version)" "$compare_version" | sed 's/\([0-9.]*\).*/\1/' | sort -c -t. -k1,1n -k2,2n -k3,3n >/dev/null 2>&1 +} + +# Convert a string something usable as a RWX key. +# +# Replaces all non-alphanumeric characters with hyphens, compressing multiple hyphens into one. +rwx_keyify() { + printf '%s' "$*" | tr -c -s '[:alnum:]' '-' +} + +# Check if the provided list contains a given element. +# +# Usage: rwx_contains two one two three +rwx_contains() { + if [ "$#" -eq 0 ]; then + return 1 + fi + + needle=$1 + shift + + for item do + if [ "$item" = "$needle" ]; then + return 0 + fi + done + + return 1 +} + +rwx_os_name_in() { + rwx_contains "$(rwx_os_name)" "$@" +} + +rwx_os_package_manager_in() { + rwx_contains "$(rwx_os_package_manager)" "$@" +} + +rwx_maybe_sudo() { + if [ "$(id -u)" -eq 0 ]; then + "$@" + else + # If sudo is available, use it + if command -v sudo >/dev/null 2>&1; then + sudo "$@" + else + echo "Error: need root privileges but 'sudo' not found" >&2 + return 1 + fi + fi +} diff --git a/git/clone/README.md b/git/clone/README.md index 3f6dbc0..54af8df 100644 --- a/git/clone/README.md +++ b/git/clone/README.md @@ -5,7 +5,7 @@ ```yaml tasks: - key: code - call: git/clone 1.9.0 + call: git/clone 1.9.1 with: repository: https://github.com/YOUR_ORG/YOUR_REPO.git ref: main @@ -31,7 +31,7 @@ If you're using GitHub, RWX will automatically provide a token that you can use ```yaml tasks: - key: code - call: git/clone 1.9.0 + call: git/clone 1.9.1 with: repository: https://github.com/YOUR_ORG/PROJECT.git ref: ${{ init.ref }} @@ -43,7 +43,7 @@ tasks: ```yaml tasks: - key: code - call: git/clone 1.9.0 + call: git/clone 1.9.1 with: repository: git@github.com:YOUR_ORG/PROJECT.git ref: ${{ init.ref }} @@ -61,7 +61,7 @@ If you need to reference one of these to alter behavior of a task, be sure to in ```yaml tasks: - key: code - call: git/clone 1.9.0 + call: git/clone 1.9.1 with: repository: https://github.com/YOUR_ORG/YOUR_REPO.git ref: main diff --git a/git/clone/rwx-package.yml b/git/clone/rwx-package.yml index 8bf28c4..93ac794 100644 --- a/git/clone/rwx-package.yml +++ b/git/clone/rwx-package.yml @@ -1,5 +1,5 @@ name: git/clone -version: 1.9.0 +version: 1.9.1 description: Clone git repositories over ssh or http, with support for Git Large File Storage (LFS) source_code_url: https://github.com/rwx-cloud/packages/tree/main/git/clone issue_tracker_url: https://github.com/rwx-cloud/packages/issues diff --git a/git/clone/rwx-utils.sh b/git/clone/rwx-utils.sh index 1d1e0cf..7e906ff 100755 --- a/git/clone/rwx-utils.sh +++ b/git/clone/rwx-utils.sh @@ -1,5 +1,5 @@ #!/bin/sh -# rwx-utils version 2.0.0 +# rwx-utils version 2.0.1 detected_os="" detected_os_version="" @@ -84,7 +84,7 @@ rwx_os_version_gte() { rwx_os_version_lte() { compare_version="$1" - printf '%s\n' "$compare_version" "$(rwx_os_version)" | sed 's/\([0-9.]*\).*/\1/' | sort -c -t. -k1,1n -k2,2n -k3,3n -r >/dev/null 2>&1 + printf '%s\n' "$(rwx_os_version)" "$compare_version" | sed 's/\([0-9.]*\).*/\1/' | sort -c -t. -k1,1n -k2,2n -k3,3n >/dev/null 2>&1 } # Convert a string something usable as a RWX key. diff --git a/github/install-cli/README.md b/github/install-cli/README.md index 1ba95b2..9bc4cb6 100644 --- a/github/install-cli/README.md +++ b/github/install-cli/README.md @@ -5,5 +5,5 @@ To install the latest version of the GitHub CLI: ```yaml tasks: - key: github-cli - call: github/install-cli 1.0.8 + call: github/install-cli 1.0.9 ``` diff --git a/github/install-cli/mint-utils.sh b/github/install-cli/mint-utils.sh deleted file mode 100755 index 725ee83..0000000 --- a/github/install-cli/mint-utils.sh +++ /dev/null @@ -1,111 +0,0 @@ -#!/usr/bin/env bash -# mint-utils version 1.0.3 - -detected_os="" -detected_os_version="" -detected_os_codename="" -detected_arch="" -detected_package_manager="" - -function mint__detect_os_arch { - if [ -f /etc/os-release ]; then - . /etc/os-release - - detected_os="$ID" - detected_os_version="$VERSION_ID" - detected_os_codename="$VERSION_CODENAME" - - case "$ID" in - ubuntu|debian) - detected_package_manager="apt" - ;; - esac - fi - - detected_arch=$(uname -m) -} - -function mint_os_name { - if [ -z "$detected_os" ]; then - mint__detect_os_arch - fi - echo "$detected_os" -} - -function mint_os_version { - if [ -z "$detected_os_version" ]; then - mint__detect_os_arch - fi - echo "$detected_os_version" -} - -# Output the name and version of the operating system as expected by Mint's `base.os` field. -function mint_os_name_version { - echo "$(mint_os_name) $(mint_os_version)" -} - -function mint_os_codename { - if [ -z "$detected_os_codename" ]; then - mint__detect_os_arch - fi - echo "$detected_os_codename" -} - -function mint_arch { - if [ -z "$detected_arch" ]; then - mint__detect_os_arch - fi - echo "$detected_arch" -} - -function mint_arch_amd { - local arch - arch="$(mint_arch)" - if [ "$arch" = "x86_64" ]; then - echo "amd64" - else - echo "$arch" - fi -} - -function mint_os_package_manager { - if [ -z "$detected_package_manager" ]; then - mint__detect_os_arch - fi - echo "$detected_package_manager" -} - -function mint_os_version_gte { - local compare_version="$1" - printf '%s\n' "$compare_version" "$(mint_os_version)" | sort -Vsc >/dev/null 2>&1 -} - -function mint_os_version_lte { - local compare_version="$1" - printf '%s\n' "$compare_version" "$(mint_os_version)" | sort -Vsc -r >/dev/null 2>&1 -} - -# Convert a string something usable as a Mint key. -# -# Replaces all non-alphanumeric characters with hyphens, compressing multiple hyphens into one. -function mint_keyify { - echo -n "$*" | tr -c -s '[:alnum:]' '-' -} - -# Check if an array contains a given element. -# -# Usage: mint_contains two one two three -function mint_contains { - local needle="$1" - local elements=("${@:2}") - for item in "${elements[@]}"; do - if [ "$item" = "$needle" ]; then - return 0 - fi - done - return 1 -} - -function mint_os_package_manager_in { - mint_contains "$(mint_os_package_manager)" "$@" -} diff --git a/github/install-cli/rwx-package.yml b/github/install-cli/rwx-package.yml index 6bb67a2..42e4a06 100644 --- a/github/install-cli/rwx-package.yml +++ b/github/install-cli/rwx-package.yml @@ -1,5 +1,5 @@ name: github/install-cli -version: 1.0.8 +version: 1.0.9 description: Install the GitHub CLI, gh. It is GitHub on the command line. source_code_url: https://github.com/rwx-cloud/packages/tree/main/github/install-cli issue_tracker_url: https://github.com/rwx-cloud/packages/issues @@ -7,9 +7,9 @@ issue_tracker_url: https://github.com/rwx-cloud/packages/issues tasks: - key: install run: | - source "$RWX_PACKAGE_PATH/mint-utils.sh" - if ! mint_os_package_manager_in apt; then - echo "Unsupported operating system or package manager \`$(mint_os_package_manager)\`" > "$(mktemp "$RWX_ERRORS/error-XXXX")" + source "$RWX_PACKAGE_PATH/rwx-utils.sh" + if ! rwx_os_package_manager_in apt; then + echo "Unsupported operating system or package manager \`$(rwx_os_package_manager)\`" > "$(mktemp "$RWX_ERRORS/error-XXXX")" exit 1 fi diff --git a/github/install-cli/rwx-utils.sh b/github/install-cli/rwx-utils.sh new file mode 100755 index 0000000..7e906ff --- /dev/null +++ b/github/install-cli/rwx-utils.sh @@ -0,0 +1,137 @@ +#!/bin/sh +# rwx-utils version 2.0.1 + +detected_os="" +detected_os_version="" +detected_os_codename="" +detected_arch="" +detected_package_manager="" + +rwx__detect_os_arch() { + if [ -f /etc/os-release ]; then + . /etc/os-release + + detected_os="$ID" + detected_os_version="$VERSION_ID" + detected_os_codename="$VERSION_CODENAME" + + case "$ID" in + ubuntu|debian) + detected_package_manager="apt" + ;; + alpine) + detected_package_manager="apk" + ;; + esac + fi + + detected_arch=$(uname -m) +} + +rwx_os_name() { + if [ -z "$detected_os" ]; then + rwx__detect_os_arch + fi + printf '%s\n' "$detected_os" +} + +rwx_os_version() { + if [ -z "$detected_os_version" ]; then + rwx__detect_os_arch + fi + printf '%s\n' "$detected_os_version" +} + +# Output the name and version of the operating system as expected by RWX's `base.os` field. +rwx_os_name_version() { + printf '%s %s\n' "$(rwx_os_name)" "$(rwx_os_version)" +} + +rwx_os_codename() { + if [ -z "$detected_os_codename" ]; then + rwx__detect_os_arch + fi + printf '%s\n' "$detected_os_codename" +} + +rwx_arch() { + if [ -z "$detected_arch" ]; then + rwx__detect_os_arch + fi + printf '%s\n' "$detected_arch" +} + +rwx_arch_amd() { + arch="$(rwx_arch)" + if [ "$arch" = "x86_64" ]; then + printf '%s\n' "amd64" + else + printf '%s\n' "$arch" + fi +} + +rwx_os_package_manager() { + if [ -z "$detected_package_manager" ]; then + rwx__detect_os_arch + fi + printf '%s\n' "$detected_package_manager" +} + +rwx_os_version_gte() { + compare_version="$1" + printf '%s\n' "$compare_version" "$(rwx_os_version)" | sed 's/\([0-9.]*\).*/\1/' | sort -c -t. -k1,1n -k2,2n -k3,3n >/dev/null 2>&1 +} + +rwx_os_version_lte() { + compare_version="$1" + printf '%s\n' "$(rwx_os_version)" "$compare_version" | sed 's/\([0-9.]*\).*/\1/' | sort -c -t. -k1,1n -k2,2n -k3,3n >/dev/null 2>&1 +} + +# Convert a string something usable as a RWX key. +# +# Replaces all non-alphanumeric characters with hyphens, compressing multiple hyphens into one. +rwx_keyify() { + printf '%s' "$*" | tr -c -s '[:alnum:]' '-' +} + +# Check if the provided list contains a given element. +# +# Usage: rwx_contains two one two three +rwx_contains() { + if [ "$#" -eq 0 ]; then + return 1 + fi + + needle=$1 + shift + + for item do + if [ "$item" = "$needle" ]; then + return 0 + fi + done + + return 1 +} + +rwx_os_name_in() { + rwx_contains "$(rwx_os_name)" "$@" +} + +rwx_os_package_manager_in() { + rwx_contains "$(rwx_os_package_manager)" "$@" +} + +rwx_maybe_sudo() { + if [ "$(id -u)" -eq 0 ]; then + "$@" + else + # If sudo is available, use it + if command -v sudo >/dev/null 2>&1; then + sudo "$@" + else + echo "Error: need root privileges but 'sudo' not found" >&2 + return 1 + fi + fi +} diff --git a/google-cloud/install-cli/README.md b/google-cloud/install-cli/README.md index c714a2a..0d9a9d3 100644 --- a/google-cloud/install-cli/README.md +++ b/google-cloud/install-cli/README.md @@ -5,7 +5,7 @@ To install the latest version of the Google Cloud CLI: ```yaml tasks: - key: gcloud-cli - call: google-cloud/install-cli 1.1.6 + call: google-cloud/install-cli 1.1.7 ``` To install a specific version of the Google Cloud CLI: @@ -13,7 +13,7 @@ To install a specific version of the Google Cloud CLI: ```yaml tasks: - key: gcloud-cli - call: google-cloud/install-cli 1.1.6 + call: google-cloud/install-cli 1.1.7 with: cli-version: "465.0.0" ``` diff --git a/google-cloud/install-cli/mint-utils.sh b/google-cloud/install-cli/mint-utils.sh deleted file mode 100755 index 725ee83..0000000 --- a/google-cloud/install-cli/mint-utils.sh +++ /dev/null @@ -1,111 +0,0 @@ -#!/usr/bin/env bash -# mint-utils version 1.0.3 - -detected_os="" -detected_os_version="" -detected_os_codename="" -detected_arch="" -detected_package_manager="" - -function mint__detect_os_arch { - if [ -f /etc/os-release ]; then - . /etc/os-release - - detected_os="$ID" - detected_os_version="$VERSION_ID" - detected_os_codename="$VERSION_CODENAME" - - case "$ID" in - ubuntu|debian) - detected_package_manager="apt" - ;; - esac - fi - - detected_arch=$(uname -m) -} - -function mint_os_name { - if [ -z "$detected_os" ]; then - mint__detect_os_arch - fi - echo "$detected_os" -} - -function mint_os_version { - if [ -z "$detected_os_version" ]; then - mint__detect_os_arch - fi - echo "$detected_os_version" -} - -# Output the name and version of the operating system as expected by Mint's `base.os` field. -function mint_os_name_version { - echo "$(mint_os_name) $(mint_os_version)" -} - -function mint_os_codename { - if [ -z "$detected_os_codename" ]; then - mint__detect_os_arch - fi - echo "$detected_os_codename" -} - -function mint_arch { - if [ -z "$detected_arch" ]; then - mint__detect_os_arch - fi - echo "$detected_arch" -} - -function mint_arch_amd { - local arch - arch="$(mint_arch)" - if [ "$arch" = "x86_64" ]; then - echo "amd64" - else - echo "$arch" - fi -} - -function mint_os_package_manager { - if [ -z "$detected_package_manager" ]; then - mint__detect_os_arch - fi - echo "$detected_package_manager" -} - -function mint_os_version_gte { - local compare_version="$1" - printf '%s\n' "$compare_version" "$(mint_os_version)" | sort -Vsc >/dev/null 2>&1 -} - -function mint_os_version_lte { - local compare_version="$1" - printf '%s\n' "$compare_version" "$(mint_os_version)" | sort -Vsc -r >/dev/null 2>&1 -} - -# Convert a string something usable as a Mint key. -# -# Replaces all non-alphanumeric characters with hyphens, compressing multiple hyphens into one. -function mint_keyify { - echo -n "$*" | tr -c -s '[:alnum:]' '-' -} - -# Check if an array contains a given element. -# -# Usage: mint_contains two one two three -function mint_contains { - local needle="$1" - local elements=("${@:2}") - for item in "${elements[@]}"; do - if [ "$item" = "$needle" ]; then - return 0 - fi - done - return 1 -} - -function mint_os_package_manager_in { - mint_contains "$(mint_os_package_manager)" "$@" -} diff --git a/google-cloud/install-cli/rwx-package.yml b/google-cloud/install-cli/rwx-package.yml index ed2f8da..1f2e810 100644 --- a/google-cloud/install-cli/rwx-package.yml +++ b/google-cloud/install-cli/rwx-package.yml @@ -1,5 +1,5 @@ name: google-cloud/install-cli -version: 1.1.6 +version: 1.1.7 description: Install the Google Cloud SDK CLI source_code_url: https://github.com/rwx-cloud/packages/tree/main/google-cloud/install-cli issue_tracker_url: https://github.com/rwx-cloud/packages/issues @@ -15,9 +15,9 @@ parameters: tasks: - key: install-cli run: | - source "$RWX_PACKAGE_PATH/mint-utils.sh" - if [ "$(mint_os_name)" != "ubuntu" ]; then - echo "Unsupported operating system \`$(mint_os_name)\`" > "$(mktemp "$RWX_ERRORS/error-XXXX")" + source "$RWX_PACKAGE_PATH/rwx-utils.sh" + if [ "$(rwx_os_name)" != "ubuntu" ]; then + echo "Unsupported operating system \`$(rwx_os_name)\`" > "$(mktemp "$RWX_ERRORS/error-XXXX")" exit 1 fi diff --git a/google-cloud/install-cli/rwx-utils.sh b/google-cloud/install-cli/rwx-utils.sh new file mode 100755 index 0000000..7e906ff --- /dev/null +++ b/google-cloud/install-cli/rwx-utils.sh @@ -0,0 +1,137 @@ +#!/bin/sh +# rwx-utils version 2.0.1 + +detected_os="" +detected_os_version="" +detected_os_codename="" +detected_arch="" +detected_package_manager="" + +rwx__detect_os_arch() { + if [ -f /etc/os-release ]; then + . /etc/os-release + + detected_os="$ID" + detected_os_version="$VERSION_ID" + detected_os_codename="$VERSION_CODENAME" + + case "$ID" in + ubuntu|debian) + detected_package_manager="apt" + ;; + alpine) + detected_package_manager="apk" + ;; + esac + fi + + detected_arch=$(uname -m) +} + +rwx_os_name() { + if [ -z "$detected_os" ]; then + rwx__detect_os_arch + fi + printf '%s\n' "$detected_os" +} + +rwx_os_version() { + if [ -z "$detected_os_version" ]; then + rwx__detect_os_arch + fi + printf '%s\n' "$detected_os_version" +} + +# Output the name and version of the operating system as expected by RWX's `base.os` field. +rwx_os_name_version() { + printf '%s %s\n' "$(rwx_os_name)" "$(rwx_os_version)" +} + +rwx_os_codename() { + if [ -z "$detected_os_codename" ]; then + rwx__detect_os_arch + fi + printf '%s\n' "$detected_os_codename" +} + +rwx_arch() { + if [ -z "$detected_arch" ]; then + rwx__detect_os_arch + fi + printf '%s\n' "$detected_arch" +} + +rwx_arch_amd() { + arch="$(rwx_arch)" + if [ "$arch" = "x86_64" ]; then + printf '%s\n' "amd64" + else + printf '%s\n' "$arch" + fi +} + +rwx_os_package_manager() { + if [ -z "$detected_package_manager" ]; then + rwx__detect_os_arch + fi + printf '%s\n' "$detected_package_manager" +} + +rwx_os_version_gte() { + compare_version="$1" + printf '%s\n' "$compare_version" "$(rwx_os_version)" | sed 's/\([0-9.]*\).*/\1/' | sort -c -t. -k1,1n -k2,2n -k3,3n >/dev/null 2>&1 +} + +rwx_os_version_lte() { + compare_version="$1" + printf '%s\n' "$(rwx_os_version)" "$compare_version" | sed 's/\([0-9.]*\).*/\1/' | sort -c -t. -k1,1n -k2,2n -k3,3n >/dev/null 2>&1 +} + +# Convert a string something usable as a RWX key. +# +# Replaces all non-alphanumeric characters with hyphens, compressing multiple hyphens into one. +rwx_keyify() { + printf '%s' "$*" | tr -c -s '[:alnum:]' '-' +} + +# Check if the provided list contains a given element. +# +# Usage: rwx_contains two one two three +rwx_contains() { + if [ "$#" -eq 0 ]; then + return 1 + fi + + needle=$1 + shift + + for item do + if [ "$item" = "$needle" ]; then + return 0 + fi + done + + return 1 +} + +rwx_os_name_in() { + rwx_contains "$(rwx_os_name)" "$@" +} + +rwx_os_package_manager_in() { + rwx_contains "$(rwx_os_package_manager)" "$@" +} + +rwx_maybe_sudo() { + if [ "$(id -u)" -eq 0 ]; then + "$@" + else + # If sudo is available, use it + if command -v sudo >/dev/null 2>&1; then + sudo "$@" + else + echo "Error: need root privileges but 'sudo' not found" >&2 + return 1 + fi + fi +} diff --git a/google/install-chrome/README.md b/google/install-chrome/README.md index 3f9f923..6f8cece 100644 --- a/google/install-chrome/README.md +++ b/google/install-chrome/README.md @@ -12,7 +12,7 @@ Versions 115 and greater are supported. ```yaml tasks: - key: chrome - call: google/install-chrome 2.1.8 + call: google/install-chrome 2.1.9 with: chrome-version: 130 ``` @@ -22,7 +22,7 @@ tasks: ```yaml tasks: - key: chrome - call: google/install-chrome 2.1.8 + call: google/install-chrome 2.1.9 with: chrome-version: 130 install-chromedriver: true @@ -35,7 +35,7 @@ If you are installing multiple versions of chrome and using them within the same ```yaml tasks: - key: chrome-129 - call: google/install-chrome 2.1.8 + call: google/install-chrome 2.1.9 with: chrome-version: 129 install-chromedriver: true @@ -44,7 +44,7 @@ tasks: add-to-path: false - key: chrome-130 - call: google/install-chrome 2.1.8 + call: google/install-chrome 2.1.9 with: chrome-version: 130 install-chromedriver: true @@ -68,7 +68,7 @@ By default, `google/install-chrome` supports tools that interact with Chrome in ```yml - key: chrome - call: google/install-chrome 2.1.8 + call: google/install-chrome 2.1.9 with: chrome-version: stable install-chromedriver: true @@ -117,7 +117,7 @@ You can also use tools that interact with headed Chrome. To do so, wrap your com ```yml - key: chrome - call: google/install-chrome 2.1.8 + call: google/install-chrome 2.1.9 with: chrome-version: stable install-chromedriver: true diff --git a/google/install-chrome/mint-utils.sh b/google/install-chrome/mint-utils.sh deleted file mode 100755 index 97d280c..0000000 --- a/google/install-chrome/mint-utils.sh +++ /dev/null @@ -1,115 +0,0 @@ -#!/usr/bin/env bash -# mint-utils version 1.0.4 - -detected_os="" -detected_os_version="" -detected_os_codename="" -detected_arch="" -detected_package_manager="" - -function mint__detect_os_arch { - if [ -f /etc/os-release ]; then - . /etc/os-release - - detected_os="$ID" - detected_os_version="$VERSION_ID" - detected_os_codename="$VERSION_CODENAME" - - case "$ID" in - ubuntu|debian) - detected_package_manager="apt" - ;; - esac - fi - - detected_arch=$(uname -m) -} - -function mint_os_name { - if [ -z "$detected_os" ]; then - mint__detect_os_arch - fi - echo "$detected_os" -} - -function mint_os_version { - if [ -z "$detected_os_version" ]; then - mint__detect_os_arch - fi - echo "$detected_os_version" -} - -# Output the name and version of the operating system as expected by Mint's `base.os` field. -function mint_os_name_version { - echo "$(mint_os_name) $(mint_os_version)" -} - -function mint_os_codename { - if [ -z "$detected_os_codename" ]; then - mint__detect_os_arch - fi - echo "$detected_os_codename" -} - -function mint_arch { - if [ -z "$detected_arch" ]; then - mint__detect_os_arch - fi - echo "$detected_arch" -} - -function mint_arch_amd { - local arch - arch="$(mint_arch)" - if [ "$arch" = "x86_64" ]; then - echo "amd64" - else - echo "$arch" - fi -} - -function mint_os_package_manager { - if [ -z "$detected_package_manager" ]; then - mint__detect_os_arch - fi - echo "$detected_package_manager" -} - -function mint_os_version_gte { - local compare_version="$1" - printf '%s\n' "$compare_version" "$(mint_os_version)" | sort -Vsc >/dev/null 2>&1 -} - -function mint_os_version_lte { - local compare_version="$1" - printf '%s\n' "$compare_version" "$(mint_os_version)" | sort -Vsc -r >/dev/null 2>&1 -} - -# Convert a string something usable as a Mint key. -# -# Replaces all non-alphanumeric characters with hyphens, compressing multiple hyphens into one. -function mint_keyify { - echo -n "$*" | tr -c -s '[:alnum:]' '-' -} - -# Check if an array contains a given element. -# -# Usage: mint_contains two one two three -function mint_contains { - local needle="$1" - local elements=("${@:2}") - for item in "${elements[@]}"; do - if [ "$item" = "$needle" ]; then - return 0 - fi - done - return 1 -} - -function mint_os_name_in { - mint_contains "$(mint_os_name)" "$@" -} - -function mint_os_package_manager_in { - mint_contains "$(mint_os_package_manager)" "$@" -} diff --git a/google/install-chrome/rwx-package.yml b/google/install-chrome/rwx-package.yml index 8e7956e..e0727da 100644 --- a/google/install-chrome/rwx-package.yml +++ b/google/install-chrome/rwx-package.yml @@ -1,5 +1,5 @@ name: google/install-chrome -version: 2.1.8 +version: 2.1.9 description: Install Google Chrome, the official web browser from Google source_code_url: https://github.com/rwx-cloud/packages/tree/main/google/install-chrome issue_tracker_url: https://github.com/rwx-cloud/packages/issues @@ -31,9 +31,9 @@ outputs: tasks: - key: resolve-chrome-version run: | - source "$RWX_PACKAGE_PATH/mint-utils.sh" - if ! mint_os_name_in ubuntu; then - echo "Unsupported operating system \`$(mint_os_name)\`" > "$(mktemp "$RWX_ERRORS/error-XXXX")" + source "$RWX_PACKAGE_PATH/rwx-utils.sh" + if ! rwx_os_name_in ubuntu; then + echo "Unsupported operating system \`$(rwx_os_name)\`" > "$(mktemp "$RWX_ERRORS/error-XXXX")" exit 1 fi @@ -84,9 +84,9 @@ tasks: - key: install run: | - source "$RWX_PACKAGE_PATH/mint-utils.sh" + source "$RWX_PACKAGE_PATH/rwx-utils.sh" os_packages="" - if mint_os_version_gte 24.04; then + if rwx_os_version_gte 24.04; then os_packages="libasound2t64 libgtk-4-1 libatk-bridge2.0-0t64 libatk1.0-0t64 libatspi2.0-0t64 libcups2t64 libglib2.0-0t64 libgtk-3-0t64" else os_packages="libasound2 libgtk-3-0 libatk-bridge2.0-0 libatk1.0-0 libatspi2.0-0 libcups2 libglib2.0-0 libgtk-3-0" diff --git a/google/install-chrome/rwx-utils.sh b/google/install-chrome/rwx-utils.sh new file mode 100755 index 0000000..7e906ff --- /dev/null +++ b/google/install-chrome/rwx-utils.sh @@ -0,0 +1,137 @@ +#!/bin/sh +# rwx-utils version 2.0.1 + +detected_os="" +detected_os_version="" +detected_os_codename="" +detected_arch="" +detected_package_manager="" + +rwx__detect_os_arch() { + if [ -f /etc/os-release ]; then + . /etc/os-release + + detected_os="$ID" + detected_os_version="$VERSION_ID" + detected_os_codename="$VERSION_CODENAME" + + case "$ID" in + ubuntu|debian) + detected_package_manager="apt" + ;; + alpine) + detected_package_manager="apk" + ;; + esac + fi + + detected_arch=$(uname -m) +} + +rwx_os_name() { + if [ -z "$detected_os" ]; then + rwx__detect_os_arch + fi + printf '%s\n' "$detected_os" +} + +rwx_os_version() { + if [ -z "$detected_os_version" ]; then + rwx__detect_os_arch + fi + printf '%s\n' "$detected_os_version" +} + +# Output the name and version of the operating system as expected by RWX's `base.os` field. +rwx_os_name_version() { + printf '%s %s\n' "$(rwx_os_name)" "$(rwx_os_version)" +} + +rwx_os_codename() { + if [ -z "$detected_os_codename" ]; then + rwx__detect_os_arch + fi + printf '%s\n' "$detected_os_codename" +} + +rwx_arch() { + if [ -z "$detected_arch" ]; then + rwx__detect_os_arch + fi + printf '%s\n' "$detected_arch" +} + +rwx_arch_amd() { + arch="$(rwx_arch)" + if [ "$arch" = "x86_64" ]; then + printf '%s\n' "amd64" + else + printf '%s\n' "$arch" + fi +} + +rwx_os_package_manager() { + if [ -z "$detected_package_manager" ]; then + rwx__detect_os_arch + fi + printf '%s\n' "$detected_package_manager" +} + +rwx_os_version_gte() { + compare_version="$1" + printf '%s\n' "$compare_version" "$(rwx_os_version)" | sed 's/\([0-9.]*\).*/\1/' | sort -c -t. -k1,1n -k2,2n -k3,3n >/dev/null 2>&1 +} + +rwx_os_version_lte() { + compare_version="$1" + printf '%s\n' "$(rwx_os_version)" "$compare_version" | sed 's/\([0-9.]*\).*/\1/' | sort -c -t. -k1,1n -k2,2n -k3,3n >/dev/null 2>&1 +} + +# Convert a string something usable as a RWX key. +# +# Replaces all non-alphanumeric characters with hyphens, compressing multiple hyphens into one. +rwx_keyify() { + printf '%s' "$*" | tr -c -s '[:alnum:]' '-' +} + +# Check if the provided list contains a given element. +# +# Usage: rwx_contains two one two three +rwx_contains() { + if [ "$#" -eq 0 ]; then + return 1 + fi + + needle=$1 + shift + + for item do + if [ "$item" = "$needle" ]; then + return 0 + fi + done + + return 1 +} + +rwx_os_name_in() { + rwx_contains "$(rwx_os_name)" "$@" +} + +rwx_os_package_manager_in() { + rwx_contains "$(rwx_os_package_manager)" "$@" +} + +rwx_maybe_sudo() { + if [ "$(id -u)" -eq 0 ]; then + "$@" + else + # If sudo is available, use it + if command -v sudo >/dev/null 2>&1; then + sudo "$@" + else + echo "Error: need root privileges but 'sudo' not found" >&2 + return 1 + fi + fi +} diff --git a/hashicorp/install-terraform/README.md b/hashicorp/install-terraform/README.md index 57900d7..8906bef 100644 --- a/hashicorp/install-terraform/README.md +++ b/hashicorp/install-terraform/README.md @@ -5,7 +5,7 @@ To install the latest version of the Terraform CLI: ```yaml tasks: - key: terraform - call: hashicorp/install-terraform 1.0.10 + call: hashicorp/install-terraform 1.0.11 ``` To install a specific version of the Terraform CLI: @@ -13,7 +13,7 @@ To install a specific version of the Terraform CLI: ```yaml tasks: - key: terraform - call: hashicorp/install-terraform 1.0.10 + call: hashicorp/install-terraform 1.0.11 with: terraform-version: "1.7.3" ``` diff --git a/hashicorp/install-terraform/mint-utils.sh b/hashicorp/install-terraform/mint-utils.sh deleted file mode 100755 index 725ee83..0000000 --- a/hashicorp/install-terraform/mint-utils.sh +++ /dev/null @@ -1,111 +0,0 @@ -#!/usr/bin/env bash -# mint-utils version 1.0.3 - -detected_os="" -detected_os_version="" -detected_os_codename="" -detected_arch="" -detected_package_manager="" - -function mint__detect_os_arch { - if [ -f /etc/os-release ]; then - . /etc/os-release - - detected_os="$ID" - detected_os_version="$VERSION_ID" - detected_os_codename="$VERSION_CODENAME" - - case "$ID" in - ubuntu|debian) - detected_package_manager="apt" - ;; - esac - fi - - detected_arch=$(uname -m) -} - -function mint_os_name { - if [ -z "$detected_os" ]; then - mint__detect_os_arch - fi - echo "$detected_os" -} - -function mint_os_version { - if [ -z "$detected_os_version" ]; then - mint__detect_os_arch - fi - echo "$detected_os_version" -} - -# Output the name and version of the operating system as expected by Mint's `base.os` field. -function mint_os_name_version { - echo "$(mint_os_name) $(mint_os_version)" -} - -function mint_os_codename { - if [ -z "$detected_os_codename" ]; then - mint__detect_os_arch - fi - echo "$detected_os_codename" -} - -function mint_arch { - if [ -z "$detected_arch" ]; then - mint__detect_os_arch - fi - echo "$detected_arch" -} - -function mint_arch_amd { - local arch - arch="$(mint_arch)" - if [ "$arch" = "x86_64" ]; then - echo "amd64" - else - echo "$arch" - fi -} - -function mint_os_package_manager { - if [ -z "$detected_package_manager" ]; then - mint__detect_os_arch - fi - echo "$detected_package_manager" -} - -function mint_os_version_gte { - local compare_version="$1" - printf '%s\n' "$compare_version" "$(mint_os_version)" | sort -Vsc >/dev/null 2>&1 -} - -function mint_os_version_lte { - local compare_version="$1" - printf '%s\n' "$compare_version" "$(mint_os_version)" | sort -Vsc -r >/dev/null 2>&1 -} - -# Convert a string something usable as a Mint key. -# -# Replaces all non-alphanumeric characters with hyphens, compressing multiple hyphens into one. -function mint_keyify { - echo -n "$*" | tr -c -s '[:alnum:]' '-' -} - -# Check if an array contains a given element. -# -# Usage: mint_contains two one two three -function mint_contains { - local needle="$1" - local elements=("${@:2}") - for item in "${elements[@]}"; do - if [ "$item" = "$needle" ]; then - return 0 - fi - done - return 1 -} - -function mint_os_package_manager_in { - mint_contains "$(mint_os_package_manager)" "$@" -} diff --git a/hashicorp/install-terraform/rwx-package.yml b/hashicorp/install-terraform/rwx-package.yml index c4e98c8..ec71d07 100644 --- a/hashicorp/install-terraform/rwx-package.yml +++ b/hashicorp/install-terraform/rwx-package.yml @@ -1,5 +1,5 @@ name: hashicorp/install-terraform -version: 1.0.10 +version: 1.0.11 description: Install the Terraform CLI, a tool for building, changing, and versioning infrastructure safely and efficiently source_code_url: https://github.com/rwx-cloud/packages/tree/main/hashicorp/install-terraform issue_tracker_url: https://github.com/rwx-cloud/packages/issues @@ -12,9 +12,9 @@ parameters: tasks: - key: install run: | - source "$RWX_PACKAGE_PATH/mint-utils.sh" - if ! mint_os_package_manager_in apt; then - echo "Unsupported operating system or package manager \`$(mint_os_package_manager)\`" > "$(mktemp "$RWX_ERRORS/error-XXXX")" + source "$RWX_PACKAGE_PATH/rwx-utils.sh" + if ! rwx_os_package_manager_in apt; then + echo "Unsupported operating system or package manager \`$(rwx_os_package_manager)\`" > "$(mktemp "$RWX_ERRORS/error-XXXX")" exit 1 fi diff --git a/hashicorp/install-terraform/rwx-utils.sh b/hashicorp/install-terraform/rwx-utils.sh new file mode 100755 index 0000000..7e906ff --- /dev/null +++ b/hashicorp/install-terraform/rwx-utils.sh @@ -0,0 +1,137 @@ +#!/bin/sh +# rwx-utils version 2.0.1 + +detected_os="" +detected_os_version="" +detected_os_codename="" +detected_arch="" +detected_package_manager="" + +rwx__detect_os_arch() { + if [ -f /etc/os-release ]; then + . /etc/os-release + + detected_os="$ID" + detected_os_version="$VERSION_ID" + detected_os_codename="$VERSION_CODENAME" + + case "$ID" in + ubuntu|debian) + detected_package_manager="apt" + ;; + alpine) + detected_package_manager="apk" + ;; + esac + fi + + detected_arch=$(uname -m) +} + +rwx_os_name() { + if [ -z "$detected_os" ]; then + rwx__detect_os_arch + fi + printf '%s\n' "$detected_os" +} + +rwx_os_version() { + if [ -z "$detected_os_version" ]; then + rwx__detect_os_arch + fi + printf '%s\n' "$detected_os_version" +} + +# Output the name and version of the operating system as expected by RWX's `base.os` field. +rwx_os_name_version() { + printf '%s %s\n' "$(rwx_os_name)" "$(rwx_os_version)" +} + +rwx_os_codename() { + if [ -z "$detected_os_codename" ]; then + rwx__detect_os_arch + fi + printf '%s\n' "$detected_os_codename" +} + +rwx_arch() { + if [ -z "$detected_arch" ]; then + rwx__detect_os_arch + fi + printf '%s\n' "$detected_arch" +} + +rwx_arch_amd() { + arch="$(rwx_arch)" + if [ "$arch" = "x86_64" ]; then + printf '%s\n' "amd64" + else + printf '%s\n' "$arch" + fi +} + +rwx_os_package_manager() { + if [ -z "$detected_package_manager" ]; then + rwx__detect_os_arch + fi + printf '%s\n' "$detected_package_manager" +} + +rwx_os_version_gte() { + compare_version="$1" + printf '%s\n' "$compare_version" "$(rwx_os_version)" | sed 's/\([0-9.]*\).*/\1/' | sort -c -t. -k1,1n -k2,2n -k3,3n >/dev/null 2>&1 +} + +rwx_os_version_lte() { + compare_version="$1" + printf '%s\n' "$(rwx_os_version)" "$compare_version" | sed 's/\([0-9.]*\).*/\1/' | sort -c -t. -k1,1n -k2,2n -k3,3n >/dev/null 2>&1 +} + +# Convert a string something usable as a RWX key. +# +# Replaces all non-alphanumeric characters with hyphens, compressing multiple hyphens into one. +rwx_keyify() { + printf '%s' "$*" | tr -c -s '[:alnum:]' '-' +} + +# Check if the provided list contains a given element. +# +# Usage: rwx_contains two one two three +rwx_contains() { + if [ "$#" -eq 0 ]; then + return 1 + fi + + needle=$1 + shift + + for item do + if [ "$item" = "$needle" ]; then + return 0 + fi + done + + return 1 +} + +rwx_os_name_in() { + rwx_contains "$(rwx_os_name)" "$@" +} + +rwx_os_package_manager_in() { + rwx_contains "$(rwx_os_package_manager)" "$@" +} + +rwx_maybe_sudo() { + if [ "$(id -u)" -eq 0 ]; then + "$@" + else + # If sudo is available, use it + if command -v sudo >/dev/null 2>&1; then + sudo "$@" + else + echo "Error: need root privileges but 'sudo' not found" >&2 + return 1 + fi + fi +} diff --git a/nodejs/install/README.md b/nodejs/install/README.md index f6cc552..ab2d7d4 100644 --- a/nodejs/install/README.md +++ b/nodejs/install/README.md @@ -7,7 +7,7 @@ You'll either need to specify `node-version` or `node-version-file` ```yaml tasks: - key: node - call: nodejs/install 1.1.10 + call: nodejs/install 1.1.11 with: node-version: "21.4.0" ``` @@ -20,7 +20,7 @@ Or with a file named `.node-version` containing the version of node to install: tasks: - key: node use: code # or whichever task provides the .node-version file - call: nodejs/install 1.1.10 + call: nodejs/install 1.1.11 with: node-version-file: .node-version filter: diff --git a/nodejs/install/mint-utils.sh b/nodejs/install/mint-utils.sh deleted file mode 100755 index 725ee83..0000000 --- a/nodejs/install/mint-utils.sh +++ /dev/null @@ -1,111 +0,0 @@ -#!/usr/bin/env bash -# mint-utils version 1.0.3 - -detected_os="" -detected_os_version="" -detected_os_codename="" -detected_arch="" -detected_package_manager="" - -function mint__detect_os_arch { - if [ -f /etc/os-release ]; then - . /etc/os-release - - detected_os="$ID" - detected_os_version="$VERSION_ID" - detected_os_codename="$VERSION_CODENAME" - - case "$ID" in - ubuntu|debian) - detected_package_manager="apt" - ;; - esac - fi - - detected_arch=$(uname -m) -} - -function mint_os_name { - if [ -z "$detected_os" ]; then - mint__detect_os_arch - fi - echo "$detected_os" -} - -function mint_os_version { - if [ -z "$detected_os_version" ]; then - mint__detect_os_arch - fi - echo "$detected_os_version" -} - -# Output the name and version of the operating system as expected by Mint's `base.os` field. -function mint_os_name_version { - echo "$(mint_os_name) $(mint_os_version)" -} - -function mint_os_codename { - if [ -z "$detected_os_codename" ]; then - mint__detect_os_arch - fi - echo "$detected_os_codename" -} - -function mint_arch { - if [ -z "$detected_arch" ]; then - mint__detect_os_arch - fi - echo "$detected_arch" -} - -function mint_arch_amd { - local arch - arch="$(mint_arch)" - if [ "$arch" = "x86_64" ]; then - echo "amd64" - else - echo "$arch" - fi -} - -function mint_os_package_manager { - if [ -z "$detected_package_manager" ]; then - mint__detect_os_arch - fi - echo "$detected_package_manager" -} - -function mint_os_version_gte { - local compare_version="$1" - printf '%s\n' "$compare_version" "$(mint_os_version)" | sort -Vsc >/dev/null 2>&1 -} - -function mint_os_version_lte { - local compare_version="$1" - printf '%s\n' "$compare_version" "$(mint_os_version)" | sort -Vsc -r >/dev/null 2>&1 -} - -# Convert a string something usable as a Mint key. -# -# Replaces all non-alphanumeric characters with hyphens, compressing multiple hyphens into one. -function mint_keyify { - echo -n "$*" | tr -c -s '[:alnum:]' '-' -} - -# Check if an array contains a given element. -# -# Usage: mint_contains two one two three -function mint_contains { - local needle="$1" - local elements=("${@:2}") - for item in "${elements[@]}"; do - if [ "$item" = "$needle" ]; then - return 0 - fi - done - return 1 -} - -function mint_os_package_manager_in { - mint_contains "$(mint_os_package_manager)" "$@" -} diff --git a/nodejs/install/rwx-package.yml b/nodejs/install/rwx-package.yml index 86f784a..4cdf053 100644 --- a/nodejs/install/rwx-package.yml +++ b/nodejs/install/rwx-package.yml @@ -1,5 +1,5 @@ name: nodejs/install -version: 1.1.10 +version: 1.1.11 description: Install Node.js, the cross-platform JavaScript runtime environment source_code_url: https://github.com/rwx-cloud/packages/tree/main/nodejs/install issue_tracker_url: https://github.com/rwx-cloud/packages/issues @@ -15,9 +15,9 @@ parameters: tasks: - key: install run: | - source "$RWX_PACKAGE_PATH/mint-utils.sh" - if ! mint_os_package_manager_in apt; then - echo "Unsupported operating system or package manager \`$(mint_os_package_manager)\`" > "$(mktemp "$RWX_ERRORS/error-XXXX")" + source "$RWX_PACKAGE_PATH/rwx-utils.sh" + if ! rwx_os_package_manager_in apt; then + echo "Unsupported operating system or package manager \`$(rwx_os_package_manager)\`" > "$(mktemp "$RWX_ERRORS/error-XXXX")" exit 1 fi diff --git a/nodejs/install/rwx-utils.sh b/nodejs/install/rwx-utils.sh new file mode 100755 index 0000000..7e906ff --- /dev/null +++ b/nodejs/install/rwx-utils.sh @@ -0,0 +1,137 @@ +#!/bin/sh +# rwx-utils version 2.0.1 + +detected_os="" +detected_os_version="" +detected_os_codename="" +detected_arch="" +detected_package_manager="" + +rwx__detect_os_arch() { + if [ -f /etc/os-release ]; then + . /etc/os-release + + detected_os="$ID" + detected_os_version="$VERSION_ID" + detected_os_codename="$VERSION_CODENAME" + + case "$ID" in + ubuntu|debian) + detected_package_manager="apt" + ;; + alpine) + detected_package_manager="apk" + ;; + esac + fi + + detected_arch=$(uname -m) +} + +rwx_os_name() { + if [ -z "$detected_os" ]; then + rwx__detect_os_arch + fi + printf '%s\n' "$detected_os" +} + +rwx_os_version() { + if [ -z "$detected_os_version" ]; then + rwx__detect_os_arch + fi + printf '%s\n' "$detected_os_version" +} + +# Output the name and version of the operating system as expected by RWX's `base.os` field. +rwx_os_name_version() { + printf '%s %s\n' "$(rwx_os_name)" "$(rwx_os_version)" +} + +rwx_os_codename() { + if [ -z "$detected_os_codename" ]; then + rwx__detect_os_arch + fi + printf '%s\n' "$detected_os_codename" +} + +rwx_arch() { + if [ -z "$detected_arch" ]; then + rwx__detect_os_arch + fi + printf '%s\n' "$detected_arch" +} + +rwx_arch_amd() { + arch="$(rwx_arch)" + if [ "$arch" = "x86_64" ]; then + printf '%s\n' "amd64" + else + printf '%s\n' "$arch" + fi +} + +rwx_os_package_manager() { + if [ -z "$detected_package_manager" ]; then + rwx__detect_os_arch + fi + printf '%s\n' "$detected_package_manager" +} + +rwx_os_version_gte() { + compare_version="$1" + printf '%s\n' "$compare_version" "$(rwx_os_version)" | sed 's/\([0-9.]*\).*/\1/' | sort -c -t. -k1,1n -k2,2n -k3,3n >/dev/null 2>&1 +} + +rwx_os_version_lte() { + compare_version="$1" + printf '%s\n' "$(rwx_os_version)" "$compare_version" | sed 's/\([0-9.]*\).*/\1/' | sort -c -t. -k1,1n -k2,2n -k3,3n >/dev/null 2>&1 +} + +# Convert a string something usable as a RWX key. +# +# Replaces all non-alphanumeric characters with hyphens, compressing multiple hyphens into one. +rwx_keyify() { + printf '%s' "$*" | tr -c -s '[:alnum:]' '-' +} + +# Check if the provided list contains a given element. +# +# Usage: rwx_contains two one two three +rwx_contains() { + if [ "$#" -eq 0 ]; then + return 1 + fi + + needle=$1 + shift + + for item do + if [ "$item" = "$needle" ]; then + return 0 + fi + done + + return 1 +} + +rwx_os_name_in() { + rwx_contains "$(rwx_os_name)" "$@" +} + +rwx_os_package_manager_in() { + rwx_contains "$(rwx_os_package_manager)" "$@" +} + +rwx_maybe_sudo() { + if [ "$(id -u)" -eq 0 ]; then + "$@" + else + # If sudo is available, use it + if command -v sudo >/dev/null 2>&1; then + sudo "$@" + else + echo "Error: need root privileges but 'sudo' not found" >&2 + return 1 + fi + fi +} diff --git a/python/install/README.md b/python/install/README.md index 94475f4..ecffde6 100644 --- a/python/install/README.md +++ b/python/install/README.md @@ -5,7 +5,7 @@ RWX currently supports Python versions 3.7.0 through 3.14.0. You'll need to spec ```yaml tasks: - key: python - call: python/install 1.3.10 + call: python/install 1.3.11 with: python-version: 3.14.0 ``` @@ -15,7 +15,7 @@ You can optionally specify the version of `pip` to install: ```yaml tasks: - key: python - call: python/install 1.3.10 + call: python/install 1.3.11 with: python-version: 3.14.0 pip-version: 25.0.1 @@ -26,7 +26,7 @@ And the version of `setuptools`: ```yaml tasks: - key: python - call: python/install 1.3.10 + call: python/install 1.3.11 with: python-version: 3.14.0 pip-version: 25.0.1 diff --git a/python/install/mint-utils.sh b/python/install/mint-utils.sh deleted file mode 100755 index 97d280c..0000000 --- a/python/install/mint-utils.sh +++ /dev/null @@ -1,115 +0,0 @@ -#!/usr/bin/env bash -# mint-utils version 1.0.4 - -detected_os="" -detected_os_version="" -detected_os_codename="" -detected_arch="" -detected_package_manager="" - -function mint__detect_os_arch { - if [ -f /etc/os-release ]; then - . /etc/os-release - - detected_os="$ID" - detected_os_version="$VERSION_ID" - detected_os_codename="$VERSION_CODENAME" - - case "$ID" in - ubuntu|debian) - detected_package_manager="apt" - ;; - esac - fi - - detected_arch=$(uname -m) -} - -function mint_os_name { - if [ -z "$detected_os" ]; then - mint__detect_os_arch - fi - echo "$detected_os" -} - -function mint_os_version { - if [ -z "$detected_os_version" ]; then - mint__detect_os_arch - fi - echo "$detected_os_version" -} - -# Output the name and version of the operating system as expected by Mint's `base.os` field. -function mint_os_name_version { - echo "$(mint_os_name) $(mint_os_version)" -} - -function mint_os_codename { - if [ -z "$detected_os_codename" ]; then - mint__detect_os_arch - fi - echo "$detected_os_codename" -} - -function mint_arch { - if [ -z "$detected_arch" ]; then - mint__detect_os_arch - fi - echo "$detected_arch" -} - -function mint_arch_amd { - local arch - arch="$(mint_arch)" - if [ "$arch" = "x86_64" ]; then - echo "amd64" - else - echo "$arch" - fi -} - -function mint_os_package_manager { - if [ -z "$detected_package_manager" ]; then - mint__detect_os_arch - fi - echo "$detected_package_manager" -} - -function mint_os_version_gte { - local compare_version="$1" - printf '%s\n' "$compare_version" "$(mint_os_version)" | sort -Vsc >/dev/null 2>&1 -} - -function mint_os_version_lte { - local compare_version="$1" - printf '%s\n' "$compare_version" "$(mint_os_version)" | sort -Vsc -r >/dev/null 2>&1 -} - -# Convert a string something usable as a Mint key. -# -# Replaces all non-alphanumeric characters with hyphens, compressing multiple hyphens into one. -function mint_keyify { - echo -n "$*" | tr -c -s '[:alnum:]' '-' -} - -# Check if an array contains a given element. -# -# Usage: mint_contains two one two three -function mint_contains { - local needle="$1" - local elements=("${@:2}") - for item in "${elements[@]}"; do - if [ "$item" = "$needle" ]; then - return 0 - fi - done - return 1 -} - -function mint_os_name_in { - mint_contains "$(mint_os_name)" "$@" -} - -function mint_os_package_manager_in { - mint_contains "$(mint_os_package_manager)" "$@" -} diff --git a/python/install/rwx-package.yml b/python/install/rwx-package.yml index 5b38d9d..bf2faa3 100644 --- a/python/install/rwx-package.yml +++ b/python/install/rwx-package.yml @@ -1,5 +1,5 @@ name: python/install -version: 1.3.10 +version: 1.3.11 description: Install Python, a programming language that lets you work quickly and integrate systems more effectively source_code_url: https://github.com/rwx-cloud/packages/tree/main/python/install issue_tracker_url: https://github.com/rwx-cloud/packages/issues @@ -19,14 +19,14 @@ tasks: - key: install-python run: | set -u - source "$RWX_PACKAGE_PATH/mint-utils.sh" + source "$RWX_PACKAGE_PATH/rwx-utils.sh" # # Check OS support # - source "$RWX_PACKAGE_PATH/mint-utils.sh" - if ! mint_os_name_in ubuntu; then - echo "Unsupported operating system \`$(mint_os_name)\`" > "$(mktemp "$RWX_ERRORS/error-XXXX")" + source "$RWX_PACKAGE_PATH/rwx-utils.sh" + if ! rwx_os_name_in ubuntu; then + echo "Unsupported operating system \`$(rwx_os_name)\`" > "$(mktemp "$RWX_ERRORS/error-XXXX")" exit 1 fi @@ -44,7 +44,7 @@ tasks: # Install system dependencies # os_packages="ca-certificates libexpat1 libsqlite3-0 media-types readline-common tzdata" - if mint_os_version_lte 22.04; then + if rwx_os_version_lte 22.04; then os_packages+=" libmpdec3 libreadline8 libssl3" else os_packages+=" libreadline8t64 libssl3t64 openssl" @@ -60,8 +60,8 @@ tasks: # Find the prebuilt Python echo "Looking for Python $PYTHON_VERSION..." escaped_version=$(echo "$PYTHON_VERSION" | sed "s/\./\\\\./g") # 3.2.2 => 3\.2\.2 - escaped_os=$(mint_os_name_version | sed "s/\./\\\\./g") - escaped_arch=$(mint_arch) + escaped_os=$(rwx_os_name_version | sed "s/\./\\\\./g") + escaped_arch=$(rwx_arch) if [ "$escaped_arch" = "aarch64" ]; then escaped_arch="arm64" fi diff --git a/python/install/rwx-utils.sh b/python/install/rwx-utils.sh new file mode 100755 index 0000000..7e906ff --- /dev/null +++ b/python/install/rwx-utils.sh @@ -0,0 +1,137 @@ +#!/bin/sh +# rwx-utils version 2.0.1 + +detected_os="" +detected_os_version="" +detected_os_codename="" +detected_arch="" +detected_package_manager="" + +rwx__detect_os_arch() { + if [ -f /etc/os-release ]; then + . /etc/os-release + + detected_os="$ID" + detected_os_version="$VERSION_ID" + detected_os_codename="$VERSION_CODENAME" + + case "$ID" in + ubuntu|debian) + detected_package_manager="apt" + ;; + alpine) + detected_package_manager="apk" + ;; + esac + fi + + detected_arch=$(uname -m) +} + +rwx_os_name() { + if [ -z "$detected_os" ]; then + rwx__detect_os_arch + fi + printf '%s\n' "$detected_os" +} + +rwx_os_version() { + if [ -z "$detected_os_version" ]; then + rwx__detect_os_arch + fi + printf '%s\n' "$detected_os_version" +} + +# Output the name and version of the operating system as expected by RWX's `base.os` field. +rwx_os_name_version() { + printf '%s %s\n' "$(rwx_os_name)" "$(rwx_os_version)" +} + +rwx_os_codename() { + if [ -z "$detected_os_codename" ]; then + rwx__detect_os_arch + fi + printf '%s\n' "$detected_os_codename" +} + +rwx_arch() { + if [ -z "$detected_arch" ]; then + rwx__detect_os_arch + fi + printf '%s\n' "$detected_arch" +} + +rwx_arch_amd() { + arch="$(rwx_arch)" + if [ "$arch" = "x86_64" ]; then + printf '%s\n' "amd64" + else + printf '%s\n' "$arch" + fi +} + +rwx_os_package_manager() { + if [ -z "$detected_package_manager" ]; then + rwx__detect_os_arch + fi + printf '%s\n' "$detected_package_manager" +} + +rwx_os_version_gte() { + compare_version="$1" + printf '%s\n' "$compare_version" "$(rwx_os_version)" | sed 's/\([0-9.]*\).*/\1/' | sort -c -t. -k1,1n -k2,2n -k3,3n >/dev/null 2>&1 +} + +rwx_os_version_lte() { + compare_version="$1" + printf '%s\n' "$(rwx_os_version)" "$compare_version" | sed 's/\([0-9.]*\).*/\1/' | sort -c -t. -k1,1n -k2,2n -k3,3n >/dev/null 2>&1 +} + +# Convert a string something usable as a RWX key. +# +# Replaces all non-alphanumeric characters with hyphens, compressing multiple hyphens into one. +rwx_keyify() { + printf '%s' "$*" | tr -c -s '[:alnum:]' '-' +} + +# Check if the provided list contains a given element. +# +# Usage: rwx_contains two one two three +rwx_contains() { + if [ "$#" -eq 0 ]; then + return 1 + fi + + needle=$1 + shift + + for item do + if [ "$item" = "$needle" ]; then + return 0 + fi + done + + return 1 +} + +rwx_os_name_in() { + rwx_contains "$(rwx_os_name)" "$@" +} + +rwx_os_package_manager_in() { + rwx_contains "$(rwx_os_package_manager)" "$@" +} + +rwx_maybe_sudo() { + if [ "$(id -u)" -eq 0 ]; then + "$@" + else + # If sudo is available, use it + if command -v sudo >/dev/null 2>&1; then + sudo "$@" + else + echo "Error: need root privileges but 'sudo' not found" >&2 + return 1 + fi + fi +} diff --git a/ruby/install/README.md b/ruby/install/README.md index 22bf480..fbb746b 100644 --- a/ruby/install/README.md +++ b/ruby/install/README.md @@ -9,7 +9,7 @@ If your project has a `.ruby-version` file: ```yaml tasks: - key: ruby - call: ruby/install 1.2.13 + call: ruby/install 1.2.14 with: ruby-version-file: .ruby-version filter: [.ruby-version] @@ -24,7 +24,7 @@ If your project does not have a `.ruby-version` file, you can specify the versio ```yaml tasks: - key: ruby - call: ruby/install 1.2.13 + call: ruby/install 1.2.14 with: ruby-version: 3.4.7 ``` diff --git a/ruby/install/mint-utils.sh b/ruby/install/mint-utils.sh deleted file mode 100755 index 725ee83..0000000 --- a/ruby/install/mint-utils.sh +++ /dev/null @@ -1,111 +0,0 @@ -#!/usr/bin/env bash -# mint-utils version 1.0.3 - -detected_os="" -detected_os_version="" -detected_os_codename="" -detected_arch="" -detected_package_manager="" - -function mint__detect_os_arch { - if [ -f /etc/os-release ]; then - . /etc/os-release - - detected_os="$ID" - detected_os_version="$VERSION_ID" - detected_os_codename="$VERSION_CODENAME" - - case "$ID" in - ubuntu|debian) - detected_package_manager="apt" - ;; - esac - fi - - detected_arch=$(uname -m) -} - -function mint_os_name { - if [ -z "$detected_os" ]; then - mint__detect_os_arch - fi - echo "$detected_os" -} - -function mint_os_version { - if [ -z "$detected_os_version" ]; then - mint__detect_os_arch - fi - echo "$detected_os_version" -} - -# Output the name and version of the operating system as expected by Mint's `base.os` field. -function mint_os_name_version { - echo "$(mint_os_name) $(mint_os_version)" -} - -function mint_os_codename { - if [ -z "$detected_os_codename" ]; then - mint__detect_os_arch - fi - echo "$detected_os_codename" -} - -function mint_arch { - if [ -z "$detected_arch" ]; then - mint__detect_os_arch - fi - echo "$detected_arch" -} - -function mint_arch_amd { - local arch - arch="$(mint_arch)" - if [ "$arch" = "x86_64" ]; then - echo "amd64" - else - echo "$arch" - fi -} - -function mint_os_package_manager { - if [ -z "$detected_package_manager" ]; then - mint__detect_os_arch - fi - echo "$detected_package_manager" -} - -function mint_os_version_gte { - local compare_version="$1" - printf '%s\n' "$compare_version" "$(mint_os_version)" | sort -Vsc >/dev/null 2>&1 -} - -function mint_os_version_lte { - local compare_version="$1" - printf '%s\n' "$compare_version" "$(mint_os_version)" | sort -Vsc -r >/dev/null 2>&1 -} - -# Convert a string something usable as a Mint key. -# -# Replaces all non-alphanumeric characters with hyphens, compressing multiple hyphens into one. -function mint_keyify { - echo -n "$*" | tr -c -s '[:alnum:]' '-' -} - -# Check if an array contains a given element. -# -# Usage: mint_contains two one two three -function mint_contains { - local needle="$1" - local elements=("${@:2}") - for item in "${elements[@]}"; do - if [ "$item" = "$needle" ]; then - return 0 - fi - done - return 1 -} - -function mint_os_package_manager_in { - mint_contains "$(mint_os_package_manager)" "$@" -} diff --git a/ruby/install/rwx-package.yml b/ruby/install/rwx-package.yml index 85dd88c..0226049 100644 --- a/ruby/install/rwx-package.yml +++ b/ruby/install/rwx-package.yml @@ -1,5 +1,5 @@ name: ruby/install -version: 1.2.13 +version: 1.2.14 description: Install Ruby, a dynamic programming language with a focus on simplicity and productivity source_code_url: https://github.com/rwx-cloud/packages/tree/main/ruby/install issue_tracker_url: https://github.com/rwx-cloud/packages/issues @@ -20,9 +20,9 @@ tasks: # # Check OS support # - source "$RWX_PACKAGE_PATH/mint-utils.sh" - if ! mint_os_package_manager_in apt; then - echo "Unsupported operating system or package manager \`$(mint_os_package_manager)\`" > "$(mktemp "$RWX_ERRORS/error-XXXX")" + source "$RWX_PACKAGE_PATH/rwx-utils.sh" + if ! rwx_os_package_manager_in apt; then + echo "Unsupported operating system or package manager \`$(rwx_os_package_manager)\`" > "$(mktemp "$RWX_ERRORS/error-XXXX")" exit 1 fi @@ -79,10 +79,10 @@ tasks: # # Find the prebuilt Ruby echo "Looking for Ruby $RUBY_VERSION..." - source "$RWX_PACKAGE_PATH/mint-utils.sh" + source "$RWX_PACKAGE_PATH/rwx-utils.sh" escaped_version=$(echo "$RUBY_VERSION" | sed "s/\./\\\\./g") # 3.2.2 => 3\.2\.2 - escaped_os=$(mint_os_name_version | sed "s/\./\\\\./g") - escaped_arch=$(mint_arch) + escaped_os=$(rwx_os_name_version | sed "s/\./\\\\./g") + escaped_arch=$(rwx_arch) if [ "$escaped_arch" = "aarch64" ]; then escaped_arch="arm64" fi diff --git a/ruby/install/rwx-utils.sh b/ruby/install/rwx-utils.sh new file mode 100755 index 0000000..7e906ff --- /dev/null +++ b/ruby/install/rwx-utils.sh @@ -0,0 +1,137 @@ +#!/bin/sh +# rwx-utils version 2.0.1 + +detected_os="" +detected_os_version="" +detected_os_codename="" +detected_arch="" +detected_package_manager="" + +rwx__detect_os_arch() { + if [ -f /etc/os-release ]; then + . /etc/os-release + + detected_os="$ID" + detected_os_version="$VERSION_ID" + detected_os_codename="$VERSION_CODENAME" + + case "$ID" in + ubuntu|debian) + detected_package_manager="apt" + ;; + alpine) + detected_package_manager="apk" + ;; + esac + fi + + detected_arch=$(uname -m) +} + +rwx_os_name() { + if [ -z "$detected_os" ]; then + rwx__detect_os_arch + fi + printf '%s\n' "$detected_os" +} + +rwx_os_version() { + if [ -z "$detected_os_version" ]; then + rwx__detect_os_arch + fi + printf '%s\n' "$detected_os_version" +} + +# Output the name and version of the operating system as expected by RWX's `base.os` field. +rwx_os_name_version() { + printf '%s %s\n' "$(rwx_os_name)" "$(rwx_os_version)" +} + +rwx_os_codename() { + if [ -z "$detected_os_codename" ]; then + rwx__detect_os_arch + fi + printf '%s\n' "$detected_os_codename" +} + +rwx_arch() { + if [ -z "$detected_arch" ]; then + rwx__detect_os_arch + fi + printf '%s\n' "$detected_arch" +} + +rwx_arch_amd() { + arch="$(rwx_arch)" + if [ "$arch" = "x86_64" ]; then + printf '%s\n' "amd64" + else + printf '%s\n' "$arch" + fi +} + +rwx_os_package_manager() { + if [ -z "$detected_package_manager" ]; then + rwx__detect_os_arch + fi + printf '%s\n' "$detected_package_manager" +} + +rwx_os_version_gte() { + compare_version="$1" + printf '%s\n' "$compare_version" "$(rwx_os_version)" | sed 's/\([0-9.]*\).*/\1/' | sort -c -t. -k1,1n -k2,2n -k3,3n >/dev/null 2>&1 +} + +rwx_os_version_lte() { + compare_version="$1" + printf '%s\n' "$(rwx_os_version)" "$compare_version" | sed 's/\([0-9.]*\).*/\1/' | sort -c -t. -k1,1n -k2,2n -k3,3n >/dev/null 2>&1 +} + +# Convert a string something usable as a RWX key. +# +# Replaces all non-alphanumeric characters with hyphens, compressing multiple hyphens into one. +rwx_keyify() { + printf '%s' "$*" | tr -c -s '[:alnum:]' '-' +} + +# Check if the provided list contains a given element. +# +# Usage: rwx_contains two one two three +rwx_contains() { + if [ "$#" -eq 0 ]; then + return 1 + fi + + needle=$1 + shift + + for item do + if [ "$item" = "$needle" ]; then + return 0 + fi + done + + return 1 +} + +rwx_os_name_in() { + rwx_contains "$(rwx_os_name)" "$@" +} + +rwx_os_package_manager_in() { + rwx_contains "$(rwx_os_package_manager)" "$@" +} + +rwx_maybe_sudo() { + if [ "$(id -u)" -eq 0 ]; then + "$@" + else + # If sudo is available, use it + if command -v sudo >/dev/null 2>&1; then + sudo "$@" + else + echo "Error: need root privileges but 'sudo' not found" >&2 + return 1 + fi + fi +} diff --git a/rwx-utils.sh b/rwx-utils.sh index 1d1e0cf..7e906ff 100755 --- a/rwx-utils.sh +++ b/rwx-utils.sh @@ -1,5 +1,5 @@ #!/bin/sh -# rwx-utils version 2.0.0 +# rwx-utils version 2.0.1 detected_os="" detected_os_version="" @@ -84,7 +84,7 @@ rwx_os_version_gte() { rwx_os_version_lte() { compare_version="$1" - printf '%s\n' "$compare_version" "$(rwx_os_version)" | sed 's/\([0-9.]*\).*/\1/' | sort -c -t. -k1,1n -k2,2n -k3,3n -r >/dev/null 2>&1 + printf '%s\n' "$(rwx_os_version)" "$compare_version" | sed 's/\([0-9.]*\).*/\1/' | sort -c -t. -k1,1n -k2,2n -k3,3n >/dev/null 2>&1 } # Convert a string something usable as a RWX key. diff --git a/rwx/base/README.md b/rwx/base/README.md index 122e1be..00c8611 100644 --- a/rwx/base/README.md +++ b/rwx/base/README.md @@ -8,6 +8,5 @@ This package applies recommended base image configuration. It currently works wi ```yaml base: image: ubuntu:24.04 - config: rwx/base 1.0.0 + config: rwx/base 1.0.1 ``` - diff --git a/rwx/base/rwx-package.yml b/rwx/base/rwx-package.yml index 9fda2af..2ed9f81 100644 --- a/rwx/base/rwx-package.yml +++ b/rwx/base/rwx-package.yml @@ -1,5 +1,5 @@ name: rwx/base -version: 1.0.0 +version: 1.0.1 description: The default base image configuration source_code_url: https://github.com/rwx-cloud/packages/tree/main/rwx/base issue_tracker_url: https://github.com/rwx-cloud/packages/issues @@ -7,10 +7,10 @@ issue_tracker_url: https://github.com/rwx-cloud/packages/issues tasks: - key: configure run: | - source "$RWX_PACKAGE_PATH/scripts/mint-utils.sh" + source "$RWX_PACKAGE_PATH/scripts/rwx-utils.sh" supported_os_version=("ubuntu 20.04" "ubuntu 22.04" "ubuntu 24.04") - current_os_version="$(mint_os_name_version)" + current_os_version="$(rwx_os_name_version)" supported=false for os_v in "${supported_os_version[@]}"; do diff --git a/rwx/base/scripts/docker.sh b/rwx/base/scripts/docker.sh index 9be3ff8..af59ee3 100755 --- a/rwx/base/scripts/docker.sh +++ b/rwx/base/scripts/docker.sh @@ -2,11 +2,11 @@ set -euo pipefail -source "${RWX_PACKAGE_PATH}/scripts/mint-utils.sh" +source "${RWX_PACKAGE_PATH}/scripts/rwx-utils.sh" -echo "Installing Docker on $(mint_os_name_version)" +echo "Installing Docker on $(rwx_os_name_version)" -case "$(mint_os_name_version)" in +case "$(rwx_os_name_version)" in "ubuntu 24.04") DOCKER_VERSION=5:28.0.4-1~ubuntu.24.04~noble DOCKER_BUILDX_VERSION=0.22.0-1~ubuntu.24.04~noble diff --git a/rwx/base/scripts/mint-utils.sh b/rwx/base/scripts/mint-utils.sh deleted file mode 100644 index 97d280c..0000000 --- a/rwx/base/scripts/mint-utils.sh +++ /dev/null @@ -1,115 +0,0 @@ -#!/usr/bin/env bash -# mint-utils version 1.0.4 - -detected_os="" -detected_os_version="" -detected_os_codename="" -detected_arch="" -detected_package_manager="" - -function mint__detect_os_arch { - if [ -f /etc/os-release ]; then - . /etc/os-release - - detected_os="$ID" - detected_os_version="$VERSION_ID" - detected_os_codename="$VERSION_CODENAME" - - case "$ID" in - ubuntu|debian) - detected_package_manager="apt" - ;; - esac - fi - - detected_arch=$(uname -m) -} - -function mint_os_name { - if [ -z "$detected_os" ]; then - mint__detect_os_arch - fi - echo "$detected_os" -} - -function mint_os_version { - if [ -z "$detected_os_version" ]; then - mint__detect_os_arch - fi - echo "$detected_os_version" -} - -# Output the name and version of the operating system as expected by Mint's `base.os` field. -function mint_os_name_version { - echo "$(mint_os_name) $(mint_os_version)" -} - -function mint_os_codename { - if [ -z "$detected_os_codename" ]; then - mint__detect_os_arch - fi - echo "$detected_os_codename" -} - -function mint_arch { - if [ -z "$detected_arch" ]; then - mint__detect_os_arch - fi - echo "$detected_arch" -} - -function mint_arch_amd { - local arch - arch="$(mint_arch)" - if [ "$arch" = "x86_64" ]; then - echo "amd64" - else - echo "$arch" - fi -} - -function mint_os_package_manager { - if [ -z "$detected_package_manager" ]; then - mint__detect_os_arch - fi - echo "$detected_package_manager" -} - -function mint_os_version_gte { - local compare_version="$1" - printf '%s\n' "$compare_version" "$(mint_os_version)" | sort -Vsc >/dev/null 2>&1 -} - -function mint_os_version_lte { - local compare_version="$1" - printf '%s\n' "$compare_version" "$(mint_os_version)" | sort -Vsc -r >/dev/null 2>&1 -} - -# Convert a string something usable as a Mint key. -# -# Replaces all non-alphanumeric characters with hyphens, compressing multiple hyphens into one. -function mint_keyify { - echo -n "$*" | tr -c -s '[:alnum:]' '-' -} - -# Check if an array contains a given element. -# -# Usage: mint_contains two one two three -function mint_contains { - local needle="$1" - local elements=("${@:2}") - for item in "${elements[@]}"; do - if [ "$item" = "$needle" ]; then - return 0 - fi - done - return 1 -} - -function mint_os_name_in { - mint_contains "$(mint_os_name)" "$@" -} - -function mint_os_package_manager_in { - mint_contains "$(mint_os_package_manager)" "$@" -} diff --git a/rwx/base/scripts/rwx-utils.sh b/rwx/base/scripts/rwx-utils.sh new file mode 100755 index 0000000..7e906ff --- /dev/null +++ b/rwx/base/scripts/rwx-utils.sh @@ -0,0 +1,137 @@ +#!/bin/sh +# rwx-utils version 2.0.1 + +detected_os="" +detected_os_version="" +detected_os_codename="" +detected_arch="" +detected_package_manager="" + +rwx__detect_os_arch() { + if [ -f /etc/os-release ]; then + . /etc/os-release + + detected_os="$ID" + detected_os_version="$VERSION_ID" + detected_os_codename="$VERSION_CODENAME" + + case "$ID" in + ubuntu|debian) + detected_package_manager="apt" + ;; + alpine) + detected_package_manager="apk" + ;; + esac + fi + + detected_arch=$(uname -m) +} + +rwx_os_name() { + if [ -z "$detected_os" ]; then + rwx__detect_os_arch + fi + printf '%s\n' "$detected_os" +} + +rwx_os_version() { + if [ -z "$detected_os_version" ]; then + rwx__detect_os_arch + fi + printf '%s\n' "$detected_os_version" +} + +# Output the name and version of the operating system as expected by RWX's `base.os` field. +rwx_os_name_version() { + printf '%s %s\n' "$(rwx_os_name)" "$(rwx_os_version)" +} + +rwx_os_codename() { + if [ -z "$detected_os_codename" ]; then + rwx__detect_os_arch + fi + printf '%s\n' "$detected_os_codename" +} + +rwx_arch() { + if [ -z "$detected_arch" ]; then + rwx__detect_os_arch + fi + printf '%s\n' "$detected_arch" +} + +rwx_arch_amd() { + arch="$(rwx_arch)" + if [ "$arch" = "x86_64" ]; then + printf '%s\n' "amd64" + else + printf '%s\n' "$arch" + fi +} + +rwx_os_package_manager() { + if [ -z "$detected_package_manager" ]; then + rwx__detect_os_arch + fi + printf '%s\n' "$detected_package_manager" +} + +rwx_os_version_gte() { + compare_version="$1" + printf '%s\n' "$compare_version" "$(rwx_os_version)" | sed 's/\([0-9.]*\).*/\1/' | sort -c -t. -k1,1n -k2,2n -k3,3n >/dev/null 2>&1 +} + +rwx_os_version_lte() { + compare_version="$1" + printf '%s\n' "$(rwx_os_version)" "$compare_version" | sed 's/\([0-9.]*\).*/\1/' | sort -c -t. -k1,1n -k2,2n -k3,3n >/dev/null 2>&1 +} + +# Convert a string something usable as a RWX key. +# +# Replaces all non-alphanumeric characters with hyphens, compressing multiple hyphens into one. +rwx_keyify() { + printf '%s' "$*" | tr -c -s '[:alnum:]' '-' +} + +# Check if the provided list contains a given element. +# +# Usage: rwx_contains two one two three +rwx_contains() { + if [ "$#" -eq 0 ]; then + return 1 + fi + + needle=$1 + shift + + for item do + if [ "$item" = "$needle" ]; then + return 0 + fi + done + + return 1 +} + +rwx_os_name_in() { + rwx_contains "$(rwx_os_name)" "$@" +} + +rwx_os_package_manager_in() { + rwx_contains "$(rwx_os_package_manager)" "$@" +} + +rwx_maybe_sudo() { + if [ "$(id -u)" -eq 0 ]; then + "$@" + else + # If sudo is available, use it + if command -v sudo >/dev/null 2>&1; then + sudo "$@" + else + echo "Error: need root privileges but 'sudo' not found" >&2 + return 1 + fi + fi +} diff --git a/tailscale/install/README.md b/tailscale/install/README.md index c288885..b092d3f 100644 --- a/tailscale/install/README.md +++ b/tailscale/install/README.md @@ -5,7 +5,7 @@ To install the latest version of Tailscale: ```yaml tasks: - key: tailscale - call: tailscale/install 1.0.4 + call: tailscale/install 1.0.5 ``` To install a specific version of Tailscale: @@ -13,7 +13,7 @@ To install a specific version of Tailscale: ```yaml tasks: - key: tailscale - call: tailscale/install 1.0.4 + call: tailscale/install 1.0.5 with: version: "1.78.1" ``` diff --git a/tailscale/install/mint-utils.sh b/tailscale/install/mint-utils.sh deleted file mode 100755 index 97d280c..0000000 --- a/tailscale/install/mint-utils.sh +++ /dev/null @@ -1,115 +0,0 @@ -#!/usr/bin/env bash -# mint-utils version 1.0.4 - -detected_os="" -detected_os_version="" -detected_os_codename="" -detected_arch="" -detected_package_manager="" - -function mint__detect_os_arch { - if [ -f /etc/os-release ]; then - . /etc/os-release - - detected_os="$ID" - detected_os_version="$VERSION_ID" - detected_os_codename="$VERSION_CODENAME" - - case "$ID" in - ubuntu|debian) - detected_package_manager="apt" - ;; - esac - fi - - detected_arch=$(uname -m) -} - -function mint_os_name { - if [ -z "$detected_os" ]; then - mint__detect_os_arch - fi - echo "$detected_os" -} - -function mint_os_version { - if [ -z "$detected_os_version" ]; then - mint__detect_os_arch - fi - echo "$detected_os_version" -} - -# Output the name and version of the operating system as expected by Mint's `base.os` field. -function mint_os_name_version { - echo "$(mint_os_name) $(mint_os_version)" -} - -function mint_os_codename { - if [ -z "$detected_os_codename" ]; then - mint__detect_os_arch - fi - echo "$detected_os_codename" -} - -function mint_arch { - if [ -z "$detected_arch" ]; then - mint__detect_os_arch - fi - echo "$detected_arch" -} - -function mint_arch_amd { - local arch - arch="$(mint_arch)" - if [ "$arch" = "x86_64" ]; then - echo "amd64" - else - echo "$arch" - fi -} - -function mint_os_package_manager { - if [ -z "$detected_package_manager" ]; then - mint__detect_os_arch - fi - echo "$detected_package_manager" -} - -function mint_os_version_gte { - local compare_version="$1" - printf '%s\n' "$compare_version" "$(mint_os_version)" | sort -Vsc >/dev/null 2>&1 -} - -function mint_os_version_lte { - local compare_version="$1" - printf '%s\n' "$compare_version" "$(mint_os_version)" | sort -Vsc -r >/dev/null 2>&1 -} - -# Convert a string something usable as a Mint key. -# -# Replaces all non-alphanumeric characters with hyphens, compressing multiple hyphens into one. -function mint_keyify { - echo -n "$*" | tr -c -s '[:alnum:]' '-' -} - -# Check if an array contains a given element. -# -# Usage: mint_contains two one two three -function mint_contains { - local needle="$1" - local elements=("${@:2}") - for item in "${elements[@]}"; do - if [ "$item" = "$needle" ]; then - return 0 - fi - done - return 1 -} - -function mint_os_name_in { - mint_contains "$(mint_os_name)" "$@" -} - -function mint_os_package_manager_in { - mint_contains "$(mint_os_package_manager)" "$@" -} diff --git a/tailscale/install/rwx-package.yml b/tailscale/install/rwx-package.yml index 06366f3..0fe3386 100644 --- a/tailscale/install/rwx-package.yml +++ b/tailscale/install/rwx-package.yml @@ -1,5 +1,5 @@ name: tailscale/install -version: 1.0.4 +version: 1.0.5 description: Install Tailscale source_code_url: https://github.com/rwx-cloud/packages/tree/main/tailscale/install issue_tracker_url: https://github.com/rwx-cloud/packages/issues @@ -13,12 +13,12 @@ tasks: - key: download run: | set -u - source "$RWX_PACKAGE_PATH/mint-utils.sh" + source "$RWX_PACKAGE_PATH/rwx-utils.sh" if [ "$VERSION" = "latest" ]; then VERSION=$(curl -fs "https://pkgs.tailscale.com/stable/?mode=json" | jq -r .Version) fi - ARCH=$(mint_arch_amd) + ARCH=$(rwx_arch_amd) if [ "$ARCH" = "aarch64" ]; then ARCH="arm64" fi diff --git a/tailscale/install/rwx-utils.sh b/tailscale/install/rwx-utils.sh new file mode 100755 index 0000000..7e906ff --- /dev/null +++ b/tailscale/install/rwx-utils.sh @@ -0,0 +1,137 @@ +#!/bin/sh +# rwx-utils version 2.0.1 + +detected_os="" +detected_os_version="" +detected_os_codename="" +detected_arch="" +detected_package_manager="" + +rwx__detect_os_arch() { + if [ -f /etc/os-release ]; then + . /etc/os-release + + detected_os="$ID" + detected_os_version="$VERSION_ID" + detected_os_codename="$VERSION_CODENAME" + + case "$ID" in + ubuntu|debian) + detected_package_manager="apt" + ;; + alpine) + detected_package_manager="apk" + ;; + esac + fi + + detected_arch=$(uname -m) +} + +rwx_os_name() { + if [ -z "$detected_os" ]; then + rwx__detect_os_arch + fi + printf '%s\n' "$detected_os" +} + +rwx_os_version() { + if [ -z "$detected_os_version" ]; then + rwx__detect_os_arch + fi + printf '%s\n' "$detected_os_version" +} + +# Output the name and version of the operating system as expected by RWX's `base.os` field. +rwx_os_name_version() { + printf '%s %s\n' "$(rwx_os_name)" "$(rwx_os_version)" +} + +rwx_os_codename() { + if [ -z "$detected_os_codename" ]; then + rwx__detect_os_arch + fi + printf '%s\n' "$detected_os_codename" +} + +rwx_arch() { + if [ -z "$detected_arch" ]; then + rwx__detect_os_arch + fi + printf '%s\n' "$detected_arch" +} + +rwx_arch_amd() { + arch="$(rwx_arch)" + if [ "$arch" = "x86_64" ]; then + printf '%s\n' "amd64" + else + printf '%s\n' "$arch" + fi +} + +rwx_os_package_manager() { + if [ -z "$detected_package_manager" ]; then + rwx__detect_os_arch + fi + printf '%s\n' "$detected_package_manager" +} + +rwx_os_version_gte() { + compare_version="$1" + printf '%s\n' "$compare_version" "$(rwx_os_version)" | sed 's/\([0-9.]*\).*/\1/' | sort -c -t. -k1,1n -k2,2n -k3,3n >/dev/null 2>&1 +} + +rwx_os_version_lte() { + compare_version="$1" + printf '%s\n' "$(rwx_os_version)" "$compare_version" | sed 's/\([0-9.]*\).*/\1/' | sort -c -t. -k1,1n -k2,2n -k3,3n >/dev/null 2>&1 +} + +# Convert a string something usable as a RWX key. +# +# Replaces all non-alphanumeric characters with hyphens, compressing multiple hyphens into one. +rwx_keyify() { + printf '%s' "$*" | tr -c -s '[:alnum:]' '-' +} + +# Check if the provided list contains a given element. +# +# Usage: rwx_contains two one two three +rwx_contains() { + if [ "$#" -eq 0 ]; then + return 1 + fi + + needle=$1 + shift + + for item do + if [ "$item" = "$needle" ]; then + return 0 + fi + done + + return 1 +} + +rwx_os_name_in() { + rwx_contains "$(rwx_os_name)" "$@" +} + +rwx_os_package_manager_in() { + rwx_contains "$(rwx_os_package_manager)" "$@" +} + +rwx_maybe_sudo() { + if [ "$(id -u)" -eq 0 ]; then + "$@" + else + # If sudo is available, use it + if command -v sudo >/dev/null 2>&1; then + sudo "$@" + else + echo "Error: need root privileges but 'sudo' not found" >&2 + return 1 + fi + fi +} diff --git a/twingate/setup/README.md b/twingate/setup/README.md index 217f05e..839685f 100644 --- a/twingate/setup/README.md +++ b/twingate/setup/README.md @@ -5,7 +5,7 @@ To install & setup the latest version of Twingate: ```yaml tasks: - key: twingate - call: twingate/setup 1.0.8 + call: twingate/setup 1.0.9 with: twingate-service-key: ${{ secrets.twingate-service-key }} ``` diff --git a/twingate/setup/mint-utils.sh b/twingate/setup/mint-utils.sh deleted file mode 100755 index 725ee83..0000000 --- a/twingate/setup/mint-utils.sh +++ /dev/null @@ -1,111 +0,0 @@ -#!/usr/bin/env bash -# mint-utils version 1.0.3 - -detected_os="" -detected_os_version="" -detected_os_codename="" -detected_arch="" -detected_package_manager="" - -function mint__detect_os_arch { - if [ -f /etc/os-release ]; then - . /etc/os-release - - detected_os="$ID" - detected_os_version="$VERSION_ID" - detected_os_codename="$VERSION_CODENAME" - - case "$ID" in - ubuntu|debian) - detected_package_manager="apt" - ;; - esac - fi - - detected_arch=$(uname -m) -} - -function mint_os_name { - if [ -z "$detected_os" ]; then - mint__detect_os_arch - fi - echo "$detected_os" -} - -function mint_os_version { - if [ -z "$detected_os_version" ]; then - mint__detect_os_arch - fi - echo "$detected_os_version" -} - -# Output the name and version of the operating system as expected by Mint's `base.os` field. -function mint_os_name_version { - echo "$(mint_os_name) $(mint_os_version)" -} - -function mint_os_codename { - if [ -z "$detected_os_codename" ]; then - mint__detect_os_arch - fi - echo "$detected_os_codename" -} - -function mint_arch { - if [ -z "$detected_arch" ]; then - mint__detect_os_arch - fi - echo "$detected_arch" -} - -function mint_arch_amd { - local arch - arch="$(mint_arch)" - if [ "$arch" = "x86_64" ]; then - echo "amd64" - else - echo "$arch" - fi -} - -function mint_os_package_manager { - if [ -z "$detected_package_manager" ]; then - mint__detect_os_arch - fi - echo "$detected_package_manager" -} - -function mint_os_version_gte { - local compare_version="$1" - printf '%s\n' "$compare_version" "$(mint_os_version)" | sort -Vsc >/dev/null 2>&1 -} - -function mint_os_version_lte { - local compare_version="$1" - printf '%s\n' "$compare_version" "$(mint_os_version)" | sort -Vsc -r >/dev/null 2>&1 -} - -# Convert a string something usable as a Mint key. -# -# Replaces all non-alphanumeric characters with hyphens, compressing multiple hyphens into one. -function mint_keyify { - echo -n "$*" | tr -c -s '[:alnum:]' '-' -} - -# Check if an array contains a given element. -# -# Usage: mint_contains two one two three -function mint_contains { - local needle="$1" - local elements=("${@:2}") - for item in "${elements[@]}"; do - if [ "$item" = "$needle" ]; then - return 0 - fi - done - return 1 -} - -function mint_os_package_manager_in { - mint_contains "$(mint_os_package_manager)" "$@" -} diff --git a/twingate/setup/rwx-package.yml b/twingate/setup/rwx-package.yml index 1987365..766d092 100644 --- a/twingate/setup/rwx-package.yml +++ b/twingate/setup/rwx-package.yml @@ -1,5 +1,5 @@ name: twingate/setup -version: 1.0.8 +version: 1.0.9 description: Install & setup Twingate source_code_url: https://github.com/rwx-cloud/packages/tree/main/twingate/setup issue_tracker_url: https://github.com/rwx-cloud/packages/issues @@ -12,9 +12,9 @@ parameters: tasks: - key: install run: | - source "$RWX_PACKAGE_PATH/mint-utils.sh" - if ! mint_os_package_manager_in apt; then - echo "Unsupported operating system or package manager \`$(mint_os_package_manager)\`" > "$(mktemp "$RWX_ERRORS/error-XXXX")" + source "$RWX_PACKAGE_PATH/rwx-utils.sh" + if ! rwx_os_package_manager_in apt; then + echo "Unsupported operating system or package manager \`$(rwx_os_package_manager)\`" > "$(mktemp "$RWX_ERRORS/error-XXXX")" exit 1 fi diff --git a/twingate/setup/rwx-utils.sh b/twingate/setup/rwx-utils.sh new file mode 100755 index 0000000..7e906ff --- /dev/null +++ b/twingate/setup/rwx-utils.sh @@ -0,0 +1,137 @@ +#!/bin/sh +# rwx-utils version 2.0.1 + +detected_os="" +detected_os_version="" +detected_os_codename="" +detected_arch="" +detected_package_manager="" + +rwx__detect_os_arch() { + if [ -f /etc/os-release ]; then + . /etc/os-release + + detected_os="$ID" + detected_os_version="$VERSION_ID" + detected_os_codename="$VERSION_CODENAME" + + case "$ID" in + ubuntu|debian) + detected_package_manager="apt" + ;; + alpine) + detected_package_manager="apk" + ;; + esac + fi + + detected_arch=$(uname -m) +} + +rwx_os_name() { + if [ -z "$detected_os" ]; then + rwx__detect_os_arch + fi + printf '%s\n' "$detected_os" +} + +rwx_os_version() { + if [ -z "$detected_os_version" ]; then + rwx__detect_os_arch + fi + printf '%s\n' "$detected_os_version" +} + +# Output the name and version of the operating system as expected by RWX's `base.os` field. +rwx_os_name_version() { + printf '%s %s\n' "$(rwx_os_name)" "$(rwx_os_version)" +} + +rwx_os_codename() { + if [ -z "$detected_os_codename" ]; then + rwx__detect_os_arch + fi + printf '%s\n' "$detected_os_codename" +} + +rwx_arch() { + if [ -z "$detected_arch" ]; then + rwx__detect_os_arch + fi + printf '%s\n' "$detected_arch" +} + +rwx_arch_amd() { + arch="$(rwx_arch)" + if [ "$arch" = "x86_64" ]; then + printf '%s\n' "amd64" + else + printf '%s\n' "$arch" + fi +} + +rwx_os_package_manager() { + if [ -z "$detected_package_manager" ]; then + rwx__detect_os_arch + fi + printf '%s\n' "$detected_package_manager" +} + +rwx_os_version_gte() { + compare_version="$1" + printf '%s\n' "$compare_version" "$(rwx_os_version)" | sed 's/\([0-9.]*\).*/\1/' | sort -c -t. -k1,1n -k2,2n -k3,3n >/dev/null 2>&1 +} + +rwx_os_version_lte() { + compare_version="$1" + printf '%s\n' "$(rwx_os_version)" "$compare_version" | sed 's/\([0-9.]*\).*/\1/' | sort -c -t. -k1,1n -k2,2n -k3,3n >/dev/null 2>&1 +} + +# Convert a string something usable as a RWX key. +# +# Replaces all non-alphanumeric characters with hyphens, compressing multiple hyphens into one. +rwx_keyify() { + printf '%s' "$*" | tr -c -s '[:alnum:]' '-' +} + +# Check if the provided list contains a given element. +# +# Usage: rwx_contains two one two three +rwx_contains() { + if [ "$#" -eq 0 ]; then + return 1 + fi + + needle=$1 + shift + + for item do + if [ "$item" = "$needle" ]; then + return 0 + fi + done + + return 1 +} + +rwx_os_name_in() { + rwx_contains "$(rwx_os_name)" "$@" +} + +rwx_os_package_manager_in() { + rwx_contains "$(rwx_os_package_manager)" "$@" +} + +rwx_maybe_sudo() { + if [ "$(id -u)" -eq 0 ]; then + "$@" + else + # If sudo is available, use it + if command -v sudo >/dev/null 2>&1; then + sudo "$@" + else + echo "Error: need root privileges but 'sudo' not found" >&2 + return 1 + fi + fi +}