Skip to content

Commit

Permalink
Bug 1595368: [firefox-ci] Use consitent logic to determine tooltool u…
Browse files Browse the repository at this point in the history
…rl; r=callek a=task-fix CLOSED TREE

Summary: e15867a663717a5866759bdb1162431f91bcf1eb has an artifact_commands.py patch that does the same thing. Esr68 doesn't have artifact_commands.py; it has the code in mach_commands.py. This patch copies over the change to mach_commands.py

Reviewers: Callek

Tags: #secure-revision

Bug #: 1595368

Differential Revision: https://phabricator.services.mozilla.com/D52586

--HG--
extra : amend_source : 23fbd86f076c5fb598aae7ea907980a25aa9d835
extra : histedit_source : dbce83f6f11ef30063ccc2263ef57425b779f716
  • Loading branch information
escapewindow committed Nov 11, 2019
1 parent 52696eb commit 0fe89bf
Showing 1 changed file with 7 additions and 20 deletions.
27 changes: 7 additions & 20 deletions python/mozbuild/mozbuild/mach_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -1376,8 +1376,6 @@ def artifact_clear_cache(self, tree=None, job=None, verbose=False):
help='Explicit tooltool manifest to process')
@CommandArgument('--authentication-file', metavar='FILE',
help='Use the RelengAPI token found in the given file to authenticate')
@CommandArgument('--tooltool-url', metavar='URL',
help='Use the given url as tooltool server')
@CommandArgument('--no-unpack', action='store_true',
help='Do not unpack any downloaded file')
@CommandArgument('--retry', type=int, default=4,
Expand All @@ -1390,7 +1388,7 @@ def artifact_clear_cache(self, tree=None, job=None, verbose=False):
def artifact_toolchain(self, verbose=False, cache_dir=None,
skip_cache=False, from_build=(),
tooltool_manifest=None, authentication_file=None,
tooltool_url=None, no_unpack=False, retry=None,
no_unpack=False, retry=None,
artifact_manifest=None, files=()):
'''Download, cache and install pre-built toolchains.
'''
Expand All @@ -1400,7 +1398,6 @@ def artifact_toolchain(self, verbose=False, cache_dir=None,
open_manifest,
unpack_file,
)
from requests.adapters import HTTPAdapter
import redo
import requests

Expand All @@ -1424,26 +1421,16 @@ def artifact_toolchain(self, verbose=False, cache_dir=None,
if not cache_dir:
cache_dir = os.path.join(self._mach_context.state_dir, 'toolchains')

tooltool_url = (tooltool_url or
'https://tooltool.mozilla-releng.net').rstrip('/')
tooltool_host = os.environ.get('TOOLTOOL_HOST', 'tooltool.mozilla-releng.net')
taskcluster_proxy_url = os.environ.get('TASKCLUSTER_PROXY_URL')
if taskcluster_proxy_url:
tooltool_url = '{}/{}'.format(taskcluster_proxy_url, tooltool_host)
else:
tooltool_url = 'https://{}'.format(tooltool_host)

cache = ArtifactCache(cache_dir=cache_dir, log=self.log,
skip_cache=skip_cache)

if authentication_file:
with open(authentication_file, 'rb') as f:
token = f.read().strip()

class TooltoolAuthenticator(HTTPAdapter):
def send(self, request, *args, **kwargs):
request.headers['Authorization'] = \
'Bearer {}'.format(token)
return super(TooltoolAuthenticator, self).send(
request, *args, **kwargs)

cache._download_manager.session.mount(
tooltool_url, TooltoolAuthenticator())

class DownloadRecord(FileRecord):
def __init__(self, url, *args, **kwargs):
super(DownloadRecord, self).__init__(*args, **kwargs)
Expand Down

0 comments on commit 0fe89bf

Please sign in to comment.