예제 #1
0
def real_handle():
    dbpath = mkdtemp(dir='/tmp')
    handle = Handle('/', dbpath)
    repo = handle.register_syncdb(REPO_1, 0)
    repo.servers = [TEST_MIRROR.format(REPO_1, ARCH)]
    yield handle
    rmtree(dbpath)
예제 #2
0
파일: conftest.py 프로젝트: lilydjwg/pyalpm
def real_handle(tmpdir_factory, generate_syncdb, generate_localdb, db_data):
    dbpath = str(tmpdir_factory.mktemp('dbpath'))
    syncdb = f"{dbpath}/sync"
    localdb = f"{dbpath}/local"
    # TODO: use a different location for clarity
    mirrorpath = f'{dbpath}/{REPO_1}'
    syncdbfile = f'{syncdb}/{REPO_1}.db'

    mkdir(syncdb)
    mkdir(mirrorpath)

    generate_syncdb(db_data, basename(syncdbfile), syncdb)
    generate_localdb(db_data, dbpath)

    # Generate localdb content after the db is initialised
    handle = Handle('/', dbpath)

    # Generate local repo by copying the sync core.db
    # TODO: use a different sync db with a more packages
    copyfile(syncdbfile, f'{mirrorpath}/{REPO_1}.db')

    repo = handle.register_syncdb(REPO_1, 0)
    repo.servers = [f'file:///{mirrorpath}']

    yield handle
예제 #3
0
파일: pacman.py 프로젝트: arcan1s/ahriman
class Pacman:
    """
    alpm wrapper
    :ivar handle: pyalpm root `Handle`
    """

    def __init__(self, configuration: Configuration) -> None:
        """
        default constructor
        :param configuration: configuration instance
        """
        root = configuration.get("alpm", "root")
        pacman_root = configuration.getpath("alpm", "database")
        self.handle = Handle(root, str(pacman_root))
        for repository in configuration.getlist("alpm", "repositories"):
            self.handle.register_syncdb(repository, 0)  # 0 is pgp_level

    def all_packages(self) -> List[str]:
        """
        get list of packages known for alpm
        :return: list of package names
        """
        result: Set[str] = set()
        for database in self.handle.get_syncdbs():
            result.update({package.name for package in database.pkgcache})

        return list(result)
예제 #4
0
파일: pacman.py 프로젝트: arcan1s/ahriman
 def __init__(self, configuration: Configuration) -> None:
     """
     default constructor
     :param configuration: configuration instance
     """
     root = configuration.get("alpm", "root")
     pacman_root = configuration.getpath("alpm", "database")
     self.handle = Handle(root, str(pacman_root))
     for repository in configuration.getlist("alpm", "repositories"):
         self.handle.register_syncdb(repository, 0)  # 0 is pgp_level
예제 #5
0
def download_package(package, arch='x86_64'):
    global makechrootpkg_args

    dbpath = f'/var/lib/archbuild/extra-{arch}/root/var/lib/pacman/'
    gpgpath = f'/var/lib/archbuild/extra-{arch}/root/etc/pacman.d/gnupg'
    mirror = 'https://mirrors.tuna.tsinghua.edu.cn/archlinux'
    handle = Handle('/', dbpath)
    for i in ['core', 'extra', 'community']:
        repo = handle.register_syncdb(i, 0)

    for repo in handle.get_syncdbs():
        result = repo.get_pkg(package)
        if result:
            if arch == 'x86_64':
                url = f'{mirror}/{repo.name}/os/{arch}/{result.filename}'
            makechrootpkg_args += ['-I', 'tmp/' + result.filename]
            break

    run_cmd(['wget', '-nc', '-P', 'tmp', url, url + '.sig'])
    run_cmd([
        'gpg', '--homedir', gpgpath, '--verify',
        'tmp/' + result.filename + '.sig', 'tmp/' + result.filename
    ])
예제 #6
0
파일: conftest.py 프로젝트: lilydjwg/pyalpm
def handle():
    return Handle('/', '/tmp')
예제 #7
0
async def open_db(info):
    dbpath, repo = info
    handle = Handle('/', dbpath)
    db = handle.register_syncdb(repo, 0)
    return handle, db
예제 #8
0
#!/usr/bin/env python3
from lilaclib import *

from pyalpm import Handle
arch = 'x86_64'
package = 'glfw-wayland'
dbpath = '/var/lib/archbuild/extra-x86_64/root/var/lib/pacman/'
gpgpath = '/var/lib/archbuild/extra-x86_64/root/etc/pacman.d/gnupg'
mirror = 'https://mirrors.tuna.tsinghua.edu.cn/archlinux'
handle = Handle('/', dbpath)
for i in ['core', 'extra', 'community']:
    repo = handle.register_syncdb(i, 0)
for repo in handle.get_syncdbs():
    result = repo.get_pkg(package)
    if result:
        url = f'{mirror}/{repo.name}/os/{arch}/{result.filename}'
        break

repo_depends = [
    'mumps-par', 'oce', 'hypre', 'mmg', 'libnn-git', 'libcsa-git', 'scalapack'
]
build_prefix = 'extra-x86_64'
time_limit_hours = 8
makechrootpkg_args = ['-I', 'tmp/' + result.filename]


def pre_build():
    vcs_update()

    run_cmd(['wget', '-nc', url, url + '.sig'])
    run_cmd([
예제 #9
0
ignore.append('liblief')  # already provided by lief
ignore.append('libllvm9')  # let pacman choose llvm automatically
ignore.append('libstdcxx-ng')  # already provided by gcc-libs
ignore.append('navigator-updater')  # anaconda related
ignore.append('prompt_toolkit')  # already provided by python-prompt_toolkit
ignore.append('simplegeneric')  # already provided by ipython
ignore.append('singledispatch')  # not needed for python3
ignore.append('sphinxcontrib')  # empty
ignore.append('unicodecsv')  # not needed for python3
ignore.append('zope')  # empty

from pyalpm import Handle
arch = 'x86_64'
package = 'jre8-openjdk'
dbpath = '/var/lib/pacman/'
handle = Handle('/', dbpath)
for i in ['core', 'extra', 'community', 'arch4edu']:
    handle.register_syncdb(i, 0)


def check(package):

    for repo in handle.get_syncdbs():
        result = repo.get_pkg(package)
        if result:
            return result
    return None


lines = run_cmd(['pacman', '-Flq', 'anaconda'], silent=True).split('\n')
lines = [
예제 #10
0
from typing import Optional

import pyalpm
import requests
from loguru import logger
from pyalpm import Handle
from pydantic import BaseModel

from builder.arch.package_common import verdeps_dict, optdeps_dict
from builder.util.misc import listify

_alpm_handle = Handle('/', '/var/lib/pacman')
_repos = [
    _alpm_handle.register_syncdb('core', pyalpm.SIG_DATABASE_OPTIONAL),
    _alpm_handle.register_syncdb('community', pyalpm.SIG_DATABASE_OPTIONAL),
    _alpm_handle.register_syncdb('extra', pyalpm.SIG_DATABASE_OPTIONAL),
    _alpm_handle.register_syncdb('multilib', pyalpm.SIG_DATABASE_OPTIONAL)
]


class LocalPackage(BaseModel):
    """ Represents a local package from a repo (a "syncdb") """

    arch: str
    """ target architecture """

    backup: list[tuple[str, str]]
    """ list of tuples (filename, md5sum) """

    base: str
    """package base name"""
예제 #11
0
def get_syncdb():
    # Return syncdb, so handle should go out of scope
    handle = Handle('/', '/tmp/')
    repo = handle.register_syncdb(REPO_1, 0)
    repo.servers = [TEST_MIRROR.format(repo=REPO_1, arch=ARCH)]
    return handle.get_syncdbs()[0]
예제 #12
0
def register_syncdb():
    handle = Handle('/', '/tmp/')
    repo = handle.register_syncdb(REPO_1, 0)
    repo.servers = [TEST_MIRROR.format(repo=REPO_1, arch=ARCH)]
    return repo
예제 #13
0
def get_localdb():
    handle = Handle('/', '/tmp/')
    return handle.get_localdb()
예제 #14
0
import pyalpm
from pyalpm import Handle
# TODO (POSSIBLY): wrap all in a single function for a frontend to use instead (and allow for changing root dir)
handle = Handle("/", "/var/lib/pacman")

# Now some of the keen eyed amongst you may have noticed
# that this is an import statement right smack-dab in the
# middle of code. Why? Because circular imports. database.py
# (the file that's being imported) imports the handle variable
# from itself, but if this import statement were at the top,
# handle wouldn't be defined yet and we would have ciruclar
# imports. - Sophon96
from libtwirl.core.database import register_repos

# Register synced repositories automatically for now
# Preferred if a frontend does it themselves, see TODO below
# TODO: parse config to find repositories to register (or make the frontend handle it) instead of arbitrary repo list at end
# TODO: parse config and mirrorlist to find mirrors instead of arbitrary mirror
register_repos({
    "core": ["https://mirror.osbeck.com/archlinux/$repo/os/$arch"],
    "extra": ["https://mirror.osbeck.com/archlinux/$repo/os/$arch"],
    "community": ["https://mirror.osbeck.com/archlinux/$repo/os/$arch"]
})
예제 #15
0
파일: __init__.py 프로젝트: mugman174/Twirl
import pyalpm
from pyalpm import Handle

handle = Handle("/", "/var/lib/pacman")
localdb = handle.get_localdb()
coredb = handle.register_syncdb("core", pyalpm.SIG_DATABASE_OPTIONAL)