示例#1
0
    def get_feed(self, url, force=False):
        feed = iface_cache.IfaceCache.get_feed(self, url, force)
        if not feed: return None

        if feed not in self.done:
            self.done.add(feed)

            # For each source impl, add a corresponding binary
            # (the binary has no dependencies as we can't predict them here,
            # but they're not the same as the source's dependencies)

            srcs = [
                x for x in feed.implementations.itervalues()
                if x.arch and x.arch.endswith('-src')
            ]
            for x in srcs:
                new_id = '0compile=' + x.id
                if not new_id in feed.implementations:
                    new = NewBuildImplementation(feed, new_id, None)
                    feed.implementations[new_id] = new
                    new.set_arch(host_arch)
                    new.version = x.version

                    # Give it some dummy commands in case we're using it as a <runner>, etc (otherwise it can't be selected)
                    for cmd_name in get_commands(x):
                        cmd = qdom.Element(namespaces.XMLNS_IFACE, 'command', {
                            'path': 'new-build',
                            'name': cmd_name
                        })
                        new.commands[cmd_name] = model.Command(cmd, None)

                    # Find the <command name='compile'/>
                    add_binary_deps(x, new)

        return feed
示例#2
0
    def installed_fixup(self, impl):
        # OpenSUSE uses _, Fedora uses .
        impl_id = impl.id.replace('_', '.')

        # Hack: If we added any Java implementations, find the corresponding JAVA_HOME...

        if impl_id.startswith('package:rpm:java-1.6.0-openjdk:'):
            java_version = '1.6.0-openjdk'
        elif impl_id.startswith('package:rpm:java-1.7.0-openjdk:'):
            java_version = '1.7.0-openjdk'
        else:
            return

        # On Fedora, unlike Debian, the arch is x86_64, not amd64

        java_bin = '/usr/lib/jvm/jre-%s.%s/bin/java' % (java_version,
                                                        impl.machine)
        if not os.path.exists(java_bin):
            # Try without the arch...
            java_bin = '/usr/lib/jvm/jre-%s/bin/java' % java_version
            if not os.path.exists(java_bin):
                logger.info("Java binary not found (%s)", java_bin)
                if impl.main is None:
                    java_bin = '/usr/bin/java'
                else:
                    return

        impl.commands["run"] = model.Command(
            qdom.Element(namespaces.XMLNS_IFACE, 'command', {
                'path': java_bin,
                'name': 'run'
            }), None)
示例#3
0
    def installed_fixup(self, impl):
        # Hack: If we added any Java implementations, find the corresponding JAVA_HOME...
        if impl.id.startswith('package:deb:openjdk-6-jre:'):
            java_version = '6-openjdk'
        elif impl.id.startswith('package:deb:openjdk-7-jre:'):
            java_version = '7-openjdk'
        else:
            return

        if impl.machine == 'x86_64':
            java_arch = 'amd64'
        else:
            java_arch = impl.machine

        java_bin = '/usr/lib/jvm/java-%s-%s/jre/bin/java' % (java_version,
                                                             java_arch)
        if not os.path.exists(java_bin):
            # Try without the arch...
            java_bin = '/usr/lib/jvm/java-%s/jre/bin/java' % java_version
            if not os.path.exists(java_bin):
                logger.info("Java binary not found (%s)", java_bin)
                if impl.main is None:
                    java_bin = '/usr/bin/java'
                else:
                    return

        impl.commands["run"] = model.Command(
            qdom.Element(namespaces.XMLNS_IFACE, 'command', {
                'path': java_bin,
                'name': 'run'
            }), None)
示例#4
0
 def clone_command_for(command, arch):
     # This is a bit messy. We need to make a copy of the command, without the
     # unnecessary <requires> elements.
     all_dep_elems = set(dep.qdom for dep in command.requires)
     required_dep_elems = set(dep.qdom
                              for dep in deps_in_use(command, arch))
     if all_dep_elems == required_dep_elems:
         return command  # No change
     dep_elems_to_remove = all_dep_elems - required_dep_elems
     old_root = command.qdom
     new_qdom = qdom.Element(old_root.uri, old_root.name,
                             old_root.attrs)
     new_qdom.childNodes = [
         node for node in command.qdom.childNodes
         if node not in dep_elems_to_remove
     ]
     return model.Command(new_qdom, command._local_dir)
示例#5
0
    def testLocalPath(self):
        # 0launch --get-selections Local.xml
        iface = os.path.join(mydir, "Local.xml")
        driver = Driver(requirements=Requirements(iface), config=self.config)
        driver.need_download()
        assert driver.solver.ready
        s1 = driver.solver.selections
        xml = s1.toDOM().toxml("utf-8")

        # Reload selections and check they're the same
        root = qdom.parse(BytesIO(xml))
        s2 = selections.Selections(root)
        local_path = s2.selections[iface].local_path
        assert os.path.isdir(local_path), local_path
        assert not s2.selections[iface].digests, s2.selections[iface].digests

        # Add a newer implementation and try again
        feed = self.config.iface_cache.get_feed(iface)
        impl = model.ZeroInstallImplementation(feed,
                                               "foo bar=123",
                                               local_path=None)
        impl.version = model.parse_version('1.0')
        impl.commands["run"] = model.Command(
            qdom.Element(namespaces.XMLNS_IFACE, 'command', {
                'path': 'dummy',
                'name': 'run'
            }), None)
        impl.add_download_source('http://localhost/bar.tgz', 1000, None)
        feed.implementations = {impl.id: impl}
        assert driver.need_download()
        assert driver.solver.ready, driver.solver.get_failure_reason()
        s1 = driver.solver.selections
        xml = s1.toDOM().toxml("utf-8")
        root = qdom.parse(BytesIO(xml))
        s2 = selections.Selections(root)
        xml = s2.toDOM().toxml("utf-8")
        qdom.parse(BytesIO(xml))
        assert s2.selections[iface].local_path is None
        assert not s2.selections[iface].digests, s2.selections[iface].digests
        assert s2.selections[iface].id == 'foo bar=123'