Skip to content

Commit ff6e58f

Browse files
committed
---
yaml --- r: 2319 b: refs/heads/master c: d987b49 h: refs/heads/master i: 2317: ffa95d7 2315: db9f77c 2311: 0083466 2303: 75ae5b4 v: v3
1 parent ac02b43 commit ff6e58f

File tree

6 files changed

+40
-38
lines changed

6 files changed

+40
-38
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: ed40c85af5c6eec82746696d3ce2d0e7ae22c1d4
2+
refs/heads/master: d987b49a4bd658d59501b7c4d4ccba3083093037

trunk/Makefile.in

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,6 @@ GENERATED :=
108108
%:: s.%
109109
%:: SCCS/s.%
110110

111-
112111
######################################################################
113112
# Standard library variables
114113
######################################################################
@@ -135,6 +134,13 @@ SREQ1 := stage1/rustc$(X) $(LREQ) stage2/glue.o stage2/$(CFG_STDLIB)
135134
SREQ2 := stage2/rustc$(X) $(LREQ) stage3/glue.o stage3/$(CFG_STDLIB)
136135

137136

137+
######################################################################
138+
# Exports for sub-utilities
139+
######################################################################
140+
141+
export CFG_SRC_DIR
142+
143+
138144
######################################################################
139145
# Single-target rules
140146
######################################################################
@@ -179,5 +185,6 @@ include $(CFG_SRC_DIR)/mk/rustllvm.mk
179185
include $(CFG_SRC_DIR)/mk/docs.mk
180186
include $(CFG_SRC_DIR)/mk/tests.mk
181187
include $(CFG_SRC_DIR)/mk/dist.mk
188+
include $(CFG_SRC_DIR)/mk/snap.mk
182189
include $(CFG_SRC_DIR)/mk/clean.mk
183190
include $(CFG_SRC_DIR)/mk/autodep.mk

trunk/src/etc/get-snapshot.py

Lines changed: 11 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -9,34 +9,15 @@ def snap_filename_hash_part(snap):
99
raise Exception("unable to find hash in filename: " + snap)
1010
return match.group(1)
1111

12-
def get_snapshot_and_check_hash(snap):
13-
14-
hsh = snap_filename_hash_part(snap)
15-
16-
h = hashlib.sha1()
17-
url = download_url_base + "/" + snap
18-
print "downloading " + url
19-
u = urllib2.urlopen(url)
20-
print "checking hash on download"
21-
data = u.read()
22-
h.update(data)
23-
if h.hexdigest() != hsh:
24-
raise Exception("hash check failed on " + snap)
25-
26-
print "hash ok"
27-
with open(os.path.join(download_dir_base, snap), "w+b") as f:
28-
f.write(data)
29-
return True
30-
3112
def unpack_snapshot(snap):
3213
dl_path = os.path.join(download_dir_base, snap)
33-
print "opening snapshot " + dl_path
14+
print("opening snapshot " + dl_path)
3415
tar = tarfile.open(dl_path)
3516
kernel = get_kernel()
3617
for name in snapshot_files[kernel]:
3718
p = os.path.join("rust-stage0", name)
3819
fp = os.path.join("stage0", name)
39-
print "extracting " + fp
20+
print("extracting " + fp)
4021
tar.extract(p, download_unpack_base)
4122
tp = os.path.join(download_unpack_base, p)
4223
shutil.move(tp, fp)
@@ -80,16 +61,16 @@ def determine_last_snapshot_for_platform():
8061
# Main
8162

8263
snap = determine_last_snapshot_for_platform()
83-
print "determined most recent snapshot: " + snap
8464
dl = os.path.join(download_dir_base, snap)
85-
if (os.path.exists(dl)):
86-
if (snap_filename_hash_part(snap) == hash_file(dl)):
87-
print "found existing download with ok hash"
88-
else:
89-
print "bad hash on existing download, re-fetching"
90-
get_snapshot_and_check_hash(snap)
65+
url = download_url_base + "/" + snap
66+
print("determined most recent snapshot: " + snap)
67+
68+
if (not os.path.exists(dl)):
69+
get_url_to_file(url, dl)
70+
71+
if (snap_filename_hash_part(snap) == hash_file(dl)):
72+
print("got download with ok hash")
9173
else:
92-
print "no cached download, fetching"
93-
get_snapshot_and_check_hash(snap)
74+
raise Exception("bad hash on download")
9475

9576
unpack_snapshot(snap)

trunk/src/etc/make-snapshot.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@
2121

2222
shutil.move(file0, file1)
2323

24-
print file1
24+
print(file1)

trunk/src/etc/snapshot.py

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1-
import re, os, sys, hashlib, tarfile, shutil, subprocess, urllib2, tempfile
1+
import re, os, sys, hashlib, tarfile, shutil, subprocess, tempfile
22

3-
snapshotfile = "snapshots.txt"
3+
src_dir = os.getenv("CFG_SRC_DIR")
4+
if not src_dir:
5+
raise Exception("missing env var CFG_SRC_DIR")
6+
7+
snapshotfile = os.path.join(src_dir, "snapshots.txt")
48
download_url_base = "http://dl.rust-lang.org/stage0-snapshots"
59
download_dir_base = "dl"
610
download_unpack_base = os.path.join(download_dir_base, "unpack")
@@ -59,11 +63,16 @@ def get_cpu():
5963
def get_platform():
6064
return "%s-%s" % (get_kernel(), get_cpu())
6165

66+
def scrub(b):
67+
if sys.version_info >= (3,) and type(b) == bytes:
68+
return b.decode('ascii')
69+
else:
70+
return b
6271

6372
def cmd_out(cmdline):
6473
p = subprocess.Popen(cmdline,
6574
stdout=subprocess.PIPE)
66-
return p.communicate()[0].strip()
75+
return scrub(p.communicate()[0].strip())
6776

6877

6978
def local_rev_info(field):
@@ -82,8 +91,10 @@ def local_rev_short_sha():
8291
def local_rev_committer_date():
8392
return local_rev_info("ci")
8493

94+
def get_url_to_file(u,f):
95+
subprocess.check_call(["curl", "-o", f, u])
8596

8697
def hash_file(x):
8798
h = hashlib.sha1()
88-
h.update(open(x).read())
89-
return h.hexdigest()
99+
h.update(open(x, "rb").read())
100+
return scrub(h.hexdigest())

trunk/src/snapshots.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
S 2011-05-02 ed40c85
2+
winnt-i386 e69c11fbc62639ac3a3eef7ea36c9ad77209e2b1
3+
14
S 2011-04-29 7b95b5c
25
linux-i386 f0e166816ce34adc9f7202bd3cfbd80623505f28
36
macos-i386 abf2ee279da63676ca17c9dc9e54d04d8f752b00

0 commit comments

Comments
 (0)