14
14
from snapshot import *
15
15
16
16
def unpack_snapshot (triple , dl_path ):
17
- print ("opening snapshot " + dl_path )
18
- tar = tarfile .open (dl_path )
19
- kernel = get_kernel (triple )
17
+ print ("opening snapshot " + dl_path )
18
+ tar = tarfile .open (dl_path )
19
+ kernel = get_kernel (triple )
20
20
21
- stagep = os .path .join (triple , "stage0" )
21
+ stagep = os .path .join (triple , "stage0" )
22
22
23
- # Remove files from prior unpackings, since snapshot rustc may not
24
- # be able to disambiguate between multiple candidate libraries.
25
- # (Leave dirs in place since extracting step still needs them.)
26
- for root , _ , files in os .walk (stagep ):
27
- for f in files :
28
- print ("removing " + os .path .join (root , f ))
29
- os .unlink (os .path .join (root , f ))
23
+ # Remove files from prior unpackings, since snapshot rustc may not
24
+ # be able to disambiguate between multiple candidate libraries.
25
+ # (Leave dirs in place since extracting step still needs them.)
26
+ for root , _ , files in os .walk (stagep ):
27
+ for f in files :
28
+ print ("removing " + os .path .join (root , f ))
29
+ os .unlink (os .path .join (root , f ))
30
30
31
- for p in tar .getnames ():
32
- name = p .replace ("rust-stage0/" , "" , 1 );
31
+ for p in tar .getnames ():
32
+ name = p .replace ("rust-stage0/" , "" , 1 );
33
33
34
- fp = os .path .join (stagep , name )
35
- print ("extracting " + p )
36
- tar .extract (p , download_unpack_base )
37
- tp = os .path .join (download_unpack_base , p )
38
- if os .path .isdir (tp ) and os .path .exists (fp ):
39
- continue
40
- shutil .move (tp , fp )
41
- tar .close ()
42
- shutil .rmtree (download_unpack_base )
34
+ fp = os .path .join (stagep , name )
35
+ print ("extracting " + p )
36
+ tar .extract (p , download_unpack_base )
37
+ tp = os .path .join (download_unpack_base , p )
38
+ if os .path .isdir (tp ) and os .path .exists (fp ):
39
+ continue
40
+ shutil .move (tp , fp )
41
+ tar .close ()
42
+ shutil .rmtree (download_unpack_base )
43
43
44
44
45
45
# Main
@@ -50,21 +50,21 @@ def unpack_snapshot(triple, dl_path):
50
50
51
51
triple = sys .argv [1 ]
52
52
if len (sys .argv ) == 3 :
53
- dl_path = sys .argv [2 ]
53
+ dl_path = sys .argv [2 ]
54
54
else :
55
- snap = determine_curr_snapshot (triple )
56
- dl = os .path .join (download_dir_base , snap )
57
- url = download_url_base + "/" + snap
58
- print ("determined most recent snapshot: " + snap )
55
+ snap = determine_curr_snapshot (triple )
56
+ dl = os .path .join (download_dir_base , snap )
57
+ url = download_url_base + "/" + snap
58
+ print ("determined most recent snapshot: " + snap )
59
59
60
- if (not os .path .exists (dl )):
61
- get_url_to_file (url , dl )
60
+ if (not os .path .exists (dl )):
61
+ get_url_to_file (url , dl )
62
62
63
- if (snap_filename_hash_part (snap ) == hash_file (dl )):
64
- print ("got download with ok hash" )
65
- else :
66
- raise Exception ("bad hash on download" )
63
+ if (snap_filename_hash_part (snap ) == hash_file (dl )):
64
+ print ("got download with ok hash" )
65
+ else :
66
+ raise Exception ("bad hash on download" )
67
67
68
- dl_path = os .path .join (download_dir_base , snap )
68
+ dl_path = os .path .join (download_dir_base , snap )
69
69
70
70
unpack_snapshot (triple , dl_path )
0 commit comments