Skip to content

Commit c255b71

Browse files
committed
Few more fixes to JSOn file generation
1 parent 0dcea3c commit c255b71

File tree

1 file changed

+29
-10
lines changed

1 file changed

+29
-10
lines changed

scripts/generate-armbian-images-json.sh

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -292,9 +292,27 @@ strip_img_ext() {
292292
extract_file_extension() {
293293
local n="$1"
294294

295-
# U-Boot artifacts
296-
if [[ "$n" == *".u-boot.bin."* ]]; then
297-
echo "u-boot.bin.${n##*.u-boot.bin.}" # e.g. u-boot.bin.xz
295+
# U-Boot ROM artifacts
296+
# ...minimal.u-boot.rom.xz -> u-boot.rom.xz
297+
# ...minimal.u-boot.rom -> u-boot.rom
298+
if [[ "$n" == *".u-boot.rom" ]] || [[ "$n" == *".u-boot.rom."* ]]; then
299+
if [[ "$n" == *".u-boot.rom."* ]]; then
300+
echo "u-boot.rom.${n##*.u-boot.rom.}"
301+
else
302+
echo "u-boot.rom"
303+
fi
304+
return
305+
fi
306+
307+
# U-Boot BIN artifacts
308+
# ...minimal.u-boot.bin.xz -> u-boot.bin.xz
309+
# ...minimal.u-boot.bin -> u-boot.bin
310+
if [[ "$n" == *".u-boot.bin" ]] || [[ "$n" == *".u-boot.bin."* ]]; then
311+
if [[ "$n" == *".u-boot.bin."* ]]; then
312+
echo "u-boot.bin.${n##*.u-boot.bin.}"
313+
else
314+
echo "u-boot.bin"
315+
fi
298316
return
299317
fi
300318

@@ -314,14 +332,12 @@ extract_file_extension() {
314332
# ...desktop.boot_sm8250-xiaomi-elish-boe.img.xz -> boe.img.xz
315333
# ...desktop.boot_recovery.img.xz -> recovery.img.xz
316334
if [[ "$n" == *".boot_"*".img."* ]]; then
317-
local after_boot="${n#*.boot_}" # everything after the first ".boot_"
318-
local boot_stem="${after_boot%%.img.*}" # up to before ".img."
335+
local after_boot="${n#*.boot_}" # after ".boot_"
336+
local boot_stem="${after_boot%%.img.*}" # before ".img."
319337
local flavor="$boot_stem"
320338

321339
# if it's boot_sm8250-...-boe, take last '-' token
322-
if [[ "$boot_stem" == *-* ]]; then
323-
flavor="${boot_stem##*-}"
324-
fi
340+
[[ "$boot_stem" == *-* ]] && flavor="${boot_stem##*-}"
325341

326342
echo "${flavor}.img.${n##*.img.}"
327343
return
@@ -343,7 +359,6 @@ extract_file_extension() {
343359
echo "${n##*.}"
344360
}
345361

346-
347362
get_download_repository() {
348363
local url="$1"
349364
if [[ "$url" == https://github.com/armbian/* ]]; then
@@ -507,19 +522,23 @@ cat "$tmpdir/a.txt" "$tmpdir/bcd.txt" >"$feed"
507522
""|img|oowow) BOOT_SUFFIX="";;
508523
esac
509524

525+
# U-Boot ROM suffix
526+
UBOOT_ROM_SUFFIX=""
527+
[[ "$FILE_EXTENSION" == u-boot.rom* ]] && UBOOT_ROM_SUFFIX="u-boot-rom"
528+
510529
# U-Boot artifacts should show up as "-boot" in REDI_URL
511530
UBOOT_SUFFIX=""
512531
if [[ "$FILE_EXTENSION" == u-boot.bin* ]]; then
513532
UBOOT_SUFFIX="boot"
514533
fi
515534

516535
if [[ "$FILE_EXTENSION" == img.qcow2* ]]; then
517-
REDI_BRANCH="cloud"
518536
REDI_VARIANT="${VARIANT}-qcow2"
519537
else
520538
# Append boot flavor for non-cloud images
521539
[[ -n "$BOOT_SUFFIX" ]] && REDI_VARIANT="${REDI_VARIANT}-${BOOT_SUFFIX}"
522540
[[ -n "$UBOOT_SUFFIX" ]] && REDI_VARIANT="${REDI_VARIANT}-${UBOOT_SUFFIX}"
541+
[[ -n "$UBOOT_ROM_SUFFIX" ]] && REDI_VARIANT="${REDI_VARIANT}-${UBOOT_ROM_SUFFIX}"
523542
fi
524543

525544
REDI_URL="https://dl.armbian.com/${PREFIX}${BOARD_SLUG}/${DISTRO^}_${REDI_BRANCH}_${REDI_VARIANT}"

0 commit comments

Comments
 (0)