diff --git a/README.md b/README.md index c4fa8ca..311fd6d 100644 --- a/README.md +++ b/README.md @@ -6,11 +6,12 @@ not already covered by the VSCode Go plugin. Where applicable, multiple different distribution base images are supported, but unfortunately only to the limitation of different distribution support in Dev -Containers features we rely on. In case of Go tools, this unfortunately leaves -out Alpine, because [Microsoft's Go Dev Container feature does not support +Containers features we rely on. In case of **Go** tools, this unfortunately +leaves out Alpine, because [Microsoft's Go Dev Container feature does not +support Alpine](https://github.com/devcontainers/features/blob/091886b3568dad70f835cc428dad1fdf7bc6a9b3/src/go/install.sh#L32-L44). -Same unfortunate situation Microsoft's node Dev Container feature that also -doesn't support Alpine. +The same unfortunate situation applies also to Microsoft's **node** Dev +Container feature that also doesn't support Alpine. | Feature | Alpine | Alma | Debian | Fedora | Ubuntu | | --------------------------- | ------ | ---- | ------ | ------ | ------ | @@ -25,6 +26,7 @@ doesn't support Alpine. | lazygit | ✅ | ✅ | ✅ | ✅ | ✅ | | local-pkgsite | | ✅ | ✅ | ✅ | ✅ | | nerdctl | | ✅ | ✅ | ✅ | ✅ | +| pinact | ✅ | ✅ | ✅ | ✅ | ✅ | | pin-github-action | | ✅ | ✅ | ✅ | ✅ | | pull-through-cache-registry | | | ✅ | | ✅ | | wal-wahl | | ✅ | ✅ | ✅ | ✅ | diff --git a/src/lazygit/NOTES.md b/src/lazygit/NOTES.md index 23d2d21..39087f4 100644 --- a/src/lazygit/NOTES.md +++ b/src/lazygit/NOTES.md @@ -6,7 +6,3 @@ Tested with: - [mcr.microsoft.com/devcontainers/base:debian](https://mcr.microsoft.com/en-us/artifact/mar/devcontainers/base/about#about:_debian), - [fedora](https://hub.docker.com/_/fedora), - [mcr.microsoft.com/devcontainers/base:ubuntu](https://mcr.microsoft.com/en-us/artifact/mar/devcontainers/base/about#about:_ubuntu). - -## Acknowledgement - -[@bpftool](https://github.com/libbpf/bpftool) diff --git a/src/lazygit/README.md b/src/lazygit/README.md index f7ea143..c72d714 100644 --- a/src/lazygit/README.md +++ b/src/lazygit/README.md @@ -26,10 +26,6 @@ Tested with: - [fedora](https://hub.docker.com/_/fedora), - [mcr.microsoft.com/devcontainers/base:ubuntu](https://mcr.microsoft.com/en-us/artifact/mar/devcontainers/base/about#about:_ubuntu). -## Acknowledgement - -[@bpftool](https://github.com/libbpf/bpftool) - --- diff --git a/src/pinact/NOTES.md b/src/pinact/NOTES.md new file mode 100644 index 0000000..39087f4 --- /dev/null +++ b/src/pinact/NOTES.md @@ -0,0 +1,8 @@ +## OS Support + +Tested with: +- [mcr.microsoft.com/devcontainers/base:alpine](mcr.microsoft.com/devcontainers/base:alpine), +- [ghcr.io/almalinux/almalinux](https://ghcr.io/almalinux/almalinux), +- [mcr.microsoft.com/devcontainers/base:debian](https://mcr.microsoft.com/en-us/artifact/mar/devcontainers/base/about#about:_debian), +- [fedora](https://hub.docker.com/_/fedora), +- [mcr.microsoft.com/devcontainers/base:ubuntu](https://mcr.microsoft.com/en-us/artifact/mar/devcontainers/base/about#about:_ubuntu). diff --git a/src/pinact/README.md b/src/pinact/README.md new file mode 100644 index 0000000..ab27533 --- /dev/null +++ b/src/pinact/README.md @@ -0,0 +1,32 @@ + +# pinact (pinact) + +Installs pinact from upstream https://github.com/suzuki-shunsuke/pinact binary releases. + +## Example Usage + +```json +"features": { + "ghcr.io/thediveo/devcontainer-features/pinact:0": {} +} +``` + +## Options + +| Options Id | Description | Type | Default Value | +|-----|-----|-----|-----| +| version | version of pinact to install from upstream | string | latest | + +## OS Support + +Tested with: +- [mcr.microsoft.com/devcontainers/base:alpine](mcr.microsoft.com/devcontainers/base:alpine), +- [ghcr.io/almalinux/almalinux](https://ghcr.io/almalinux/almalinux), +- [mcr.microsoft.com/devcontainers/base:debian](https://mcr.microsoft.com/en-us/artifact/mar/devcontainers/base/about#about:_debian), +- [fedora](https://hub.docker.com/_/fedora), +- [mcr.microsoft.com/devcontainers/base:ubuntu](https://mcr.microsoft.com/en-us/artifact/mar/devcontainers/base/about#about:_ubuntu). + + +--- + +_Note: This file was auto-generated from the [devcontainer-feature.json](https://github.com/thediveo/devcontainer-features/blob/main/src/pinact/devcontainer-feature.json). Add additional notes to a `NOTES.md`._ diff --git a/src/pinact/devcontainer-feature.json b/src/pinact/devcontainer-feature.json new file mode 100644 index 0000000..17dabf6 --- /dev/null +++ b/src/pinact/devcontainer-feature.json @@ -0,0 +1,13 @@ +{ + "name": "pinact", + "id": "pinact", + "version": "0.0.1", + "description": "Installs pinact from upstream https://github.com/suzuki-shunsuke/pinact binary releases.", + "options": { + "version": { + "type": "string", + "default": "latest", + "description": "version of pinact to install from upstream" + } + } +} \ No newline at end of file diff --git a/src/pinact/install.sh b/src/pinact/install.sh new file mode 100755 index 0000000..bf49795 --- /dev/null +++ b/src/pinact/install.sh @@ -0,0 +1,177 @@ +#!/usr/bin/env bash + +# Distribution and package manager detection are licensed by Microsoft +# Corporation under the MIT License, please refer to: +# https://github.com/devcontainers/features/blob/main/src/go/install.sh: +# +# Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the +# MIT License. See https://go.microsoft.com/fwlink/?linkid=2090316 for license +# information + +set -e + +PINACT_VERSION="${VERSION:-"latest"}" + +REPOSLUG="suzuki-shunsuke/pinact" +QUERYLATEST_URL="https://api.github.com/repos/${REPOSLUG}/releases/latest" +RELEASE_URL="https://github.com/${REPOSLUG}/releases/download/" + +echo "installing feature pinact..." + +if [ "$(id -u)" -ne 0 ]; then + echo -e 'Script must be run as root. Use sudo, su, or add "USER root" to your Dockerfile before running this script.' + exit 1 +fi + +# Bring in ID, ID_LIKE, VERSION_ID, VERSION_CODENAME +. /etc/os-release +# Get an adjusted ID independent of distro variants +MAJOR_VERSION_ID=$(echo ${VERSION_ID} | cut -d . -f 1) +if [ "${ID}" = "debian" ] || [ "${ID_LIKE}" = "debian" ]; then + ADJUSTED_ID="debian" +elif [ "${ID}" = "alpine" ]; then + ADJUSTED_ID="alpine" +elif [[ "${ID}" = "rhel" || "${ID}" = "fedora" || "${ID}" = "mariner" || "${ID_LIKE}" = *"rhel"* || "${ID_LIKE}" = *"fedora"* || "${ID_LIKE}" = *"mariner"* ]]; then + ADJUSTED_ID="rhel" + if [[ "${ID}" = "rhel" ]] || [[ "${ID}" = *"alma"* ]] || [[ "${ID}" = *"rocky"* ]]; then + VERSION_CODENAME="rhel${MAJOR_VERSION_ID}" + else + VERSION_CODENAME="${ID}${MAJOR_VERSION_ID}" + fi +else + echo "Linux distro ${ID} not supported." + exit 1 +fi + +if [ "${ADJUSTED_ID}" = "rhel" ] && [ "${VERSION_CODENAME-}" = "centos7" ]; then + # As of 1 July 2024, mirrorlist.centos.org no longer exists. + # Update the repo files to reference vault.centos.org. + sed -i s/mirror.centos.org/vault.centos.org/g /etc/yum.repos.d/*.repo + sed -i s/^#.*baseurl=http/baseurl=http/g /etc/yum.repos.d/*.repo + sed -i s/^mirrorlist=http/#mirrorlist=http/g /etc/yum.repos.d/*.repo +fi + +# Setup INSTALL_CMD & PKG_MGR_CMD +if type apt-get > /dev/null 2>&1; then + PKG_MGR_CMD=apt-get + INSTALL_CMD="${PKG_MGR_CMD} -y install --no-install-recommends" +elif type apk > /dev/null 2>&1; then + PKG_MGR_CMD=apk + INSTALL_CMD="${PKG_MGR_CMD} add --no-interactive" +elif type microdnf > /dev/null 2>&1; then + PKG_MGR_CMD=microdnf + INSTALL_CMD="${PKG_MGR_CMD} ${INSTALL_CMD_ADDL_REPOS} -y install --refresh --best --nodocs --noplugins --setopt=install_weak_deps=0" +elif type dnf > /dev/null 2>&1; then + PKG_MGR_CMD=dnf + INSTALL_CMD="${PKG_MGR_CMD} ${INSTALL_CMD_ADDL_REPOS} -y install --refresh --best --nodocs --noplugins --setopt=install_weak_deps=0" +else + PKG_MGR_CMD=yum + INSTALL_CMD="${PKG_MGR_CMD} ${INSTALL_CMD_ADDL_REPOS} -y install --noplugins --setopt=install_weak_deps=0" +fi + +# Clean up +clean_up() { + case ${ADJUSTED_ID} in + alpine) + rm -rf /var/cache/apk/* + ;; + debian) + rm -rf /var/lib/apt/lists/* + ;; + rhel) + rm -rf /var/cache/dnf/* /var/cache/yum/* + rm -rf /tmp/yum.log + rm -rf ${GPG_INSTALL_PATH} + ;; + esac +} +clean_up + +pkg_mgr_update() { + case $ADJUSTED_ID in + alpine) + if [ "$(find /var/cache/apk/* | wc -l)" = "0" ]; then + echo "Running apk update..." + ${PKG_MGR_CMD} update + fi + ;; + debian) + if [ "$(find /var/lib/apt/lists/* | wc -l)" = "0" ]; then + echo "Running apt-get update..." + ${PKG_MGR_CMD} update -y + fi + ;; + rhel) + if [ ${PKG_MGR_CMD} = "microdnf" ]; then + if [ "$(ls /var/cache/yum/* 2>/dev/null | wc -l)" = 0 ]; then + echo "Running ${PKG_MGR_CMD} makecache ..." + ${PKG_MGR_CMD} makecache + fi + else + if [ "$(ls /var/cache/${PKG_MGR_CMD}/* 2>/dev/null | wc -l)" = 0 ]; then + echo "Running ${PKG_MGR_CMD} check-update ..." + set +e + ${PKG_MGR_CMD} check-update + rc=$? + if [ $rc != 0 ] && [ $rc != 100 ]; then + exit 1 + fi + set -e + fi + fi + ;; + esac +} + +# Checks if packages are installed and installs them if not +check_packages() { + case ${ADJUSTED_ID} in + alpine) + ${INSTALL_CMD} "$@" + ;; + debian) + if ! dpkg -s "$@" > /dev/null 2>&1; then + pkg_mgr_update + ${INSTALL_CMD} "$@" + fi + ;; + rhel) + if ! rpm -q "$@" > /dev/null 2>&1; then + pkg_mgr_update + ${INSTALL_CMD} "$@" + fi + ;; + esac +} + +case $(uname -m) in + x86_64) ARCH="amd64";; + aarch64 | armv8*) ARCH="arm64";; + *) echo "Unsupported architecture: $(uname -m)"; exit 1;; +esac + +export DEBIAN_FRONTEND=noninteractive + +if ! type curl > /dev/null 2>&1; then + check_packages curl +fi + +if [ "$PINACT_VERSION" = "latest" ]; then + # get latest release + PINACT_VERSION=$(curl -s ${QUERYLATEST_URL} | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/') +fi + +echo "installing pinact version: ${PINACT_VERSION}" +echo "for architecture ${ARCH}" + +URL="${RELEASE_URL}${PINACT_VERSION}/pinact_linux_${ARCH}.tar.gz" +echo "from: ${URL}" + +curl -sSL -o /tmp/pinact.tar.gz "${URL}" +ls -l /tmp/pinact.tar.gz +tar xzof /tmp/pinact.tar.gz -C /usr/local/bin/ pinact +rm /tmp/pinact.tar.gz + +clean_up + +echo "Done!" diff --git a/test/pinact/almalinux.sh b/test/pinact/almalinux.sh new file mode 100644 index 0000000..59f7c4d --- /dev/null +++ b/test/pinact/almalinux.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env bash +set -e + +. ./default.sh diff --git a/test/pinact/alpine.sh b/test/pinact/alpine.sh new file mode 100644 index 0000000..59f7c4d --- /dev/null +++ b/test/pinact/alpine.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env bash +set -e + +. ./default.sh diff --git a/test/pinact/debian.sh b/test/pinact/debian.sh new file mode 100644 index 0000000..59f7c4d --- /dev/null +++ b/test/pinact/debian.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env bash +set -e + +. ./default.sh diff --git a/test/pinact/default.sh b/test/pinact/default.sh new file mode 100755 index 0000000..c3e5448 --- /dev/null +++ b/test/pinact/default.sh @@ -0,0 +1,8 @@ +#!/usr/bin/env bash +set -e + +source dev-container-features-test-lib + +check "pinact" bash -c "pinact version | grep -E '[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+'" + +reportResults diff --git a/test/pinact/fedora.sh b/test/pinact/fedora.sh new file mode 100644 index 0000000..59f7c4d --- /dev/null +++ b/test/pinact/fedora.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env bash +set -e + +. ./default.sh diff --git a/test/pinact/scenarios.json b/test/pinact/scenarios.json new file mode 100644 index 0000000..64eeb21 --- /dev/null +++ b/test/pinact/scenarios.json @@ -0,0 +1,40 @@ +{ + "default": { + "image": "mcr.microsoft.com/devcontainers/base:ubuntu", + "features": { + "pinact": {} + } + }, + "v3.10.1": { + "image": "mcr.microsoft.com/devcontainers/base:ubuntu", + "features": { + "pinact": { + "version": "v3.10.1" + } + } + }, + "almalinux": { + "image": "ghcr.io/almalinux/almalinux:10", + "features": { + "pinact": {} + } + }, + "alpine": { + "image": "mcr.microsoft.com/devcontainers/base:alpine", + "features": { + "pinact": {} + } + }, + "debian": { + "image": "mcr.microsoft.com/devcontainers/base:debian-13", + "features": { + "pinact": {} + } + }, + "fedora": { + "image": "fedora", + "features": { + "pinact": {} + } + } +} \ No newline at end of file diff --git a/test/pinact/v3.10.1.sh b/test/pinact/v3.10.1.sh new file mode 100755 index 0000000..d1f89f5 --- /dev/null +++ b/test/pinact/v3.10.1.sh @@ -0,0 +1,8 @@ +#!/usr/bin/env bash +set -e + +source dev-container-features-test-lib + +check "pinact" bash -c "pinact version | grep '3.10.1'" + +reportResults