From: George Dunlap Date: Mon, 26 Jun 2017 11:17:32 +0000 (+0100) Subject: Implement reset-base X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=5c7e0f419123f748448b22e09fc7e8a05a7ab781;p=people%2Fgdunlap%2Fxsatool Implement reset-base 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 --- diff --git a/README.md b/README.md index 3cc374e..64a9c33 100644 --- 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 de18d59..b92549f 100644 --- 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 d1aa76e..5bdbeeb 100644 --- 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 552fabc..76c7baa 100644 --- 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 +}