Bug 1432563: Fetch rustfmt when repackaging rust. r?rillian draft
authorEmilio Cobos Álvarez <emilio@crisal.io>
Tue, 23 Jan 2018 17:01:16 +0100
changeset 747926 5c0d5c7c0cd0ffb92e42a319f8d802657e1c21cf
parent 747925 34abf97931631c9d4504f25ac0ce7f0e509aa62f
push id97032
push userbmo:emilio@crisal.io
push dateSat, 27 Jan 2018 01:02:51 +0000
reviewersrillian
bugs1432563, 1432153
milestone60.0a1
Bug 1432563: Fetch rustfmt when repackaging rust. r?rillian I tested this on automation and the build went on, though I couldn't test the bindgen output because the build right now is busted on one dependent crate with rust beta, which is the first toolchain that has this package, and will go to release shortly. This should work though! If I need more changes I'll adjust them in bug 1432153. You can test the repackage manually with repack_rust.py --toolchain beta, for example. MozReview-Commit-ID: GI2f6vGVqTe
taskcluster/scripts/misc/repack_rust.py
--- a/taskcluster/scripts/misc/repack_rust.py
+++ b/taskcluster/scripts/misc/repack_rust.py
@@ -226,16 +226,24 @@ def fetch_package(manifest, pkg, host):
 def fetch_std(manifest, targets):
     stds = []
     for target in targets:
         info = fetch_package(manifest, 'rust-std', target)
         stds.append(info)
     return stds
 
 
+def fetch_optional(manifest, pkg, host):
+    try:
+        return fetch_package(manifest, pkg, host)
+    except KeyError:
+        # The package is not available, oh well!
+        return None
+
+
 def tar_for_host(host):
     if 'linux' in host:
         tar_options = 'cJf'
         tar_ext = '.tar.xz'
     else:
         tar_options = 'cjf'
         tar_ext = '.tar.bz2'
     return tar_options, tar_ext
@@ -269,27 +277,30 @@ def repack(host, targets, channel='stabl
         cargo_manifest = fetch_manifest(cargo_channel)
         log('Using manifest for cargo %s as of %s.' %
             (cargo_channel, cargo_manifest['date']))
 
     log('Fetching packages...')
     rustc = fetch_package(manifest, 'rustc', host)
     cargo = fetch_package(cargo_manifest, 'cargo', host)
     stds = fetch_std(manifest, targets)
+    rustfmt = fetch_optional(manifest, 'rustfmt-preview', host)
 
     log('Installing packages...')
     install_dir = 'rustc'
     # Clear any previous install directory.
     try:
         shutil.rmtree(install_dir)
     except OSError as e:
         if e.errno != errno.ENOENT:
             raise
     install(os.path.basename(rustc['url']), install_dir)
     install(os.path.basename(cargo['url']), install_dir)
+    if rustfmt:
+        install(os.path.basename(rustfmt['url']), install_dir)
     for std in stds:
         install(os.path.basename(std['url']), install_dir)
         pass
 
     log('Creating archive...')
     tar_options, tar_ext = tar_for_host(host)
     tar_file = install_dir + tar_ext
     subprocess.check_call(