]> xenbits.xensource.com Git - people/gdunlap/xsatool/commitdiff
meta: Avoid redundant XenVersion information in recipe files
authorGeorge Dunlap <george.dunlap@citrix.com>
Fri, 8 Dec 2017 17:40:32 +0000 (17:40 +0000)
committerGeorge Dunlap <george.dunlap@citrix.com>
Fri, 8 Dec 2017 17:40:32 +0000 (17:40 +0000)
In the per-XSA meta file, we used to map recipes from XenVersion to
recipe; and then the recipe itself also contained the XenVersion.
This was loaded off the disk verbatim and not checked.

This presents an opportunity to make a mistake when editing the file
by hand (or with generic JSON-parsing libraries): if they don't match,
you might ask for a recipe for 4.10 but end up with a tree based on
master.

There's no need to save the version number in each recipe in the file.
Exclude the XenVersion struct element from being marshalled, and set
it on load with the version in the map (as we set the xsa
information).

Old metadata formats will still load correctly; `xsatool NNN
canonical` will effectively remove the information.

Signed-off-by: George Dunlap <george.dunlap@citrix.com>
meta.go
recipe.go

diff --git a/meta.go b/meta.go
index 0a9736ea05568ed9faf0b99af5ee4091bd54a6f2..1073052a128d650dad7afc1cfbdd7a58940eb3cd 100644 (file)
--- a/meta.go
+++ b/meta.go
@@ -335,6 +335,7 @@ func (xm *XSAMeta) Load(xsanum int) (err error) {
 
        for i := range xm.Recipes {
                xm.Recipes[i].xsa = xm.XSA
+               xm.Recipes[i].XenVersion = i
        }
 
        sort.Sort(xm.SupportedVersions)
index b29f9631a71228356cd74c05ce06580de0a764fb..71d12d3b99d76b96c27d139363f5d7a370bda626 100644 (file)
--- a/recipe.go
+++ b/recipe.go
@@ -22,8 +22,9 @@ func (tr *TreeRecipe) HasPatches() bool {
 }
 
 type Recipe struct {
-       XenVersion
        Recipes map[Tree]*TreeRecipe
+       // Data not exported to JSON.  Must be re-constructed on load.
+       XenVersion `json:"-"`
        xsa     int
 }