summaryrefslogtreecommitdiff
path: root/pkgver_test.py
diff options
context:
space:
mode:
Diffstat (limited to 'pkgver_test.py')
-rw-r--r--pkgver_test.py114
1 files changed, 62 insertions, 52 deletions
diff --git a/pkgver_test.py b/pkgver_test.py
index ac96824..0a39f90 100644
--- a/pkgver_test.py
+++ b/pkgver_test.py
@@ -15,14 +15,14 @@ from apkkit.base.index import Index
from output import FORMATTERS, Yes, No, YES_MISSING, PARTIAL_MISSING
from version import is_older
-def analyze(opts):
+def analyze(opts, repo):
newest = dict()
arch_newest = {arch: dict() for arch in opts.arches}
for arch in opts.arches:
- print(f"Loading {arch}...", file=sys.stderr)
+ print(f"Loading {repo}/{arch}...", file=sys.stderr)
- url = f"{opts.url}/{opts.repo}/{arch}/APKINDEX.tar.gz"
+ url = f"{opts.url}/{repo}/{arch}/APKINDEX.tar.gz"
for pkg in Index(url=url).packages:
if pkg.name != pkg.origin:
continue
@@ -37,55 +37,71 @@ def analyze(opts):
return newest, arch_newest
-def order_arch(opts, ign):
- newest, arch_newest = analyze(opts)
+def order_arch(opts):
+ yield ["repo", "arch", "package", "version for arch", "newest version"]
- yield ["arch", "package", "version for arch", "newest version"]
- for arch in opts.arches:
- old = list()
+ for repo in opts.repos:
+ if Path(repo + "-specific").is_file():
+ with open(repo + '-specific', 'r') as ignore_file:
+ ign = set(pkg[:-1] for pkg in ignore_file.readlines())
+ else:
+ ign = set()
- for pkg in newest.keys():
- ver = newest[pkg]
- archver = arch_newest[arch].get(pkg, None)
+ newest, arch_newest = analyze(opts, repo)
- if archver is None and pkg not in ign:
- yield [arch, pkg, PARTIAL_MISSING, ver]
+ for arch in opts.arches:
+ old = list()
- elif archver is not None and is_older(archver, ver):
- if opts.only_missing:
- continue
+ for pkg in newest.keys():
+ ver = newest[pkg]
+ archver = arch_newest[arch].get(pkg, None)
- yield [arch, pkg, archver, ver]
+ if archver is None and pkg not in ign:
+ yield [repo, arch, pkg, PARTIAL_MISSING, ver]
-def order_pkg(opts, ign):
- newest, arch_newest = analyze(opts)
+ elif archver is not None and is_older(archver, ver):
+ if opts.only_missing:
+ continue
- yield ["package", *opts.arches]
- for pkg in sorted(newest.keys()):
- 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
+ yield [repo, arch, pkg, archver, ver]
+
+def order_pkg(opts):
+ yield ["repo", "package", *opts.arches]
+
+ for repo in opts.repos:
+ if Path(repo + "-specific").is_file():
+ with open(repo + '-specific', 'r') as ignore_file:
+ ign = set(pkg[:-1] for pkg in ignore_file.readlines())
else:
- continue
-
- row = [pkg]
- for i in opts.arches:
- archver = arch_newest[i].get(pkg, None)
- if archver is None and pkg in ign:
- row.append(YES_MISSING)
- elif archver is None:
- row.append(PARTIAL_MISSING)
- elif is_older(archver, newest[pkg]):
- row.append(No(archver))
+ ign = set()
+
+ newest, arch_newest = analyze(opts, repo)
+
+ for pkg in sorted(newest.keys()):
+ 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:
- row.append(Yes(archver))
+ continue
+
+ row = [repo, pkg]
+ for i in opts.arches:
+ archver = arch_newest[i].get(pkg, None)
+ if archver is None and pkg in ign:
+ row.append(YES_MISSING)
+ elif archver is None:
+ row.append(PARTIAL_MISSING)
+ elif is_older(archver, newest[pkg]):
+ row.append(No(archver))
+ else:
+ row.append(Yes(archver))
- yield row
+ yield row
ORDERS = {
"pkg": order_pkg,
@@ -121,28 +137,22 @@ if __name__ == "__main__":
help="base URL (no repository or arch)",
)
opts.add_argument(
- "repo", metavar="REPO",
- help="repository",
+ "repos", metavar="REPOS",
+ help="repositories (comma separated)",
)
opts.add_argument(
"arches", metavar="ARCHES",
help="architectures (comma separated, at least 2)",
)
opts = opts.parse_args()
+ opts.repos = opts.repos.split(",")
opts.arches = opts.arches.split(",")
if len(opts.arches) < 2:
print("At least two arches are required", file=sys.stderr)
sys.exit(1)
- if Path(opts.repo + "-specific").is_file():
- with open(opts.repo + '-specific', 'r') as ignore_file:
- ign = set(pkg[:-1] for pkg in ignore_file.readlines())
- else:
- ign = set()
-
- # FIXME: support multiple repos
FORMATTERS[opts.format](
opts,
- ORDERS[opts.order](opts, ign),
+ ORDERS[opts.order](opts),
)