Skip to content

Commit be99146

Browse files
committed
allow snapshot to be specified in make command line
1 parent 8e4c5d2 commit be99146

File tree

2 files changed

+24
-14
lines changed

2 files changed

+24
-14
lines changed

mk/stage0.mk

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ $(HBIN0_H_$(CFG_HOST_TRIPLE))/rustc$(X): \
44
$(S)src/snapshots.txt \
55
$(S)src/etc/get-snapshot.py $(MKFILE_DEPS)
66
@$(call E, fetch: $@)
7-
$(Q)$(S)src/etc/get-snapshot.py $(CFG_HOST_TRIPLE)
7+
# Note: the variable "SNAPSHOT_FILE" is generally not set, and so
8+
# we generally only pass one argument to this script.
9+
$(Q)$(S)src/etc/get-snapshot.py $(CFG_HOST_TRIPLE) $(SNAPSHOT_FILE)
810
$(Q)touch $@
911

1012
# Host libs will be extracted by the above rule

src/etc/get-snapshot.py

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
import os, tarfile, hashlib, re, shutil, sys
44
from snapshot import *
55

6-
def unpack_snapshot(triple, snap):
7-
dl_path = os.path.join(download_dir_base, snap)
6+
def unpack_snapshot(triple, dl_path):
87
print("opening snapshot " + dl_path)
98
tar = tarfile.open(dl_path)
109
kernel = get_kernel(triple)
@@ -60,18 +59,27 @@ def determine_curr_snapshot(triple):
6059

6160
# Main
6261

62+
# this gets called with one or two arguments:
63+
# The first is the O/S triple.
64+
# The second is an optional path to the snapshot to use.
65+
6366
triple = sys.argv[1]
64-
snap = determine_curr_snapshot(triple)
65-
dl = os.path.join(download_dir_base, snap)
66-
url = download_url_base + "/" + snap
67-
print("determined most recent snapshot: " + snap)
67+
if len(sys.argv) == 3:
68+
dl_path = sys.argv[2]
69+
else:
70+
snap = determine_curr_snapshot(triple)
71+
dl = os.path.join(download_dir_base, snap)
72+
url = download_url_base + "/" + snap
73+
print("determined most recent snapshot: " + snap)
6874

69-
if (not os.path.exists(dl)):
70-
get_url_to_file(url, dl)
75+
if (not os.path.exists(dl)):
76+
get_url_to_file(url, dl)
7177

72-
if (snap_filename_hash_part(snap) == hash_file(dl)):
73-
print("got download with ok hash")
74-
else:
75-
raise Exception("bad hash on download")
78+
if (snap_filename_hash_part(snap) == hash_file(dl)):
79+
print("got download with ok hash")
80+
else:
81+
raise Exception("bad hash on download")
82+
83+
dl_path = os.path.join(download_dir_base, snap)
7684

77-
unpack_snapshot(triple, snap)
85+
unpack_snapshot(triple, dl_path)

0 commit comments

Comments
 (0)