File tree 3 files changed +49
-34
lines changed
3 files changed +49
-34
lines changed Original file line number Diff line number Diff line change @@ -32,40 +32,6 @@ def unpack_snapshot(triple, dl_path):
32
32
tar .close ()
33
33
shutil .rmtree (download_unpack_base )
34
34
35
- def determine_curr_snapshot (triple ):
36
- i = 0
37
- platform = get_platform (triple )
38
-
39
- found_file = False
40
- found_snap = False
41
- hsh = None
42
- date = None
43
- rev = None
44
-
45
- f = open (snapshotfile )
46
- for line in f .readlines ():
47
- i += 1
48
- parsed = parse_line (i , line )
49
- if (not parsed ): continue
50
-
51
- if found_snap and parsed ["type" ] == "file" :
52
- if parsed ["platform" ] == platform :
53
- hsh = parsed ["hash" ]
54
- found_file = True
55
- break ;
56
- elif parsed ["type" ] == "snapshot" :
57
- date = parsed ["date" ]
58
- rev = parsed ["rev" ]
59
- found_snap = True
60
-
61
- if not found_snap :
62
- raise Exception ("no snapshot entries in file" )
63
-
64
- if not found_file :
65
- raise Exception ("no snapshot file found for platform %s, rev %s" %
66
- (platform , rev ))
67
-
68
- return full_snapshot_name (date , rev , platform , hsh )
69
35
70
36
# Main
71
37
Original file line number Diff line number Diff line change @@ -194,3 +194,41 @@ def in_tar_name(fn):
194
194
shutil .move (file0 , file1 )
195
195
196
196
return file1
197
+
198
+ def determine_curr_snapshot_info (triple ):
199
+ i = 0
200
+ platform = get_platform (triple )
201
+
202
+ found_file = False
203
+ found_snap = False
204
+ hsh = None
205
+ date = None
206
+ rev = None
207
+
208
+ f = open (snapshotfile )
209
+ for line in f .readlines ():
210
+ i += 1
211
+ parsed = parse_line (i , line )
212
+ if (not parsed ): continue
213
+
214
+ if found_snap and parsed ["type" ] == "file" :
215
+ if parsed ["platform" ] == platform :
216
+ hsh = parsed ["hash" ]
217
+ found_file = True
218
+ break ;
219
+ elif parsed ["type" ] == "snapshot" :
220
+ date = parsed ["date" ]
221
+ rev = parsed ["rev" ]
222
+ found_snap = True
223
+
224
+ if not found_snap :
225
+ raise Exception ("no snapshot entries in file" )
226
+
227
+ if not found_file :
228
+ raise Exception ("no snapshot file found for platform %s, rev %s" %
229
+ (platform , rev ))
230
+
231
+ return (date , rev , platform , hsh )
232
+
233
+ def determine_curr_snapshot (triple ):
234
+ return full_snapshot_name (* determine_curr_snapshot_info (triple ))
Original file line number Diff line number Diff line change 3
3
4
4
import sys , fileinput , subprocess , re
5
5
from licenseck import *
6
+ import snapshot
6
7
7
8
err = 0
8
9
cols = 100
@@ -52,6 +53,16 @@ def do_license_check(name, contents):
52
53
match = re .match (r'^.*//\s*(NOTE.*)$' , line )
53
54
if match :
54
55
report_warn (match .group (1 ))
56
+ match = re .match (r'^.*//\s*SNAP\s+(\w+)' , line )
57
+ if match :
58
+ hsh = match .group (1 )
59
+ a , b , c , phash = snapshot .determine_curr_snapshot_info ()
60
+ if not phash .startswith (hsh ):
61
+ report_err ("Snapshot out of date: " + line )
62
+ else :
63
+ if "SNAP" in line :
64
+ report_warn ("Unmatched SNAP line: " + line )
65
+
55
66
if (line .find ('\t ' ) != - 1 and
56
67
fileinput .filename ().find ("Makefile" ) == - 1 ):
57
68
report_err ("tab character" )
You can’t perform that action at this time.
0 commit comments