Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support for uboot bin extensions #19

Merged
merged 1 commit into from
Jan 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions map.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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("-")
Expand All @@ -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(".")
Expand Down
21 changes: 20 additions & 1 deletion map_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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"
}
]
}`
Expand All @@ -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"))

})
})
Loading