From 5dbf5b978da47095472c07a73f32fa70ead8ac25 Mon Sep 17 00:00:00 2001 From: Thomas Leonard Date: Sun, 26 Aug 2012 14:07:10 +0100 Subject: [PATCH] Fix up Java's main path after installing We can only detect the correct value for main when the Java package is installed. If 0install needed to install it (using PackageKit), we would fail to get the right path the first time. --- tests/testpackagekit.py | 5 +++++ zeroinstall/injector/distro.py | 24 ++++++++++++++++++------ zeroinstall/injector/packagekit.py | 3 +++ 3 files changed, 26 insertions(+), 6 deletions(-) diff --git a/tests/testpackagekit.py b/tests/testpackagekit.py index ff9d36e..065ba29 100755 --- a/tests/testpackagekit.py +++ b/tests/testpackagekit.py @@ -179,6 +179,7 @@ class TestPackageKit(BaseTest): pk.get_candidates('gimp', factory, 'package:test') self.assertEqual(["package:test:gimp:2.6.8-2:x86_64"], list(impls.keys())) + self.assertEqual(False, list(impls.values())[0].installed) impl, = impls.values() fetcher = fetch.Fetcher(config = self.config) @@ -186,6 +187,10 @@ class TestPackageKit(BaseTest): b = fetcher.download_impl(impl, impl.download_sources[0], stores = None) tasks.wait_for_blocker(b) tasks.check(b) + self.assertEqual("/usr/bin/fixed", list(impls.values())[0].main) + + def installed_fixup(self, impl): + impl.main = '/usr/bin/fixed' if __name__ == '__main__': unittest.main() diff --git a/zeroinstall/injector/distro.py b/zeroinstall/injector/distro.py index 183341f..14e4836 100644 --- a/zeroinstall/injector/distro.py +++ b/zeroinstall/injector/distro.py @@ -210,6 +210,8 @@ class Distribution(object): for impl in new_impls: self.fixup(package, impl) + if impl.installed: + self.installed_fixup(impl) if master_feed.url == 'http://repo.roscidus.com/python/python' and all(not impl.installed for impl in feed.implementations.values()): # Hack: we can support Python on platforms with unsupported package managers @@ -253,6 +255,13 @@ class Distribution(object): @param impl: the constructed implementation""" pass + def installed_fixup(self, impl): + """Called when an installed package is added (after L{fixup}), or when installation + completes. This is useful to fix up the main value. + @type impl: L{DistributionImplementation} + @since: 1.11""" + pass + class WindowsDistribution(Distribution): def get_package_info(self, package, factory): def _is_64bit_windows(): @@ -516,18 +525,21 @@ class DebianDistribution(Distribution): impl.download_sources.append(model.DistributionSource(package, cached['size'], install, needs_confirmation = False)) def fixup(self, package, impl): + if impl.id.startswith('package:deb:openjdk-6-jre:') or \ + impl.id.startswith('package:deb:openjdk-7-jre:'): + # Debian marks all Java versions as pre-releases + # See: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=685276 + impl.version = model.parse_version(impl.get_version().replace('-pre', '.')) + + def installed_fixup(self, impl): # Hack: If we added any Java implementations, find the corresponding JAVA_HOME... - if package == 'openjdk-6-jre': + if impl.id.startswith('package:deb:openjdk-6-jre:'): java_version = '6-openjdk' - elif package == 'openjdk-7-jre': + elif impl.id.startswith('package:deb:openjdk-7-jre:'): java_version = '7-openjdk' else: return - # Debian marks all Java versions as pre-releases - # See: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=685276 - impl.version = model.parse_version(impl.get_version().replace('-pre', '.')) - if impl.machine == 'x86_64': java_arch = 'amd64' else: diff --git a/zeroinstall/injector/packagekit.py b/zeroinstall/injector/packagekit.py index 970b41e..a1d8d4f 100644 --- a/zeroinstall/injector/packagekit.py +++ b/zeroinstall/injector/packagekit.py @@ -199,7 +199,10 @@ class PackageKitDownload: self.downloaded.trigger(exception = (ex, None)) def installed_cb(sender): + assert not self._impl.installed, impl self._impl.installed = True + self._impl.distro.installed_fixup(self._impl) + self.status = download.download_complete self.downloaded.trigger() -- 2.11.4.GIT