Skip to content

Commit 8ef0071

Browse files
committed
fix: move apt_get_download to Ubuntu-specific script file
Flatcar is breaking the OSProfile limit again, so savings need to be made somewhere. This helper function is only used in that one file. Signed-off-by: James Le Cuirot <jlecuirot@microsoft.com>
1 parent d67864a commit 8ef0071

2 files changed

Lines changed: 24 additions & 26 deletions

File tree

parts/linux/cloud-init/artifacts/cse_helpers.sh

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -566,32 +566,6 @@ semverCompare() {
566566
return 1
567567
}
568568

569-
570-
571-
apt_get_download() {
572-
retries=$1; wait_sleep=$2; shift && shift;
573-
local ret=0
574-
pushd $APT_CACHE_DIR || return 1
575-
for i in $(seq 1 "$retries"); do
576-
dpkg --configure -a --force-confdef
577-
wait_for_apt_locks
578-
579-
# Pull the first quoted URL from --print-uris
580-
url="$(apt-get --print-uris -o Dpkg::Options::=--force-confold download -y -- "$@" \
581-
| awk -F"'" 'NR==1 && $2 {print $2}')"
582-
if [ -n "$url" ]; then
583-
# This avoids issues with the naming in the package. `apt-get download`
584-
# encodes the package names with special characters and does not decode
585-
# them when saving to disk, but `curl -J` handles the names correctly.
586-
if curl -fLJO -- "$url"; then ret=0; break; fi
587-
fi
588-
589-
if [ "$i" -eq "$retries" ]; then ret=1; else sleep "$wait_sleep"; fi
590-
done
591-
popd || return 1
592-
return "$ret"
593-
}
594-
595569
getCPUArch() {
596570
arch=$(uname -m)
597571
# shellcheck disable=SC3010

parts/linux/cloud-init/artifacts/ubuntu/cse_helpers_ubuntu.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,4 +178,28 @@ apt_get_install_from_local_repo() {
178178

179179
return 0
180180
}
181+
182+
apt_get_download() {
183+
retries=$1; wait_sleep=$2; shift && shift;
184+
local ret=0
185+
pushd $APT_CACHE_DIR || return 1
186+
for i in $(seq 1 "$retries"); do
187+
dpkg --configure -a --force-confdef
188+
wait_for_apt_locks
189+
190+
# Pull the first quoted URL from --print-uris
191+
url="$(apt-get --print-uris -o Dpkg::Options::=--force-confold download -y -- "$@" \
192+
| awk -F"'" 'NR==1 && $2 {print $2}')"
193+
if [ -n "$url" ]; then
194+
# This avoids issues with the naming in the package. `apt-get download`
195+
# encodes the package names with special characters and does not decode
196+
# them when saving to disk, but `curl -J` handles the names correctly.
197+
if curl -fLJO -- "$url"; then ret=0; break; fi
198+
fi
199+
200+
if [ "$i" -eq "$retries" ]; then ret=1; else sleep "$wait_sleep"; fi
201+
done
202+
popd || return 1
203+
return "$ret"
204+
}
181205
#EOF

0 commit comments

Comments
 (0)