2018-08-30 22:39:24 +00:00
|
|
|
#!/usr/bin/env python3
|
2021-01-07 23:16:08 +00:00
|
|
|
# Copyright 2021 Oliver Smith
|
2018-08-30 22:39:24 +00:00
|
|
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
2018-12-29 16:59:32 +00:00
|
|
|
""" Make sure that components of frameworks (Qt, KDE, ...) have the same
|
|
|
|
version in all packages. We scan all packages, categorize them by URL
|
|
|
|
and then compare the versions of all packages in each category. """
|
|
|
|
|
2018-08-30 22:39:24 +00:00
|
|
|
import glob
|
|
|
|
import logging
|
|
|
|
import os
|
|
|
|
import pytest
|
|
|
|
import sys
|
|
|
|
|
|
|
|
import add_pmbootstrap_to_import_path
|
|
|
|
import pmb.config
|
|
|
|
import pmb.parse
|
|
|
|
|
|
|
|
|
2018-12-29 16:59:32 +00:00
|
|
|
def get_categorized_packages(args):
|
2018-08-30 22:39:24 +00:00
|
|
|
"""
|
2018-12-29 16:59:32 +00:00
|
|
|
Parse all aports and categorize them.
|
2018-08-30 22:39:24 +00:00
|
|
|
|
|
|
|
:returns: {"plasma": {"kwin": "5.13.3", ...},
|
|
|
|
"kde": {"kcrash": "5.48.0", ...},
|
2018-12-29 16:59:32 +00:00
|
|
|
"qt": {"qt5-qtbase": "5.12.0", ...},
|
2018-08-30 22:39:24 +00:00
|
|
|
"other": {"konsole": "1234", ...}}
|
|
|
|
"""
|
2018-12-29 16:59:32 +00:00
|
|
|
ret = {}
|
2018-08-30 22:39:24 +00:00
|
|
|
|
2018-12-29 16:59:32 +00:00
|
|
|
for path in glob.glob(args.aports + "/*/*/APKBUILD"):
|
2018-08-30 22:39:24 +00:00
|
|
|
# Parse APKBUILD
|
|
|
|
apkbuild = pmb.parse.apkbuild(args, path)
|
|
|
|
url = apkbuild["url"]
|
|
|
|
pkgname = apkbuild["pkgname"]
|
|
|
|
pkgver = apkbuild["pkgver"]
|
2018-12-29 16:59:32 +00:00
|
|
|
if pkgver == "9999":
|
|
|
|
pkgver = apkbuild["_pkgver"]
|
2018-08-30 22:39:24 +00:00
|
|
|
|
2019-11-30 14:12:10 +00:00
|
|
|
if "_git" in pkgver:
|
|
|
|
continue
|
|
|
|
|
2018-08-30 22:39:24 +00:00
|
|
|
# Categorize by URL
|
|
|
|
category = "other"
|
|
|
|
if "https://www.kde.org/workspaces/plasmadesktop" in url:
|
|
|
|
category = "plasma"
|
|
|
|
elif "https://community.kde.org/Frameworks" in url:
|
|
|
|
category = "kde"
|
2018-12-29 16:59:32 +00:00
|
|
|
elif url in ["http://qt-project.org/",
|
|
|
|
"https://www.qt.io/developers/"]:
|
|
|
|
category = "qt"
|
2018-08-30 22:39:24 +00:00
|
|
|
|
2019-09-29 18:36:50 +00:00
|
|
|
# Remove hotfix number (i.e. 5.16.90.1 becomes 5.16.90)
|
|
|
|
if category in ["kde", "plasma"]:
|
|
|
|
pkgver = ".".join(pkgver.split(".")[0:3])
|
|
|
|
|
2018-08-30 22:39:24 +00:00
|
|
|
# Save result
|
2018-12-29 16:59:32 +00:00
|
|
|
if category not in ret:
|
|
|
|
ret[category] = {}
|
2018-08-30 22:39:24 +00:00
|
|
|
ret[category][pkgname] = pkgver
|
|
|
|
return ret
|
|
|
|
|
|
|
|
|
|
|
|
def check_categories(categories):
|
|
|
|
"""
|
2018-12-29 16:59:32 +00:00
|
|
|
Make sure that all packages in one framework (kde, plasma, ...) have the
|
|
|
|
same package version (and that there is at least one package in each
|
|
|
|
category).
|
2018-08-30 22:39:24 +00:00
|
|
|
|
2018-12-29 16:59:32 +00:00
|
|
|
:param categories: see return of get_categorized_packages()
|
2018-08-30 22:39:24 +00:00
|
|
|
:returns: True when the check passed, False otherwise
|
|
|
|
"""
|
|
|
|
ret = True
|
|
|
|
for category, packages in categories.items():
|
|
|
|
reference = None
|
|
|
|
for pkgname, pkgver in packages.items():
|
|
|
|
|
|
|
|
# Use the first package as reference and print a summary
|
|
|
|
if not reference:
|
|
|
|
logging.info("---")
|
2018-12-29 16:59:32 +00:00
|
|
|
logging.info("Package category: " + category)
|
|
|
|
logging.info("Packages count: " + str(len(packages)))
|
2018-08-30 22:39:24 +00:00
|
|
|
|
2018-12-29 16:59:32 +00:00
|
|
|
# Category "other": done after printing the basic summary, no
|
|
|
|
# need to print each package or compare the package versions
|
2018-08-30 22:39:24 +00:00
|
|
|
if category == "other":
|
2018-12-29 16:59:32 +00:00
|
|
|
reference = True
|
2018-08-30 22:39:24 +00:00
|
|
|
break
|
|
|
|
|
2018-12-29 16:59:32 +00:00
|
|
|
# Print all packages
|
|
|
|
logging.info("Packages: " + ", ".join(sorted(packages.keys())))
|
|
|
|
|
2018-08-30 22:39:24 +00:00
|
|
|
# Print the reference and skip checking it against itself
|
2018-12-29 16:59:32 +00:00
|
|
|
reference = {"pkgname": pkgname, "pkgver": pkgver}
|
2018-08-30 22:39:24 +00:00
|
|
|
logging.info("Reference pkgver: " + pkgver + " (from '" +
|
|
|
|
pkgname + "')")
|
|
|
|
continue
|
|
|
|
|
|
|
|
# Check version against reference
|
|
|
|
if pkgver != reference["pkgver"]:
|
|
|
|
logging.info("ERROR: " + pkgname + " has version " + pkgver)
|
|
|
|
ret = False
|
|
|
|
|
|
|
|
# Each category must at least have one package
|
|
|
|
if not reference:
|
|
|
|
logging.info("ERROR: could not find any packages in category: " +
|
|
|
|
category)
|
|
|
|
ret = False
|
|
|
|
return ret
|
|
|
|
|
|
|
|
|
2018-12-29 16:59:32 +00:00
|
|
|
def test_framework_versions(args):
|
2018-08-30 22:39:24 +00:00
|
|
|
"""
|
2018-12-29 16:59:32 +00:00
|
|
|
Make sure that packages of the same framework have the same version.
|
2018-08-30 22:39:24 +00:00
|
|
|
"""
|
2018-12-29 16:59:32 +00:00
|
|
|
categories = get_categorized_packages(args)
|
2018-08-30 22:39:24 +00:00
|
|
|
if not check_categories(categories):
|
2018-12-29 16:59:32 +00:00
|
|
|
raise RuntimeError("Framework version check failed!")
|