Skip to content
This repository was archived by the owner on Nov 21, 2018. It is now read-only.

Commit 92a5919

Browse files
committed
Update how Cargo nightlies are downloaded
1 parent 970d323 commit 92a5919

File tree

1 file changed

+43
-37
lines changed

1 file changed

+43
-37
lines changed

master/build-rust-manifest.py

Lines changed: 43 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@
4242
# Temporary work directory
4343
temp_dir = sys.argv[6]
4444

45+
cargo_addy = "https://s3.amazonaws.com/rust-lang-ci/cargo-builds"
46+
4547
print "channel: " + channel
4648
print "today: " + today
4749
print "s3_addy: " + s3_addy
@@ -130,9 +132,6 @@
130132
"i686-pc-windows-gnu",
131133
])
132134

133-
# This file defines which cargos go with which rustc on beta/stable
134-
cargo_revs = "https://raw.githubusercontent.com/rust-lang/rust-packaging/master/cargo-revs.txt"
135-
136135
if os.path.isdir(temp_dir):
137136
shutil.rmtree(temp_dir)
138137
os.mkdir(temp_dir)
@@ -154,28 +153,29 @@ def main():
154153
# on s3.
155154
rustc_short_version = parse_short_version(rustc_version)
156155

157-
cargo_date = None
158156
if channel == "nightly":
159-
# Nightly rust is paired with nightly cargo
160-
cargo_date = most_recent_build_date("nightly", "cargo")
157+
cargo_branch = 'master'
161158
else:
162-
# Beta / stable rust is paired with a cargo specified
163-
# by rust-packaging
164-
cargo_date = cargo_date_from_packaging(rustc_short_version)
159+
cargo_branch = 'rust-' + rustc_short_version
160+
if channel == "nightly":
161+
cargo_branch = 'master'
162+
cargo_rev_url = "https://api.github.com/repos/rust-lang/cargo/commits/" + cargo_branch
163+
request = urllib2.Request(cargo_rev_url, headers={"Accept" : "Accept: application/vnd.github.3.sha"})
164+
cargo_rev = urllib2.urlopen(request).read()
165165

166-
cargo_version = version_from_channel("nightly", "cargo", cargo_date)
166+
cargo_version = version_from_channel(channel, "cargo", cargo_rev)
167167
cargo_short_version = parse_short_version(cargo_version)
168168

169169
print "rustc date: " + rustc_date
170170
print "rustc version: " + rustc_version
171171
print "rustc short version: " + rustc_short_version
172-
print "cargo date: " + cargo_date
172+
print "cargo rev: " + cargo_rev
173173
print "cargo version: " + cargo_version
174174
print "cargo short version: " + cargo_short_version
175175

176176
# Validate the component artifacts and generate the manifest
177177
generate_manifest(rustc_date, rustc_version, rustc_short_version,
178-
cargo_date, cargo_version, cargo_short_version)
178+
cargo_rev, cargo_version, cargo_short_version)
179179

180180
# Use the channel-$component-$channel-date.txt file to get the archive
181181
# date for cargo or rustc. These files are generated by finish_dist
@@ -195,25 +195,31 @@ def most_recent_build_date(channel, component):
195195
def version_from_channel(channel, component, date):
196196
dist = dist_folder(component)
197197

198-
# Load the manifest
199-
manifest_url = s3_addy + "/" + dist + "/" + date + "/channel-" + component + "-" + channel
200-
print "downloading " + manifest_url
201-
response = urllib2.urlopen(manifest_url)
202-
if response.getcode() != 200:
203-
raise Exception("couldn't download " + manifest_url)
204-
manifest = response.read().strip();
198+
if component == "cargo":
199+
target = "x86_64-unknown-linux-gnu"
200+
installer_name = "cargo-nightly-" + target + ".tar.gz"
201+
installer_url = cargo_addy + "/" + date + "/" + installer_name
202+
else:
203+
# Load the manifest
204+
manifest_url = s3_addy + "/" + dist + "/" + date + "/channel-" + component + "-" + channel
205+
print "downloading " + manifest_url
206+
response = urllib2.urlopen(manifest_url)
207+
if response.getcode() != 200:
208+
raise Exception("couldn't download " + manifest_url)
209+
manifest = response.read().strip();
210+
211+
# Find the installer name
212+
installer_name = None
213+
for line in manifest.split("\n"):
214+
if line.startswith(component) and line.endswith(".tar.gz"):
215+
installer_name = line
205216

206-
# Find the installer name
207-
installer_name = None
208-
for line in manifest.split("\n"):
209-
if line.startswith(component) and line.endswith(".tar.gz"):
210-
installer_name = line
217+
if installer_name == None:
218+
raise Exception("couldn't find installer in manifest for " + component)
211219

212-
if installer_name == None:
213-
raise Exception("couldn't find installer in manifest for " + component)
220+
installer_url = s3_addy + "/" + dist + "/" + date + "/" + installer_name
214221

215222
# Download the installer
216-
installer_url = s3_addy + "/" + dist + "/" + date + "/" + installer_name
217223
print "downloading " + installer_url
218224
response = urllib2.urlopen(installer_url)
219225
if response.getcode() != 200:
@@ -249,7 +255,7 @@ def dist_folder(component):
249255
return "cargo-dist"
250256
return "dist"
251257

252-
def cargo_date_from_packaging(rustc_version):
258+
def cargo_rev_from_packaging(rustc_version):
253259
print "downloading " + cargo_revs
254260
response = urllib2.urlopen(cargo_revs)
255261
if response.getcode() != 200:
@@ -275,10 +281,10 @@ def parse_short_version(version):
275281
return v
276282

277283
def generate_manifest(rustc_date, rustc_version, rustc_short_version,
278-
cargo_date, cargo_version, cargo_short_version):
284+
cargo_rev, cargo_version, cargo_short_version):
279285

280286
m = build_manifest(rustc_date, rustc_version, rustc_short_version,
281-
cargo_date, cargo_version, cargo_short_version)
287+
cargo_rev, cargo_version, cargo_short_version)
282288

283289
manifest_name = "channel-rust-" + channel + ".toml"
284290
manifest_file = rust_package_dir + "/" + manifest_name
@@ -293,7 +299,7 @@ def generate_manifest(rustc_date, rustc_version, rustc_short_version,
293299
print_summary(m)
294300

295301
def build_manifest(rustc_date, rustc_version, rustc_short_version,
296-
cargo_date, cargo_version, cargo_short_version):
302+
cargo_rev, cargo_version, cargo_short_version):
297303

298304
packages = {}
299305

@@ -308,7 +314,7 @@ def build_manifest(rustc_date, rustc_version, rustc_short_version,
308314
doc_pkg = build_package_def_from_archive("rust-docs", "dist", rustc_date,
309315
rustc_version, rustc_short_version,
310316
host_list)
311-
cargo_pkg = build_package_def_from_archive("cargo", "cargo-dist", cargo_date,
317+
cargo_pkg = build_package_def_from_archive("cargo", "cargo-dist", cargo_rev,
312318
cargo_version, cargo_short_version,
313319
host_list)
314320
mingw_pkg = build_package_def_from_archive("rust-mingw", "dist", rustc_date,
@@ -437,17 +443,17 @@ def build_package_def_from_archive(name, dist_dir, archive_date,
437443
def live_package_url(name, dist_dir, date, version, target):
438444
# Cargo builds are always named 'nightly'
439445
maybe_channel = channel
440-
if name == "cargo":
441-
maybe_channel = "nightly"
442446

443-
if name == "rust-src":
447+
if name == "cargo":
448+
url1 = cargo_addy + "/" + date + "/cargo-nightly-" + target + ".tar.gz"
449+
elif name == "rust-src":
444450
# The build system treats source packages as a separate target for `rustc`
445451
# but for rustup we'd like to treat them as a completely separate package.
446452
url1 = s3_addy + "/" + dist_dir + "/" + date + "/rust-src-" + version + ".tar.gz"
447-
url2 = s3_addy + "/" + dist_dir + "/" + date + "/rust-src-" + maybe_channel + ".tar.gz"
453+
url2 = s3_addy + "/" + dist_dir + "/" + date + "/rust-src-" + channel + ".tar.gz"
448454
else:
449455
url1 = s3_addy + "/" + dist_dir + "/" + date + "/" + name + "-" + version + "-" + target + ".tar.gz"
450-
url2 = s3_addy + "/" + dist_dir + "/" + date + "/" + name + "-" + maybe_channel + "-" + target + ".tar.gz"
456+
url2 = s3_addy + "/" + dist_dir + "/" + date + "/" + name + "-" + channel + "-" + target + ".tar.gz"
451457

452458
print "checking " + url1
453459
request = urllib2.Request(url1)

0 commit comments

Comments
 (0)