Bug 1430984 - Drive-by: Use the worker command as base for the index hash for debian package tasks. r?dustin
Not all changes to debian_packages.py lead to actual changes to the
corresponding tasks. And since the tasks are pretty much self-contained,
we can consider that variations of them will be entirely represented in
the command used for the task. The only exception is the patch content
when there is an associated patch.
--- a/taskcluster/taskgraph/transforms/job/debian_package.py
+++ b/taskcluster/taskgraph/transforms/job/debian_package.py
@@ -11,17 +11,17 @@ import os
import re
from taskgraph.util.schema import Schema
from voluptuous import Any, Optional, Required
from taskgraph.transforms.job import run_job_using
from taskgraph.transforms.job.common import add_public_artifacts
-from taskgraph.util.hash import hash_paths
+from taskgraph.util.hash import hash_path
from taskgraph import GECKO
from taskgraph.util.cached_tasks import add_optimization
DSC_PACKAGE_RE = re.compile('.*(?=_)')
SOURCE_PACKAGE_RE = re.compile('.*(?=[-_]\d)')
source_definition = {
Required('url'): basestring,
@@ -82,25 +82,25 @@ def docker_worker_debian_package(config,
src_url = src['url']
src_file = os.path.basename(src_url)
src_sha256 = src['sha256']
package = package_re.match(src_file).group(0)
unpack = unpack.format(src_file=src_file, package=package)
adjust = ''
if 'patch' in run:
- # We can't depend on docker images, so we don't have robustcheckout
+ # We can't depend on docker images, so we don't have robustcheckout or
# or run-task to get a checkout. So for this one file we'd need
# from a checkout, download it.
- adjust += ('curl -sL {head_repo}/raw-file/{head_rev}'
- '/build/debian-packages/{patch} | patch -p1 && ').format(
+ env['PATCH_URL'] = '{head_repo}/raw-file/{head_rev}/build/debian-packages/{patch}'.format(
head_repo=config.params['head_repository'],
head_rev=config.params['head_rev'],
patch=run['patch'],
)
+ adjust += 'curl -sL $PATCH_URL | patch -p1 && '
if 'pre-build-command' in run:
adjust += run['pre-build-command'] + ' && '
if 'tarball' in run:
adjust += 'mv ../{src_file} ../{package}_{ver}.orig.tar.gz && '.format(
src_file=src_file,
package=package,
ver='$(dpkg-parsechangelog | awk \'$1=="Version:"{print $2}\' | cut -f 1 -d -)',
)
@@ -158,21 +158,15 @@ def docker_worker_debian_package(config,
src_file=src_file,
src_sha256=src_sha256,
unpack=unpack,
adjust=adjust,
artifacts='/tmp/artifacts',
)
]
- files = [
- # This file
- 'taskcluster/taskgraph/transforms/job/debian_package.py',
- ]
+ # Use the command generated above as the base for the index hash.
+ # We rely on it not varying depending on the head_repository or head_rev.
+ data = list(worker['command'])
if 'patch' in run:
- files.append('build/debian-packages/{}'.format(run['patch']))
- data = [hash_paths(GECKO, files)]
- for k in ('snapshot', 'dist', 'pre-build-command'):
- if k in run:
- data.append(run[k])
- data.append(src['sha256'])
+ data.append(hash_path(os.path.join(GECKO, 'build', 'debian-packages', run['patch'])))
add_optimization(config, taskdesc, cache_type='packages.v1',
cache_name=name, digest_data=data)