=== modified file 'linaro_image_tools/hwpack/packages.py'
@@ -674,19 +674,35 @@
base = os.path.basename(candidate.filename)
result_package = FetchedPackage.from_apt(candidate, base)
fetched[package] = result_package
- for package in packages:
- self.cache.cache[package].mark_install(auto_fix=False)
+
+ def check_no_broken_packages():
if self.cache.cache.broken_count:
raise DependencyNotSatisfied(
"Unable to satisfy dependencies of %s" %
", ".join([p.name for p in self.cache.cache
if p.is_inst_broken]))
+
+ for package in packages:
+ try:
+ self.cache.cache[package].mark_install(auto_fix=True)
+ except SystemError:
+ # Either we raise a DependencyNotSatisfied error
+ # if some packages are broken, or we raise the original
+ # error if there was another cause
+ check_no_broken_packages()
+ raise
+ # Check that nothing was broken, even if mark_install didn't
+ # raise SystemError, just to make sure.
+ check_no_broken_packages()
self._filter_ignored(fetched)
if not download_content:
+ self.cache.cache.clear()
return fetched.values()
acq = apt_pkg.Acquire(DummyProgress())
acqfiles = []
for package in self.cache.cache.get_changes():
+ if (package.marked_delete or package.marked_keep):
+ continue
logger.debug("Fetching %s ..." % package)
candidate = package.candidate
base = os.path.basename(candidate.filename)
=== modified file 'linaro_image_tools/hwpack/tests/test_packages.py'
@@ -1114,6 +1114,38 @@
fetcher.fetch_packages(["foo"])
self.assertEqual([], list(fetcher.cache.cache.get_changes()))
+ def test_fetch_packages_without_content_leaves_no_marked_changes(self):
+ wanted_package = DummyFetchedPackage("foo", "1.0")
+ source = self.useFixture(AptSourceFixture([wanted_package]))
+ fetcher = self.get_fetcher([source])
+ fetcher.fetch_packages(["foo"], download_content=False)
+ self.assertEqual([], list(fetcher.cache.cache.get_changes()))
+
+ def test_fetch_packages_can_remove_package(self):
+ """Check that removed packages aren't included in the hwpack
+
+ When installing the hwpack would cause an "assume-installed" package
+ to be removed the hwpack shouldn't contain that package.
+ """
+ wanted_package = DummyFetchedPackage(
+ "foo", "1.0", conflicts="provided", provides="provided",
+ depends="zoo", replaces="provided")
+ top_package = DummyFetchedPackage(
+ "top", "1.0", recommends="bar, baz")
+ dep_package = DummyFetchedPackage(
+ "bar", "1.0", depends="baz")
+ conflict_package = DummyFetchedPackage(
+ "baz", "1.0", recommends="bar", provides="provided",
+ conflicts="provided", replaces="provided")
+ extra_package = DummyFetchedPackage("zoo", "1.0")
+ source = self.useFixture(AptSourceFixture(
+ [wanted_package, dep_package, conflict_package, extra_package,
+ top_package]))
+ fetcher = self.get_fetcher([source])
+ fetcher.ignore_packages(["top"])
+ fetched = fetcher.fetch_packages(["foo"])
+ self.assertEqual([wanted_package, extra_package], fetched)
+
def test_ignore_with_provides(self):
ignored_package = DummyFetchedPackage(
"ubuntu-minimal", "1.0", depends="apt-utils")