From patchwork Wed May 25 21:01:24 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Westby X-Patchwork-Id: 1620 Return-Path: Delivered-To: unknown Received: from imap.gmail.com (74.125.159.109) by localhost6.localdomain6 with IMAP4-SSL; 08 Jun 2011 14:53:37 -0000 Delivered-To: patches@linaro.org Received: by 10.52.181.230 with SMTP id dz6cs252238vdc; Wed, 25 May 2011 14:01:28 -0700 (PDT) Received: by 10.216.81.203 with SMTP id m53mr5578540wee.9.1306357287206; Wed, 25 May 2011 14:01:27 -0700 (PDT) Received: from adelie.canonical.com (adelie.canonical.com [91.189.90.139]) by mx.google.com with ESMTP id r76si33091weq.203.2011.05.25.14.01.26; Wed, 25 May 2011 14:01:27 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of bounces@canonical.com designates 91.189.90.139 as permitted sender) client-ip=91.189.90.139; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of bounces@canonical.com designates 91.189.90.139 as permitted sender) smtp.mail=bounces@canonical.com Received: from loganberry.canonical.com ([91.189.90.37]) by adelie.canonical.com with esmtp (Exim 4.71 #1 (Debian)) id 1QPLCn-000080-Hk for ; Wed, 25 May 2011 21:01:25 +0000 Received: from loganberry.canonical.com (localhost [127.0.0.1]) by loganberry.canonical.com (Postfix) with ESMTP id 84F4C2E8950 for ; Wed, 25 May 2011 21:01:24 +0000 (UTC) MIME-Version: 1.0 X-Launchpad-Project: linaro-image-tools X-Launchpad-Branch: ~linaro-image-tools/linaro-image-tools/trunk X-Launchpad-Message-Rationale: Subscriber X-Launchpad-Branch-Revision-Number: 347 X-Launchpad-Notification-Type: branch-revision To: Linaro Patch Tracker From: noreply@launchpad.net Subject: [Branch ~linaro-image-tools/linaro-image-tools/trunk] Rev 347: Allow hwpacks to remove packages from the assume-installed set. Message-Id: <20110525210124.10110.44485.launchpad@loganberry.canonical.com> Date: Wed, 25 May 2011 21:01:24 -0000 Reply-To: noreply@launchpad.net Sender: bounces@canonical.com Errors-To: bounces@canonical.com Precedence: bulk X-Generated-By: Launchpad (canonical.com); Revision="13085"; Instance="initZopeless config overlay" X-Launchpad-Hash: b298e9e2e6d54bc3edc185ee01f11362ac4ebd89 Merge authors: James Westby (james-w) Related merge proposals: https://code.launchpad.net/~james-w/linaro-image-tools/allow-remove-packages/+merge/62357 proposed by: James Westby (james-w) ------------------------------------------------------------ revno: 347 [merge] committer: James Westby branch nick: trunk timestamp: Wed 2011-05-25 16:59:19 -0400 message: Allow hwpacks to remove packages from the assume-installed set. modified: linaro_image_tools/hwpack/packages.py linaro_image_tools/hwpack/tests/test_packages.py --- lp:linaro-image-tools https://code.launchpad.net/~linaro-image-tools/linaro-image-tools/trunk You are subscribed to branch lp:linaro-image-tools. To unsubscribe from this branch go to https://code.launchpad.net/~linaro-image-tools/linaro-image-tools/trunk/+edit-subscription === modified file 'linaro_image_tools/hwpack/packages.py' --- linaro_image_tools/hwpack/packages.py 2011-05-10 15:06:52 +0000 +++ linaro_image_tools/hwpack/packages.py 2011-05-25 20:59:19 +0000 @@ -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' --- linaro_image_tools/hwpack/tests/test_packages.py 2011-04-05 21:31:29 +0000 +++ linaro_image_tools/hwpack/tests/test_packages.py 2011-05-25 20:55:24 +0000 @@ -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")