- Update to version 1681202780.6d8bb3c:

* Run unit & install test only for the system python
  * Add python 3.11 tox environment
  * Switch to using rpm.labelCompare instead of parse_version
  * Fix copyright strings
  * Fix test_find_package_version
  * Bump mock from 4.0.3 to 5.0.1
  * Bump pytest-xdist from 2.5.0 to 3.0.2
  * Bump tox from 3.25.1 to 3.28.0
  * Bump Gr1N/setup-poetry from 7 to 8
  * Bump pytest-container from 0.0.2 to 0.1.1
  * Bump actions/setup-python from 4.3.0 to 4.5.0

OBS-URL: https://build.opensuse.org/package/show/Virtualization:containers/obs-service-replace_using_package_version?expand=0&rev=18
This commit is contained in:
David Cassany 2023-04-11 10:19:59 +00:00 committed by Git OBS Bridge
parent 51cc6c8f52
commit 9ea162b06e
4 changed files with 29 additions and 13 deletions

View File

@ -1,4 +1,4 @@
<servicedata> <servicedata>
<service name="tar_scm"> <service name="tar_scm">
<param name="url">https://github.com/openSUSE/obs-service-replace_using_package_version.git</param> <param name="url">https://github.com/openSUSE/obs-service-replace_using_package_version.git</param>
<param name="changesrevision">6dcaef0f89b089ac6f83200ce25c0d907e45111a</param></service></servicedata> <param name="changesrevision">eb96e8582f54b9e2c5c5259e379ced1e79cd642d</param></service></servicedata>

View File

@ -1,3 +1,19 @@
-------------------------------------------------------------------
Tue Apr 11 10:19:11 UTC 2023 - containers@suse.com
- Update to version 1681202780.6d8bb3c:
* Run unit & install test only for the system python
* Add python 3.11 tox environment
* Switch to using rpm.labelCompare instead of parse_version
* Fix copyright strings
* Fix test_find_package_version
* Bump mock from 4.0.3 to 5.0.1
* Bump pytest-xdist from 2.5.0 to 3.0.2
* Bump tox from 3.25.1 to 3.28.0
* Bump Gr1N/setup-poetry from 7 to 8
* Bump pytest-container from 0.0.2 to 0.1.1
* Bump actions/setup-python from 4.3.0 to 4.5.0
------------------------------------------------------------------- -------------------------------------------------------------------
Thu Mar 30 07:25:53 UTC 2023 - containers@suse.com Thu Mar 30 07:25:53 UTC 2023 - containers@suse.com

View File

@ -30,7 +30,7 @@ Source1: %{service}.service
Source2: LICENSE Source2: LICENSE
BuildRequires: sed BuildRequires: sed
Requires: python3-docopt Requires: python3-docopt
Requires: python3-setuptools Requires: python3-rpm
BuildRoot: %{_tmppath}/%{name}-%{version}-build BuildRoot: %{_tmppath}/%{name}-%{version}-build
BuildArch: noarch BuildArch: noarch

View File

@ -1,7 +1,7 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# #
# Copyright (c) 2018 SUSE Linux GmbH. All rights reserved. # SPDX-FileCopyrightText: (c) 2023 SUSE LLC
# #
# This file is part of obs-service-replace_using_package_version. # This file is part of obs-service-replace_using_package_version.
# #
@ -49,7 +49,7 @@ import docopt
import re import re
import os import os
import subprocess import subprocess
from pkg_resources import parse_version from rpm import labelCompare
from typing import List from typing import List
version_regex = { version_regex = {
@ -185,7 +185,7 @@ def find_package_version_in_local_repos(repo_path, package):
rpm_file = os.path.join(root, pkg) rpm_file = os.path.join(root, pkg)
if get_pkg_name_from_rpm(rpm_file) == package: if get_pkg_name_from_rpm(rpm_file) == package:
rpm_ver = get_pkg_version_from_rpm(rpm_file) rpm_ver = get_pkg_version_from_rpm(rpm_file)
if version is None or rpm_ver >= version: if version is None or labelCompare(rpm_ver, version) >= 0:
version = rpm_ver version = rpm_ver
return version return version
@ -195,7 +195,7 @@ def find_package_version_in_obsinfo(path, package):
for f in os.listdir(path): for f in os.listdir(path):
if f.endswith('obsinfo') and package in f: if f.endswith('obsinfo') and package in f:
obsinfo_ver = get_pkg_version_from_obsinfo(f) obsinfo_ver = get_pkg_version_from_obsinfo(f)
if version is None or obsinfo_ver >= version: if version is None or labelCompare(obsinfo_ver, version) >= 0:
version = obsinfo_ver version = obsinfo_ver
return version return version
@ -212,35 +212,35 @@ def run_command(command: List[str]) -> str:
return subprocess.check_output(command).decode() return subprocess.check_output(command).decode()
def get_pkg_version_from_obsinfo(obsinfo_file): def get_pkg_version_from_obsinfo(obsinfo_file: str) -> Optional[str]:
regex = re.compile(obsinfo_regex) regex = re.compile(obsinfo_regex)
with open(obsinfo_file) as f: with open(obsinfo_file) as f:
for line in f: for line in f:
match = regex.match(line) match = regex.match(line)
if match: if match:
return parse_version(match[1]) return match[1]
return None return None
def get_pkg_name_from_rpm(rpm_file): def get_pkg_name_from_rpm(rpm_file: str) -> str:
command = [ command = [
'rpm', '-qp', '--queryformat', '%{NAME}', rpm_file 'rpm', '-qp', '--queryformat', '%{NAME}', rpm_file
] ]
return run_command(command) return run_command(command)
def get_pkg_version_from_rpm(rpm_file): def get_pkg_version_from_rpm(rpm_file: str) -> str:
command = [ command = [
'rpm', '-qp', '--queryformat', '%{VERSION}', rpm_file 'rpm', '-qp', '--queryformat', '%{VERSION}', rpm_file
] ]
return parse_version(run_command(command)) return run_command(command)
def get_pkg_version(package): def get_pkg_version(package: str) -> str:
command = [ command = [
'rpm', '-q', '--queryformat', '%{VERSION}', package 'rpm', '-q', '--queryformat', '%{VERSION}', package
] ]
return parse_version(run_command(command)) return run_command(command)
def init(__name__): def init(__name__):