]> xenbits.xensource.com Git - people/gdunlap/xsatool/commitdiff
recipe: Handle prerequisites
authorGeorge Dunlap <george.dunlap@citrix.com>
Fri, 16 Jun 2017 10:14:52 +0000 (11:14 +0100)
committerGeorge Dunlap <george.dunlap@citrix.com>
Fri, 16 Jun 2017 10:14:52 +0000 (11:14 +0100)
When making baselines, iterate through prerequisite list and apply all
patches.

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

index 09e337ac139fae0f553541f3ea6253e42eedf075..59be8fd8175e3e0bddf188e1404991d371dae175 100644 (file)
--- a/recipe.go
+++ b/recipe.go
@@ -391,10 +391,36 @@ func (r *Recipe) ApplyBaselines(prefix string) (err error) {
                                baseline, r.XenVersion, err)
                }
 
-               // FIXME Apply previous patches
+               // Apply previous patches
                for _, xsanum := range tr.Prereqs {
-                       err = fmt.Errorf("%d: Don't know how to apply XSA prerequisites yet!", xsanum)
-                       return
+                       var xsa XSAMeta
+
+                       // Load xsa file
+                       // FIXME Might be nice not to have to re-load this for every tree
+                       if err = xsa.Load(xsanum); err != nil {
+                               err = fmt.Errorf("Loading prerequisite xsa %v metadata: %v\n",
+                                       xsanum, err)
+                               return
+                       }
+
+                       // Check to see if there are any patches to apply
+                       subr := xsa.GetRecipe(r.XenVersion)
+
+                       subtr, prs := subr.Recipes[tree]
+
+                       if !prs || !subtr.HasPatches() {
+                               fmt.Printf(" No patches for prereq xsa %d\n", xsanum)
+                               continue
+                       }
+                       
+                       // git am the appropriate patches
+                       for _, glob := range subtr.Patches {
+                               _, err = xr.AmClean(G.config.Tool.GetPath(TreeXSA) + "/" + glob)
+                               if err != nil {
+                                       return fmt.Errorf("Appling prerequiste xsa %d am %s: %v\n",
+                                               xsanum, glob, err)
+                               }
+                       }
                }
                
                return