mirror of
https://github.com/lilydjwg/nvchecker
synced 2024-12-24 23:52:40 +00:00
Support source package too
This commit is contained in:
parent
819a8461a4
commit
b620ed4e90
@ -618,8 +618,11 @@ Check APT repository
|
||||
|
||||
This enables you to track the update of an arbitary APT repository, without needing of apt and an updated local APT database.
|
||||
|
||||
apt
|
||||
Name of the APT package.
|
||||
pkg
|
||||
Name of the APT binary package.
|
||||
|
||||
source_pkg
|
||||
Name of the APT source package.
|
||||
|
||||
mirror
|
||||
URL of the repository (defaults to http://deb.debian.org/debian/)
|
||||
@ -636,6 +639,8 @@ arch
|
||||
strip_release
|
||||
Strip the release part.
|
||||
|
||||
Note that either pkg or source_pkg needs to be specified (but not both) or the item name will be used as package.
|
||||
|
||||
Manually updating
|
||||
~~~~~~~~~~~~~~~~~
|
||||
::
|
||||
|
@ -22,13 +22,19 @@ async def get_url(url):
|
||||
return data.decode('utf-8')
|
||||
|
||||
async def get_version(name, conf, *, cache, **kwargs):
|
||||
pkg = conf.get('apt') or name
|
||||
source_pkg = conf.get('source_pkg')
|
||||
pkg = conf.get('pkg')
|
||||
mirror = conf.get('mirror', "http://deb.debian.org/debian/")
|
||||
suite = conf.get('suite', 'sid')
|
||||
repo = conf.get('repo', 'main')
|
||||
arch = conf.get('arch', 'amd64')
|
||||
strip_release = conf.get('strip_release', False)
|
||||
|
||||
if source_pkg and pkg:
|
||||
raise GetVersionError('Setting both source_pkg and pkg is ambigious')
|
||||
elif not source_pkg and not pkg:
|
||||
pkg = name
|
||||
|
||||
apt_release = await cache.get(APT_RELEASE_URL % (mirror, suite), get_url)
|
||||
for suffix in APT_PACKAGES_SUFFIX_PREFER:
|
||||
packages_path = APT_PACKAGES_PATH % (repo, arch, suffix)
|
||||
@ -41,7 +47,9 @@ async def get_version(name, conf, *, cache, **kwargs):
|
||||
|
||||
pkg_found = False
|
||||
for line in apt_packages.split("\n"):
|
||||
if line == "Package: " + pkg:
|
||||
if pkg and line == "Package: " + pkg:
|
||||
pkg_found = True
|
||||
if source_pkg and line == "Source: " + source_pkg:
|
||||
pkg_found = True
|
||||
if pkg_found and line.startswith("Version: "):
|
||||
version = line[9:]
|
||||
|
@ -12,6 +12,13 @@ async def test_apt(get_version):
|
||||
"source": "apt",
|
||||
}) == "0.1.7-1"
|
||||
|
||||
@flaky(max_runs=10)
|
||||
async def test_apt_source_pkg(get_version):
|
||||
assert await get_version("test", {
|
||||
"source": "apt",
|
||||
"source_pkg": "golang-github-dataence-porter2",
|
||||
}) == "0.0~git20150829.56e4718-2"
|
||||
|
||||
@flaky(max_runs=10)
|
||||
async def test_apt_strip_release(get_version):
|
||||
assert await get_version("sigrok-firmware-fx2lafw", {
|
||||
|
Loading…
Reference in New Issue
Block a user