summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--depver_test.py17
-rw-r--r--pkgver_test.py37
2 files changed, 36 insertions, 18 deletions
diff --git a/depver_test.py b/depver_test.py
index 3dcf596..5e25c39 100644
--- a/depver_test.py
+++ b/depver_test.py
@@ -31,7 +31,7 @@ def atomize(spec):
# Not reached
assert False
-def analyze(url, repos, arch):
+def analyze(opts, arch):
pkgs = collections.defaultdict(dict)
newest = {}
providers = collections.defaultdict(list)
@@ -39,8 +39,9 @@ def analyze(url, repos, arch):
print("Loading " + arch + "...", file=sys.stderr)
index = []
- for repo in repos:
- index.extend(Index(url=url + f"/{repo}/{arch}/APKINDEX.tar.gz").packages)
+ for repo in opts.repos:
+ url = f"{opts.url}/{repo}/{arch}/APKINDEX.tar.gz"
+ index.extend(Index(url=url).packages)
for pkg in index:
new = pkg.version
@@ -69,7 +70,6 @@ def analyze(url, repos, arch):
providers[i].append((pkg.name, pver))
yield ["arch", "package", "version", "issue"]
-
for name in sorted(pkgs.keys()):
# DON'T use newest[] here. It is possible that a package
# provides= another package's name with a newer version
@@ -96,6 +96,9 @@ def analyze(url, repos, arch):
else:
yield [arch, name, ver, No(f"Missing {spec}")]
+ if opts.only_missing:
+ continue
+
for _, pver in providers[dep]:
if is_same(pver, newest[dep]):
break
@@ -119,6 +122,10 @@ if __name__ == "__main__":
help="display format",
)
opts.add_argument(
+ "-m", "--only-missing", action="store_true",
+ help="show only missing dependencies",
+ )
+ opts.add_argument(
"url", metavar="URL",
help="base URL (no repository or arch)",
)
@@ -138,5 +145,5 @@ if __name__ == "__main__":
# FIXME: with html, wrapping will repeat for > 1 arch
FORMATTERS[opts.format](
opts,
- analyze(opts.url, opts.repos, arch),
+ analyze(opts, arch),
)
diff --git a/pkgver_test.py b/pkgver_test.py
index 9566908..ac96824 100644
--- a/pkgver_test.py
+++ b/pkgver_test.py
@@ -15,14 +15,15 @@ from apkkit.base.index import Index
from output import FORMATTERS, Yes, No, YES_MISSING, PARTIAL_MISSING
from version import is_older
-def analyze(url, repo, arches):
+def analyze(opts):
newest = dict()
- arch_newest = {arch: dict() for arch in arches}
+ arch_newest = {arch: dict() for arch in opts.arches}
- for arch in arches:
+ for arch in opts.arches:
print(f"Loading {arch}...", file=sys.stderr)
- for pkg in Index(url=f"{url}/{repo}/{arch}/APKINDEX.tar.gz").packages:
+ url = f"{opts.url}/{opts.repo}/{arch}/APKINDEX.tar.gz"
+ for pkg in Index(url=url).packages:
if pkg.name != pkg.origin:
continue
new = pkg.version
@@ -36,10 +37,11 @@ def analyze(url, repo, arches):
return newest, arch_newest
-def order_arch(arches, newest, arch_newest, ign):
- yield ["arch", "package", "version for arch", "newest version"]
+def order_arch(opts, ign):
+ newest, arch_newest = analyze(opts)
- for arch in arches:
+ yield ["arch", "package", "version for arch", "newest version"]
+ for arch in opts.arches:
old = list()
for pkg in newest.keys():
@@ -50,23 +52,29 @@ def order_arch(arches, newest, arch_newest, ign):
yield [arch, pkg, PARTIAL_MISSING, ver]
elif archver is not None and is_older(archver, ver):
+ if opts.only_missing:
+ continue
+
yield [arch, pkg, archver, ver]
-def order_pkg(arches, newest, arch_newest, ign):
- yield ["package", *arches]
+def order_pkg(opts, ign):
+ newest, arch_newest = analyze(opts)
+ yield ["package", *opts.arches]
for pkg in sorted(newest.keys()):
- for i in arches:
+ for i in opts.arches:
archver = arch_newest[i].get(pkg, None)
if archver is None:
break
+ if opts.only_missing:
+ continue
if archver is not None and is_older(archver, newest[pkg]):
break
else:
continue
row = [pkg]
- for i in arches:
+ for i in opts.arches:
archver = arch_newest[i].get(pkg, None)
if archver is None and pkg in ign:
row.append(YES_MISSING)
@@ -100,6 +108,10 @@ if __name__ == "__main__":
help="display format",
)
opts.add_argument(
+ "-m", "--only-missing", action="store_true",
+ help="show only missing packages",
+ )
+ opts.add_argument(
"-o", "--order", choices=ORDERS.keys(),
default="pkg",
help="display order",
@@ -129,9 +141,8 @@ if __name__ == "__main__":
else:
ign = set()
- newest, arch_newest = analyze(opts.url, opts.repo, opts.arches)
# FIXME: support multiple repos
FORMATTERS[opts.format](
opts,
- ORDERS[opts.order](opts.arches, newest, arch_newest, ign),
+ ORDERS[opts.order](opts, ign),
)