diff --git a/images/linux/scripts/base/apt-mock-remove.sh b/images/linux/scripts/base/apt-mock-remove.sh new file mode 100644 index 00000000..cfa179a9 --- /dev/null +++ b/images/linux/scripts/base/apt-mock-remove.sh @@ -0,0 +1,7 @@ +#!/bin/bash -e + +prefix=/usr/local/bin + +for tool in apt apt-get apt-fast;do + sudo rm -f $prefix/$tool +done diff --git a/images/linux/scripts/base/apt-mock.sh b/images/linux/scripts/base/apt-mock.sh new file mode 100644 index 00000000..986068b0 --- /dev/null +++ b/images/linux/scripts/base/apt-mock.sh @@ -0,0 +1,27 @@ +#!/bin/bash -e + +# A temporary workaround for https://github.com/Azure/azure-linux-extensions/issues/1238 + +prefix=/usr/local/bin + +for tool in apt apt-get apt-fast;do + real_tool=`which $tool` + cat >$prefix/$tool </dev/null 2>&1 + result=\$? + if [ \$result -eq 0 ];then + sleep 1 + echo "/var/lib/dpkg/locked... retry \$i" + i=\$((i + 1)) + else + break + fi +done +$real_tool "\$@" +EOT + chmod +x $prefix/$tool +done diff --git a/images/linux/ubuntu1604.json b/images/linux/ubuntu1604.json index 5e45fded..a519b30d 100644 --- a/images/linux/ubuntu1604.json +++ b/images/linux/ubuntu1604.json @@ -74,6 +74,11 @@ "script": "{{template_dir}}/scripts/base/apt.sh", "execute_command": "sudo sh -c '{{ .Vars }} {{ .Path }}'" }, + { + "type": "shell", + "script": "{{template_dir}}/scripts/base/apt-mock.sh", + "execute_command": "sudo sh -c '{{ .Vars }} {{ .Path }}'" + }, { "type": "shell", "script": "{{template_dir}}/scripts/base/limits.sh", @@ -282,6 +287,11 @@ ], "execute_command": "sudo sh -c '{{ .Vars }} {{ .Path }}'" }, + { + "type": "shell", + "script": "{{template_dir}}/scripts/base/apt-mock-remove.sh", + "execute_command": "sudo sh -c '{{ .Vars }} {{ .Path }}'" + }, { "type": "shell", "scripts": [ diff --git a/images/linux/ubuntu1804.json b/images/linux/ubuntu1804.json index e6af0e41..977464e3 100644 --- a/images/linux/ubuntu1804.json +++ b/images/linux/ubuntu1804.json @@ -77,6 +77,11 @@ "script": "{{template_dir}}/scripts/base/apt.sh", "execute_command": "sudo sh -c '{{ .Vars }} {{ .Path }}'" }, + { + "type": "shell", + "script": "{{template_dir}}/scripts/base/apt-mock.sh", + "execute_command": "sudo sh -c '{{ .Vars }} {{ .Path }}'" + }, { "type": "shell", "script": "{{template_dir}}/scripts/base/limits.sh", @@ -286,6 +291,11 @@ ], "execute_command": "sudo sh -c '{{ .Vars }} {{ .Path }}'" }, + { + "type": "shell", + "script": "{{template_dir}}/scripts/base/apt-mock-remove.sh", + "execute_command": "sudo sh -c '{{ .Vars }} {{ .Path }}'" + }, { "type": "shell", "scripts": [ diff --git a/images/linux/ubuntu2004.json b/images/linux/ubuntu2004.json index 477f8c55..54bc6fb5 100644 --- a/images/linux/ubuntu2004.json +++ b/images/linux/ubuntu2004.json @@ -79,6 +79,11 @@ "script": "{{template_dir}}/scripts/base/apt.sh", "execute_command": "sudo sh -c '{{ .Vars }} {{ .Path }}'" }, + { + "type": "shell", + "script": "{{template_dir}}/scripts/base/apt-mock.sh", + "execute_command": "sudo sh -c '{{ .Vars }} {{ .Path }}'" + }, { "type": "shell", "script": "{{template_dir}}/scripts/base/limits.sh", @@ -288,6 +293,11 @@ ], "execute_command": "sudo sh -c '{{ .Vars }} {{ .Path }}'" }, + { + "type": "shell", + "script": "{{template_dir}}/scripts/base/apt-mock-remove.sh", + "execute_command": "sudo sh -c '{{ .Vars }} {{ .Path }}'" + }, { "type": "shell", "scripts": [ diff --git a/images/macos/provision/assets/select-xamarin-sdk.sh b/images/macos/provision/assets/select-xamarin-sdk.sh index 0fb4a343..014075ce 100644 --- a/images/macos/provision/assets/select-xamarin-sdk.sh +++ b/images/macos/provision/assets/select-xamarin-sdk.sh @@ -19,4 +19,4 @@ do echo "Set Current folder for ${FOLDER}" sudo rm -f ${FOLDER}/Current sudo ln -s ${FOLDER}/${XAMARIN_SDK} ${FOLDER}/Current -done \ No newline at end of file +done diff --git a/images/macos/provision/core/pipx-packages.sh b/images/macos/provision/core/pipx-packages.sh index 47de190f..8e1da3f3 100644 --- a/images/macos/provision/core/pipx-packages.sh +++ b/images/macos/provision/core/pipx-packages.sh @@ -16,4 +16,4 @@ for package in $pipx_packages; do echo "Install $package into default python" pipx install $package fi -done \ No newline at end of file +done