]> xenbits.xensource.com Git - people/gdunlap/xsatool.git/log
people/gdunlap/xsatool.git
8 years agomain: Open xsa repo in OpenRepos
George Dunlap [Wed, 10 May 2017 16:02:20 +0000 (17:02 +0100)]
main: Open xsa repo in OpenRepos

Signed-off-by: George Dunlap <george.dunlap@citrix.com>
8 years agogit: Add Repo.ResetBranch
George Dunlap [Wed, 10 May 2017 16:01:14 +0000 (17:01 +0100)]
git: Add Repo.ResetBranch

To check out a particular branch.  This will be used in testing to set
up a particular view of the tree.

Signed-off-by: George Dunlap <george.dunlap@citrix.com>
8 years agoRefactor main to be more test-friendly
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>
8 years agoXenRepo: Quieten tagsToVersions
George Dunlap [Wed, 10 May 2017 13:32:42 +0000 (14:32 +0100)]
XenRepo: Quieten tagsToVersions

Signed-off-by: George Dunlap <george.dunlap@citrix.com>
8 years agorecipe: Replace Prerequisite glob with xsa list
George Dunlap [Wed, 10 May 2017 13:32:03 +0000 (14:32 +0100)]
recipe: Replace Prerequisite glob with xsa list

Punt on actually implementing applying the XSA until later.

Signed-off-by: George Dunlap <george.dunlap@citrix.com>
8 years agoRun go fmt
George Dunlap [Tue, 9 May 2017 17:05:49 +0000 (18:05 +0100)]
Run go fmt

No functional change.

Signed-off-by: George Dunlap <george.dunlap@citrix.com>
8 years agoAdd global config
George Dunlap [Tue, 9 May 2017 14:51:55 +0000 (15:51 +0100)]
Add global config

Modify global metadata to be a map (for easier readability).

Modify per-version metadata to include most recent full version and
XSAs since that point.

Add 'global update' command which will create a metadata file if not
there, and update it if there.

Signed-off-by: George Dunlap <george.dunlap@citrix.com>
8 years agoFix global.Load() to return IsNotExist() error
George Dunlap [Tue, 9 May 2017 14:48:15 +0000 (15:48 +0100)]
Fix global.Load() to return IsNotExist() error

Signed-off-by: George Dunlap <george.dunlap@citrix.com>
8 years agoImplement unit tests for various parsing / comparsions
George Dunlap [Tue, 9 May 2017 14:46:00 +0000 (15:46 +0100)]
Implement unit tests for various parsing / comparsions

Signed-off-by: George Dunlap <george.dunlap@citrix.com>
8 years agoxen: Implement XenRepo.GetVersions()
George Dunlap [Tue, 9 May 2017 14:45:06 +0000 (15:45 +0100)]
xen: Implement XenRepo.GetVersions()

Have GetVersions() fetch the tags from the repo, parse the releases,
and return a list of versions present in the tree.

Also implement XenVersion.Check() and XenVersion.IsGreaterEqualThan().

Signed-off-by: George Dunlap <george.dunlap@citrix.com>
8 years agogit: Add Tags() method to get tags
George Dunlap [Tue, 9 May 2017 11:29:35 +0000 (12:29 +0100)]
git: Add Tags() method to get tags

Signed-off-by: George Dunlap <george.dunlap@citrix.com>
8 years agoMove XenVersion and XenVersionFull into xen.go
George Dunlap [Fri, 5 May 2017 16:17:25 +0000 (17:17 +0100)]
Move XenVersion and XenVersionFull into xen.go

Code-motion only (apart from dependency changes)

Signed-off-by: George Dunlap <george.dunlap@citrix.com>
8 years agoExtend XenVersion parsing: fv.Check() and fv.Point()
George Dunlap [Fri, 5 May 2017 16:14:18 +0000 (17:14 +0100)]
Extend XenVersion parsing: fv.Check() and fv.Point()

Add an internal function to parse XenVersionFull into XenVersion and
Point.  Have .Check(), .Point(), and .XenVersion() be wrappers of
this.

Signed-off-by: George Dunlap <george.dunlap@citrix.com>
8 years agoAdd NNN new-recipe command
George Dunlap [Fri, 28 Apr 2017 10:18:33 +0000 (11:18 +0100)]
Add NNN new-recipe command

Signed-off-by: George Dunlap <george.dunlap@citrix.com>
8 years agorepo init: Actually save config file
George Dunlap [Fri, 5 May 2017 14:31:42 +0000 (15:31 +0100)]
repo init: Actually save config file

Signed-off-by: George Dunlap <george.dunlap@citrix.com>
8 years agosync-patches: Actually update and write the recipe file
George Dunlap [Fri, 5 May 2017 14:30:40 +0000 (15:30 +0100)]
sync-patches: Actually update and write the recipe file

Signed-off-by: George Dunlap <george.dunlap@citrix.com>
8 years agoUse a string for Tree rather than an int; make maps instead of arrays
George Dunlap [Fri, 5 May 2017 14:20:30 +0000 (15:20 +0100)]
Use a string for Tree rather than an int; make maps instead of arrays

This is primarily to get better config files, where the indexes are
strings rather than integers or lists.

Signed-off-by: George Dunlap <george.dunlap@citrix.com>
8 years agoA number of miscellaneous fixes
George Dunlap [Fri, 5 May 2017 14:04:58 +0000 (15:04 +0100)]
A number of miscellaneous fixes

* In main(), actually include the xsa number in the printf when the load fails

* Load and save the actual xsa file (xsa.git/xsaNNN.meta) rather than
  the global meta file.  "Normalize" (set the xsa number for recipes) on load.

* Use the correct path for QEMU_TRADITIONAL_URL

Signed-off-by: George Dunlap <george.dunlap@citrix.com>
8 years agoFix config load
George Dunlap [Fri, 5 May 2017 13:52:26 +0000 (14:52 +0100)]
Fix config load

Have ToolConfig.Load return an error which returns true for
os.IsNotExist().

When the config isn't present, initialize it.

Signed-off-by: George Dunlap <george.dunlap@citrix.com>
8 years agoIntroduce Tree type to avoid hard-coding tree names
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>
8 years agoAdd XSA.Load() and Save(), and use it rather than hardcoding
George Dunlap [Fri, 28 Apr 2017 10:30:03 +0000 (11:30 +0100)]
Add XSA.Load() and Save(), and use it rather than hardcoding

Signed-off-by: George Dunlap <george.dunlap@citrix.com>
8 years agoDo a bit more towards global security metadata
George Dunlap [Fri, 31 Mar 2017 16:02:57 +0000 (17:02 +0100)]
Do a bit more towards global security metadata

Still need to sort out the Time serialization issue; leave a comment
to this effect.

Signed-off-by: George Dunlap <george.dunlap@citrix.com>
8 years agoLoad xsatool config from a file
George Dunlap [Fri, 31 Mar 2017 14:28:42 +0000 (15:28 +0100)]
Load xsatool config from a file

Recursively look for ".xsatool" in all directories going up until
there are no more.

Add 'repo info' command to read config and print info

Also:

 - Use config.GetXXXPath() to get normalized path rather than
   accessing config.XXXPath directly

 - Change config.GetXXXPath() to return NULL if either config.rootDir
   or config.XXXPath are undefined

 - Separate out XSA fake loading into a separate flag

 - use xenproject.org rather than xen.org for default configuration

Signed-off-by: George Dunlap <george.dunlap@citrix.com>
8 years agohack: Include hack recipes for both 206 and 212
George Dunlap [Fri, 31 Mar 2017 11:10:07 +0000 (12:10 +0100)]
hack: Include hack recipes for both 206 and 212

NB that 212 requires you to make an e-mail-able version.

Signed-off-by: George Dunlap <george.dunlap@citrix.com>
8 years agoImplement test[-apply|-build]
George Dunlap [Fri, 24 Mar 2017 17:50:01 +0000 (17:50 +0000)]
Implement test[-apply|-build]

Signed-off-by: George Dunlap <george.dunlap@citrix.com>
8 years agoFinish sync-patch, add sync-branch as well
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>
8 years agomain: Add partial implementation of sync-patches command
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>
8 years agorecipe: Have branchName return both branch and baseline branch names
George Dunlap [Fri, 24 Mar 2017 10:54:12 +0000 (10:54 +0000)]
recipe: Have branchName return both branch and baseline branch names

...to make sure we have consistent naming.

Signed-off-by: George Dunlap <george.dunlap@citrix.com>
8 years agoMain: Fake up config and xsa info
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>
8 years agoRecipe: Break down per-tree recipe into prerequisites and patches
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>
8 years agotest: Make separate backport and test frameworks
George Dunlap [Thu, 23 Mar 2017 10:47:53 +0000 (10:47 +0000)]
test: Make separate backport and test frameworks

Signed-off-by: George Dunlap <george.dunlap@citrix.com>
8 years agoRecipe: Make more flexible for both backporting and testing
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>
8 years agoRecipe: Don't clean up temporary branches automatically (for now)
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>
8 years agogit: Implement VerifyRef and AmClean
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>
8 years agoMake XenVersion string-only
George Dunlap [Fri, 17 Mar 2017 10:11:18 +0000 (10:11 +0000)]
Make XenVersion string-only

Hopefully this will make it easier to store in a human-readable
format.

Signed-off-by: George Dunlap <george.dunlap@citrix.com>
8 years agoAllow Recipes to have multiple globs, implement Recipe.Build()
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>
8 years agoGit: Misc functionality and fixes
George Dunlap [Thu, 16 Mar 2017 12:39:31 +0000 (12:39 +0000)]
Git: Misc functionality and fixes

Have Repo.Am() check to make sure that the glob matched at least one
file; if not, throw an error.

Do "git clean -ffdx" after checkout in MakeBranch and Checkout.

Add GetPath to return the full path of a repository.

Signed-off-by: George Dunlap <george.dunlap@citrix.com>
8 years agoRefactor arguments to make "repo" target
George Dunlap [Wed, 1 Mar 2017 17:36:40 +0000 (17:36 +0000)]
Refactor arguments to make "repo" target

Rather than "repoinit" as a single argument, make the first argument
the target (either an xsa or the repo), and separate commands based on
that.

Also fix a bug that causes a range check if there aren't enough
arguments.

Signed-off-by: George Dunlap <george.dunlap@citrix.com>
8 years agoImplement basic repoinit
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>
8 years agoAdd draft infrastructure for different commands
George Dunlap [Fri, 24 Feb 2017 14:32:58 +0000 (14:32 +0000)]
Add draft infrastructure for different commands

Signed-off-by: George Dunlap <george.dunlap@citrix.com>
8 years agoAdd support for all repos, and test different versions.
George Dunlap [Fri, 24 Feb 2017 13:45:44 +0000 (13:45 +0000)]
Add support for all repos, and test different versions.

Also rename the structure to XSAMeta, in preparation for adding other
metadata.

Signed-off-by: George Dunlap <george.dunlap@citrix.com>
8 years agoTeach Recipe to be able to apply a git am
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>
8 years agoAdd metadata and proof-of-concept tag checkout
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>
8 years agoRudimentary functionality
George Dunlap [Thu, 23 Feb 2017 18:49:58 +0000 (18:49 +0000)]
Rudimentary functionality

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