Add tidy support for snapshots
This let's us specify exactly which snapshot a given note to update after snapshot is for. Closes #2483
This commit is contained in:
parent
cb6451c5af
commit
1535a29f01
@ -32,40 +32,6 @@ def unpack_snapshot(triple, dl_path):
|
||||
tar.close()
|
||||
shutil.rmtree(download_unpack_base)
|
||||
|
||||
def determine_curr_snapshot(triple):
|
||||
i = 0
|
||||
platform = get_platform(triple)
|
||||
|
||||
found_file = False
|
||||
found_snap = False
|
||||
hsh = None
|
||||
date = None
|
||||
rev = None
|
||||
|
||||
f = open(snapshotfile)
|
||||
for line in f.readlines():
|
||||
i += 1
|
||||
parsed = parse_line(i, line)
|
||||
if (not parsed): continue
|
||||
|
||||
if found_snap and parsed["type"] == "file":
|
||||
if parsed["platform"] == platform:
|
||||
hsh = parsed["hash"]
|
||||
found_file = True
|
||||
break;
|
||||
elif parsed["type"] == "snapshot":
|
||||
date = parsed["date"]
|
||||
rev = parsed["rev"]
|
||||
found_snap = True
|
||||
|
||||
if not found_snap:
|
||||
raise Exception("no snapshot entries in file")
|
||||
|
||||
if not found_file:
|
||||
raise Exception("no snapshot file found for platform %s, rev %s" %
|
||||
(platform, rev))
|
||||
|
||||
return full_snapshot_name(date, rev, platform, hsh)
|
||||
|
||||
# Main
|
||||
|
||||
|
@ -194,3 +194,41 @@ def make_snapshot(stage, triple):
|
||||
shutil.move(file0, file1)
|
||||
|
||||
return file1
|
||||
|
||||
def determine_curr_snapshot_info(triple):
|
||||
i = 0
|
||||
platform = get_platform(triple)
|
||||
|
||||
found_file = False
|
||||
found_snap = False
|
||||
hsh = None
|
||||
date = None
|
||||
rev = None
|
||||
|
||||
f = open(snapshotfile)
|
||||
for line in f.readlines():
|
||||
i += 1
|
||||
parsed = parse_line(i, line)
|
||||
if (not parsed): continue
|
||||
|
||||
if found_snap and parsed["type"] == "file":
|
||||
if parsed["platform"] == platform:
|
||||
hsh = parsed["hash"]
|
||||
found_file = True
|
||||
break;
|
||||
elif parsed["type"] == "snapshot":
|
||||
date = parsed["date"]
|
||||
rev = parsed["rev"]
|
||||
found_snap = True
|
||||
|
||||
if not found_snap:
|
||||
raise Exception("no snapshot entries in file")
|
||||
|
||||
if not found_file:
|
||||
raise Exception("no snapshot file found for platform %s, rev %s" %
|
||||
(platform, rev))
|
||||
|
||||
return (date, rev, platform, hsh)
|
||||
|
||||
def determine_curr_snapshot(triple):
|
||||
return full_snapshot_name(*determine_curr_snapshot_info(triple))
|
||||
|
@ -3,6 +3,7 @@
|
||||
|
||||
import sys, fileinput, subprocess, re
|
||||
from licenseck import *
|
||||
import snapshot
|
||||
|
||||
err=0
|
||||
cols=100
|
||||
@ -52,6 +53,16 @@ try:
|
||||
match = re.match(r'^.*//\s*(NOTE.*)$', line)
|
||||
if match:
|
||||
report_warn(match.group(1))
|
||||
match = re.match(r'^.*//\s*SNAP\s+(\w+)', line)
|
||||
if match:
|
||||
hsh = match.group(1)
|
||||
a, b, c, phash = snapshot.determine_curr_snapshot_info()
|
||||
if not phash.startswith(hsh):
|
||||
report_err("Snapshot out of date: " + line)
|
||||
else:
|
||||
if "SNAP" in line:
|
||||
report_warn("Unmatched SNAP line: " + line)
|
||||
|
||||
if (line.find('\t') != -1 and
|
||||
fileinput.filename().find("Makefile") == -1):
|
||||
report_err("tab character")
|
||||
|
Loading…
x
Reference in New Issue
Block a user