]> xenbits.xensource.com Git - people/gdunlap/xsatool/commitdiff
Implement reset-base
authorGeorge Dunlap <george.dunlap@citrix.com>
Mon, 26 Jun 2017 11:17:32 +0000 (12:17 +0100)
committerGeorge Dunlap <george.dunlap@citrix.com>
Tue, 27 Jun 2017 11:32:29 +0000 (12:32 +0100)
Implement reset-base, to reset the 'base' version to the upstream
stable trees without rebasing.

While we're here, document 'repo update' and add some comments.

Signed-off-by: George Dunlap <george.dunlap@citrix.com>
README.md
main.go
xen.go
xsa.go

index 3cc374ef3cfee186c26d8a04ba86d60a6287be1e..64a9c33080b34607de2b8b81b724d6ca6cfe9c1a 100644 (file)
--- a/README.md
+++ b/README.md
@@ -263,6 +263,22 @@ you can leave the version blank and it will make branches for versions
 This could also be useful, for example, if prerequisites are manually
 added or removed.
 
+## Pulling in new versions of upstream repos
+
+`xsatool repo update`
+
+For each tree, this will do a fetch, then go through `master` and any
+branch named `stable-*` and to a 'merge'.
+
+## Updating the 'base' of an outstanding XSA when the stable branches have changed
+
+`xsatool NNN reset-base [versions]`
+
+For each version, this will update StableRef to point to the current
+value of the 'stable' branch (either `master` or `stable-VV`).  It
+will then re-apply the patch and any prerequisites as-is (i.e., *not*
+doing a rebase), failing out in case of an error.
+
 # Potential future functionality
 
 ## Automatically de-duplicating patches
diff --git a/main.go b/main.go
index de18d59d94710b6455c38d240a1f0fc2fe690db1..b92549f755cac1081bbd31a56b9792c6e640a7b9 100644 (file)
--- a/main.go
+++ b/main.go
@@ -31,11 +31,17 @@ func ForEachXenRepo(f func(*XenRepo, Tree) error) error {
        return ForEachCodeTree(f2)
 }
 
+// Convert argument list into a set of versions:
+// - If no versions exist, use SupportedVersions from metadata
+//   - If hasPatches is true, include only versions which have patches; otherwise
+//     include all of them.
+// - Otherwise add the list of versions in order
 func VersionsFromArgs(xsa *XSAMeta, args []string, hasPatches bool) (vers []XenVersion) {
        if len(args) == 0 || (len(args) == 1 && args[0] == "all") {
                for _, v := range xsa.SupportedVersions {
                        // Check to see if the branch exists
                        if hasPatches && !xsa.RepoHasPatches(v) {
+                               // FIXME: Should this be "break" instead?
                                continue
                        }
                        vers = append(vers, v)
@@ -137,6 +143,10 @@ func XsaMain(args []string) int {
                        main = MainTest
                        loadConfig = true
                        loadXSA = true
+               case "reset-base":
+                       main = MainResetBase
+                       loadConfig = true
+                       loadXSA = true
                default:
                        fmt.Printf("Unknown command: %s\n", cmd)
                        return 1
diff --git a/xen.go b/xen.go
index d1aa76eca481d45c13847bf7708c73fe03fa235c..5bdbeeb802496e6ba125c779dff1d488c434cafc 100644 (file)
--- a/xen.go
+++ b/xen.go
@@ -246,6 +246,7 @@ func (xr *XenRepo) GetRefVersion(v XenVersion) (ref string, err error) {
        return
 }
 
+// NB this leaves the tree in a non-deterministic state
 func (xr *XenRepo) MakeStableBranch(v XenVersion) (err error) {
        stableBranch := XenStableBranch(v)
 
diff --git a/xsa.go b/xsa.go
index 552fabc1b1969e612ba91f25690e15dbf846492d..76c7baad183d39ab730424fea6a5e5ee581df4ab 100644 (file)
--- a/xsa.go
+++ b/xsa.go
@@ -226,3 +226,60 @@ func MainBackport(xsa *XSAMeta, args []string) (ret int) {
 }
 
 // xsatool NNN backport-fixup [version]
+
+// xsatool NNN reset-base [versions]
+func MainResetBase(xsa *XSAMeta, args []string) (ret int) {
+       // Starting with master:
+       //  -- Re-set stableref to upstream
+       //  -- Re-apply recipe
+
+       
+       vers := VersionsFromArgs(xsa, args, false)
+
+       for _, v := range vers {
+               r := xsa.GetRecipe(v)
+               if r == nil {
+                       fmt.Printf("Couldn't find recipe for XenVersion %s\n", v)
+                       return 1
+               }
+
+               fmt.Printf("Resetting base for version %v\n", v)
+
+               for _, t := range xsa.Trees {
+                       var err error
+                       
+                       xr := G.repos.XenRepos[t]
+
+                       if err = xr.MakeStableBranch(v); err != nil {
+                               fmt.Printf("Checking out stable branch for tree %v version %v: %v\n",
+                                       t, v, err)
+                               return 1
+                       }
+                       
+                       tr, prs := r.Recipes[t]
+
+                       if !prs {
+                               err = fmt.Errorf("Internal data error: no recipe for tree %s\n", t)
+                               return
+                       }
+
+                       tr.StableRef, err = xr.GetRefVersion(v)
+                       if err != nil {
+                               fmt.Printf("Getting ref for stable version %v: %v\n",
+                                       v, err)
+                       }
+               }
+               
+               if err := r.ApplyAll("xsa"); err != nil {
+                       fmt.Printf("Making recipe baseline for version %v: %v\n", v, err)
+                       return 1
+               }
+       }
+
+       if err := xsa.Save(); err != nil {
+               fmt.Printf("Saving xsa: %v\n", err)
+               return 1
+       }
+
+       return
+}