return
}
-func (r *Recipe) branchName(prefix string) (branch, baseline string) {
+func BranchName(prefix string, xsa int, v XenVersion) (branch, baseline string) {
// Construct branchname
- branch = prefix + "/" + strconv.Itoa(r.xsa) + "/" + r.XenVersionFull.XenVersion().String()
+ branch = prefix + "/" + strconv.Itoa(xsa) + "/" + v.String()
baseline = branch + "-baseline"
+ return
+}
+
+func (r *Recipe) branchName(prefix string) (branch, baseline string) {
+ branch, baseline = BranchName(prefix, r.xsa, r.XenVersionFull.XenVersion())
+
fmt.Printf("Branchnames: %s %s\n", branch, baseline)
return
return
}
-func (r *Recipe) CreateBranch(prefix string, tree Tree) (err error) {
- tr, err := r.GetTreeRecipe(tree)
- if err != nil {
- return err
- }
- return r.apply(G.repos.XenRepos[tree], tr, prefix)
-}
-
func (r *Recipe) Build(prefix string) (err error) {
branch, _ := r.branchName(prefix)
return 0
}
-// xsatool NNN new-recipe $FULLVERSION {xen,qemuu,qemut} [prerequisites]
-func MainNewRecipe(xsa *XSAMeta, args []string) (ret int) {
- if len(args) < 2 {
- fmt.Printf("Not enough argruments\n")
- return 1
- }
-
- // FIXME: Check to make sure this is a valid full Xen version
- fv := XenVersionFull(args[0])
- args = args[1:]
-
- v := fv.XenVersion()
- if v == "error" {
- fmt.Printf("Cannot get Xen release from %s\n", string(fv))
+// xsatool NNN init {xen,qemuu,qemut}
+func MainInit(xsa *XSAMeta, args []string) (ret int) {
+ if len(args) < 1 {
+ fmt.Printf("Not enough arguments\n")
return 1
}
+ // FIXME parse multiple trees
tree, err := TreeFromString(args[0])
if err != nil {
fmt.Printf("Getting tree: %v\n", err)
}
args = args[1:]
+ sm := &G.config.Security
+
// FIXME -- deal with multiple components
- r := xsa.GetRecipe(v)
-
- if r != nil {
- // FIXME: Deal with colliding version numbers (only want one fullversion per
- // xenversion)
- fmt.Printf("Loaded existing metadata: %v\n", *r)
- tr, prs := r.Recipes[tree]
- if prs && tr.HasPatches() {
- fmt.Printf("Recipe for release %v component %s already exists (full version %v)\n",
- v, tree, r.XenVersionFull)
- return 1
+
+ // Check to see if there are already components
+ if len(xsa.Trees) != 0 {
+ // FIXME deal with this better
+ // Always overwrite old versions...?
+ fmt.Printf("Recipe for XSA %d exists!\n", xsa.XSA)
+ return 1
+ }
+
+ // Initialize a new xsa
+ xsa.Trees = []Tree{tree}
+ xsa.Recipes = make(map[XenVersion]*Recipe)
+
+ for v := range sm.Versions {
+ vm := sm.Versions[v]
+
+ xsa.SupportedVersions = append(xsa.SupportedVersions, v)
+
+ r := xsa.NewRecipe(vm.Latest)
+
+ for _, t := range xsa.Trees {
+ tr := &TreeRecipe{}
+ tr.Prereqs = append([]int{}, vm.XSAs[t]...)
+ tr.Patches = []string{}
+
+ r.Recipes[t] = tr
+
}
- } else {
- r = xsa.NewRecipe(fv)
- fmt.Printf("Made new metadata: %v\n", *r)
- if r.xsa != xsa.XSA {
- fmt.Printf("xsanum didn't get set!\n")
+
+ err = r.Apply("xsa")
+ if err != nil {
+ fmt.Printf("Applying initial recipe for version %v\n", v)
return 1
}
}
- // FIXME: Deal with prerequisites
+ // Check out "xsa/NNN/master" on all relevant trees
+ branch, _ := BranchName("xsa", xsa.XSA, XenVersion("master"))
+ for _, t := range xsa.Trees {
+ _, err = G.repos.XenRepos[t].Checkout(branch)
+ if err != nil {
+ fmt.Printf("Checkout out branch %s\n", branch)
+ return 1
+ }
+ }
- // Make appropriate branches (including prerequisites)
- r.CreateBranch("xsa", tree)
+ fmt.Printf("Branch(es) %s created in the appropriate repositories."+
+ " Create fix and run sync-patches.\n", branch)
// Save 'empty' recipe
err = xsa.Save()
return 1
}
+ sm.AddXSA(xsa)
+
+ err = sm.Save()
+ if err != nil {
+ fmt.Printf("Error saving global metadata: %v\n", err)
+ return 1
+ }
+
return
}