- 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/package/show/Virtualization:containers/obs-service-replace_using_package_version?expand=0&rev=16
This commit is contained in:
parent
4012585222
commit
51cc6c8f52
@ -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">71deb28fee3d2bd774404ee4018080fbb47a6247</param></service></servicedata>
|
||||
<param name="changesrevision">6dcaef0f89b089ac6f83200ce25c0d907e45111a</param></service></servicedata>
|
@ -1,3 +1,11 @@
|
||||
-------------------------------------------------------------------
|
||||
Thu Mar 30 07:25:53 UTC 2023 - containers@suse.com
|
||||
|
||||
- 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
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Thu Nov 10 14:26:46 UTC 2022 - containers@suse.com
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
#
|
||||
# spec file
|
||||
#
|
||||
# Copyright (c) 2022 SUSE LLC
|
||||
# Copyright (c) 2023 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.6
|
||||
Version: 0.0.7
|
||||
Release: 0
|
||||
Summary: An OBS service: Replaces a regex with the version value of a package
|
||||
License: GPL-3.0-or-later
|
||||
|
@ -161,22 +161,22 @@ def apply_regex_to_file(input_file, output_file, regex, replacement):
|
||||
|
||||
|
||||
def find_package_version(package, rpm_dir):
|
||||
version = parse_version('')
|
||||
version = None
|
||||
try:
|
||||
version = get_pkg_version(package)
|
||||
except Exception:
|
||||
version = find_package_version_in_local_repos(rpm_dir, package)
|
||||
|
||||
if not str(version):
|
||||
if version is None:
|
||||
version = find_package_version_in_obsinfo('.', package)
|
||||
|
||||
if not str(version):
|
||||
if version is None:
|
||||
raise Exception('Package version not found')
|
||||
return str(version)
|
||||
|
||||
|
||||
def find_package_version_in_local_repos(repo_path, package):
|
||||
version = parse_version('')
|
||||
version = None
|
||||
for root, _, files in os.walk(repo_path):
|
||||
packages = [
|
||||
f for f in files if f.endswith('rpm') and package in f
|
||||
@ -185,17 +185,17 @@ def find_package_version_in_local_repos(repo_path, package):
|
||||
rpm_file = os.path.join(root, pkg)
|
||||
if get_pkg_name_from_rpm(rpm_file) == package:
|
||||
rpm_ver = get_pkg_version_from_rpm(rpm_file)
|
||||
if rpm_ver >= version:
|
||||
if version is None or rpm_ver >= version:
|
||||
version = rpm_ver
|
||||
return version
|
||||
|
||||
|
||||
def find_package_version_in_obsinfo(path, package):
|
||||
version = parse_version('')
|
||||
version = None
|
||||
for f in os.listdir(path):
|
||||
if f.endswith('obsinfo') and package in f:
|
||||
obsinfo_ver = get_pkg_version_from_obsinfo(f)
|
||||
if obsinfo_ver >= version:
|
||||
if version is None or obsinfo_ver >= version:
|
||||
version = obsinfo_ver
|
||||
return version
|
||||
|
||||
@ -219,7 +219,7 @@ def get_pkg_version_from_obsinfo(obsinfo_file):
|
||||
match = regex.match(line)
|
||||
if match:
|
||||
return parse_version(match[1])
|
||||
return parse_version('')
|
||||
return None
|
||||
|
||||
|
||||
def get_pkg_name_from_rpm(rpm_file):
|
||||
|
Loading…
Reference in New Issue
Block a user