97 os.unlink(file) |
97 os.unlink(file) |
98 |
98 |
99 |
99 |
100 def getzippedDB(location): |
100 def getzippedDB(location): |
101 db = dict() |
101 db = dict() |
102 #This is really crude, but will do for now |
102 md5zip = os.path.join(location,'build_md5.zip') |
103 # temp = tempfile.NamedTemporaryFile() |
103 print md5zip |
104 # print temp.name |
104 temp_dir = tempfile.mkdtemp() |
105 # Date Time Attr Size Compressed Name |
105 print temp_dir |
106 #------------------- ----- ------------ ------------ ------------------------ |
106 if(os.path.exists(md5zip)): |
107 #2010-03-10 01:02:30 D.... 0 0 epoc32 |
107 files = set(); |
108 #2010-03-10 01:02:30 D.... 0 0 epoc32\relinfo |
108 files.add('*') |
109 #2010-03-10 00:49:12 ..... 2327835 575578 epoc32\relinfo\epoc32_data.md5 |
109 extractfromzip(files,md5zip,temp_dir) |
110 reattribs = re.compile('(\d+-\d+-\d+\s\d+:\d+:\d+)\s+\..+\s+(\d+)\s+\d*\s*(\S.+)') |
110 globsearch = os.path.join(temp_dir, os.path.join(patch_path_internal(),'*.md5')) |
111 fixpath = re.compile('\\\\') |
111 print globsearch |
112 |
112 hashes = glob.glob(globsearch) |
113 tmpfilename = os.tmpnam( ) |
113 for file in hashes: |
114 print tmpfilename |
114 # print 'Reading: %s\n' % file |
115 |
115 gethashes(db, file, True) |
116 # exestr = '7z l -i!epoc32 -x!epoc32/relinfo %s/*.zip >%s' % (path,temp.name) |
116 shutil.rmtree(temp_dir) |
117 exestr = '7z l -i!epoc32 -x!epoc32/relinfo %s/*.zip >%s' % (location,tmpfilename) |
|
118 |
|
119 exeresult = os.system(exestr) |
|
120 if(exeresult): |
|
121 sys.exit('Fatal error executing: %s\nReported error: %s' % (exestr,os.strerror(exeresult))) |
|
122 else: |
|
123 temp = open(tmpfilename,'r') |
|
124 for line in temp: |
|
125 res = reattribs.match(line) |
|
126 if(res): |
|
127 entry = dict() |
|
128 entry['time'] = int(time.mktime(time.strptime(res.group(1), '%Y-%m-%d %H:%M:%S'))) |
|
129 entry['size'] = res.group(2) |
|
130 entry['md5'] = 'xxx' |
|
131 filename = string.lower(fixpath.sub('/',res.group(3))) |
|
132 db[filename] = entry |
|
133 temp.close() |
|
134 os.unlink(tmpfilename) |
|
135 #now fill with the MD5s... |
|
136 md5zip = os.path.join(location,'build_md5.zip') |
|
137 print md5zip |
|
138 temp_dir = tempfile.mkdtemp() |
|
139 print temp_dir |
|
140 if(os.path.exists(md5zip)): |
|
141 files = set(); |
|
142 files.add('*') |
|
143 extractfromzip(files,md5zip,temp_dir) |
|
144 globsearch = os.path.join(temp_dir, os.path.join(patch_path_internal(),'*.md5')) |
|
145 print globsearch |
|
146 hashes = glob.glob(globsearch) |
|
147 for file in hashes: |
|
148 print 'Reading: %s\n' % file |
|
149 gethashes(db, file, False) |
|
150 shutil.rmtree(temp_dir) |
|
151 return db |
117 return db |
152 |
118 |
153 |
119 |
154 def generateMD5s(testset): |
120 def generateMD5s(testset): |
155 db = dict() |
121 db = dict() |
171 # print exestr |
137 # print exestr |
172 exeresult = os.system(exestr) |
138 exeresult = os.system(exestr) |
173 if(exeresult): |
139 if(exeresult): |
174 sys.exit('Fatal error executing: %s\nReported error: %s' % (exestr,os.strerror(exeresult))) |
140 sys.exit('Fatal error executing: %s\nReported error: %s' % (exestr,os.strerror(exeresult))) |
175 else: |
141 else: |
176 db = gethashes(db,outputfile, False) |
142 db = gethashes(db, outputfile, True) |
177 os.unlink(outputfile) |
143 os.unlink(outputfile) |
178 os.unlink(tmpfilename) |
144 os.unlink(tmpfilename) |
179 return db |
145 return db |
180 |
146 |
181 # Brittle and nasty!!! |
147 # Brittle and nasty!!! |
195 filename = "%s%s" % (root,res.group(1)) |
161 filename = "%s%s" % (root,res.group(1)) |
196 filename = string.lower(fixpath.sub('/',leadingslash.sub('',filename))) |
162 filename = string.lower(fixpath.sub('/',leadingslash.sub('',filename))) |
197 # print "found %s" % filename |
163 # print "found %s" % filename |
198 if(create): |
164 if(create): |
199 entry = dict() |
165 entry = dict() |
200 entry['time'] = 'xxx' |
166 entry['time'] = '0' |
201 entry['size'] = 'xxx' |
167 entry['size'] = '0' |
202 entry['md5'] = res.group(3) |
168 entry['md5'] = res.group(3) |
203 db[filename] = entry |
169 db[filename] = entry |
204 else: |
170 else: |
205 if(filename in db): |
171 if(filename in db): |
206 db[filename]['md5'] = res.group(3) |
172 db[filename]['md5'] = res.group(3) |