Add ability to stage any file from a google storage archive_url.
This CL adds the ability to stage any file from GS following the
the cache/stage model of 'named' artifacts. I implement this by
adding files to the stage rpc.
stage?...&files=sysroot_chromeos-base_chromeos.tar.xz
stages this file if it exists and caches in it static under the
appropiate label defined by ...
file_artifacts and artifacts can be used either way or both
be used.
BUG=chromium:267896
TEST=Ran it with above + unittest.
Change-Id: Ie71b8e9b8027e256bc2181be15ca63f4c58b7193
Reviewed-on: https://gerrit.chromium.org/gerrit/64720
Reviewed-by: Chris Sosa <sosa@chromium.org>
Tested-by: Chris Sosa <sosa@chromium.org>
Commit-Queue: Chris Sosa <sosa@chromium.org>
diff --git a/downloader.py b/downloader.py
index d927181..e4734a2 100755
--- a/downloader.py
+++ b/downloader.py
@@ -92,7 +92,7 @@
os.remove(file_name)
os.rmdir(directory_path)
- def Download(self, artifacts, async=False):
+ def Download(self, artifacts, files, async=False):
"""Downloads and caches the |artifacts|.
Downloads and caches the |artifacts|. Returns once these
@@ -100,9 +100,10 @@
non-specified artifacts in the background following the principle of
spatial locality.
- @params artifacts: A list of artifact names that correspond to artifacts to
- stage.
- @params async: True to return without waiting for download to complete.
+ artifacts: A list of artifact names that correspond to
+ artifacts defined in artifact_info.py to stage.
+ files: A list of filenames to stage from an archive_url.
+ async: If True, return without waiting for download to complete.
"""
common_util.MkDirP(self._build_dir)
@@ -113,8 +114,9 @@
# Create factory to create build_artifacts from artifact names.
build = self.ParseUrl(self._archive_url)[1]
- factory = build_artifact.ArtifactFactory(self._build_dir, self._archive_url,
- artifacts, build)
+ factory = build_artifact.ArtifactFactory(
+ self._build_dir, self._archive_url, artifacts, files,
+ build)
background_artifacts = factory.OptionalArtifacts()
if background_artifacts:
self._DownloadArtifactsInBackground(background_artifacts)
@@ -131,17 +133,19 @@
Downloader._TryRemoveStageDir(self._build_dir)
raise
- def IsStaged(self, artifacts):
+ def IsStaged(self, artifacts, files):
"""Check if all artifacts have been downloaded.
- @param artifacts: A list of artifacts to be checked.
+ artifacts: A list of artifact names that correspond to
+ artifacts defined in artifact_info.py to stage.
+ files: A list of filenames to stage from an archive_url.
@returns: True if all artifacts are staged.
"""
# Create factory to create build_artifacts from artifact names.
build = self.ParseUrl(self._archive_url)[1]
- factory = build_artifact.ArtifactFactory(self._build_dir, self._archive_url,
- artifacts, build)
+ factory = build_artifact.ArtifactFactory(
+ self._build_dir, self._archive_url, artifacts, files, build)
required_artifacts = factory.RequiredArtifacts()
return all([artifact.ArtifactStaged() for artifact in required_artifacts])