diff --git a/test/test_upstream_compatibility.py b/test/test_upstream_compatibility.py index 05fb2c52..47b4f202 100644 --- a/test/test_upstream_compatibility.py +++ b/test/test_upstream_compatibility.py @@ -74,3 +74,51 @@ def test_qt_versions(args): pkgver_upstream) assert [] == failed + + +def test_aportgen_versions(args): + """ + Verify that the packages generated by 'pmbootstrap aportgen' have + the same version (pkgver *and* pkgrel!) as the upstream packages + they are based on. + """ + + # Get Alpine's "main" repository APKINDEX path + pmb.helpers.repo.update(args) + repository = args.mirror_alpine + args.alpine_version + "/main" + hash = pmb.helpers.repo.hash(repository) + index_path = (args.work + "/cache_apk_armhf/APKINDEX." + hash + + ".tar.gz") + + # Alpine packages and patterns for our derivatives + map = {"binutils": "binutils-*", + "busybox": "busybox-static-*", + "gcc": "gcc-*", + "musl": "musl-*"} + + # Iterate over Alpine packages + failed = [] + generated = "# Automatically generated aport, do not edit!" + for pkgname, pattern in map.items(): + # Upstream version + index_data = pmb.parse.apkindex.read(args, pkgname, index_path) + version_upstream = index_data["version"] + + # Iterate over our packages + for path in glob.glob(args.aports + "/*/" + pattern + "/APKBUILD"): + # Skip non-aportgen APKBUILDs + with open(path) as handle: + if generated not in handle.read(): + continue + + # Compare the version + print("Checking " + path) + apkbuild = pmb.parse.apkbuild(args, path) + version = apkbuild["pkgver"] + "-r" + apkbuild["pkgrel"] + if version != version_upstream: + failed.append(apkbuild["pkgname"] + ": " + version + + " != " + version_upstream + + " (from " + pkgname + ")") + continue + + assert [] == failed