[lxc-devel] [distrobuilder/master] sources/openwrt: Use fallback image if necessary

monstermunchkin on Github lxc-bot at linuxcontainers.org
Tue Dec 8 16:47:02 UTC 2020


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 310 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20201208/96a37111/attachment.bin>
-------------- next part --------------
From 4eed9c1197d39fb2f054c18425dfd41599c34d53 Mon Sep 17 00:00:00 2001
From: Thomas Hipp <thomas.hipp at canonical.com>
Date: Tue, 8 Dec 2020 17:46:40 +0100
Subject: [PATCH] sources/openwrt: Use fallback image if necessary

Signed-off-by: Thomas Hipp <thomas.hipp at canonical.com>
---
 sources/openwrt-http.go | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/sources/openwrt-http.go b/sources/openwrt-http.go
index 4093f50..d40de2e 100644
--- a/sources/openwrt-http.go
+++ b/sources/openwrt-http.go
@@ -68,6 +68,18 @@ func (s *OpenWrtHTTP) Run(definition shared.Definition, rootfsDir string) error
 			strings.Replace(definition.Image.ArchitectureMapped, "_", "-", 1))
 	}
 
+	resp, err := http.Head(baseURL)
+	if err != nil {
+		return err
+	}
+
+	// Use fallback image "generic"
+	if resp.StatusCode == http.StatusNotFound && definition.Image.ArchitectureMapped == "x86_64" {
+		baseURL = strings.ReplaceAll(baseURL, "x86/64", "x86/generic")
+		baseURL = strings.ReplaceAll(baseURL, "x86-64", "x86-generic")
+		fname = strings.ReplaceAll(fname, "x86-64", "x86-generic")
+	}
+
 	url, err := url.Parse(baseURL)
 	if err != nil {
 		return err


More information about the lxc-devel mailing list