summaryrefslogtreecommitdiff
path: root/cbuildbot/repository.py
diff options
context:
space:
mode:
authorDon Garrett <dgarrett@google.com>2015-03-26 15:45:57 -0700
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2015-03-31 23:00:30 +0000
commit72fb8d4630a3f670dadbbf8ee2e684dd9c39e90b (patch)
tree68342c22fe11d36c76d29b9e2fabc404a3968bf4 /cbuildbot/repository.py
parent95603c8e4d4474f96d6e40bdd7ec3e8dcbb97cba (diff)
downloadchromite-72fb8d4630a3f670dadbbf8ee2e684dd9c39e90b.tar.gz
repository: Add PrepManifestForRepo.
This is prep work which makes it easier to initialize a repo from a local manifest file. Nobody is using it... yet. BUG=brillo:630 TEST=lint + unitests. Change-Id: Ifbdfd9f19186f9ba973e04de1829ababb8b7e0f6 Reviewed-on: https://chromium-review.googlesource.com/262727 Reviewed-by: Don Garrett <dgarrett@chromium.org> Tested-by: Don Garrett <dgarrett@chromium.org> Commit-Queue: Don Garrett <dgarrett@chromium.org>
Diffstat (limited to 'cbuildbot/repository.py')
-rw-r--r--cbuildbot/repository.py30
1 files changed, 30 insertions, 0 deletions
diff --git a/cbuildbot/repository.py b/cbuildbot/repository.py
index 217a066a6..2104c69d0 100644
--- a/cbuildbot/repository.py
+++ b/cbuildbot/repository.py
@@ -132,6 +132,36 @@ def ClearBuildRoot(buildroot, preserve_paths=()):
CreateTrybotMarker(buildroot)
+def PrepManifestForRepo(git_repo, manifest):
+ """Use this to store a local manifest in a git repo suitable for repo.
+
+ The repo tool can only fetch manifests from git repositories. So, to use
+ a local manifest file as the basis for a checkout, it must be checked into
+ a local git repository.
+
+ Common Usage:
+ manifest = CreateOrFetchWondrousManifest()
+ with osutils.TempDir() as manifest_git_dir:
+ PrepManifestForRepo(manifest_git_dir, manifest)
+ repo = RepoRepository(manifest_git_dir, repo_dir)
+ repo.Sync()
+
+ Args:
+ git_repo: Path at which to create the git repository (directory created, if
+ needed). If a tempdir, then cleanup is owned by the caller.
+ manifest: Path to existing manifest file to copy into the new git
+ repository.
+ """
+ git.Init(git_repo)
+
+ new_manifest = os.path.join(git_repo, constants.DEFAULT_MANIFEST)
+
+ shutil.copyfile(manifest, new_manifest)
+ git.AddPath(new_manifest)
+ message = 'Local repository holding: %s' % manifest
+ git.Commit(git_repo, message)
+
+
class RepoRepository(object):
"""A Class that encapsulates a repo repository."""
# Use our own repo, in case android.kernel.org (the default location) is down.