From 393c970a07ad42e5b08466dc3218ef9cb648e47b Mon Sep 17 00:00:00 2001 From: Muhammed Efe Cetin Date: Fri, 17 Jan 2025 18:35:51 +0300 Subject: [PATCH] add support for uboot bin extensions --- map.go | 14 +++++++++----- map_test.go | 21 ++++++++++++++++++++- 2 files changed, 29 insertions(+), 6 deletions(-) diff --git a/map.go b/map.go index 8f2de18..9c68f53 100644 --- a/map.go +++ b/map.go @@ -88,6 +88,8 @@ type ReleaseFile struct { var distroCaser = cases.Title(language.Und) +var imageExtensions = []string{"img.xz", "img.qcow2.xz", "boot.bin.xz"} + // loadMapJSON loads a map file from JSON, based on the format specified in the github issue. // See: https://github.com/armbian/os/pull/129 func loadMapJSON(f io.Reader) (map[string]string, error) { @@ -124,11 +126,8 @@ func loadMapJSON(f io.Reader) (map[string]string, error) { sb.WriteString(distroCaser.String(file.DistroRelease)) sb.WriteString("_") sb.WriteString(file.KernelBranch) - - //if file.ImageVariant != "server" { sb.WriteString("_") sb.WriteString(file.ImageVariant) - //} if file.Preinstalled != "" { sb.WriteString("-") @@ -147,11 +146,16 @@ func loadMapJSON(f io.Reader) (map[string]string, error) { sb.WriteString("-rootfs") case strings.Contains(file.Extension, "img.qcow2.xz"): sb.WriteString("-qcow2") + case strings.Contains(file.Extension, "boot.bin.xz"): + sb.WriteString("-uboot-bin") } // Add board into the map without an extension - if strings.HasSuffix(file.Extension, "img.xz") || strings.HasSuffix(file.Extension, "img.qcow2.xz") { - m[sb.String()] = u.Path + for _, ext := range imageExtensions { + if strings.HasSuffix(file.Extension, ext) { + m[sb.String()] = u.Path + break + } } sb.WriteString(".") diff --git a/map_test.go b/map_test.go index 75613d5..9554c33 100644 --- a/map_test.go +++ b/map_test.go @@ -95,7 +95,7 @@ var _ = Describe("Map", func() { It("Should work with files that have weird extensions", func() { data := `{ "assets": [ - { + { "board_slug": "khadas-vim4", "armbian_version": "23.11.1", "file_url": "https://dl.armbian.com/khadas-vim4/archive/Armbian_23.11.1_Khadas-vim4_bookworm_legacy_5.4.180.oowow.img.xz", @@ -181,6 +181,21 @@ var _ = Describe("Map", func() { "promoted": "false", "download_repository": "archive", "file_extension": "img.qcow2.xz.sha" + }, + { + "board_slug": "qemu-uboot-arm64", + "armbian_version": "24.8.0-trunk.542", + "file_url": "https://github.com/armbian/os/releases/download/24.8.0-trunk.542/Armbian_24.8.0-trunk.542_Qemu-uboot-arm64_bookworm_current_6.6.44_minimal.u-boot.bin.xz", + "redi_url": "https://dl.armbian.com/qemu-uboot-arm64/Bookworm_current_minimal", + "file_updated": "2024-08-09T10:07:43Z", + "file_size": "314832", + "distro_release": "bookworm", + "kernel_branch": "current", + "image_variant": "minimal", + "preinstalled_application": "", + "promoted": "false", + "download_repository": "os", + "file_extension": "boot.bin.xz" } ] }` @@ -195,5 +210,9 @@ var _ = Describe("Map", func() { Expect(m["uefi-arm64/Bookworm_current_minimal-qcow2"]).To(Equal("/uefi-arm64/archive/Armbian_24.5.5_Uefi-arm64_bookworm_current_6.6.42_minimal.img.qcow2.xz")) Expect(m["uefi-arm64/Bookworm_current_minimal-qcow2.asc"]).To(Equal("/uefi-arm64/archive/Armbian_24.5.5_Uefi-arm64_bookworm_current_6.6.42_minimal.img.qcow2.xz.asc")) Expect(m["uefi-arm64/Bookworm_current_minimal-qcow2.sha"]).To(Equal("/uefi-arm64/archive/Armbian_24.5.5_Uefi-arm64_bookworm_current_6.6.42_minimal.img.qcow2.xz.sha")) + + Expect(m["nightly/qemu-uboot-arm64/Bookworm_current_minimal-uboot-bin"]).To(Equal("/armbian/os/releases/download/24.8.0-trunk.542/Armbian_24.8.0-trunk.542_Qemu-uboot-arm64_bookworm_current_6.6.44_minimal.u-boot.bin.xz")) + Expect(m["nightly/qemu-uboot-arm64/Bookworm_current_minimal-uboot-bin.boot.bin.xz"]).To(Equal("/armbian/os/releases/download/24.8.0-trunk.542/Armbian_24.8.0-trunk.542_Qemu-uboot-arm64_bookworm_current_6.6.44_minimal.u-boot.bin.xz")) + }) })