Skip to content

Commit 10e15e7

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 d0162b1 commit 10e15e7

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
@@ -564,32 +564,6 @@ semverCompare() {
564564
return 1
565565
}
566566

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

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

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,29 @@
11
#!/bin/bash
22

3+
apt_get_download() {
4+
retries=$1; wait_sleep=$2; shift && shift;
5+
local ret=0
6+
pushd $APT_CACHE_DIR || return 1
7+
for i in $(seq 1 "$retries"); do
8+
dpkg --configure -a --force-confdef
9+
wait_for_apt_locks
10+
11+
# Pull the first quoted URL from --print-uris
12+
url="$(apt-get --print-uris -o Dpkg::Options::=--force-confold download -y -- "$@" \
13+
| awk -F"'" 'NR==1 && $2 {print $2}')"
14+
if [ -n "$url" ]; then
15+
# This avoids issues with the naming in the package. `apt-get download`
16+
# encodes the package names with special characters and does not decode
17+
# them when saving to disk, but `curl -J` handles the names correctly.
18+
if curl -fLJO -- "$url"; then ret=0; break; fi
19+
fi
20+
21+
if [ "$i" -eq "$retries" ]; then ret=1; else sleep "$wait_sleep"; fi
22+
done
23+
popd || return 1
24+
return "$ret"
25+
}
26+
327
removeContainerd() {
428
apt_get_purge 10 5 300 moby-containerd
529
}

0 commit comments

Comments
 (0)