Пример #1
0
 def factory(id, only_if_missing=False, installed=True):
     assert not only_if_missing
     impl = model.DistributionImplementation(self.feed, id, distro)
     assert id not in self.feed.implementations
     self.feed.implementations[id] = impl
     impl.installed = installed
     return impl
Пример #2
0
            def factory(id, only_if_missing=False, installed=True):
                assert id.startswith('package:')
                if id in feed.implementations:
                    if only_if_missing:
                        return None
                    logger.warn(
                        _("Duplicate ID '%s' for DistributionImplementation"),
                        id)
                impl = model.DistributionImplementation(feed, id, self, item)
                feed.implementations[id] = impl
                new_impls.append(impl)

                impl.installed = installed
                impl.metadata = item_attrs
                impl.requires = depends

                if 'run' not in impl.commands:
                    item_main = item_attrs.get('main', None)
                    if item_main:
                        if item_main.startswith('/'):
                            impl.main = item_main
                        else:
                            raise model.InvalidInterface(
                                _("'main' attribute must be absolute, but '%s' doesn't start with '/'!"
                                  ) % item_main)
                impl.upstream_stability = model.packaged

                return impl
Пример #3
0
		def factory(impl_id, only_if_missing, installed):
			assert impl_id.startswith('package:')
			assert only_if_missing is True
			assert installed is False

			feed = None

			impl = model.DistributionImplementation(feed, impl_id, self)
			impl.installed = installed
			impls[impl_id] = impl
			return impl
Пример #4
0
    def get_feed(self, master_feed):
        """Generate a feed containing information about distribution packages.
		This should immediately return a feed containing an implementation for the
		package if it's already installed. Information about versions that could be
		installed using the distribution's package manager can be added asynchronously
		later (see L{fetch_candidates}).
		@param master_feed: feed containing the <package-implementation> elements
		@type master_feed: L{model.ZeroInstallFeed}
		@rtype: L{model.ZeroInstallFeed}"""

        feed = model.ZeroInstallFeed(None)
        feed.url = 'distribution:' + master_feed.url

        for item, item_attrs in master_feed.get_package_impls(self):
            package = item_attrs.get('package', None)
            if package is None:
                raise model.InvalidInterface(
                    _("Missing 'package' attribute on %s") % item)

            def factory(id, only_if_missing=False, installed=True):
                assert id.startswith('package:')
                if id in feed.implementations:
                    if only_if_missing:
                        return None
                    warn(_("Duplicate ID '%s' for DistributionImplementation"),
                         id)
                impl = model.DistributionImplementation(feed, id, self)
                feed.implementations[id] = impl

                impl.installed = installed
                impl.metadata = item_attrs

                item_main = item_attrs.get('main', None)
                if item_main and not item_main.startswith('/'):
                    raise model.InvalidInterface(
                        _("'main' attribute must be absolute, but '%s' doesn't start with '/'!"
                          ) % item_main)
                impl.main = item_main
                impl.upstream_stability = model.packaged

                return impl

            self.get_package_info(package, factory)

        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
            # by adding the implementation of Python running us now to the list.
            python_version = '.'.join(
                [str(v) for v in sys.version_info if isinstance(v, int)])
            impl_id = 'package:host:python:' + python_version
            assert impl_id not in feed.implementations
            impl = model.DistributionImplementation(feed, impl_id, self)
            impl.installed = True
            impl.version = model.parse_version(python_version)
            impl.main = sys.executable
            impl.upstream_stability = model.packaged
            impl.machine = host_machine  # (hopefully)
            feed.implementations[impl_id] = impl

        return feed