@@ -123,13 +123,52 @@ def check_config(data, dirs):
123
123
return ret
124
124
125
125
def list_git ():
126
+ if not os .path .exists (".git" ):
127
+ sys .stderr .write ("Skipping git ls-files check, no .git dir" )
128
+ return None
129
+
126
130
git = os .popen ("git ls-files" )
127
131
for file in git :
128
132
yield file .rstrip ("\n " )
129
133
130
134
if git .close ():
131
135
sys .stderr .write ("WHENCE: skipped contents validation, git file listing failed\n " )
132
136
137
+ def check_dir (subdir ):
138
+ pattern_shell = re .compile ("^fastrpc_shell(_unsigned)?_[0-9]$" )
139
+ # XXX: do we need to be that precise for map files?
140
+ pattern_map1 = re .compile ("^map_SHARED_LIBS_[a-z0-9]*\\ .(a|c|gp)dsp[01]?\\ .prodQ\\ .txt$" )
141
+ pattern_map2 = re .compile ("^map_AVS_SHARED_LIBS_[a-z0-9]*\\ .adsp\\ .prodQ\\ .txt$" )
142
+ pattern_map3 = re .compile ("^map_SLPI_SHARED_LIBS_[a-z0-9]*\\ .slpi\\ .prodQ\\ .txt$" )
143
+ pattern_map4 = re .compile ("^map_SSC_SLPI_USER_[a-z0-9]*\\ .slpi\\ .prodQ\\ .txt$" )
144
+ pattern_map5 = re .compile ("^map_SENSOR_IMG_[a-z0-9]*\\ .adsp\\ .prodQ_SHARED_LIBS\\ .txt$" )
145
+ pattern_map6 = re .compile ("^map_(AVS_)?SHARED_LIBS_AAAAAAAAQ\\ .txt$" )
146
+ pattern_map7 = re .compile ("^map_SSC_SLPI_USER_AAAAAAAAQ\\ .txt$" )
147
+ pattern_library = re .compile ("^[-_+0-9a-zA-Z]*\\ .so(\\ .[0-9]*)?$" )
148
+
149
+ okay = True
150
+
151
+ for file in os .listdir (subdir ):
152
+ fullname = os .path .join (subdir , file )
153
+
154
+ if not os .path .isfile (fullname ):
155
+ sys .stderr .write ("WHENCE: not a file %s\n " % fullname )
156
+ okay = False
157
+
158
+ if not pattern_shell .match (file ) and \
159
+ not pattern_map1 .match (file ) and \
160
+ not pattern_map2 .match (file ) and \
161
+ not pattern_map3 .match (file ) and \
162
+ not pattern_map4 .match (file ) and \
163
+ not pattern_map5 .match (file ) and \
164
+ not pattern_map6 .match (file ) and \
165
+ not pattern_map7 .match (file ) and \
166
+ not pattern_library .match (file ):
167
+ sys .stderr .write ("WHENCE: unknown file type %s\n " % fullname )
168
+ okay = False
169
+
170
+ return okay
171
+
133
172
def main ():
134
173
okay = True
135
174
dirs = {}
@@ -173,6 +212,11 @@ def main():
173
212
sys .stderr .write ("%s\n " % e )
174
213
okay = False
175
214
215
+ for entry in dirs .keys ():
216
+ if not check_dir (entry ):
217
+ sys .stderr .write ("WHENCE: subdir %s failed the checks\n " % entry )
218
+ okay = False
219
+
176
220
return 0 if okay else 1
177
221
178
222
if __name__ == "__main__" :
0 commit comments