Bug 1288567 - Pass topsrcdir into create_context_tar; r?dustin
Relying on global variables like GECKO is a bit dangerous. To facilitate
testing of archive generation in subsequent commits, let's pass an
path into this function.
The argument is currently unused.
MozReview-Commit-ID: Et1UYraflDP
--- a/taskcluster/taskgraph/task/docker_image.py
+++ b/taskcluster/taskgraph/task/docker_image.py
@@ -138,17 +138,17 @@ class DockerImageTask(base.Task):
"""Creates a tar file of a particular context directory.
Returns the SHA-256 hex digest of the created file.
"""
destination = os.path.abspath(destination)
if not os.path.exists(os.path.dirname(destination)):
os.makedirs(os.path.dirname(destination))
- return create_context_tar(context_dir, destination, image_name)
+ return create_context_tar(GECKO, context_dir, destination, image_name)
@classmethod
def from_json(cls, task_dict):
# Generating index_paths for optimization
routes = task_dict['task']['routes']
index_paths = []
for route in routes:
index_path_regex = re.compile(INDEX_REGEX)
--- a/taskcluster/taskgraph/util/docker.py
+++ b/taskcluster/taskgraph/util/docker.py
@@ -55,17 +55,17 @@ def generate_context_hash(image_path):
file_hash = hashlib.sha256()
data = f.read()
file_hash.update(data)
context_hash.update(file_hash.hexdigest() + '\t' + relative_filename + '\n')
return context_hash.hexdigest()
-def create_context_tar(context_dir, out_path, prefix):
+def create_context_tar(topsrcdir, context_dir, out_path, prefix):
"""Create a context tarball.
A directory ``context_dir`` containing a Dockerfile will be assembled into
a gzipped tar file at ``out_path``. Files inside the archive will be
prefixed by directory ``prefix``.
Returns the SHA-256 hex digest of the created archive.
"""