undo_items: Gracefully handle skipped cruft items in undo

In 203466b, we stopped migrating cruft items if they were not in
testing already.  However, if the migration failed we would still
attempt to undo it from testing, which (unsurprisingly) does not work
very well.

Signed-off-by: Niels Thykier <niels@thykier.net>
debian
Niels Thykier 9 years ago
parent 4ced8a3d41
commit 2e81e55c56

@ -123,10 +123,17 @@ def undo_changes(lundo, inst_tester, sources, binaries, all_binary_packages,
# undo all new binaries (consequence of the above)
for (undo, item) in lundo:
if not item.is_removal and item.package in sources[item.suite]:
for pkg_id in sources[item.suite][item.package][BINARIES]:
source_data = sources[item.suite][item.package]
for pkg_id in source_data[BINARIES]:
binary, _, arch = pkg_id
if item.architecture in ['source', arch]:
try:
del binaries["testing"][arch][0][binary]
except KeyError:
# If this happens, pkg_id must be a cruft item that
# was *not* migrated.
assert source_data[VERSION] != all_binary_packages[pkg_id][VERSION]
assert not inst_tester.any_of_these_are_in_testing((pkg_id,))
inst_tester.remove_testing_binary(pkg_id)

Loading…
Cancel
Save