Skip to content

Commit

Permalink
Merge branch 'main' into desktop-lite_vnc-resolution_test_env_var
Browse files Browse the repository at this point in the history
  • Loading branch information
gauravsaini04 authored Sep 2, 2024
2 parents 8b1294a + 6123e41 commit 08a2c8b
Show file tree
Hide file tree
Showing 29 changed files with 346 additions and 53 deletions.
58 changes: 58 additions & 0 deletions .github/workflows/update-aws-cli-completer-scripts.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: "Updates vendor 'aws_bash_completer' and 'aws_zsh_completer.sh' scripts"
on:
workflow_dispatch:
schedule:
- cron: '0 0 * * 0' # Runs every Sunday at midnight UTC (adjust as needed)

jobs:
fetch-latest-aws-completer-scripts:
runs-on: ubuntu-latest
environment: documentation # grants access to secrets.PAT, for creating pull requests
permissions:
contents: write
pull-requests: write
steps:
- uses: actions/checkout@v3

- name: Run fetch-latest-completer-scripts.sh
run: src/aws-cli/scripts/fetch-latest-completer-scripts.sh

- name: Create a PR for completer scripts
id: push_image_info
env:
GITHUB_TOKEN: ${{ secrets.PAT }}
run: |
set -e
echo "Start."
# Configure git and Push updates
git config --global user.email [email protected]
git config --global user.name github-actions
git config pull.rebase false
branch=automated-script-update-$GITHUB_RUN_ID
git checkout -b $branch
message='[Updates] Automated vendor 'aws-cli' completer scripts'
# Add / update and commit
git add src/aws-cli/scripts/vendor/aws_bash_completer
git add src/aws-cli/scripts/vendor/aws_zsh_completer.sh
git commit -m 'Automated completer scripts update' || export NO_UPDATES=true
# Bump version and push
if [ "$NO_UPDATES" != "true" ] ; then
echo "$(jq --indent 4 '.version = (.version | split(".") | map(tonumber) | .[2] += 1 | join("."))' src/aws-cli/devcontainer-feature.json)" > src/aws-cli/devcontainer-feature.json
git add src/aws-cli/devcontainer-feature.json
git commit -m 'Bump version'
git push origin "$branch"
gh api \
--method POST \
-H "Accept: application/vnd.github+json" \
/repos/${GITHUB_REPOSITORY}/pulls \
-f title="$message" \
-f body="$message" \
-f head="$branch" \
-f base="$GITHUB_REF_NAME"
fi
2 changes: 1 addition & 1 deletion src/aws-cli/devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"id": "aws-cli",
"version": "1.0.7",
"version": "1.1.0",
"name": "AWS CLI",
"documentationURL": "https://github.com/devcontainers/features/tree/main/src/aws-cli",
"description": "Installs the AWS CLI along with needed dependencies. Useful for base Dockerfiles that often are missing required install dependencies like gpg.",
Expand Down
24 changes: 17 additions & 7 deletions src/aws-cli/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,24 +52,23 @@ fi

apt_get_update()
{
echo "Running apt-get update..."
apt-get update -y
if [ "$(find /var/lib/apt/lists/* | wc -l)" = "0" ]; then
echo "Running apt-get update..."
apt-get update -y
fi
}

# Checks if packages are installed and installs them if not
check_packages() {
if ! dpkg -s "$@" > /dev/null 2>&1; then
if [ "$(find /var/lib/apt/lists/* | wc -l)" = "0" ]; then
echo "Running apt-get update..."
apt-get update -y
fi
apt_get_update
apt-get -y install --no-install-recommends "$@"
fi
}

export DEBIAN_FRONTEND=noninteractive

check_packages curl ca-certificates gnupg2 dirmngr unzip
check_packages curl ca-certificates gnupg2 dirmngr unzip bash-completion

verify_aws_cli_gpg_signature() {
local filePath=$1
Expand Down Expand Up @@ -114,6 +113,17 @@ install() {
unzip "${scriptZipFile}"
./aws/install

# kubectl bash completion
mkdir -p /etc/bash_completion.d
cp ./scripts/vendor/aws_bash_completer /etc/bash_completion.d/aws

# kubectl zsh completion
if [ -e "${USERHOME}/.oh-my-zsh" ]; then
mkdir -p "${USERHOME}/.oh-my-zsh/completions"
cp ./scripts/vendor/aws_zsh_completer.sh "${USERHOME}/.oh-my-zsh/completions/_aws"
chown -R "${USERNAME}" "${USERHOME}/.oh-my-zsh"
fi

rm -rf ./aws
}

Expand Down
20 changes: 20 additions & 0 deletions src/aws-cli/scripts/fetch-latest-completer-scripts.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash
#-------------------------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See https://go.microsoft.com/fwlink/?linkid=2090316 for license information.
#-------------------------------------------------------------------------------------------------------------
#
# Docs: https://github.com/devcontainers/features/tree/main/src/aws-cli
# Maintainer: The Dev Container spec maintainers
#
# Run this script to replace aws_bash_completer and aws_zsh_completer.sh with the latest and greatest available version
#
COMPLETER_SCRIPTS=$(dirname "${BASH_SOURCE[0]}")
BASH_COMPLETER_SCRIPT="$COMPLETER_SCRIPTS/vendor/aws_bash_completer"
ZSH_COMPLETER_SCRIPT="$COMPLETER_SCRIPTS/vendor/aws_zsh_completer.sh"

wget https://raw.githubusercontent.com/aws/aws-cli/v2/bin/aws_bash_completer -O "$BASH_COMPLETER_SCRIPT"
chmod +x "$BASH_COMPLETER_SCRIPT"

wget https://raw.githubusercontent.com/aws/aws-cli/v2/bin/aws_zsh_completer.sh -O "$ZSH_COMPLETER_SCRIPT"
chmod +x "$ZSH_COMPLETER_SCRIPT"
12 changes: 12 additions & 0 deletions src/aws-cli/scripts/vendor/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
### **IMPORTANT NOTE**

Scripts in this directory are sourced externally and not maintained by the Dev Container spec maintainers. Do not make changes directly as they might be overwritten at any moment.

## aws_bash_completer

`aws_bash_completer` is a copy of <https://raw.githubusercontent.com/aws/aws-cli/v2/bin/aws_bash_completer>.

## aws_zsh_completer.sh

`aws_zsh_completer.sh` is a copy of <https://raw.githubusercontent.com/aws/aws-cli/v2/bin/aws_zsh_completer.sh>.

6 changes: 6 additions & 0 deletions src/aws-cli/scripts/vendor/aws_bash_completer
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Typically that would be added under one of the following paths:
# - /etc/bash_completion.d
# - /usr/local/etc/bash_completion.d
# - /usr/share/bash-completion/completions

complete -C aws_completer aws
60 changes: 60 additions & 0 deletions src/aws-cli/scripts/vendor/aws_zsh_completer.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Source this file to activate auto completion for zsh using the bash
# compatibility helper. Make sure to run `compinit` before, which should be
# given usually.
#
# % source /path/to/zsh_complete.sh
#
# Typically that would be called somewhere in your .zshrc.
#
# Note, the overwrite of _bash_complete() is to export COMP_LINE and COMP_POINT
# That is only required for zsh <= edab1d3dbe61da7efe5f1ac0e40444b2ec9b9570
#
# https://github.com/zsh-users/zsh/commit/edab1d3dbe61da7efe5f1ac0e40444b2ec9b9570
#
# zsh releases prior to that version do not export the required env variables!

autoload -Uz bashcompinit
bashcompinit -i

_bash_complete() {
local ret=1
local -a suf matches
local -x COMP_POINT COMP_CWORD
local -a COMP_WORDS COMPREPLY BASH_VERSINFO
local -x COMP_LINE="$words"
local -A savejobstates savejobtexts

(( COMP_POINT = 1 + ${#${(j. .)words[1,CURRENT]}} + $#QIPREFIX + $#IPREFIX + $#PREFIX ))
(( COMP_CWORD = CURRENT - 1))
COMP_WORDS=( $words )
BASH_VERSINFO=( 2 05b 0 1 release )

savejobstates=( ${(kv)jobstates} )
savejobtexts=( ${(kv)jobtexts} )

[[ ${argv[${argv[(I)nospace]:-0}-1]} = -o ]] && suf=( -S '' )

matches=( ${(f)"$(compgen $@ -- ${words[CURRENT]})"} )

if [[ -n $matches ]]; then
if [[ ${argv[${argv[(I)filenames]:-0}-1]} = -o ]]; then
compset -P '*/' && matches=( ${matches##*/} )
compset -S '/*' && matches=( ${matches%%/*} )
compadd -Q -f "${suf[@]}" -a matches && ret=0
else
compadd -Q "${suf[@]}" -a matches && ret=0
fi
fi

if (( ret )); then
if [[ ${argv[${argv[(I)default]:-0}-1]} = -o ]]; then
_default "${suf[@]}" && ret=0
elif [[ ${argv[${argv[(I)dirnames]:-0}-1]} = -o ]]; then
_directories "${suf[@]}" && ret=0
fi
fi

return ret
}

complete -C aws_completer aws
8 changes: 8 additions & 0 deletions src/common-utils/main.sh
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,14 @@ if [ "${ADJUSTED_ID}" = "rhel" ] && [ "${VERSION_CODENAME-}" = "centos7" ]; then
sed -i s/^mirrorlist=http/#mirrorlist=http/g /etc/yum.repos.d/*.repo
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

# Install packages for appropriate OS
case "${ADJUSTED_ID}" in
"debian")
Expand Down
8 changes: 4 additions & 4 deletions src/go/devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"id": "go",
"version": "1.3.0",
"version": "1.3.1",
"name": "Go",
"documentationURL": "https://github.com/devcontainers/features/tree/main/src/go",
"description": "Installs Go and common Go utilities. Auto-detects latest version and installs needed dependencies.",
Expand All @@ -10,8 +10,8 @@
"proposals": [
"latest",
"none",
"1.21",
"1.20"
"1.23",
"1.22"
],
"default": "latest",
"description": "Select or enter a Go version to install"
Expand Down Expand Up @@ -44,4 +44,4 @@
"installsAfter": [
"ghcr.io/devcontainers/features/common-utils"
]
}
}
8 changes: 8 additions & 0 deletions src/go/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,14 @@ else
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
Expand Down
1 change: 1 addition & 0 deletions src/node/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Installs Node.js, nvm, yarn, pnpm, and needed dependencies.
| version | Select or enter a Node.js version to install | string | lts |
| nodeGypDependencies | Install dependencies to compile native node modules (node-gyp)? | boolean | true |
| nvmInstallPath | The path where NVM will be installed. | string | /usr/local/share/nvm |
| pnpmVersion | Select or enter the PNPM version to install | string | latest |
| nvmVersion | Version of NVM to install. | string | latest |
| installYarnUsingApt | On Debian and Ubuntu systems, you have the option to install Yarn globally via APT. If you choose not to use this option, Yarn will be set up using Corepack instead. This choice is specific to Debian and Ubuntu; for other Linux distributions, Yarn is always installed using Corepack, with a fallback to installation via NPM if an error occurs. | boolean | true |

Expand Down
16 changes: 15 additions & 1 deletion src/node/devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"id": "node",
"version": "1.5.0",
"version": "1.6.0",
"name": "Node.js (via nvm), yarn and pnpm",
"documentationURL": "https://github.com/devcontainers/features/tree/main/src/node",
"description": "Installs Node.js, nvm, yarn, pnpm, and needed dependencies.",
Expand Down Expand Up @@ -28,6 +28,20 @@
"default": "/usr/local/share/nvm",
"description": "The path where NVM will be installed."
},
"pnpmVersion": {
"type": "string",
"proposals": [
"latest",
"8.8.0",
"8.0.0",
"7.30.0",
"6.14.8",
"5.18.10",
"none"
],
"default": "latest",
"description": "Select or enter the PNPM version to install"
},
"nvmVersion": {
"type": "string",
"proposals": [
Expand Down
15 changes: 12 additions & 3 deletions src/node/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
# Maintainer: The Dev Container spec maintainers

export NODE_VERSION="${VERSION:-"lts"}"
export PNPM_VERSION="${PNPMVERSION:-"latest"}"
export NVM_VERSION="${NVMVERSION:-"latest"}"
export NVM_DIR="${NVMINSTALLPATH:-"/usr/local/share/nvm"}"
INSTALL_TOOLS_FOR_NODE_GYP="${NODEGYPDEPENDENCIES:-true}"
Expand Down Expand Up @@ -45,6 +46,14 @@ else
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
Expand Down Expand Up @@ -370,16 +379,16 @@ if [ ! -z "${ADDITIONAL_VERSIONS}" ]; then
fi

# Install pnpm
if bash -c ". '${NVM_DIR}/nvm.sh' && type pnpm >/dev/null 2>&1"; then
echo "pnpm already installed."
if [ ! -z "${PNPM_VERSION}" ] && [ "${PNPM_VERSION}" = "none" ]; then
echo "Ignoring installation of PNPM"
else
if bash -c ". '${NVM_DIR}/nvm.sh' && type npm >/dev/null 2>&1"; then
(
. "${NVM_DIR}/nvm.sh"
[ ! -z "$http_proxy" ] && npm set proxy="$http_proxy"
[ ! -z "$https_proxy" ] && npm set https-proxy="$https_proxy"
[ ! -z "$no_proxy" ] && npm set noproxy="$no_proxy"
npm install -g pnpm
npm install -g pnpm@$PNPM_VERSION --force
)
else
echo "Skip installing pnpm because npm is missing"
Expand Down
6 changes: 4 additions & 2 deletions src/powershell/devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"id": "powershell",
"version": "1.4.0",
"version": "1.5.0",
"name": "PowerShell",
"documentationURL": "https://github.com/devcontainers/features/tree/main/src/powershell",
"description": "Installs PowerShell along with needed dependencies. Useful for base Dockerfiles that often are missing required install dependencies like gpg.",
Expand All @@ -10,7 +10,9 @@
"proposals": [
"latest",
"none",
"7.1"
"7.4",
"7.3",
"7.2"
],
"default": "latest",
"description": "Select or enter a version of PowerShell."
Expand Down
Loading

0 comments on commit 08a2c8b

Please sign in to comment.