- return all(cache_tree_paths(c)[2].exists() for c in incremental) and not all(
- have_cache(c) for c in incremental
- )
+ if all(cache_tree_paths(c)[2].exists() for c in incremental):
+ if all(have_cache(c) for c in incremental):
+ if log:
+ logging.info(
+ "Skipping package manager metadata sync: all incremental image caches are up to date"
+ )
+ return False
+ if log:
+ stale = sorted(c.image for c in incremental if not have_cache(c))
+ logging.info(
+ f"Syncing package manager metadata: cached images are out of date: ({', '.join(stale)})"
+ )
+ return True
+
+ if log:
+ with_manifest = sorted(c.image for c in incremental if cache_tree_paths(c)[2].exists())
+ without_manifest = sorted(c.image for c in incremental if not cache_tree_paths(c)[2].exists())
+ logging.info(
+ "Skipping package manager metadata sync: assuming mid-build-failure recovery "
+ f"(images with cache manifest: {', '.join(with_manifest)}; "
+ f"without: {', '.join(without_manifest)})"
+ )
+ logging.info("If package installation fails because of stale metadata, re-run with '-ff'")
+
+ return False