Compare commits

1 Commits
1.1 ... main

5 changed files with 81 additions and 9 deletions

View File

@@ -1,5 +1,5 @@
<services>
<service name="obs_scm" mode="disabled">
<service name="obs_scm" mode="manual">
<param name="url">https://github.com/openSUSE/obs-service-replace_using_package_version.git</param>
<param name="scm">git</param>
<param name="filename">replace_using_package_version</param>
@@ -11,6 +11,6 @@
<param name="version">_none_</param>
<param name="changesgenerate">enable</param>
<param name="changesauthor">containers@suse.com</param>
<param name="revision">master</param>
<param name="revision">@PARENT_TAG@</param>
</service>
</services>

View File

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

View File

@@ -1,3 +1,45 @@
-------------------------------------------------------------------
Mon Oct 28 14:47:12 UTC 2024 - containers@suse.com
- Update to version 1730126702.6c2bf3a:
* Bump version: 0.0.10 → 0.0.11
* Fix shebang of service to /usr/bin/python3
* Bump version: 0.0.9 → 0.0.10
* Unrestrict dev dependencies
* Add support for replacing package versions by capability
* Bump actions/setup-python from 5.2.0 to 5.3.0
* Bump actions/setup-python from 5.1.1 to 5.2.0
* Bump actions/setup-python from 5.1.0 to 5.1.1
* Bump actions/setup-python from 5.0.0 to 5.1.0
* Bump Gr1N/setup-poetry from 8 to 9
* Bump actions/cache from 3 to 4
* Whitespace cleanup
* Add instructions to update new releases in OBS
* How to cut a new release
-------------------------------------------------------------------
Fri Jun 14 18:33:15 UTC 2024 - Matej Cepl <mcepl@cepl.eu>
- Fix shebang of the script to use the explicit version of Python
(bsc#1212476).
-------------------------------------------------------------------
Wed Dec 13 20:47:44 UTC 2023 - containers@suse.com
- Update to version 1702495728.72fe58b:
* Bump version: 0.0.8 → 0.0.9
* Bump actions/setup-python from 4.8.0 to 5.0.0
* Bump actions/setup-python from 4.7.1 to 4.8.0
* Workaround integration test failures due to PEP 668 marker
* Bump actions/setup-python from 4.6.1 to 4.7.1
* Bump actions/checkout from 3 to 4
* Report the package name that is missing (#56)
* Bump pytest-container from 0.1.1 to 0.2.0
* Drop mock dependency, stdlib has it
* Bump actions/setup-python from 4.6.0 to 4.6.1
* Bump actions/setup-python from 4.5.0 to 4.6.0
* Bump version: 0.0.7 → 0.0.8
-------------------------------------------------------------------
Tue Apr 11 10:19:11 UTC 2023 - containers@suse.com

View File

@@ -1,7 +1,7 @@
#
# spec file
# spec file for package obs-service-replace_using_package_version
#
# Copyright (c) 2023 SUSE LLC
# Copyright (c) 2024 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@@ -19,7 +19,7 @@
%define service replace_using_package_version
Name: obs-service-%{service}
Version: 0.0.7
Version: 0.0.11
Release: 0
Summary: An OBS service: Replaces a regex with the version value of a package
License: GPL-3.0-or-later
@@ -45,7 +45,7 @@ cp %{S:1} .
cp %{S:2} .
%build
sed -i "s|#!/usr/bin/env python3|#!/usr/bin/python3|g" %{service}.py
# intentionally blank - nothing to do
%install

View File

@@ -1,4 +1,4 @@
#!/usr/bin/env python3
#!/usr/bin/python3
# -*- coding: utf-8 -*-
#
# SPDX-FileCopyrightText: (c) 2023 SUSE LLC
@@ -171,7 +171,10 @@ def find_package_version(package, rpm_dir):
version = find_package_version_in_obsinfo('.', package)
if version is None:
raise Exception('Package version not found')
version = find_package_version_by_capability(rpm_dir, package)
if version is None:
raise Exception(f'Package {package} version not found')
return str(version)
@@ -190,6 +193,26 @@ def find_package_version_in_local_repos(repo_path, package):
return version
def find_package_version_by_capability(
repo_path: str, capability: str
) -> Optional[str]:
"""Find the highest rpm package version of all packages in `repo_path` that
have a rpm provides containing the string `capability`.
"""
version = None
for root, _, files in os.walk(repo_path):
packages = [f for f in files if f.endswith('rpm')]
for pkg in packages:
rpm_file = os.path.join(root, pkg)
for provide in get_pkg_provides_from_rpm(rpm_file):
if capability in provide:
rpm_ver = get_pkg_version_from_rpm(rpm_file)
if version is None or labelCompare(rpm_ver, version) >= 0:
version = rpm_ver
return version
def find_package_version_in_obsinfo(path, package):
version = None
for f in os.listdir(path):
@@ -236,6 +259,13 @@ def get_pkg_version_from_rpm(rpm_file: str) -> str:
return run_command(command)
def get_pkg_provides_from_rpm(rpm_file: str) -> List[str]:
res = subprocess.run(['rpm', '-qP', rpm_file], stdout=subprocess.PIPE)
if res.returncode == 0:
return res.stdout.decode().strip().splitlines()
return []
def get_pkg_version(package: str) -> str:
command = [
'rpm', '-q', '--queryformat', '%{VERSION}', package