Skip to content

Commit 109ffff

Browse files
committed
Review BuildVersionManifest to support Incus
The distrobuilder 3.0 now generates incus.tar.xz instead of lxd.tar.xz. In order to generate correctly the version manifest file now we check if exists incus.tar.xz and we generate the combined sha256 hash.
1 parent 307ab3a commit 109ffff

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

pkg/images/versions.go

+19-3
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ func BuildVersionsManifest(product *config.SimpleStreamsProduct,
7979
var err error
8080
var files []os.FileInfo
8181
var productBasePath, itemDir, eolDuration string
82-
var item, lxdTarXzItem *streams.ProductVersionItem
82+
var item, lxdTarXzItem, incusTarXzItem *streams.ProductVersionItem
8383
var ans *VersionsSSBuilderManifest = &VersionsSSBuilderManifest{
8484
Name: product.Name,
8585
Versions: make(map[string]streams.ProductVersion),
@@ -147,6 +147,7 @@ func BuildVersionsManifest(product *config.SimpleStreamsProduct,
147147
product.Name, productBasePath))
148148

149149
lxdTarXzItem, _ = checkItem("lxd.tar.xz", itemDir, productBasePath, &combined)
150+
incusTarXzItem, _ = checkItem("incus.tar.xz", itemDir, productBasePath, &combined)
150151
item, _ = checkItem("rootfs.squashfs", itemDir, productBasePath, &combined)
151152
if item != nil {
152153
version.Items["root.squashfs"] = *item
@@ -171,6 +172,21 @@ func BuildVersionsManifest(product *config.SimpleStreamsProduct,
171172
version.Items["lxd.tar.xz"] = *lxdTarXzItem
172173
}
173174

175+
if incusTarXzItem != nil {
176+
if combined.SquashFsIsPresent {
177+
(*incusTarXzItem).CombinedHashSha256SquashFs = hex.EncodeToString(
178+
combined.CombinedSquashfsSha256.Sum(nil),
179+
)
180+
}
181+
182+
if combined.TarXzIsPresent {
183+
sha := hex.EncodeToString(combined.CombinedRootxzSha256.Sum(nil))
184+
(*incusTarXzItem).CombinedHashSha256RootXz = sha
185+
(*incusTarXzItem).CombinedHashSha256 = sha
186+
}
187+
version.Items["incus.tar.xz"] = *incusTarXzItem
188+
}
189+
174190
ans.Versions[f.Name()] = version
175191
}
176192

@@ -196,7 +212,7 @@ func checkItem(base, dir, productBasePath string, combined *CombinedSha256Builde
196212
if base == "rootfs.squashfs" {
197213
ftype = "squashfs"
198214
(*combined).SquashFsIsPresent = true
199-
} else if base == "lxd.tar.xz" {
215+
} else if base == "lxd.tar.xz" || base == "incus.tar.xz" {
200216
ftype = base
201217
} else if base == "rootfs.tar.xz" {
202218
(*combined).TarXzIsPresent = true
@@ -231,7 +247,7 @@ func checkItem(base, dir, productBasePath string, combined *CombinedSha256Builde
231247
pb = buf[0:nBytes]
232248
fmd5.Write(pb)
233249
fsha.Write(pb)
234-
if base == "lxd.tar.xz" {
250+
if base == "lxd.tar.xz" || base == "incus.tar.xz" {
235251
(*combined).CombinedRootxzSha256.Write(pb)
236252
(*combined).CombinedSquashfsSha256.Write(pb)
237253
} else if base == "rootfs.tar.xz" {

0 commit comments

Comments
 (0)