George Dunlap [Wed, 11 Dec 2019 15:55:32 +0000 (15:55 +0000)]
Allow config-specified build sequences
At the moment, the sequence of steps used to to a build test of XSA
recipes is hardcoded to `./configure` followed by `make -j 8`.
Sometimes you may want to run other sequences of commands; for
instance to decrease build times or required dependencies.
Add the concept of a "build sequence" to the config file. This is a
series of commands which will be run.
Add BuildSequences and DefaultBuildSequence to the config file.
Refactor test() to be able to handle either "-buildsequence" or "-bs"
arguments mixed in with the version numbers. If this isn't set, use
the value from the config file (which may be empty).
If the final value is non-empty, use the sequence of commands defined
in the config file (returning an error if it's not present); if it's
empty, use the existing built-in sequences.
Modify `xsatool repo init` to contain a standard set of pre-defined
build sequences.
Document all this in README.md.
While here do a number of other minor clean-ups instigated by `go fmt`
and delete-trailing-whitespace.
Signed-off-by: George Dunlap <george.dunlap@citrix.com>
George Dunlap [Thu, 8 Nov 2018 16:28:15 +0000 (16:28 +0000)]
Allow builds to happen in temporary worktrees
Allow builds to happen in separate worktrees, so that further work can
carry on while the build is happening.
Add TreeWork ("worktree") to be able to have a configurable path to
place the worktrees.
Add a new Worktree type. Add Repo.WorktreeAdd(), which will:
- Create a new worktree of the name `name` in the given path
- Create a new branch for that worktree based on the name
Add Worktree.Delete() which will remove the worktree, and delete its
branch from the main repo.
In Recipe.Build(), if the worktree path is set in the config, make a
new worktree to do the build; otherwise, fall back to creating a
temporary branch. As with the temporary branch, clean up the worktree
only if the build succeeded.
Signed-off-by: George Dunlap <george.dunlap@citrix.com>
George Dunlap [Wed, 7 Nov 2018 17:00:30 +0000 (17:00 +0000)]
recipe: Refactor temporary branch creation
The two paths are identical except for the branch name and the error
message; just use a variable for the branch name and call the branch
creation code once.
Signed-off-by: George Dunlap <george.dunlap@citrix.com>
George Dunlap [Wed, 7 Nov 2018 14:55:24 +0000 (14:55 +0000)]
Pipe build output directly to a file
Open `build.log` and pipe stdout and stderr to it when building,
rather than using CombinedOutput (which will send it to a memory
buffer instead). This will cause output to be written to the file as
it goes along, rather than only at the end.
Signed-off-by: George Dunlap <george.dunalp@citrix.com>
George Dunlap [Fri, 27 Jul 2018 10:16:31 +0000 (11:16 +0100)]
git: Add `-f` flag to all checkouts
All the current instances of 'git checkout' are meant to be
destructive (several have `git clean -ffdx` afterwards). In cases
where a file is generated and untracked in one version of Xen but tracked
in another version of Xen, `git checkout` will fail without the `-f` flag.
Since we're going to be destructive anyway, add `-f` to all `git
checkout` commands.
Signed-off-by: Georg Dunlap <george.dunlap@citrix.com>
George Dunlap [Thu, 26 Jul 2018 15:39:07 +0000 (16:39 +0100)]
global: Fix checking for new versions
The documentation claims that `xsatool global update` will check for
and initialize new versions. But the code only does the check when
initializing a new global.meta.
Fix this by setting `limit` when global.meta already exists to the
most recent non-master version, and adding any version greater than
that version.
Signed-off-by: George Dunlap <george.dunlap@citrix.com>
George Dunlap [Tue, 13 Mar 2018 17:59:51 +0000 (17:59 +0000)]
Fix "backport needed" detection
VersionsFromArgs() and MainBackport() were both using
xsa.RepoHasPatches() for slightly different things neither of them
quite correct.
xsa.RepoHasPatches() was checking to see that 1) a recipe existed, and
2) a "patch branch" existed. At some point these basically became
identical, and so this test stopped behaving as expected.
VersionsFromArgs() wants to know what versions it should use if
nothing (or "all") is specified. So a add new method, "HasRecipe()",
which simply checks to see if a recipe exists (even if it's empty).
MainBackport() wants to know if we need to perform a backport for a
particular version. Add a new method, NeedsBackport() which answers
this question directly. Return true if:
* A recipe exists and it's empty
* MakePatches() wouldn't make any patches given the current tree state
-- that is, xsa/NNN-baseline == xsa/NNN.
Signed-off-by: George Dunlap <george.dunlap@citrix.com>
George Dunlap [Fri, 8 Dec 2017 17:40:32 +0000 (17:40 +0000)]
meta: Avoid redundant XenVersion information in recipe files
In the per-XSA meta file, we used to map recipes from XenVersion to
recipe; and then the recipe itself also contained the XenVersion.
This was loaded off the disk verbatim and not checked.
This presents an opportunity to make a mistake when editing the file
by hand (or with generic JSON-parsing libraries): if they don't match,
you might ask for a recipe for 4.10 but end up with a tree based on
master.
There's no need to save the version number in each recipe in the file.
Exclude the XenVersion struct element from being marshalled, and set
it on load with the version in the map (as we set the xsa
information).
Old metadata formats will still load correctly; `xsatool NNN
canonical` will effectively remove the information.
Signed-off-by: George Dunlap <george.dunlap@citrix.com>
George Dunlap [Fri, 8 Dec 2017 17:03:02 +0000 (17:03 +0000)]
xen: Use staging-VV rather than stable-VV
The logic is the same as using 'staging' rather than 'master': We
ultimately want to make sure that it checks in as-is, without relying
on the push gate to have succeeded.
Update it in XenStableBranch, repo update, and the systemtest.
Signed-off-by: George Dunlap <george.dunlap@citrix.com>
George Dunlap [Fri, 8 Dec 2017 14:58:01 +0000 (14:58 +0000)]
xsa: Add 'canonicalize' command
Canonicalize will simply read the metadata file and write it out
again. This may be useful after editing it by hand or with external
JSON tools, to put it back in "golang canonical" form.
Signed-off-by: George Dunlap <george.dunlap@citrix.com>
George Dunlap [Fri, 8 Dec 2017 12:27:14 +0000 (12:27 +0000)]
xen: Use MaxInt32 rather than MaxInt64 for internal version of 'master'
We currently use MaxInt64 as the "version number" for 'master' internally so that 'master'
always compares as "greater than" all normal Xen versions. Unfortunately,
on 32-bit builds 'int' is only 32 bits, so building results in the following
error:
The 'math' package doesn't contain a MaxInt (which is why it was
MaxInt64 in the first place); but MaxInt32 will be fit for purpose for
both architectures. At such time as Xen's major number exceeds 2
billion, we can deprecate the 32-bit build of this tool.
The other option would have been to use code from this template to
calculate MaxInt at compile time:
George Dunlap [Mon, 20 Nov 2017 11:40:22 +0000 (11:40 +0000)]
xsa: Patch de-duping, first take
First take of patch deduping: Run a separate command which, for each
version of an XSA:
- Makes a branch with the current recipe
- Takes the hash of that tree
- Tries to make a branch with a potential "de-dupped" recipe
- If that works, compare the hash with the previous hash
If the dedupped recipe applies, and the hashes match, change to using
the de-dupped recipe. Otherwise, use the current recipe.
This will need to be reworked somewhat to support automatic de-dupping
during patch creation, but get a working copy in the tree.
Signed-off-by: George Dunlap <george.dunlap@citrix.com>
George Dunlap [Mon, 30 Oct 2017 12:23:29 +0000 (12:23 +0000)]
Fix systemtest after move to use staging for 'master' version
Commit 54c104c switched the default "reference" for XenVersionMaster
to 'staging', but didn't update systemtest with the new expectations.
Do so now by doing the following.
Have the "InitialTreeState" set up both `staging` and `master` to point to
the same place.
Teach Story206Init to expect 'master' to look like 'staging'.
While we're here, update some hard-coded XenVersion("master")
instances to be the constant XenVersionMaster instead.
Signed-off-by: George Dunlap <george.dunlap@citrix.com>
George Dunlap [Mon, 30 Oct 2017 17:34:23 +0000 (17:34 +0000)]
main: Always attempt load the config
Rather than loading most of the time in main() (and failing if it fails),
and then also loading the config in "repo init" (and tolerating its absence),
always attempt to load the config, and only fail if we end up missing bits of
information that we need.
This will set the stage for unifying the configuration and the
command-line options.
Signed-off-by: George Dunlap <george.dunlap@citrix.com>
George Dunlap [Mon, 30 Oct 2017 12:33:25 +0000 (12:33 +0000)]
main: Clean up command demuxer
Minimize changing of variables by setting loadConfig to 'true', and
only disabling it for "repo init", setting loadXSA to true for all
'xsanum' commands, and using 'switch' rather than 'else'.
This also fixes a bug where an unknown 'target' would cause xsatool to
dereference nil.
Signed-off-by: George Dunlap <george.dunlap@citrix.com>
George Dunlap [Fri, 27 Oct 2017 16:10:50 +0000 (17:10 +0100)]
main: Move 'systemtest' command outside of XsaMain
XsaMain() is meant to be called by systemtest; there's no sense in
being able to call systemtest via XsaMain. Moving the test for
'systemtest' into main() allows us to get rid of systemtest
special-casing re argument counts.
Signed-off-by: George Dunlap <george.dunlap@citrix.com>
George Dunlap [Wed, 27 Sep 2017 13:48:54 +0000 (14:48 +0100)]
Use staging rather than master as the default base for `master` commits
The 'master' versions are meant to be applied to staging, and aren't
generally expected to be used directly by downstreams. If there's a
difference between master and staging, having it apply to staging is
more useful.
Signed-off-by: George Dunlap <george.dunlap@citrix.com>
George Dunlap [Mon, 7 Aug 2017 15:57:18 +0000 (16:57 +0100)]
recipe: Fix situation where there's no recipe for a prerequisite
It's not uncommon to "open up" several XSAs in a row, and to begin
work on subsequent ones before the backports to previous ones are
done.
If when making the baseline for a given Xen version for an XSA, one of
the prerequisete XSAs doesn't have a recipe for that Xen version, just
skip making the baseline for that version.
Signed-off-by: George Dunlap <george.dunlap@citrix.com>
George Dunlap [Fri, 23 Jun 2017 16:02:34 +0000 (17:02 +0100)]
systemtest: Always re-run 'repo init'
Always run `repo init`. If `tmp` already exists, delete `tmp/.xsatool`.
Set a limit that ToolConfig.Load won't go up higher than, so that when
starting the test from 'scratch' we don't get "real" configurations
from any higher-level directoiries by accident.
Signed-off-by: George Dunlap <george.dunlap@citrix.com>
George Dunlap [Fri, 5 May 2017 14:33:28 +0000 (15:33 +0100)]
git: Delete stackgit data when deleting or resetting branches
If a developer has modified a branch to be a stackgit branch as part
of development, simply deleting or resetting that branch with git
commands will "work", but will leave leftover state lying around which
may cause problems later.
Before deleting or resetting a branch, check to see if the branch is a
stackgit branch. If so, use `stg branch --delete --force` to get rid of all
the stackgit data.
Signed-off-by: George Dunlap <george.dunlap@citrix.com>
George Dunlap [Wed, 14 Jun 2017 10:06:12 +0000 (11:06 +0100)]
Implement backport
Implement Repo.Rebase() (with full head / base / onto)
Use this to implement Recipe.Backport()
Finally, implement xsatool [nnn] backport:
- Look for the latest xenversion that doens't have a "patch" branch
- Rebase next version from that onto it with 'git rebase'.
Always only do one, so that the caller has a chance to test the build
and look it over before continuing the backport process.
Signed-off-by: George Dunlap <george.dunlap@citrix.com>
George Dunlap [Fri, 16 Jun 2017 10:20:27 +0000 (11:20 +0100)]
XSAMeta: Keep SupportedVersions sorted in reverse order
There are many situations where we want to test things on master first
and then go backwards through supported versions (e.g., building,
looking for backports, &c). Keep the SupportedVersions in this order.
To do this:
- Refactor IsGreaterEqualThen to be usable by both it and IsGreaterThan
- Make a XenVersionSlice type which implements sort.Interface, using the above
- Re-sort XSAMeta.SupportedVersions on insert and load.
Also:
- Have XSAMeta.NewRecipe() add the new SupportedVersions, rather
than having the caller add it manuall.
- Keep XenVersion.PrevVersion() around, even though we're not using
it for now, in case it becomes useful in the future.
Signed-off-by: George Dunlap <george.dunlap@citrix.com>
George Dunlap [Fri, 16 Jun 2017 10:13:40 +0000 (11:13 +0100)]
Build: Use mirror paths for qemu unless there are patches
Cloning from the working tree is running into build problems saying it
can't find the right changeset, even though the changeset is present
in the working tree. For now, use the mirror directory.
This needs to be sorted out properly somehow.
Signed-off-by: George Dunlap <george.dunlap@citrix.com>
George Dunlap [Thu, 8 Jun 2017 16:37:45 +0000 (17:37 +0100)]
Use new branching scheme
New branching scheme:
- $v-stable based on the recorded stable branch at the time the xsa
was created
- $v-baseline; the above, but with 'prerequisites' (outstanding XSAs
not published yet)
- $v: Branch with actual patches, only present when patches exist (or
are being created)
To do this:
- Separate Recipe.Apply() into ApplyBaseline (which only does -stable
and -baseline) and ApplyPatches (which makes the main branch)
- Get rid of IsApplied(), which doesn't do what it says on the tin
- Implement HasPatchBranch, which detect whether the "patch"
branch(es) exist for a given recipe
Then:
- During Init, call only ApplyBaseline for all branches; only call
ApplyPatches for master.
- When calling sync-patches with 'all', have VersionsFromArgs filter
out patches based on HasPatchBranch. (sync-branches and test will still
test all supported branches for 'all'.)
- Add a test for the failure path of sync-branches with a
non-existent branch
While we're here:
- Use fmt.Print instead of fmt.Printf when there are no format tokens
- Add missing '\n' to many status output messages
Signed-off-by: George Dunlap <george.dunlap@citrix.com>
George Dunlap [Fri, 19 May 2017 16:05:44 +0000 (17:05 +0100)]
Change to in-binary test
`go test` apparently has a default 10-minute timeout. This isn't
enough for all the tests in the "system test", and there's no way to
change the default except to manually add a --timeout parameter to "go
test".
Instead pull the test out into a special xsatool command.
Signed-off-by: George Dunlap <george.dunlap@citrix.com>
George Dunlap [Fri, 19 May 2017 14:01:17 +0000 (15:01 +0100)]
main: Implement 'init' command
New method of creating a new xsa: "xsatool NNN init [trees]"
This will:
- For a given set of trees
- And all the currently-supported versions
- Create an XSA that contains all the currently-outstanding XSAs for that tree and set of versions
- And create branches for all of those versions in the correct tree
- And add it to the list of currently-outstanding XSAs
At that point, the user can go into the appropriate tree and create patches.
Signed-off-by: George Dunlap <george.dunlap@citrix.com>
George Dunlap [Wed, 17 May 2017 16:49:02 +0000 (17:49 +0100)]
Recipe: Allow MakePatches to detect and tolerate "empty" trees
In order to move to a world where all supported branches are created
automatically, with prerequisites applied, as "empty" when the XSA is
created, allow Recipe.MakePatches() to detect and tolerate "empty"
versions:
- Have MakePatches() return the number of trees which contained
patches
- Instead of verifying the reference, get the hashes for base and
branch and compare them; simply return 0 if they are the same
- Don't bother copying patches if none are to be created.
Modify xsa.go:sync() to handle this case as well.
Signed-off-by: George Dunlap <george.dunlap@citrix.com>
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>