From 82e4ec4a0a2908b07f13fac5e273b89fd8278950 Mon Sep 17 00:00:00 2001 From: Sergey Dolin Date: Wed, 21 Oct 2020 10:29:07 +0500 Subject: [PATCH 1/9] Add verbose versions of apt --- images/linux/scripts/base/apt-mock.sh | 19 +++++++++++++++++++ images/linux/ubuntu1604.json | 5 +++++ images/linux/ubuntu1804.json | 5 +++++ images/linux/ubuntu2004.json | 5 +++++ 4 files changed, 34 insertions(+) create mode 100644 images/linux/scripts/base/apt-mock.sh diff --git a/images/linux/scripts/base/apt-mock.sh b/images/linux/scripts/base/apt-mock.sh new file mode 100644 index 00000000..68fef1bf --- /dev/null +++ b/images/linux/scripts/base/apt-mock.sh @@ -0,0 +1,19 @@ +#!/bin/sh -x + +prefix=/usr/local/bin +mkdir -p $prefix + +for tool in apt apt-get apt-fast deb;do + real_tool=`which $tool` + cat >$prefix/$tool < Date: Fri, 23 Oct 2020 00:25:52 +0500 Subject: [PATCH 2/9] make retries --- images/linux/scripts/base/apt-mock.sh | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/images/linux/scripts/base/apt-mock.sh b/images/linux/scripts/base/apt-mock.sh index 68fef1bf..1cfe4eec 100644 --- a/images/linux/scripts/base/apt-mock.sh +++ b/images/linux/scripts/base/apt-mock.sh @@ -1,19 +1,24 @@ -#!/bin/sh -x +#!/bin/bash prefix=/usr/local/bin -mkdir -p $prefix -for tool in apt apt-get apt-fast deb;do +for tool in apt apt-get apt-fast;do real_tool=`which $tool` cat >$prefix/$tool < Date: Mon, 26 Oct 2020 14:18:59 +0500 Subject: [PATCH 3/9] add shbang --- images/linux/scripts/base/apt-mock.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/images/linux/scripts/base/apt-mock.sh b/images/linux/scripts/base/apt-mock.sh index 1cfe4eec..5dd1ad4a 100644 --- a/images/linux/scripts/base/apt-mock.sh +++ b/images/linux/scripts/base/apt-mock.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/bash -e prefix=/usr/local/bin From babd2e2156a014adaa69aada35fa8b31a7ac44a5 Mon Sep 17 00:00:00 2001 From: Sergey Dolin Date: Mon, 26 Oct 2020 19:15:04 +0500 Subject: [PATCH 4/9] use fuser --- images/linux/scripts/base/apt-mock.sh | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/images/linux/scripts/base/apt-mock.sh b/images/linux/scripts/base/apt-mock.sh index 5dd1ad4a..7288286d 100644 --- a/images/linux/scripts/base/apt-mock.sh +++ b/images/linux/scripts/base/apt-mock.sh @@ -8,17 +8,18 @@ for tool in apt apt-get apt-fast;do #!/bin/sh i=1 -while [ \$i -le 10 ];do - $real_tool "\$@" +while [ \$i -le 30 ];do + fuser /var/lib/dpkg/lock >/dev/null 2>&1 result=\$? if [ \$result -eq 0 ];then - break - else - sleep 5 - echo "...retry \$i" + sleep 1 + echo "/var/lib/dpkg/locked... retry \$i" i=\$((i + 1)) + else + break fi done +$real_tool "\$@" EOT chmod +x $prefix/$tool done From 4419d31ea714bc1ffaaf1252fecdeb3847caf318 Mon Sep 17 00:00:00 2001 From: Sergey Dolin Date: Mon, 26 Oct 2020 19:30:30 +0500 Subject: [PATCH 5/9] add apt-mock-remove script --- images/linux/scripts/base/apt-mock-remove.sh | 7 +++++++ images/linux/ubuntu1604.json | 5 +++++ images/linux/ubuntu1804.json | 5 +++++ images/linux/ubuntu2004.json | 5 +++++ 4 files changed, 22 insertions(+) create mode 100644 images/linux/scripts/base/apt-mock-remove.sh 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..19c45988 --- /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 + rm $prefix/$tool +done diff --git a/images/linux/ubuntu1604.json b/images/linux/ubuntu1604.json index b66b7417..25ba76f3 100644 --- a/images/linux/ubuntu1604.json +++ b/images/linux/ubuntu1604.json @@ -355,6 +355,11 @@ "/usr/sbin/waagent -force -deprovision+user && export HISTSIZE=0 && sync" ], "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 }}'" } ] } diff --git a/images/linux/ubuntu1804.json b/images/linux/ubuntu1804.json index cb522611..9cc266e0 100644 --- a/images/linux/ubuntu1804.json +++ b/images/linux/ubuntu1804.json @@ -359,6 +359,11 @@ "/usr/sbin/waagent -force -deprovision+user && export HISTSIZE=0 && sync" ], "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 }}'" } ] } diff --git a/images/linux/ubuntu2004.json b/images/linux/ubuntu2004.json index 292be0d6..8dde3454 100644 --- a/images/linux/ubuntu2004.json +++ b/images/linux/ubuntu2004.json @@ -361,6 +361,11 @@ "/usr/sbin/waagent -force -deprovision+user && export HISTSIZE=0 && sync" ], "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 }}'" } ] } From 002a944511a7e3dad060ac02a9ed3e5c6c07a700 Mon Sep 17 00:00:00 2001 From: Sergey Dolin Date: Mon, 26 Oct 2020 20:21:29 +0500 Subject: [PATCH 6/9] Add memo comment --- images/linux/scripts/base/apt-mock.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/images/linux/scripts/base/apt-mock.sh b/images/linux/scripts/base/apt-mock.sh index 7288286d..986068b0 100644 --- a/images/linux/scripts/base/apt-mock.sh +++ b/images/linux/scripts/base/apt-mock.sh @@ -1,5 +1,7 @@ #!/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 From 76f57f69f2462a973d861a6e9970d9dd33a846cc Mon Sep 17 00:00:00 2001 From: Sergey Dolin Date: Tue, 27 Oct 2020 13:05:31 +0500 Subject: [PATCH 7/9] run remove mocks as root --- images/linux/scripts/base/apt-mock-remove.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/images/linux/scripts/base/apt-mock-remove.sh b/images/linux/scripts/base/apt-mock-remove.sh index 19c45988..1697a7d9 100644 --- a/images/linux/scripts/base/apt-mock-remove.sh +++ b/images/linux/scripts/base/apt-mock-remove.sh @@ -1,7 +1,7 @@ -#!/bin/bash -e - +#!/bin/bash -e +set -x prefix=/usr/local/bin for tool in apt apt-get apt-fast;do - rm $prefix/$tool + sudo rm -f $prefix/$tool done From cab74c1ab9488c3659555bfb61aacee0fd121724 Mon Sep 17 00:00:00 2001 From: Sergey Dolin Date: Thu, 29 Oct 2020 00:03:03 +0500 Subject: [PATCH 8/9] investigate failed 1604 build --- images/linux/scripts/base/apt-mock-remove.sh | 2 +- images/linux/ubuntu1604.json | 10 +++++----- images/linux/ubuntu1804.json | 10 +++++----- images/linux/ubuntu2004.json | 10 +++++----- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/images/linux/scripts/base/apt-mock-remove.sh b/images/linux/scripts/base/apt-mock-remove.sh index 1697a7d9..286a5bcf 100644 --- a/images/linux/scripts/base/apt-mock-remove.sh +++ b/images/linux/scripts/base/apt-mock-remove.sh @@ -1,5 +1,5 @@ #!/bin/bash -e -set -x + prefix=/usr/local/bin for tool in apt apt-get apt-fast;do diff --git a/images/linux/ubuntu1604.json b/images/linux/ubuntu1604.json index 25ba76f3..a519b30d 100644 --- a/images/linux/ubuntu1604.json +++ b/images/linux/ubuntu1604.json @@ -287,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": [ @@ -355,11 +360,6 @@ "/usr/sbin/waagent -force -deprovision+user && export HISTSIZE=0 && sync" ], "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 }}'" } ] } diff --git a/images/linux/ubuntu1804.json b/images/linux/ubuntu1804.json index 9cc266e0..977464e3 100644 --- a/images/linux/ubuntu1804.json +++ b/images/linux/ubuntu1804.json @@ -291,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": [ @@ -359,11 +364,6 @@ "/usr/sbin/waagent -force -deprovision+user && export HISTSIZE=0 && sync" ], "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 }}'" } ] } diff --git a/images/linux/ubuntu2004.json b/images/linux/ubuntu2004.json index 8dde3454..54bc6fb5 100644 --- a/images/linux/ubuntu2004.json +++ b/images/linux/ubuntu2004.json @@ -293,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": [ @@ -361,11 +366,6 @@ "/usr/sbin/waagent -force -deprovision+user && export HISTSIZE=0 && sync" ], "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 }}'" } ] } From 541036c2d127ece205da17698eec017e5052fc7c Mon Sep 17 00:00:00 2001 From: Sergey Dolin Date: Fri, 30 Oct 2020 01:01:30 +0500 Subject: [PATCH 9/9] fix shbang --- images/linux/scripts/base/apt-mock-remove.sh | 2 +- images/macos/provision/assets/select-xamarin-sdk.sh | 4 ++-- images/macos/provision/core/pipx-packages.sh | 4 +++- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/images/linux/scripts/base/apt-mock-remove.sh b/images/linux/scripts/base/apt-mock-remove.sh index 286a5bcf..cfa179a9 100644 --- a/images/linux/scripts/base/apt-mock-remove.sh +++ b/images/linux/scripts/base/apt-mock-remove.sh @@ -1,4 +1,4 @@ -#!/bin/bash -e +#!/bin/bash -e prefix=/usr/local/bin diff --git a/images/macos/provision/assets/select-xamarin-sdk.sh b/images/macos/provision/assets/select-xamarin-sdk.sh index 45adc969..014075ce 100644 --- a/images/macos/provision/assets/select-xamarin-sdk.sh +++ b/images/macos/provision/assets/select-xamarin-sdk.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/bash -e -o pipefail if [ -z "$1" ]; then echo "No Xamarin SDK specified." exit 0 @@ -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 658600fa..bb6c5058 100644 --- a/images/macos/provision/core/pipx-packages.sh +++ b/images/macos/provision/core/pipx-packages.sh @@ -1,3 +1,5 @@ +#!/bin/bash -e -o pipefail + source ~/utils/utils.sh export PATH="$PATH:/opt/pipx_bin" @@ -15,4 +17,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