9 Commits

Author SHA256 Message Date
39b807cfe7 Accepting request 1220688 from Virtualization:containers
Automatic submission by obs-autosubmit

OBS-URL: https://build.opensuse.org/request/show/1220688
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/obs-service-replace_using_package_version?expand=0&rev=9
2024-11-05 14:39:16 +00:00
70279b6f23 - 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

OBS-URL: https://build.opensuse.org/package/show/Virtualization:containers/obs-service-replace_using_package_version?expand=0&rev=25
2024-10-28 14:48:15 +00:00
b3bdf6ae9a Accepting request 1181281 from Virtualization:containers
Fix shebang of the script to use the explicit version of Python

OBS-URL: https://build.opensuse.org/request/show/1181281
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/obs-service-replace_using_package_version?expand=0&rev=8
2024-06-17 17:27:45 +00:00
b83fa2ceb1 Accepting request 1132949 from Virtualization:containers
- 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

OBS-URL: https://build.opensuse.org/request/show/1132949
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/obs-service-replace_using_package_version?expand=0&rev=7
2023-12-15 20:46:43 +00:00
76713b453e Accepting request 1078414 from Virtualization:containers
- 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/request/show/1078414
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/obs-service-replace_using_package_version?expand=0&rev=6
2023-04-12 10:50:58 +00:00
f8974b1d4a Accepting request 1075472 from Virtualization:containers
- Update to version 1680160876.6dcaef0:
  * Bump version: 0.0.6 → 0.0.7
  * Fix default value for empty or missing version
  * Bump flake8 from 5.0.1 to 5.0.4

OBS-URL: https://build.opensuse.org/request/show/1075472
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/obs-service-replace_using_package_version?expand=0&rev=5
2023-03-31 19:14:08 +00:00
cd52a4dfba Accepting request 1035098 from Virtualization:containers
OBS-URL: https://build.opensuse.org/request/show/1035098
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/obs-service-replace_using_package_version?expand=0&rev=4
2022-11-11 13:36:18 +00:00
f10624ca67 Accepting request 711909 from Virtualization:containers
OBS-URL: https://build.opensuse.org/request/show/711909
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/obs-service-replace_using_package_version?expand=0&rev=3
2019-06-26 14:03:52 +00:00
f04f826abc Accepting request 640750 from Virtualization:containers
- Update to version 1539069197.d0e12bd:
  * Bump version: 0.0.1 → 0.0.2
  * Add bumpversion support
  * Add the `--parse-version` flag (fixes bsc#1111089)
  * Add a simple example in README.md
  * Adjusting readme and tests code style

OBS-URL: https://build.opensuse.org/request/show/640750
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/obs-service-replace_using_package_version?expand=0&rev=2
2018-10-09 13:54:13 +00:00
4 changed files with 53 additions and 9 deletions

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">72fe58b8a7d29342985f4304dcf1c0c4d0b1c18c</param></service></servicedata>
<param name="changesrevision">6c2bf3a805028b1555eac71ac545d9dddfdfc857</param></service></servicedata>

View File

@@ -1,3 +1,22 @@
-------------------------------------------------------------------
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>

View File

@@ -19,7 +19,7 @@
%define service replace_using_package_version
Name: obs-service-%{service}
Version: 0.0.9
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
@@ -29,8 +29,6 @@ Source0: %{service}.py
Source1: %{service}.service
Source2: LICENSE
BuildRequires: sed
# for the __python3 macro
BuildRequires: python-rpm-macros
Requires: python3-docopt
Requires: python3-rpm
BuildRoot: %{_tmppath}/%{name}-%{version}-build
@@ -47,15 +45,12 @@ 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
install -D -m 755 %{service}.py %{buildroot}%{_prefix}/lib/obs/service/%{service}
install -D -m 644 %{service}.service %{buildroot}%{_prefix}/lib/obs/service/%{service}.service
# Doing %%python3_fix_shebang_path old fashioned way for the backward compatibility
sed -i "1s@#\\!.*python\S*@#\\!$(realpath %__python3)@" \
%{buildroot}%{_prefix}/lib/obs/service/%{service}
%files
%defattr(-,root,root)

View File

@@ -1,4 +1,4 @@
#!/usr/bin/env python3
#!/usr/bin/python3
# -*- coding: utf-8 -*-
#
# SPDX-FileCopyrightText: (c) 2023 SUSE LLC
@@ -170,6 +170,9 @@ def find_package_version(package, rpm_dir):
if version is None:
version = find_package_version_in_obsinfo('.', package)
if version is None:
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