Fix erroneous install errors when iterating on an archive (preserving its name but changing its contents).
Review Request #243 - Created March 29, 2011 and submitted
| Alain Linden | Reviewers | ||
| oz.linden, brad.linden, nat_linden | |||
| None | autobuild | ||
Fixed a bug where an error would be thrown if one tried to install an archive with a filename that matches a cached version but is updated. One could hit this if they updated the same archive multiple times in a day (like when doing development work). Now if the cached archive doesn't match the hash, a download will be attempted so only true download errors will result in an exception.
| autobuild/autobuild_tool_install.py | |||
|---|---|---|---|
| Revision ea7e10fd9520 | New Change | ||
| ... | 350 lines hidden [Expand] | ||
def _install_binary(package, platform, config_file, install_dir, installed_file, dry_run): |
|||
| 351 |
# whether the installed ArchiveDescription matches the requested one. This
|
351 |
# whether the installed ArchiveDescription matches the requested one. This
|
| 352 |
# test also handles the case when inst_plat.archive is None (not yet
|
352 |
# test also handles the case when inst_plat.archive is None (not yet
|
| 353 |
# installed).
|
353 |
# installed).
|
| 354 |
if archive == inst_archive: |
354 |
if archive == inst_archive: |
| 355 |
logger.info("%s up to date" % package.name) |
355 |
logger.info("%s up to date" % package.name) |
| 356 |
return False |
356 |
return False |
| 357 | 357 | ||
| 358 |
cachefile = common.get_package_in_cache(archive.url) |
358 |
cachefile = common.get_package_in_cache(archive.url) |
| 359 | 359 | ||
| 360 |
# download the package, if it's not already in our cache
|
360 |
# download the package, if it's not already in our cache
|
| 361 |
download_required = False |
||
| 361 |
if os.path.exists(cachefile): |
362 |
if os.path.exists(cachefile): |
| 362 | logger.debug("found in cache: " + cachefile) |
363 | if hash_algorithms.verify_hash(archive.hash_algorithm, cachefile, archive.hash): |
| 364 |
logger.debug("found in cache: " + cachefile) |
||
| 365 |
else: |
||
| 366 |
download_required = True |
||
| 367 |
common.remove_package(archive.url) |
||
| 363 |
else: |
368 |
else: |
| 369 |
download_required = True |
||
| 370 |
|
||
| 371 |
if download_required: |
||
| 364 |
# download the package to the cache
|
372 |
# download the package to the cache
|
| 365 |
logger.warn("downloading %s archive from %s" % (package.name, archive.url)) |
373 |
logger.warn("downloading %s archive from %s" % (package.name, archive.url)) |
| 366 |
if not common.download_package(archive.url): |
374 |
if not common.download_package(archive.url): |
| 367 |
# Download failure has been observed to leave a zero-length file.
|
375 |
# Download failure has been observed to leave a zero-length file.
|
| 368 |
common.remove_package(archive.url) |
376 |
common.remove_package(archive.url) |
| 369 |
raise InstallError("failed to download %s" % archive.url) |
377 |
raise InstallError("failed to download %s" % archive.url) |
| 378 |
|
||
| Moved from 371 | 379 |
# error out if MD5 doesn't match
|
|
| Moved from 372 | 380 |
if not hash_algorithms.verify_hash(archive.hash_algorithm, cachefile, archive.hash): |
|
| Moved from 373 | 381 |
common.remove_package(archive.url) |
|
| 382 |
raise InstallError("download error--%s mismatch for %s" % ((archive.hash_algorithm or "md5"), cachefile)) |
||
| 370 | 383 | ||
| 371 |
# error out if MD5 doesn't match
|
Moved to 379 | |
| 372 |
if not hash_algorithms.verify_hash(archive.hash_algorithm, cachefile, archive.hash): |
Moved to 380 | |
| 373 |
common.remove_package(archive.url) |
Moved to 381 | |
| 374 |
raise InstallError("%s mismatch for %s" % ((archive.hash_algorithm or "md5"), cachefile)) |
||
| 375 | |||
| 376 |
# dry run mode = download but don't install packages
|
384 |
# dry run mode = download but don't install packages
|
| 377 |
if dry_run: |
385 |
if dry_run: |
| 378 |
dry_run_msg("Dry run mode: not installing %s" % package.name) |
386 |
dry_run_msg("Dry run mode: not installing %s" % package.name) |
| 379 |
return False |
387 |
return False |
| 380 | 388 | ||
| 381 |
# If this package has already been installed, first uninstall the older
|
389 |
# If this package has already been installed, first uninstall the older
|
| 382 |
# version.
|
390 |
# version.
|
| 383 |
uninstall(package.name, installed_file) |
391 |
uninstall(package.name, installed_file) |
| 384 | 392 | ||
| 385 |
# check that the install dir exists...
|
393 |
# check that the install dir exists...
|
| ... | 177 lines hidden [Expand] | ||

Other reviews