From 6ff8c38aa47d417e9af5c6bf30358f077e9d3eae Mon Sep 17 00:00:00 2001 From: Luca Weiss <luca@lucaweiss.eu> Date: Wed, 16 Oct 2024 23:02:26 +0200 Subject: [PATCH] test_upstream_compat: update for pmb v3 (MR 14) Update the testcases to use the new pmb v3 API. --- test_upstream_compat.py | 44 ++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 23 deletions(-) diff --git a/test_upstream_compat.py b/test_upstream_compat.py index d5351dd..7ffd10c 100644 --- a/test_upstream_compat.py +++ b/test_upstream_compat.py @@ -3,42 +3,40 @@ # SPDX-License-Identifier: GPL-3.0-or-later import sys -import glob import os -import pytest import pmb.helpers.logging import pmb.parse.apkindex import pmb.parse +from pmb.core.context import get_context +from pmb.core.pkgrepo import pkgrepo_iglob -@pytest.fixture -def args(request): +def setup_module(module): # Initialize args sys.argv = ["pmbootstrap", "--aports", os.environ["PMAPORTS"], "chroot"] args = pmb.parse.arguments() + context = get_context() # Initialize logging - pmb.helpers.logging.init(args) - request.addfinalizer(pmb.helpers.logging.logfd.close) - return args + pmb.helpers.logging.init(context.log, args.verbose, context.details_to_stdout) -def test_qt_versions(args): +def test_qt_versions(): """ Verify, that all postmarketOS qt5- package versions match with Alpine's qt5-qtbase version. """ # Upstream version - index = pmb.helpers.repo.alpine_apkindex_path(args, "community", "x86_64") - index_data = pmb.parse.apkindex.package(args, "qt5-qtbase", indexes=[index]) - pkgver_upstream = index_data["version"].split("-r")[0] + index = pmb.helpers.repo.alpine_apkindex_path("community", "x86_64") + index_data = pmb.parse.apkindex.package("qt5-qtbase", indexes=[index]) + pkgver_upstream = index_data.version.split("-r")[0] # Iterate over our packages failed = [] - for path in glob.glob(args.aports + "/*/qt5-*/APKBUILD"): + for package in pkgrepo_iglob("*/qt5-*/APKBUILD"): # Read the pkgver - apkbuild = pmb.parse.apkbuild(path) + apkbuild = pmb.parse.apkbuild(package) pkgname = apkbuild["pkgname"] pkgver = apkbuild["pkgver"] @@ -60,14 +58,14 @@ def test_qt_versions(args): assert [] == failed -def test_aportgen_versions(args): +def test_aportgen_versions(): """ 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 - index = pmb.helpers.repo.alpine_apkindex_path(args, "main", "x86_64") + index = pmb.helpers.repo.alpine_apkindex_path("main", "x86_64") # Alpine packages and patterns for our derivatives map = { @@ -83,19 +81,19 @@ def test_aportgen_versions(args): generated = "# Automatically generated aport, do not edit!" for pkgname, pattern in map.items(): # Upstream version - index_data = pmb.parse.apkindex.package(args, pkgname, indexes=[index]) - version_upstream = index_data["version"] + index_data = pmb.parse.apkindex.package(pkgname, indexes=[index]) + version_upstream = index_data.version # Iterate over our packages - for path in glob.glob(args.aports + "/*/" + pattern + "/APKBUILD"): + for package in pkgrepo_iglob(f"*/{pattern}/APKBUILD"): # Skip non-aportgen APKBUILDs - with open(path) as handle: + with open(package) as handle: if generated not in handle.read(): continue # Compare the version - print(f"Checking {path}") - apkbuild = pmb.parse.apkbuild(path) + print(f"Checking {package}") + apkbuild = pmb.parse.apkbuild(package) version = apkbuild["pkgver"] + "-r" + apkbuild["pkgrel"] if version != version_upstream: failed.append( @@ -106,12 +104,12 @@ def test_aportgen_versions(args): assert [] == failed -def test_soname_bump(args): +def test_soname_bump(): """Use pmb.helpers.pkgrel_bump to check if the pmaports need a pkgrel bump caused by a soname bump in Alpine. Example: a new openssl version was released, which increased the soname version, and now all packages that link against it, need to be rebuilt.""" - if pmb.helpers.pkgrel_bump.auto(args, True): + if pmb.helpers.pkgrel_bump.auto(True): raise RuntimeError( "One or more packages need to be rebuilt, because a library they link against had an" " incompatible upgrade (soname bump). Run 'pmbootstrap pkgrel_bump --auto' to" -- GitLab