tarball = 'cargo-nightly-' + triple + '.tar.gz'
url = 'https://static.rust-lang.org/cargo-dist/%s/%s' % \
- (date.strip(), tarball)
+ (date.strip(), tarball)
dl_path = "target/dl/" + tarball
dst = "target/snapshot"
import sys
import tarfile
+
def get(url, path, quiet=False):
# see http://serverfault.com/questions/301128/how-to-download
if sys.platform == 'win32':
run(["PowerShell.exe", "/nologo", "-Command",
"(New-Object System.Net.WebClient).DownloadFile('" + url +
- "', '" + path + "')"], quiet=quiet)
+ "', '" + path + "')"], quiet=quiet)
else:
run(["curl", "-o", path, url], quiet=quiet)
+
def unpack(tarball, dst, quiet=False):
if quiet:
print("extracting " + tarball)
shutil.move(tp, fp)
shutil.rmtree(os.path.join(dst, fname))
+
def run(args, quiet=False):
if not quiet:
print("running: " + ' '.join(args))
# Use Popen here instead of call() as it apparently allows powershell on
# Windows to not lock up waiting for input presumably.
ret = subprocess.Popen(args,
- stdin = subprocess.PIPE,
- stdout = subprocess.PIPE,
- stderr = subprocess.PIPE)
+ stdin=subprocess.PIPE,
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE)
out, err = ret.communicate()
code = ret.wait()
if code != 0:
rust_date = open('src/rustversion.txt').read().strip()
url = 'https://static.rust-lang.org/dist/' + rust_date
+
def install_via_tarballs():
if os.path.isdir("rustc-install"):
shutil.rmtree("rustc-install")
download.unpack(host_fname, "rustc-install", quiet=True)
os.remove(host_fname)
- if extra != None:
+ if extra is not None:
extra_fname = 'rustc-nightly-' + extra + '.tar.gz'
print("adding target libs for " + extra)
download.get(url + '/' + extra_fname, extra_fname)
# When updating snapshots, run this file and pipe it into `src/snapshots.txt`
import os
-import subprocess
import sys
import hashlib
import download
tarball = 'cargo-nightly-' + triple + '.tar.gz'
url = 'https://static.rust-lang.org/cargo-dist/' + date + '/' + tarball
dl_path = "target/dl/" + tarball
- download.get(url, dl_path, quiet = True)
+ download.get(url, dl_path, quiet=True)
h = hashlib.sha1(open(dl_path, 'rb').read()).hexdigest()
print(' ' + platform + ' ' + h)