Skip to content

Commit 78f50fa

Browse files
authored
Fix download scripts (istio#23191)
* Fix download scripts * Added architecture detection * Updated to match posix if * Make shellcheck happy * CR comments
1 parent 8af485c commit 78f50fa

File tree

2 files changed

+109
-25
lines changed

2 files changed

+109
-25
lines changed

release/downloadIstioCandidate.sh

+63-21
Original file line numberDiff line numberDiff line change
@@ -42,35 +42,77 @@ if [ "x${ISTIO_VERSION}" = "x" ] ; then
4242
grep -v -E "(alpha|beta|rc)\.[0-9]$" | sort -t"." -k 1,1 -k 2,2 -k 3,3 -k 4,4 | tail -n 1)
4343
fi
4444

45+
LOCAL_ARCH=$(uname -m)
46+
if [ "${TARGET_ARCH}" ]; then
47+
LOCAL_ARCH=${TARGET_ARCH}
48+
fi
49+
50+
case "${LOCAL_ARCH}" in
51+
x86_64)
52+
ISTIO_ARCH=amd64
53+
;;
54+
armv8*)
55+
ISTIO_ARCH=arm64
56+
;;
57+
aarch64*)
58+
ISTIO_ARCH=arm64
59+
;;
60+
armv*)
61+
ISTIO_ARCH=armv7
62+
;;
63+
amd64|arm64)
64+
ISTIO_ARCH=${LOCAL_ARCH}
65+
;;
66+
*)
67+
echo "This system's architecture, ${LOCAL_ARCH}, isn't supported"
68+
exit 1
69+
;;
70+
esac
71+
4572
if [ "x${ISTIO_VERSION}" = "x" ] ; then
4673
printf "Unable to get latest Istio version. Set ISTIO_VERSION env var and re-run. For example: export ISTIO_VERSION=1.0.4"
4774
exit;
4875
fi
4976

5077
NAME="istio-$ISTIO_VERSION"
5178
URL="https://github.com/istio/istio/releases/download/${ISTIO_VERSION}/istio-${ISTIO_VERSION}-${OSEXT}.tar.gz"
79+
ARCH_URL="https://github.com/istio/istio/releases/download/${ISTIO_VERSION}/istio-${ISTIO_VERSION}-${OSEXT}-${ISTIO_ARCH}.tar.gz"
80+
5281
printf "Downloading %s from %s ..." "$NAME" "$URL"
53-
if ! curl -L "$URL" | tar xz
82+
if ! curl -fsLO "$URL"
5483
then
55-
printf "\n\n"
56-
printf "Unable to download Istio %s at this moment!\n" "$ISTIO_VERSION"
57-
printf "Please verify the version you are trying to download.\n\n"
84+
printf "Failed.\n\nTrying with TARGET_ARCH. Downloading %s from %s ...\n" "$NAME" "$ARCH_URL"
85+
if ! curl -fsLO "$ARCH_URL"
86+
then
87+
printf "\n\n"
88+
printf "Unable to download Istio %s at this moment!\n" "$ISTIO_VERSION"
89+
printf "Please verify the version you are trying to download.\n\n"
90+
exit
91+
else
92+
filename="istio-${ISTIO_VERSION}-${OSEXT}-${ISTIO_ARCH}.tar.gz"
93+
tar -xzf "${filename}"
94+
rm "${filename}"
95+
fi
5896
else
59-
printf ""
60-
printf "Istio %s Download Complete!\n" "$ISTIO_VERSION"
61-
printf "\n"
62-
printf "Istio has been successfully downloaded into the %s folder on your system.\n" "$NAME"
63-
printf "\n"
64-
BINDIR="$(cd "$NAME/bin" && pwd)"
65-
printf "Next Steps:\n"
66-
printf "See https://istio.io/docs/setup/kubernetes/install/ to add Istio to your Kubernetes cluster.\n"
67-
printf "\n"
68-
printf "To configure the istioctl client tool for your workstation,\n"
69-
printf "add the %s directory to your environment path variable with:\n" "$BINDIR"
70-
printf "\t export PATH=\"\$PATH:%s\"\n" "$BINDIR"
71-
printf "\n"
72-
printf "Begin the Istio pre-installation verification check by running:\n"
73-
printf "\t istioctl verify-install \n"
74-
printf "\n"
75-
printf "Need more information? Visit https://istio.io/docs/setup/kubernetes/install/ \n"
97+
filename="istio-${ISTIO_VERSION}-${OSEXT}.tar.gz"
98+
tar -xzf "${filename}"
99+
rm "${filename}"
76100
fi
101+
102+
printf ""
103+
printf "\nIstio %s Download Complete!\n" "$ISTIO_VERSION"
104+
printf "\n"
105+
printf "Istio has been successfully downloaded into the %s folder on your system.\n" "$NAME"
106+
printf "\n"
107+
BINDIR="$(cd "$NAME/bin" && pwd)"
108+
printf "Next Steps:\n"
109+
printf "See https://istio.io/docs/setup/kubernetes/install/ to add Istio to your Kubernetes cluster.\n"
110+
printf "\n"
111+
printf "To configure the istioctl client tool for your workstation,\n"
112+
printf "add the %s directory to your environment path variable with:\n" "$BINDIR"
113+
printf "\t export PATH=\"\$PATH:%s\"\n" "$BINDIR"
114+
printf "\n"
115+
printf "Begin the Istio pre-installation verification check by running:\n"
116+
printf "\t istioctl verify-install \n"
117+
printf "\n"
118+
printf "Need more information? Visit https://istio.io/docs/setup/kubernetes/install/ \n"

release/downloadIstioCtl.sh

100644100755
+46-4
Original file line numberDiff line numberDiff line change
@@ -43,22 +43,64 @@ if [ "x${ISTIO_VERSION}" = "x" ] ; then
4343
exit;
4444
fi
4545

46+
LOCAL_ARCH=$(uname -m)
47+
if [ "${TARGET_ARCH}" ]; then
48+
LOCAL_ARCH=${TARGET_ARCH}
49+
fi
50+
51+
case "${LOCAL_ARCH}" in
52+
x86_64)
53+
ISTIO_ARCH=amd64
54+
;;
55+
armv8*)
56+
ISTIO_ARCH=arm64
57+
;;
58+
aarch64*)
59+
ISTIO_ARCH=arm64
60+
;;
61+
armv*)
62+
ISTIO_ARCH=armv7
63+
;;
64+
amd64|arm64)
65+
ISTIO_ARCH=${LOCAL_ARCH}
66+
;;
67+
*)
68+
echo "This system's architecture, ${LOCAL_ARCH}, isn't supported"
69+
exit 1
70+
;;
71+
esac
72+
4673
download_failed () {
4774
printf "Download failed, please make sure your ISTIO_VERSION is correct and verify the download URL exists!"
4875
exit 1
4976
}
5077

5178
# Downloads the istioctl binary archive.
5279
tmp=$(mktemp -d /tmp/istioctl.XXXXXX)
53-
filename="istioctl-${ISTIO_VERSION}-${OSEXT}.tar.gz"
80+
NAME="istioctl-${ISTIO_VERSION}"
81+
5482
cd "$tmp" || exit
5583
URL="https://github.com/istio/istio/releases/download/${ISTIO_VERSION}/istioctl-${ISTIO_VERSION}-${OSEXT}.tar.gz"
56-
printf "Downloading %s from %s ... \n" "${filename}" "${URL}"
57-
curl -sLO "${URL}" || download_failed
84+
ARCH_URL="https://github.com/istio/istio/releases/download/${ISTIO_VERSION}/istioctl-${ISTIO_VERSION}-${OSEXT}-${ISTIO_ARCH}.tar.gz"
85+
86+
printf "Downloading %s from %s ... \n" "${NAME}" "${URL}"
87+
if ! curl -fsLO "$URL"
88+
then
89+
printf "Failed. \n\nTrying with TARGET_ARCH. Downloading %s from %s ...\n" "${NAME}" "$ARCH_URL"
90+
if ! curl -fsLO "$ARCH_URL"
91+
then
92+
download_failed
93+
else
94+
filename="istioctl-${ISTIO_VERSION}-${OSEXT}-${ISTIO_ARCH}.tar.gz"
95+
tar -xzf "${filename}"
96+
fi
97+
else
98+
filename="istioctl-${ISTIO_VERSION}-${OSEXT}.tar.gz"
99+
tar -xzf "${filename}"
100+
fi
58101
printf "%s download complete!\n" "${filename}"
59102

60103
# setup istioctl
61-
tar -xzf "${filename}"
62104
cd "$HOME" || exit
63105
mkdir -p ".istioctl/bin"
64106
mv "${tmp}/istioctl" ".istioctl/bin/istioctl"

0 commit comments

Comments
 (0)