Skip to content

Commit 54bfe8e

Browse files
committed
Small fixes to snapshot script.
1 parent 5617462 commit 54bfe8e

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

src/etc/snapshot.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
import re, os, sys, hashlib, tarfile, shutil, subprocess, tempfile
22

3-
src_dir = os.getenv("CFG_SRC_DIR")
3+
def scrub(b):
4+
if sys.version_info >= (3,) and type(b) == bytes:
5+
return b.decode('ascii')
6+
else:
7+
return b
8+
9+
src_dir = scrub(os.getenv("CFG_SRC_DIR"))
410
if not src_dir:
511
raise Exception("missing env var CFG_SRC_DIR")
612

@@ -63,11 +69,6 @@ def get_cpu():
6369
def get_platform():
6470
return "%s-%s" % (get_kernel(), get_cpu())
6571

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

7273
def cmd_out(cmdline):
7374
p = subprocess.Popen(cmdline,
@@ -76,7 +77,8 @@ def cmd_out(cmdline):
7677

7778

7879
def local_rev_info(field):
79-
return cmd_out(["git", "log", "-n", "1",
80+
return cmd_out(["git", "--git-dir=" + os.path.join(src_dir, ".git"),
81+
"log", "-n", "1",
8082
"--format=%%%s" % field, "HEAD"])
8183

8284

@@ -110,8 +112,8 @@ def make_snapshot():
110112

111113
tar = tarfile.open(file0, "w:bz2")
112114
for name in snapshot_files[kernel]:
113-
tar.add(os.path.join("stage2", name),
114-
os.path.join("rust-stage0", name))
115+
tar.add(os.path.join("stage2", name),
116+
os.path.join("rust-stage0", name))
115117
tar.close()
116118

117119
h = hash_file(file0)

0 commit comments

Comments
 (0)