Skip to content

Commit 858bef2

Browse files
committed
Fix corner case extensions
1 parent cf9d806 commit 858bef2

1 file changed

Lines changed: 71 additions & 8 deletions

File tree

scripts/generate-armbian-images-json.sh

Lines changed: 71 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -291,13 +291,53 @@ strip_img_ext() {
291291

292292
extract_file_extension() {
293293
local n="$1"
294-
[[ "$n" == *.img.xz ]] && echo "img.xz" && return
295-
[[ "$n" == *.img.zst ]] && echo "img.zst" && return
296-
[[ "$n" == *.img.gz ]] && echo "img.gz" && return
297-
[[ "$n" == *.img ]] && echo "img" && return
294+
295+
# rootfs images
296+
if [[ "$n" == *".rootfs.img."* ]]; then
297+
echo "rootfs.img.${n##*.rootfs.img.}"
298+
return
299+
fi
300+
301+
# oowow images
302+
if [[ "$n" == *".oowow.img."* ]]; then
303+
echo "oowow.img.${n##*.oowow.img.}"
304+
return
305+
fi
306+
307+
# boot payload images:
308+
# ...desktop.boot_sm8250-xiaomi-elish-boe.img.xz -> boe.img.xz
309+
# ...desktop.boot_recovery.img.xz -> recovery.img.xz
310+
if [[ "$n" == *".boot_"*".img."* ]]; then
311+
local after_boot="${n#*.boot_}" # everything after the first ".boot_"
312+
local boot_stem="${after_boot%%.img.*}" # up to before ".img."
313+
local flavor="$boot_stem"
314+
315+
# if it's boot_sm8250-...-boe, take last '-' token
316+
if [[ "$boot_stem" == *-* ]]; then
317+
flavor="${boot_stem##*-}"
318+
fi
319+
320+
echo "${flavor}.img.${n##*.img.}"
321+
return
322+
fi
323+
324+
# qcow2 (or other img.*) -> canonical img.<rest>
325+
if [[ "$n" == *".img."* ]]; then
326+
echo "img.${n##*.img.}"
327+
return
328+
fi
329+
330+
# plain .img
331+
if [[ "$n" == *.img ]]; then
332+
echo "img"
333+
return
334+
fi
335+
336+
# fallback
298337
echo "${n##*.}"
299338
}
300339

340+
301341
get_download_repository() {
302342
local url="$1"
303343
if [[ "$url" == https://github.com/armbian/* ]]; then
@@ -437,16 +477,39 @@ cat "$tmpdir/a.txt" "$tmpdir/bcd.txt" >"$feed"
437477
PREFIX=""; [[ "$REPO" == "os" ]] && PREFIX="nightly/"
438478

439479
BASE_EXT="$(extract_file_extension "$IMAGE_NAME")"
440-
if [[ "$IMAGE_NAME" == *.oowow.img.xz ]]; then
441-
FILE_EXTENSION="oowow.img.xz"
442-
elif [[ -n "$STORAGE" ]]; then
480+
if [[ -n "$STORAGE" ]]; then
443481
FILE_EXTENSION="${STORAGE}.${BASE_EXT}"
444482
else
445483
FILE_EXTENSION="$BASE_EXT"
446484
fi
447485

448486
APP_SUFFIX=""; [[ -n "$APP" ]] && APP_SUFFIX="-${APP}"
449-
REDI_URL="https://dl.armbian.com/${PREFIX}${BOARD_SLUG}/${DISTRO^}_${BRANCH}_${VARIANT}${APP_SUFFIX}"
487+
488+
# REDI URL "branch segment" is derived from artifact type (qcow2 => cloud)
489+
REDI_BRANCH="$BRANCH"
490+
REDI_VARIANT="$VARIANT${APP_SUFFIX}"
491+
492+
# Boot "flavor" suffix comes from FILE_EXTENSION like "boe.img.xz"
493+
BOOT_SUFFIX=""
494+
case "$FILE_EXTENSION" in
495+
*.img.*)
496+
BOOT_SUFFIX="${FILE_EXTENSION%%.img.*}" # e.g. "boe" from "boe.img.xz"
497+
;;
498+
esac
499+
# ignore non-boot pseudo prefixes
500+
case "$BOOT_SUFFIX" in
501+
""|img|oowow) BOOT_SUFFIX="";;
502+
esac
503+
504+
if [[ "$FILE_EXTENSION" == img.qcow2* ]]; then
505+
REDI_BRANCH="cloud"
506+
REDI_VARIANT="${VARIANT}-qcow2"
507+
else
508+
# Append boot flavor for non-cloud images
509+
[[ -n "$BOOT_SUFFIX" ]] && REDI_VARIANT="${REDI_VARIANT}-${BOOT_SUFFIX}"
510+
fi
511+
512+
REDI_URL="https://dl.armbian.com/${PREFIX}${BOARD_SLUG}/${DISTRO^}_${REDI_BRANCH}_${REDI_VARIANT}"
450513

451514
# file_url must remain the original URL (GitHub Releases for community/os/distribution)
452515
FILE_URL="$URL"

0 commit comments

Comments
 (0)