From be310626e05d1aa248fd8cb8aa4ef237f6c3f6a5 Mon Sep 17 00:00:00 2001 From: Vladimir Safonkin Date: Thu, 1 Oct 2020 17:52:16 +0300 Subject: [PATCH] Add pipx, yamllint and aws sam cli --- .../linux/scripts/installers/pipx-packages.sh | 25 +++++++++++++++++++ images/linux/scripts/installers/python.sh | 21 +++++++++++++--- images/linux/toolsets/toolset-1604.json | 1 - images/linux/toolsets/toolset-1804.json | 1 - images/linux/toolsets/toolset-2004.json | 1 - images/linux/ubuntu1804.json | 13 ++-------- 6 files changed, 45 insertions(+), 17 deletions(-) create mode 100644 images/linux/scripts/installers/pipx-packages.sh diff --git a/images/linux/scripts/installers/pipx-packages.sh b/images/linux/scripts/installers/pipx-packages.sh new file mode 100644 index 000000000..c6a4a6bb6 --- /dev/null +++ b/images/linux/scripts/installers/pipx-packages.sh @@ -0,0 +1,25 @@ +#!/bin/bash +################################################################################ +## File: pipx-packages.sh +## Desc: Install tools via pipx +################################################################################ + +# Install yamlint +pipx install yamllint + +if ! command -v yamllint; then + echo "yamllint was not installed" + exit 1 +fi + +echo "yamllint is successfully installed" + +# Install aws sam cli +pipx install aws-sam-cli --python /opt/hostedtoolcache/Python/3.7.9/x64/bin/python3.7 + +if ! command -v sam; then + echo "aws sam cli was not installed" + exit 1 +fi + +echo "aws sam cli is successfully installed" \ No newline at end of file diff --git a/images/linux/scripts/installers/python.sh b/images/linux/scripts/installers/python.sh index 470417783..3c7886ae6 100644 --- a/images/linux/scripts/installers/python.sh +++ b/images/linux/scripts/installers/python.sh @@ -10,17 +10,32 @@ source $HELPER_SCRIPTS/os.sh # Install Python, Python 3, pip, pip3 if isUbuntu16 || isUbuntu18; then - apt-get install -y --no-install-recommends python python-dev python-pip python3 python3-dev python3-pip + apt-get install -y --no-install-recommends python python-dev python-pip python3 python3-dev python3-pip python3-venv fi if isUbuntu20; then - apt-get install -y --no-install-recommends python3 python3-dev python3-pip + apt-get install -y --no-install-recommends python3 python3-dev python3-pip python3-venv ln -s /usr/bin/pip3 /usr/bin/pip fi +# Install pipx +# Set pipx custom directory +export PIPX_BIN_DIR=/opt/pipx_bin +export PIPX_HOME=/opt/pipx + +python3 -m pip install pipx +python3 -m pipx ensurepath + +echo "PIPX_BIN_DIR=$PIPX_BIN_DIR" | tee -a /etc/environment +echo "PIPX_HOME=$PIPX_HOME" | tee -a /etc/environment + +# Add pipx bin directory to path +export PATH="$PATH:$PIPX_BIN_DIR" +echo 'export PATH="$PATH:/opt/pipx_bin"' >> /etc/skel/.bashrc + # Run tests to determine that the software installed as expected echo "Testing to make sure that script performed as expected, and basic scenarios work" -for cmd in python pip python3 pip3; do +for cmd in python pip python3 pip3 pipx; do if ! command -v $cmd; then echo "$cmd was not installed or not found on PATH" exit 1 diff --git a/images/linux/toolsets/toolset-1604.json b/images/linux/toolsets/toolset-1604.json index 46aad66ad..fcb5fde1f 100644 --- a/images/linux/toolsets/toolset-1604.json +++ b/images/linux/toolsets/toolset-1604.json @@ -172,7 +172,6 @@ "time", "unzip", "wget", - "yamllint", "zip" ] }, diff --git a/images/linux/toolsets/toolset-1804.json b/images/linux/toolsets/toolset-1804.json index 2670b4cf3..b14a60771 100644 --- a/images/linux/toolsets/toolset-1804.json +++ b/images/linux/toolsets/toolset-1804.json @@ -167,7 +167,6 @@ "time", "unzip", "wget", - "yamllint", "zip" ] }, diff --git a/images/linux/toolsets/toolset-2004.json b/images/linux/toolsets/toolset-2004.json index 7c704263b..62aad4477 100644 --- a/images/linux/toolsets/toolset-2004.json +++ b/images/linux/toolsets/toolset-2004.json @@ -130,7 +130,6 @@ "time", "unzip", "wget", - "yamllint", "zip" ] }, diff --git a/images/linux/ubuntu1804.json b/images/linux/ubuntu1804.json index 12ef6d0c0..c35d99eb7 100644 --- a/images/linux/ubuntu1804.json +++ b/images/linux/ubuntu1804.json @@ -212,7 +212,8 @@ "{{template_dir}}/scripts/installers/hosted-tool-cache.sh", "{{template_dir}}/scripts/installers/pypy.sh", "{{template_dir}}/scripts/installers/python.sh", - "{{template_dir}}/scripts/installers/test-toolcache.sh" + "{{template_dir}}/scripts/installers/test-toolcache.sh", + "{{template_dir}}/scripts/installers/pipx-packages.sh" ], "environment_vars": [ "HELPER_SCRIPTS={{user `helper_script_folder`}}", @@ -235,16 +236,6 @@ ], "execute_command": "sudo sh -c '{{ .Vars }} pwsh -f {{ .Path }}'" }, - { - "type": "shell", - "scripts": [ - "{{template_dir}}/scripts/installers/aws-sam-cli.sh" - ], - "environment_vars": [ - "HELPER_SCRIPTS={{user `helper_script_folder`}}" - ], - "execute_command": "sudo sh -c '{{ .Vars }} {{ .Path }}'" - }, { "type": "shell", "scripts": [