[lxc-devel] [lxd/master] shared/simplestreams: Add support for combined.tar.gz

stgraber on Github lxc-bot at linuxcontainers.org
Fri Aug 2 18:41:47 UTC 2019


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 370 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20190802/1a388703/attachment.bin>
-------------- next part --------------
From 15e9f91ee58f758e883bfd3b9971a0d578cad1eb Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Fri, 2 Aug 2019 14:40:30 -0400
Subject: [PATCH] shared/simplestreams: Add support for combined.tar.gz
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Closes #6040

Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
 shared/simplestreams/simplestreams.go | 29 +++++++++++++++++++--------
 1 file changed, 21 insertions(+), 8 deletions(-)

diff --git a/shared/simplestreams/simplestreams.go b/shared/simplestreams/simplestreams.go
index 61b6fa1bec..f8fc06109d 100644
--- a/shared/simplestreams/simplestreams.go
+++ b/shared/simplestreams/simplestreams.go
@@ -124,7 +124,7 @@ func (s *SimpleStreamsManifest) ToLXD() ([]api.Image, map[string][][]string) {
 				}
 
 				// Skip the files we don't care about
-				if !shared.StringInSlice(item.FileType, []string{"root.tar.xz", "lxd.tar.xz", "squashfs"}) {
+				if !shared.StringInSlice(item.FileType, []string{"root.tar.xz", "lxd.tar.xz", "lxd_combined.tar.gz", "squashfs"}) {
 					continue
 				}
 
@@ -134,6 +134,9 @@ func (s *SimpleStreamsManifest) ToLXD() ([]api.Image, map[string][][]string) {
 					rootSquash = item
 				} else if item.FileType == "root.tar.xz" {
 					rootTar = item
+				} else if item.FileType == "lxd_combined.tar.gz" {
+					meta = item
+					rootTar = item
 				}
 			}
 
@@ -164,12 +167,17 @@ func (s *SimpleStreamsManifest) ToLXD() ([]api.Image, map[string][][]string) {
 				rootfsHash = rootSquash.HashSha256
 				rootfsSize = rootSquash.Size
 			} else {
-				if meta.LXDHashSha256RootXz != "" {
-					fingerprint = meta.LXDHashSha256RootXz
+				if meta == rootTar {
+					fingerprint = meta.HashSha256
+					size = meta.Size
 				} else {
-					fingerprint = meta.LXDHashSha256
+					if meta.LXDHashSha256RootXz != "" {
+						fingerprint = meta.LXDHashSha256RootXz
+					} else {
+						fingerprint = meta.LXDHashSha256
+					}
+					size += rootTar.Size
 				}
-				size += rootTar.Size
 				rootfsPath = rootTar.Path
 				rootfsHash = rootTar.HashSha256
 				rootfsSize = rootTar.Size
@@ -229,9 +237,14 @@ func (s *SimpleStreamsManifest) ToLXD() ([]api.Image, map[string][][]string) {
 				}
 			}
 
-			imgDownloads := [][]string{
-				{metaPath, metaHash, "meta", fmt.Sprintf("%d", metaSize)},
-				{rootfsPath, rootfsHash, "root", fmt.Sprintf("%d", rootfsSize)}}
+			imgDownloads := [][]string{}
+			if meta == rootTar {
+				imgDownloads = [][]string{{metaPath, metaHash, "meta", fmt.Sprintf("%d", metaSize)}}
+			} else {
+				imgDownloads = [][]string{
+					{metaPath, metaHash, "meta", fmt.Sprintf("%d", metaSize)},
+					{rootfsPath, rootfsHash, "root", fmt.Sprintf("%d", rootfsSize)}}
+			}
 
 			// Add the deltas
 			for _, delta := range deltas {


More information about the lxc-devel mailing list