Changeset 314
- Timestamp:
- Wed May 2 08:44:10 2007
- Files:
-
- trunk/Build.py (modified) (diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
trunk/Build.py
r303 r314 17 17 # along with this program; if not, write to the Free Software 18 18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA 19 import sys, os, shutil, mf, archive, iu, carchive, pprint, time, py_compile, bindepend, tempfile 19 import sys, os, shutil, mf, archive, iu, carchive, pprint, time, py_compile, bindepend, tempfile, md5 19 19 20 20 STRINGTYPE = type('') … … 294 294 return 1 295 295 296 def cacheDigest(fnm): 297 data = open(fnm, "rb").read() 298 digest = md5.new(data).digest() 299 return digest 300 296 301 def checkCache(fnm, strip, upx): 297 302 if not strip and not upx: … … 305 310 else: 306 311 upx = 0 312 313 # Load cache index 307 314 cachedir = os.path.join(HOMEPATH, 'bincache%d%d' % (strip, upx)) 308 315 if not os.path.exists(cachedir): 309 316 os.makedirs(cachedir) 310 basenm = os.path.basename(fnm) 311 cachedfile = os.path.join(cachedir, basenm ) 312 if os.path.exists(cachedfile): 313 if mtime(fnm) > mtime(cachedfile): 317 cacheindexfn = os.path.join(cachedir, "index.dat") 318 if os.path.exists(cacheindexfn): 319 cache_index = eval(open(cacheindexfn, "r").read()) 320 else: 321 cache_index = {} 322 323 # Verify if the file we're looking for is present in the cache. 324 basenm = os.path.normcase(os.path.basename(fnm)) 325 digest = cacheDigest(fnm) 326 cachedfile = os.path.join(cachedir, basenm) 327 if cache_index.has_key(basenm): 328 if digest != cache_index[basenm]: 314 329 os.remove(cachedfile) 315 330 else: … … 324 339 os.chmod(cachedfile, 0755) 325 340 os.system(cmd) 341 342 # update cache index 343 cache_index[basenm] = digest 344 outf = open(cacheindexfn, 'w') 345 pprint.pprint(cache_index, outf) 346 outf.close() 347 326 348 return cachedfile 327 349
