diff --git a/images/linux/scripts/installers/aws-sam-cli.sh b/images/linux/scripts/installers/aws-sam-cli.sh index 004a7f3a7..a8512e61a 100644 --- a/images/linux/scripts/installers/aws-sam-cli.sh +++ b/images/linux/scripts/installers/aws-sam-cli.sh @@ -15,13 +15,15 @@ wget $TarballUrl -O $TarballPath tar -xzvf $TarballPath -C /tmp cd /tmp/awslabs-aws-sam-cli* -# Use python 3.7 from toolcache to install aws sam, setuptools package required for the installation -Python3Dir=$(echo /opt/hostedtoolcache/Python/3.7*/x64) +mkdir /opt/python-aws-sam-cli +cp -r /opt/hostedtoolcache/Python/3.7* /opt/python-aws-sam-cli + +# Use copy of python 3.7 from toolcache to install aws sam, setuptools package required for the installation +Python3Dir=$(echo /opt/python-aws-sam-cli/3.7*/x64) Python3BinDir="${Python3Dir}/bin" -export PATH="$Python3Dir:$Python3BinDir:$PATH" -python3 -m pip install setuptools -python3 setup.py install -sudo ln -sf ${Python3BinDir}/sam /usr/local/bin/sam +$Python3BinDir/python3 -m pip install setuptools +$Python3BinDir/python3 setup.py install +ln -sf ${Python3BinDir}/sam /usr/local/bin/sam # Run tests to determine that the software installed as expected echo "Testing to make sure that script performed as expected, and basic scenarios work" diff --git a/images/linux/ubuntu1604.json b/images/linux/ubuntu1604.json index 2475f03d7..ae036bdf3 100644 --- a/images/linux/ubuntu1604.json +++ b/images/linux/ubuntu1604.json @@ -259,7 +259,7 @@ "METADATA_FILE={{user `metadata_file`}}", "HELPER_SCRIPTS={{user `helper_script_folder`}}" ], - "execute_command": "/bin/sh -c '{{ .Vars }} {{ .Path }}'" + "execute_command": "sudo sh -c '{{ .Vars }} {{ .Path }}'" }, { "type": "shell", diff --git a/images/linux/ubuntu1804.json b/images/linux/ubuntu1804.json index 7314664dd..9302e5cbe 100644 --- a/images/linux/ubuntu1804.json +++ b/images/linux/ubuntu1804.json @@ -263,7 +263,7 @@ "METADATA_FILE={{user `metadata_file`}}", "HELPER_SCRIPTS={{user `helper_script_folder`}}" ], - "execute_command": "/bin/sh -c '{{ .Vars }} {{ .Path }}'" + "execute_command": "sudo sh -c '{{ .Vars }} {{ .Path }}'" }, { "type": "shell", diff --git a/images/linux/ubuntu2004.json b/images/linux/ubuntu2004.json index 1ec55d1ef..73ef44df4 100644 --- a/images/linux/ubuntu2004.json +++ b/images/linux/ubuntu2004.json @@ -264,7 +264,7 @@ "METADATA_FILE={{user `metadata_file`}}", "HELPER_SCRIPTS={{user `helper_script_folder`}}" ], - "execute_command": "/bin/sh -c '{{ .Vars }} {{ .Path }}'" + "execute_command": "sudo sh -c '{{ .Vars }} {{ .Path }}'" }, { "type": "shell",