Skip to content

Commit a194c50

Browse files
authored
Merge pull request #2852 from norio-nomura/update-template-opensuse.sh
Add `hack/update-template-opensuse.sh`
2 parents caf7165 + c4c21db commit a194c50

File tree

3 files changed

+374
-15
lines changed

3 files changed

+374
-15
lines changed

hack/cache-common-inc.sh

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -367,21 +367,17 @@ function download_to_cache() {
367367
# check the remote location
368368
local curl_info_json write_out
369369
write_out='{
370-
"http_code":%{http_code},
371-
"last_modified":"%header{Last-Modified}",
372-
"date":"%header{Date}",
373-
"content_type":"%{content_type}",
374-
"url":"%{url_effective}",
375-
"filename":"%{filename_effective}"
370+
"json":%{json},
371+
"header":%{header_json}
376372
}'
377373
curl_info_json=$(curl -sSLI -w "${write_out}" "$1" -o /dev/null)
378374

379375
local code time type url
380-
code=$(jq -r '.http_code' <<<"${curl_info_json}")
381-
time=$(jq -r '(.last_modified|select(length>1)) // .date' <<<"${curl_info_json}")
382-
type=$(jq -r '.content_type' <<<"${curl_info_json}")
376+
code=$(jq -r '.json.http_code' <<<"${curl_info_json}")
377+
time=$(jq -r '(.header["last-modified"]|first) // (.header["date"]|first) // empty' <<<"${curl_info_json}")
378+
type=$(jq -r '.json.content_type' <<<"${curl_info_json}")
383379
if [[ ${use_redirected_location} == "YES" ]]; then
384-
url=$(jq -r '.url' <<<"${curl_info_json}")
380+
url=$(jq -r '.json.url_effective' <<<"${curl_info_json}")
385381
else
386382
url=$1
387383
fi
@@ -400,11 +396,11 @@ function download_to_cache() {
400396
curl -SL -w "${write_out}" --no-clobber -o "${cache_path}/data" "${url}"
401397
)
402398
local filename
403-
code=$(jq -r '.http_code' <<<"${curl_info_json}")
404-
time=$(jq -r '(.last_modified|select(length>1)) // .date' <<<"${curl_info_json}")
405-
type=$(jq -r '.content_type' <<<"${curl_info_json}")
406-
url=$(jq -r '.url' <<<"${curl_info_json}")
407-
filename=$(jq -r '.filename' <<<"${curl_info_json}")
399+
code=$(jq -r '.json.http_code' <<<"${curl_info_json}")
400+
time=$(jq -r '(.header["last-modified"]|first) // (.header["date"]|first) // empty' <<<"${curl_info_json}")
401+
type=$(jq -r '.json.content_type' <<<"${curl_info_json}")
402+
url=$(jq -r '.json.url_effective' <<<"${curl_info_json}")
403+
filename=$(jq -r '.json.filename_effective' <<<"${curl_info_json}")
408404
[[ ${code} == 200 ]] || error_exit "Failed to download ${url}"
409405
[[ "${cache_path}/data" == "${filename}" ]] || mv "${filename}" "${cache_path}/data"
410406
# sha256.digest seems existing if expected digest is available. so, not creating it here.

0 commit comments

Comments
 (0)