Ejemplo n.º 1
0
    def __init__(self,
                 location,
                 repo_id=None,
                 ignore_paludis_versioning=False,
                 cache_version='0'):
        """
        :param location: root of the tbz2 repository
        :keyword repo_id: unique repository id to use; else defaults to
            the location
        :keyword ignore_paludis_versioning: if False, error when -scm is seen.
            If True, silently ignore -scm ebuilds.
        """
        super(tree, self).__init__()
        self.base = self.location = location
        if repo_id is None:
            repo_id = location
        self.repo_id = repo_id
        self._versions_tmp_cache = {}
        self.ignore_paludis_versioning = ignore_paludis_versioning

        # XXX rewrite this when snakeoil.osutils grows an access equivalent.
        if not access(self.base, os.X_OK | os.R_OK):
            # either it doesn't exist, or we don't have perms.
            if not os.path.exists(self.base):
                raise errors.InitializationError("base %r doesn't exist: %s" %
                                                 self.base)
            raise errors.InitializationError(
                "base directory %r with mode 0%03o isn't readable/executable"
                " by this user" %
                (self.base, os.stat(self.base).st_mode & 04777))

        self.cache = remote.get_cache_kls(cache_version)(pjoin(
            self.base, self.cache_name))
        self.package_class = wrap_factory(self.package_factory, self)
Ejemplo n.º 2
0
    def __init__(self, location, repo_id=None, ignore_paludis_versioning=False,
                 cache_version='0'):
        """
        :param location: root of the tbz2 repository
        :keyword repo_id: unique repository id to use; else defaults to
            the location
        :keyword ignore_paludis_versioning: if False, error when -scm is seen.  If True,
            silently ignore -scm ebuilds
        """
        super(tree, self).__init__()
        self.base = location
        if repo_id is None:
            repo_id = location
        self.repo_id = repo_id
        self._versions_tmp_cache = {}
        self.ignore_paludis_versioning = ignore_paludis_versioning

        # XXX rewrite this when snakeoil.osutils grows an access equivalent.
        if not access(self.base, os.X_OK|os.R_OK):
            # either it doesn't exist, or we don't have perms.
            if not os.path.exists(self.base):
                raise errors.InitializationError(
                    "base %r doesn't exist: %s" % self.base)
            raise errors.InitializationError(
                "base directory %r with mode 0%03o isn't readable/executable"
                " by this user" % (self.base,
                os.stat(self.base).st_mode & 04777))

        self.cache = remote.get_cache_kls(cache_version)(pjoin(self.base, self.cache_name))
        self.package_class = wrap_factory(self.package_factory, self)
Ejemplo n.º 3
0
    def __init__(self, location, repo_id=None, cache_version='0'):
        """
        :param location: root of the tbz2 repository
        :keyword repo_id: unique repository id to use; else defaults to
            the location
        """
        super().__init__()
        self.base = self.location = location
        if repo_id is None:
            repo_id = location
        self.repo_id = repo_id
        self._versions_tmp_cache = {}

        # XXX rewrite this when snakeoil.osutils grows an access equivalent.
        if not access(self.base, os.X_OK | os.R_OK):
            # either it doesn't exist, or we don't have perms.
            if not os.path.exists(self.base):
                raise errors.InitializationError(
                    f"base {self.base!r} doesn't exist")
            raise errors.InitializationError(
                "base directory %r with mode 0%03o isn't readable/executable"
                " by this user" %
                (self.base, os.stat(self.base).st_mode & 0o4777))

        self.cache = remote.get_cache_kls(cache_version)(pjoin(
            self.base, self.cache_name))
        self.package_class = BinPkg(self)
Ejemplo n.º 4
0
    def __init__(self, location, repo_id=None, cache_version='0'):
        """
        :param location: root of the tbz2 repository
        :keyword repo_id: unique repository id to use; else defaults to
            the location
        """
        super().__init__()
        self.base = self.location = location
        if repo_id is None:
            repo_id = location
        self.repo_id = repo_id
        self._versions_tmp_cache = {}

        # XXX rewrite this when snakeoil.osutils grows an access equivalent.
        if not access(self.base, os.X_OK | os.R_OK):
            # either it doesn't exist, or we don't have perms.
            if not os.path.exists(self.base):
                raise errors.InitializationError(f"base {self.base!r} doesn't exist")
            raise errors.InitializationError(
                "base directory %r with mode 0%03o isn't readable/executable"
                " by this user" %
                (self.base, os.stat(self.base).st_mode & 0o4777))

        self.cache = remote.get_cache_kls(cache_version)(pjoin(self.base, self.cache_name))
        self.package_class = wrap_factory(self.package_factory, self)
Ejemplo n.º 5
0
def is_sandbox_capable(force=False):
    if not force:
        try:
            return is_sandbox_capable.cached_result
        except AttributeError:
            pass
    res = os.path.isfile(SANDBOX_BINARY) and access(SANDBOX_BINARY, os.X_OK)
    is_sandbox_capable.cached_result = res
    return res
Ejemplo n.º 6
0
def is_sandbox_capable(force=False):
    if not force:
        try:
            return is_sandbox_capable.cached_result
        except AttributeError:
            pass
    res = os.path.isfile(SANDBOX_BINARY) and access(SANDBOX_BINARY, os.X_OK)
    is_sandbox_capable.cached_result = res
    return res
Ejemplo n.º 7
0
def is_sandbox_capable(force=False):
    if not force:
        try:
            return is_sandbox_capable.cached_result
        except AttributeError:
            pass
    if not (os.path.isfile(SANDBOX_BINARY) and access(SANDBOX_BINARY, os.X_OK)):
        res = False
    else:
        try:
            r, s = spawn_get_output([SANDBOX_BINARY, "--version"])
            res = (r == 0) and ("gentoo" in s[0].lower())
        except ExecutionFailure:
            res = False
    is_sandbox_capable.cached_result = res
    return res
Ejemplo n.º 8
0
def is_sandbox_capable(force=False):
    if not force:
        try:
            return is_sandbox_capable.cached_result
        except AttributeError:
            pass
    if not (os.path.isfile(SANDBOX_BINARY)
            and access(SANDBOX_BINARY, os.X_OK)):
        res = False
    else:
        try:
            r, s = spawn_get_output([SANDBOX_BINARY, "--version"])
            res = (r == 0) and ("gentoo" in s[0].lower())
        except ExecutionFailure:
            res = False
    is_sandbox_capable.cached_result = res
    return res
Ejemplo n.º 9
0
def make_cache(cache_format, repo_path):
    # Use md5 cache if it exists or the option is selected, otherwise default
    # to the old flat hash format in /var/cache/edb/dep/*.
    if (os.path.exists(pjoin(repo_path, 'metadata', 'md5-cache'))
            or cache_format == 'md5-dict'):
        kls = 'pkgcore.cache.flat_hash.md5_cache'
        cache_parent_dir = pjoin(repo_path, 'metadata', 'md5-cache')
    else:
        kls = 'pkgcore.cache.flat_hash.database'
        repo_path = pjoin('/var/cache/edb/dep', repo_path.lstrip('/'))
        cache_parent_dir = repo_path

    while not os.path.exists(cache_parent_dir):
        cache_parent_dir = os.path.dirname(cache_parent_dir)
    readonly = (not access(cache_parent_dir, os.W_OK | os.X_OK))

    return basics.AutoConfigSection({
        'class': kls,
        'location': repo_path,
        'readonly': readonly
    })
Ejemplo n.º 10
0
def make_cache(cache_format, repo_path):
    # Use md5 cache if it exists or the option is selected, otherwise default
    # to the old flat hash format in /var/cache/edb/dep/*.
    if (os.path.exists(pjoin(repo_path, 'metadata', 'md5-cache')) or
            cache_format == 'md5-dict'):
        kls = 'pkgcore.cache.flat_hash.md5_cache'
        cache_parent_dir = pjoin(repo_path, 'metadata', 'md5-cache')
    else:
        kls = 'pkgcore.cache.flat_hash.database'
        repo_path = pjoin('/var/cache/edb/dep', repo_path.lstrip('/'))
        cache_parent_dir = repo_path

    while not os.path.exists(cache_parent_dir):
        cache_parent_dir = os.path.dirname(cache_parent_dir)
    readonly = (not access(cache_parent_dir, os.W_OK | os.X_OK))

    return basics.AutoConfigSection({
        'class': kls,
        'location': repo_path,
        'readonly': readonly
    })
Ejemplo n.º 11
0
def mk_simple_cache(config_root, tree_loc):
    # TODO: probably should pull RepoConfig objects dynamically from the config
    # instead of regenerating them
    repo_config = RepoConfig(tree_loc)

    if repo_config.cache_format == 'md5-dict':
        kls = 'pkgcore.cache.flat_hash.md5_cache'
        tree_loc = pjoin(config_root, tree_loc.lstrip('/'), 'metadata', 'md5-cache')
    else:
        kls = 'pkgcore.cache.flat_hash.database'
        tree_loc = pjoin(config_root, 'var/cache/edb/dep', tree_loc.lstrip('/'))

    cache_parent_dir = tree_loc
    while not os.path.exists(cache_parent_dir):
        cache_parent_dir = os.path.dirname(cache_parent_dir)
    readonly = (not access(cache_parent_dir, os.W_OK|os.X_OK))

    return basics.AutoConfigSection({
        'class': kls,
        'location': tree_loc,
        'readonly': readonly
    })