]> xenbits.xensource.com Git - people/gdunlap/xsatool/commitdiff
recipe: Use StableBranch to create VVV-baseline branch
authorGeorge Dunlap <george.dunlap@citrix.com>
Thu, 8 Jun 2017 16:23:56 +0000 (17:23 +0100)
committerGeorge Dunlap <george.dunlap@citrix.com>
Thu, 8 Jun 2017 16:23:56 +0000 (17:23 +0100)
Get rid of XenVersionFull from the recipe and replace it with
XenVersion for convenience.

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

diff --git a/meta.go b/meta.go
index 25cb8f7378b89a63444814335e1fa306132446af..66b98b0cc4f4c52e89c159a4cf9451f9e0223aba 100644 (file)
--- a/meta.go
+++ b/meta.go
@@ -225,14 +225,14 @@ func (m *XSAMeta) GetRecipe(v XenVersion) *Recipe {
        return m.Recipes[v]
 }
 
-func (m *XSAMeta) NewRecipe(fv XenVersionFull) *Recipe {
+func (m *XSAMeta) NewRecipe(v XenVersion) *Recipe {
        var r Recipe
 
        r.xsa = m.XSA
-       r.XenVersionFull = fv
+       r.XenVersion = v
        r.Recipes = make(map[Tree]*TreeRecipe)
 
-       m.Recipes[fv.XenVersion()] = &r
+       m.Recipes[v] = &r
 
        return &r
 }
index c5d278c4498b1153ba4b7816633c547b4b92fc08..56fc3e6703da13b17b4ce88d3ae92b4eb341004e 100644 (file)
--- a/recipe.go
+++ b/recipe.go
@@ -22,7 +22,7 @@ func (tr *TreeRecipe) HasPatches() bool {
 }
 
 type Recipe struct {
-       XenVersionFull
+       XenVersion
        Recipes map[Tree]*TreeRecipe
        xsa     int
 }
@@ -195,10 +195,10 @@ func (r *Recipe) MakePatches(prefix string, sync bool) (count int, err error) {
                        xsabase += "-" + tree.String()
                }
 
-               if r.XenVersionFull == "master" {
+               if r.XenVersion == "master" {
                        xsabase += "-unstable"
                } else {
-                       xsabase += "-" + r.XenVersionFull.XenVersion().String()
+                       xsabase += "-" + r.XenVersion.String()
                }
 
                xsatgt := G.config.Tool.GetPath(TreeXSA) + "/" + xsabase
@@ -312,7 +312,7 @@ func BranchName(prefix string, xsa int, v XenVersion) (branch, baseline string)
 }
 
 func (r *Recipe) branchName(prefix string) (branch, baseline string) {
-       branch, baseline = BranchName(prefix, r.xsa, r.XenVersionFull.XenVersion())
+       branch, baseline = BranchName(prefix, r.xsa, r.XenVersion)
 
        fmt.Printf("Branchnames: %s %s\n", branch, baseline)
 
@@ -332,11 +332,12 @@ func (r *Recipe) branchName(prefix string) (branch, baseline string) {
 func (r *Recipe) apply(xr *XenRepo, tr *TreeRecipe, prefix string) (err error) {
        branch, baseline := r.branchName(prefix)
 
-       // Make "baseline" branch, based on XenVersionFull, with Prereq patches
-       err = xr.CheckoutVersion(r.XenVersionFull, baseline)
+       // FIXME change this to tr.StableRef
+       // Make "baseline" branch, based on XenVersion, with Prereq patches
+       err = xr.MakeBranch(baseline, tr.StableRef)
        if err != nil {
                return fmt.Errorf("Making baseline %s for xenversion %v: %v\n",
-                       baseline, r.XenVersionFull)
+                       baseline, r.XenVersion)
        }
 
        for _, xsanum := range tr.Prereqs {
@@ -348,7 +349,7 @@ func (r *Recipe) apply(xr *XenRepo, tr *TreeRecipe, prefix string) (err error) {
        err = xr.MakeBranch(branch, baseline)
        if err != nil {
                return fmt.Errorf("Making tempbranch %s for xenversion %v: %v\n",
-                       branch, r.XenVersionFull)
+                       branch, r.XenVersion)
        }
 
        for _, glob := range tr.Patches {
@@ -406,10 +407,10 @@ func (r *Recipe) Build(prefix string) (err error) {
                                branch, err)
                }
        } else {
-               err = xenrepo.CheckoutVersion(r.XenVersionFull, tmpBranch)
+               err = xenrepo.MakeBranch(tmpBranch, XenStableBranch(r.XenVersion))
                if err != nil {
                        return fmt.Errorf("Making tempbranch %s for xenversion %v: %v\n",
-                               tmpBranch, r.XenVersionFull)
+                               tmpBranch, r.XenVersion)
                }
        }
 
index 9e23d0449be2cde7879bd3cf3b9d09ed0da30a85..d86841a4afbbd8694d5d7db6754b75a1ed36e169 100644 (file)
@@ -288,10 +288,10 @@ func Story206Init(st *SystemTest) (pass bool) {
                        pass = false
                } else {
                        versions[v].seen = true
-                       if versions[v].fv != r.XenVersionFull {
-                               st.Errorf("Expected fullversion %v, got %v\n",
-                                       versions[v].fv,
-                                       r.XenVersionFull)
+                       if v != r.XenVersion {
+                               st.Errorf("Expected version %v, got %v\n",
+                                       v,
+                                       r.XenVersion)
                                pass = false
                        }
                        ForEachCodeTree(func(tree Tree) error {
diff --git a/test.go b/test.go
index e39447091752e25553f100cea9ac41d97e1e6ecf..99bf0e823ec4355d98d783afd90e3ad39fac4921 100644 (file)
--- a/test.go
+++ b/test.go
@@ -4,40 +4,6 @@ import (
        "fmt"
 )
 
-/* Backport: Apply & build if the branch doesn't exist / if override is set */
-
-func backport(xsa *XSAMeta) (ret int) {
-       for i := range xsa.Recipes {
-               prefix := "xsa"
-               r := xsa.Recipes[i]
-
-               if err := r.IsApplied(prefix); err != nil {
-                       if _, isMissingBranch := err.(ErrorMissingBranch); !isMissingBranch {
-                               fmt.Printf("Error checking to see if recipe has been applied: %v\n", err)
-                               return 1
-                       }
-
-                       err = r.Apply(prefix)
-                       if err != nil {
-                               fmt.Printf("Applying recipe: %v\n", err)
-                               fmt.Printf("FAILED: %v\n", r.XenVersionFull)
-                               return 1
-                       }
-
-                       err = r.Build(prefix)
-                       if err != nil {
-                               fmt.Printf("Building recipe: %v\n", err)
-                               fmt.Printf("FAILED: %v\n", r.XenVersionFull)
-                               return 1
-                       }
-                       fmt.Printf("SUCCESS: %v\n", r.XenVersionFull)
-               }
-
-       }
-
-       return 0
-}
-
 func test(xsa *XSAMeta, args []string, apply bool, build bool) (ret int) {
 
        vers := VersionsFromArgs(xsa, args)
@@ -59,7 +25,7 @@ func test(xsa *XSAMeta, args []string, apply bool, build bool) (ret int) {
                        err := r.Apply(prefix)
                        if err != nil {
                                fmt.Printf("Applying recipe: %v\n", err)
-                               fmt.Printf("FAILED: %v\n", r.XenVersionFull)
+                               fmt.Printf("FAILED: %v\n", r.XenVersion)
                                return 1
                        }
                } else {
@@ -80,12 +46,12 @@ func test(xsa *XSAMeta, args []string, apply bool, build bool) (ret int) {
                        err := r.Build(prefix)
                        if err != nil {
                                fmt.Printf("Building recipe: %v\n", err)
-                               fmt.Printf("FAILED: %v\n", r.XenVersionFull)
+                               fmt.Printf("FAILED: %v\n", r.XenVersion)
                                return 1
                        }
                }
 
-               fmt.Printf("SUCCESS: %v\n", r.XenVersionFull)
+               fmt.Printf("SUCCESS: %v\n", r.XenVersion)
        }
 
        return 0
diff --git a/xen.go b/xen.go
index 05aed1e222039f8fff12252967dbc07fe235e657..91d4e5dea5a2a2d1686328a48e358369abc9bdc7 100644 (file)
--- a/xen.go
+++ b/xen.go
@@ -210,14 +210,7 @@ func (xr *XenRepo) MakeStableBranch(v XenVersion) (err error) {
        return
 }
 
-func (xr *XenRepo) CheckoutVersion(ver XenVersionFull, branchName string) (err error) {
-       tag := xr.GetTag(ver)
-       fmt.Printf("Creating branch %s based on tag %s\n",
-               branchName, tag)
-       err = xr.MakeBranch(branchName, tag)
-       return
-}
-
+// Check out stable-$version (or 'master') 
 func (xr *XenRepo) tagsToVersions(tags []string) (versions []XenVersionFull, err error) {
        re := regexp.MustCompile("^" + xr.releaseTagPrefix() + "([0-9]+.[0-9]+.[0-9]+)$")
 
diff --git a/xsa.go b/xsa.go
index a08d038195bf16eba1c88281646f09817db9ed6e..7b046316736ec95e428b4aaef0abf03581fe8209 100644 (file)
--- a/xsa.go
+++ b/xsa.go
@@ -60,7 +60,7 @@ func MainSyncBranch(xsa *XSAMeta, args []string) (ret int) {
                err := r.Apply(prefix)
                if err != nil {
                        fmt.Printf("Applying recipe: %v\n", err)
-                       fmt.Printf("FAILED: %v\n", r.XenVersionFull)
+                       fmt.Printf("FAILED: %v\n", r.XenVersion)
                        return 1
                }
        }
@@ -106,7 +106,7 @@ func MainInit(xsa *XSAMeta, args []string) (ret int) {
 
                xsa.SupportedVersions = append(xsa.SupportedVersions, v)
 
-               r := xsa.NewRecipe(vm.Latest)
+               r := xsa.NewRecipe(v)
 
                for _, t := range xsa.Trees {
                        var err error