@@ -7,22 +7,19 @@ function usrbin() {
7
7
LD_LIBRARY_PATH=/sysusr/usr/lib64 /sysusr/usr/bin/" ${cmd} " " $@ "
8
8
}
9
9
10
- function usrcurl() {
11
- usrbin curl -fsSL --retry-delay 1 --retry 60 --retry-connrefused --retry-max-time 60 --connect-timeout 20 " $@ "
12
- }
13
-
10
+ # Note: don't use as "if download_and_verify" or "download_and_verify || " because that disables set -e error handling
14
11
function download_and_verify() {
15
12
# Extracts release artifact to /sysroot/$final_name
16
13
# Expects the env vars: FLATCAR_BOARD, VERSION
17
14
local final_name=" $1 "
15
+ local extracted_name=" ${final_name} "
18
16
local name=" ${final_name/ .raw/ .gz} "
19
- URL=" https://update.release.flatcar-linux.net/${FLATCAR_BOARD} /${VERSION} /${name} "
17
+ local URL=" https://update.release.flatcar-linux.net/${FLATCAR_BOARD} /${VERSION} /${name} "
20
18
# Check for scripts:sdk_container/src/third_party/coreos-overlay/coreos-base/coreos-au-key/files/developer-v1.pub.pem
21
19
if [ " $( usrbin md5sum /sysroot/usr/share/update_engine/update-payload-key.pub.pem | cut -d " " -f 1) " = " 7192addf4a7f890c0057d21653eff2ea" ]; then
22
20
URL=" https://bincache.flatcar-linux.net/images/${FLATCAR_BOARD/ -usr} /${VERSION} /flatcar_test_update-${name} "
21
+ extracted_name=" flatcar_test_update-${final_name} "
23
22
fi
24
- # TODO: Replace the below with invoking an ue-rs helper binary for downloading the payload
25
- # from the URL and write the unpacked, verified file to the final name.
26
23
local COUNT=" "
27
24
# Workaround: Once curl starts and fails to resolve a DNS name (due to a race or temporary failure),
28
25
# it sticks to it for each retry, making the retry pointless. Therefore, we first have to
@@ -33,9 +30,12 @@ function download_and_verify() {
33
30
fi
34
31
sleep 1
35
32
done
36
- rm -f " /sysroot/${name} "
37
- usrcurl -o " /sysroot/${name} " " ${URL} " || { rm -f " /sysroot/${name} " ; return 1 ; }
38
- usrbin unshare -m sh -c " mount --rbind /dev /sysroot/dev/ && mount -t proc /proc /sysroot/proc/ && PROTOPATH=/usr/share/update_engine/ chroot /sysroot /usr/share/update_engine/decode_payload /usr/share/update_engine/update-payload-key.pub.pem \" /${name} \" \" /${final_name} \" " || { rm -f " /sysroot/${final_name} " ; echo " Failing boot" >&2 ; exit 1; }
33
+ local tempdir=" /sysroot/ue-rs/"
34
+ rm -rf " ${tempdir} "
35
+ mkdir -p " ${tempdir} "
36
+ usrbin download_sysext -p /sysroot/usr/share/update_engine/update-payload-key.pub.pem -o " ${tempdir} " -u " ${URL} " || { rm -f " ${tempdir} " ; echo " Failing boot" >&2 ; exit 1; }
37
+ mv " ${tempdir} /${extracted_name} " " /sysroot/${final_name} "
38
+ rm -rf " ${tempdir} "
39
39
true # Don't leak previous exit code as return code
40
40
}
41
41
0 commit comments