This creates an 'empty' xsa228.meta file, and the appropriate
`-stable` and `-baseline` branches.
-Now edit `xsa228.meta`. Under "Recipes", for each Xen version, there
-will be an entry called "Patches" that will be an empty array (`[ ]`).
-Add the name of the appropriate patch in quotes inside the brackets
-for each Xen version.
+Now set the patches for each version individually:
-In the case of XSA 228, you'd enter `"xsa228.patch"` under both
-`"master"` and `"4.9"`, `"xsa228-4.8.patch"` under `"4.8"`, `"4.7"`,
-`"4.6"`, and so on.
+`xsatool 228 set-patches master xsa228.patch`
-**TODO**
+`xsatool 228 set-patches 4.9 xsa228.patch`
-Implement a command to do this; for example:
+`xsatool 228 set-patches 4.8 xsa228-4.8.patch`
-`xsatool 228 set-patches 4.9 xsa228.patch`
+...and so on. Note that this command will only work when an XSA
+applies to only one tree; if the XSA covers more than one tree, you'll
+have to edit the metadata file by hand.
+
+**TODO** Add a way to specify multiple versions in one go; e.g.,
+`master,4.9,4.8` or something.
## Excluding a particular Xen version from an XSA
return
}
+
+// xsatool NNN set-patches version patch_glob [patch_glob ...]
+func MainSetPatches(xsa *XSAMeta, args []string) (ret int) {
+ if len(args) < 2 {
+ fmt.Printf("Not enough arguments")
+ return 1
+ }
+
+ // FIXME: Verify xenversion
+ v := XenVersion(args[0])
+
+ r := xsa.GetRecipe(v)
+ if r == nil {
+ fmt.Printf("Couldn't find recipe for xenversion %v\n", v)
+ return 1
+ }
+
+ // FIXME: Figure out what to do about this
+ if len(xsa.Trees) > 1 {
+ fmt.Printf("Error: Don't know how to handle more than one tree\n")
+ return 1
+ }
+
+ // Apply this patch to the one-and-only tree we have
+ 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.Patches = append([]string(nil), args[1:]...)
+
+ xsa.dirty = true
+ }
+
+ if err := r.ApplyAll("xsa"); err != nil {
+ fmt.Printf("Error applying recipe: %v\n", err)
+ return 1
+ }
+
+ if xsa.dirty {
+ xsa.Save()
+ }
+
+ return 0
+}