Esempio n. 1
0
class OSGiCache(Cache):
    def __init__(self, rpmconf):
        super(OSGiCache, self).__init__(rpmconf)
        self._config_name = config.osgi_cache_f
        self._cache = self._read_cache()
        self._metadata_cache = MetadataCache(rpmconf)

        if self._cache is None:
            self._cache = self._process_buildroot()
            self._write_cache(self._cache)

    def get_bundle_for_path(self, path):
        try:
            return self._cache[path]
        except KeyError:
            pass
        return None

    def get_bundle(self, name):
        for bundle in self._cache.values():
            if bundle.bundle == name:
                return bundle
        return None

    def _process_buildroot(self):
        # "path: OSGiBundle" mapping
        cache = {}

        bundle_paths = self._find_paths()
        for path in bundle_paths:
            artifact = self._metadata_cache.get_artifact_for_path(
                path, can_be_dir=True)
            if artifact and artifact.has_osgi_information():
                bundle = artifact.get_osgi_bundle()
            else:
                bundle = OSGiBundle.from_manifest(path)
            if bundle:
                cache.update({path: bundle})

        return cache

    def _check_path(self, path):
        if os.path.islink(path):
            return False
        if path.endswith(".jar"):
            return True
        if path.endswith("/MANIFEST.MF"):
            # who knows where the manifest can be in buildroot.
            # this is an attempt to identify only MANIFEST.MF files
            # which are in %{_datadir} or %{_prefix}/lib
            if "/usr/share/" in path or "/usr/lib" in path:
                return True
        return False

    def check_path_in_metadata(self, path):
        artifact = self._metadata_cache.get_artifact_for_path(path,
                                                              can_be_dir=True)
        if artifact and artifact.has_osgi_information():
            return True
        return False
Esempio n. 2
0
    def __init__(self, rpmconf):
        super(OSGiCache, self).__init__(rpmconf)
        self._config_name = config.osgi_cache_f
        self._cache = self._read_cache()
        self._metadata_cache = MetadataCache(rpmconf)

        if self._cache is None:
            self._cache = self._process_buildroot()
            self._write_cache(self._cache)
Esempio n. 3
0
    def __init__(self, rpmconf):
        super(OSGiCache, self).__init__(rpmconf)
        self._config_name = config.osgi_cache_f
        self._cache = self._read_cache()
        self._metadata_cache = MetadataCache(rpmconf)

        if self._cache is None:
            self._cache = self._process_buildroot()
            self._write_cache(self._cache)
Esempio n. 4
0
class OSGiCache(Cache):

    def __init__(self, rpmconf):
        super(OSGiCache, self).__init__(rpmconf)
        self._config_name = config.osgi_cache_f
        self._cache = self._read_cache()
        self._metadata_cache = MetadataCache(rpmconf)

        if self._cache is None:
            self._cache = self._process_buildroot()
            self._write_cache(self._cache)

    def get_bundle_for_path(self, path):
        try:
            return self._cache[path]
        except KeyError:
            pass
        return None

    def get_bundle(self, name):
        for bundle in self._cache.values():
            if bundle.bundle == name:
                return bundle
        return None

    def _process_buildroot(self):
        # "path: OSGiBundle" mapping
        cache = {}

        bundle_paths = self._find_paths()
        for path in bundle_paths:
            artifact = self._metadata_cache.get_artifact_for_path(path, can_be_dir=True)
            if artifact and artifact.has_osgi_information():
                bundle = artifact.get_osgi_bundle()
            else:
                bundle = OSGiBundle.from_manifest(path)
                if bundle:
                    if not bundle.namespace and self._scl:
                        bundle.namespace = self._scl
            if bundle:
                cache.update({path: bundle})

        return cache

    def _check_path(self, path):
        if os.path.islink(path):
            return False
        if path.endswith(".jar"):
            return True
        if path.endswith("/MANIFEST.MF"):
            # who knows where the manifest can be in buildroot.
            # this is an attempt to identify only MANIFEST.MF files
            # which are in %{_datadir} or %{_prefix}/lib
            if "/usr/share/" in path or "/usr/lib" in path:
                return True
        return False

    def check_path_in_metadata(self, path):
        artifact = self._metadata_cache.get_artifact_for_path(path,
                                                              can_be_dir=True)
        if artifact and artifact.has_osgi_information():
            return True
        return False