George Dunlap [Wed, 10 May 2017 16:09:48 +0000 (17:09 +0100)]
Testing: Introduce 'system' test
To begin with, just clone repos and begin to set them up in a specific
state, so that we can test operations.
To make testing iteration faster, set FullClone == false. After test
development is done, this should be set to "true" to make the cloning
continues to work.
Signed-off-by: George Dunlap <george.dunlap@citrix.com>
George Dunlap [Wed, 10 May 2017 13:27:05 +0000 (14:27 +0100)]
Refactor main to be more test-friendly
Have a special function, XsaMain(), which does the work and is passed
parameters and a return value. Have a wrapper which interacts with
the operating system under normal conditions. This allows the testing
infrastructure to simulate being called as closely as possible.
Get rid of global references to 'xsa' entirely; instead pass
references to a local copy on the stack.
Collect all remaining global state into a struct called 'G', and reset
its state every time XsaMain() is called.
Signed-off-by: George Dunlap <george.dunlap@citrix.com>
George Dunlap [Fri, 28 Apr 2017 10:27:47 +0000 (11:27 +0100)]
Introduce Tree type to avoid hard-coding tree names
Replace repos.{xen,qemuu,qemut}, config.*Path, and Recipes.{Xen,Qemu*}
with arrays indexed by Tree. Replace Get*Path with GetPath(t).
Replace XRType with Tree. Introduce ForEachCodeTree, ForEachTree, and
ForEachXenRepo helper functions to run a specific function for each
tree / repo; rewrite lots of code to use those functions instead of
doing code duplication.
Signed-off-by: George Dunlap <george.dunlap@citrix.com>
George Dunlap [Fri, 24 Mar 2017 17:44:50 +0000 (17:44 +0000)]
Finish sync-patch, add sync-branch as well
Have MakePatches include a flag deciding whether to sync or not.
If set, after creating all appropriate patches in /tmp, make the
appropriate directory/ies in xsa.git and copy the files there (or just
copy a single patch if the file is a single patch).
Also implement sync-branch which will delete and re-create xsa/NNN/VVV
from xsa.git according to the recipe.
Signed-off-by: George Dunlap <george.dunlap@citrix.com>
George Dunlap [Fri, 24 Mar 2017 11:07:16 +0000 (11:07 +0000)]
main: Add partial implementation of sync-patches command
Partial implementation of sync-patches, which will look for trees
which contain xsa/NNN/VVV and xsa/NNN/VVV-baseline and run
`git format-patch` to generate patches.
To do this:
- Implement Repo.FormatPatch()
- Implement XSAMeta.GetRecipe(version) to get a recipe for a specific version
- Modify IsApplied() to look for both $prefix/NNN/VVV and $prefix/NNN/VVV-baseline
- Implement Recipe.MakePatches()
- Modify IsApplied() to return only an error; but make return a
distinguishable type to say what branch wasn't applied
A full implementation would also copy the patches into xsa.git either
as a single patch or a directory full of patches, as appropriate.
Signed-off-by: George Dunlap <george.dunlap@citrix.com>
George Dunlap [Thu, 23 Mar 2017 13:52:02 +0000 (13:52 +0000)]
Main: Fake up config and xsa info
"Fake up" config and XSA info in Main(), so that we can start writing
functionality as though the config loading already existed, rather
than have to store it all in test.go.
This should make it easier to extend functionality as needed in a way
which will actually be useful once the config loading stuff is ready.
Signed-off-by: George Dunlap <george.dunlap@citrix.com>
George Dunlap [Thu, 23 Mar 2017 11:38:50 +0000 (11:38 +0000)]
Recipe: Break down per-tree recipe into prerequisites and patches
Create a new struct, TreeRecipe, to be the recipe for a particular
tree (Xen, QemuU or QemuT). Have this contain separate prereq and
patches sections.
When building, create a branch $branch-baseline to apply the Prereq
patches to, and then base $branch based on the baseline.
The idea here is to make an easy way to programmatically sync changes
to the tree back to xsa.git.
Also unconditionally use local qemu trees, even if we don't have local
patches, because we know they'll be up to date with upstream changes
(since we pull at start-of-day).
Signed-off-by: George Dunlap <george.dunlap@citrix.com>
George Dunlap [Thu, 23 Mar 2017 10:46:43 +0000 (10:46 +0000)]
Recipe: Make more flexible for both backporting and testing
Make the interface a bit more flexible, so it can be used both for
backporting (which will create branches named xsa/NNN/VVV), and for
testing (which will create branches named test/NNN/VVV).
Add branchName() helper to calculate branch name, rather than storing
a single tempBranch.
Add IsApplied() method, which will (at the moment) only check for the
existence of the target branches in the appropriate trees.
Also:
- Use AmClean() rather than Am() to make it easier to follow up a
failure by cherry-picking
- Fix a bug in Build() which would build the wrong version
Signed-off-by: George Dunlap <george.dunlap@citrix.com>
George Dunlap [Thu, 23 Mar 2017 10:39:27 +0000 (10:39 +0000)]
Recipe: Don't clean up temporary branches automatically (for now)
When doing testing, we probably want to remove temporary branches; but
when doing backporting we most certainly do not. This is something
which still needs to be figured out.
Signed-off-by: George Dunlap <george.dunlap@citrix.com>
George Dunlap [Thu, 23 Mar 2017 10:30:33 +0000 (10:30 +0000)]
git: Implement VerifyRef and AmClean
VerifyRef returns true if the specified ref exists.
AmClean() is like Am(), but will reset the tree to a useable state if
the Am fails. This is useful for situations like backporting where
you typically want to cherry-pick on a failed `git am` to take
advantage of the three-way merge functionality.
Signed-off-by: George Dunlap <george.dunlap@citrix.com>
George Dunlap [Thu, 16 Mar 2017 17:15:15 +0000 (17:15 +0000)]
Allow Recipes to have multiple globs, implement Recipe.Build()
Allow each recipe to have multiple "globs" associated with each tree.
Implement Recipe.Build(), which will construct the appropriate config
file to make the build use the appropriate branches, and then
configure and run make.
While we're here fix some mistaken status messages in Recipe.Cleanup(), and
fix XenRepo.CheckoutVersion when XenVersion == Master.
And update the "test" to XSA211.
Signed-off-by: George Dunlap <george.dunlap@citrix.com>
George Dunlap [Fri, 24 Feb 2017 16:36:48 +0000 (16:36 +0000)]
Implement basic repoinit
Clone xen.git, qemu-xen.git, qemu-xen-traditional.git, and xsa.git,
and set up a default .xsatool config file. Disable pushes on the xen
and qemu branches.
Modify gitCmd() to not add the -C prefix if r.Path isn't set.
Implement GitClone and XenRepoClone, and Repo.DisablePush.
Move global repo s into a global structure called 'repo'; and also
include a plain Repo for xsa.
Implement ToolConfig type, with Load and Save.
Signed-off-by: George Dunlap <george.dunlap@citrix.com>
George Dunlap [Fri, 24 Feb 2017 11:28:44 +0000 (11:28 +0000)]
Teach Recipe to be able to apply a git am
- Make a set of global variables for paths, including existing
hard-coded repo paths, but also one for the paths for XSAs.
- Move all global variables into main.go
- Rename Repo.Checkout to Repo.MakeBranch (since that's what it's
actually doing); add Repo.Checkout (to simply do a checkout),
Repo.DeleteBranch, and Repo.Am. Make Repo.Am take a single argument
and do globbing on it.
- Rename Recipe.*Patches to *Glob, to indicate that these are globs
- Have the recipe call qemuu.Am(); also have it clean up the branch
afterwards.
Signed-off-by: George Dunlap <george.dunlap@citrix.com>
George Dunlap [Thu, 23 Feb 2017 22:36:25 +0000 (22:36 +0000)]
Add metadata and proof-of-concept tag checkout
Add a metadata struct (which will eventually be stored as json),
containing the XSA number, supported Xen versions (according to what
is in security support at the time the XSA is issued), and 'recipes'
for building patched versions.
Each recipe consists of a full Xen version (down to point),
prerequisite XSAs that this patch depends on, and a string to "git am"
to various trees.
Applying the recipe will make a branch checked out from the release tag
appropriate to that repo.
Signed-off-by: George Dunlap <george.dunlap@citrix.com>