From d3453831ea150477ab4737eb56a2fd9a08fab84bfdff7a1a87ac87eb925539d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Schr=C3=B6der?= Date: Wed, 5 Jul 2017 14:44:31 +0000 Subject: [PATCH] Macros OBS-URL: https://build.opensuse.org/package/show/Base:System/rpm?expand=0&rev=397 --- rpm-suse_macros | 14 ++++++++++++++ rpm.changes | 18 ++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/rpm-suse_macros b/rpm-suse_macros index f4143cc..e511da3 100644 --- a/rpm-suse_macros +++ b/rpm-suse_macros @@ -264,3 +264,17 @@ BuildArch: noarch \ %description %{-n:-n %{-n*}-}lang \ Provides translations for the \"%{name}\" package. +# package version comparison macros + +# compare two versions, returns -1, 0, 1, ~~~ +%rpm_vercmp() %{lua:print(rpm.expand('%1') == '~~~' and '~~~' or rpm.vercmp(rpm.expand('%1'), rpm.expand('%2')))} + +# expand to the installed version of a package/provides +%pkg_version() %(LC_ALL=C rpm -q --whatprovides --qf "%%{version}" "%1" | sed -e "s/^no package provides .*/~~~/") + +# compare the installed version to a value. returns -1, 0, 1, ~~~ +%pkg_version_cmp() %{expand:%{expand:%%%%{rpm_vercmp %%{pkg_version %1} %%2}}} + +# convenience/readability +%pkg_vcmp() (%{expand:%%{pkg_version_cmp %1 %3}} %2 0) + diff --git a/rpm.changes b/rpm.changes index 688fdb3..e8dc561 100644 --- a/rpm.changes +++ b/rpm.changes @@ -11,6 +11,24 @@ Wed Jul 5 16:28:46 CEST 2017 - ngompa13@gmail.com timestamps New patch: changes-doc.diff +------------------------------------------------------------------- +Thu Jun 15 07:08:45 UTC 2017 - alarrosa@suse.com + +- Added a %rpm_vercmp macro which accepts two versions as parameters and + returns -1, 0, 1 if the first version is less than, equal or + greater than the second version respectively. +- Added a %pkg_version macro that accepts a package or capability name + as argument and returns the version number of the installed package. If + no package provides the argument, it returns the string ~~~ +- Added a %pkg_vcmp macro that accepts 3 parameters. The first parameter + is a package name or provided capability name, the second argument is an + operator ( < <= = >= > != ) and the third parameter is a version string + to compare the installed version of the first argument with. +- Added a %pkg_version_cmp macro which accepts a package or capability name + as first argument and a version number as second argument and returns + -1, 0, 1 or ~~~ . The number values have the same meaning as in %rpm_vercmp + and the ~~~ string is returned if the package or capability can't be found. + ------------------------------------------------------------------- Fri Jun 9 15:33:01 UTC 2017 - sriedel@suse.com