alpm: make `repo` option optional
This commit is contained in:
parent
11aea624e6
commit
494c4ddf67
|
@ -814,10 +814,10 @@ alpm
|
|||
Name of the package.
|
||||
|
||||
repo
|
||||
Name of the package repository in which the package resides.
|
||||
Name of the package repository in which the package resides. If not provided, nvchecker will search ``core``, ``extra``, ``community`` and ``multilib``, in that order.
|
||||
|
||||
dbpath
|
||||
Path to the ALPM database directory. Default: ``/var/lib/pacman``.
|
||||
Path to the ALPM database directory. Default: ``/var/lib/pacman``. You need to update the database yourself.
|
||||
|
||||
strip_release
|
||||
Strip the release part, only return the part before ``-``.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# MIT licensed
|
||||
# Copyright (c) 2020 DDoSolitary <DDoSolitary@gmail.com>, et al.
|
||||
# Copyright (c) 2020-2021 DDoSolitary <DDoSolitary@gmail.com>, et al.
|
||||
|
||||
from nvchecker.api import GetVersionError
|
||||
from pyalpm import Handle
|
||||
|
@ -15,11 +15,21 @@ async def open_db(info):
|
|||
async def get_version(name, conf, *, cache, **kwargs):
|
||||
pkgname = conf.get('alpm', name)
|
||||
dbpath = conf.get('dbpath', '/var/lib/pacman')
|
||||
repo = conf['repo']
|
||||
strip_release = conf.get('strip_release', False)
|
||||
provided = conf.get('provided')
|
||||
|
||||
repo = conf.get('repo')
|
||||
if repo is None:
|
||||
repos = ['core', 'extra', 'community', 'multilib']
|
||||
else:
|
||||
repos = [repo]
|
||||
|
||||
for repo in repos:
|
||||
db = (await cache.get((dbpath, repo), open_db))[1]
|
||||
pkg = db.get_pkg(pkgname)
|
||||
if pkg is not None:
|
||||
break
|
||||
|
||||
if pkg is None:
|
||||
raise GetVersionError('package not found in the ALPM database')
|
||||
if provided is None:
|
||||
|
|
Loading…
Reference in New Issue