aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJani Välimaa <wally@mageia.org>2023-01-07 09:27:14 +0200
committerJani Välimaa <wally@mageia.org>2023-01-07 09:27:14 +0200
commit5f0aebe692304978a79a882601e4b8d8b07506a8 (patch)
tree0a495cd14b97d84a1b032af3a692817e2cc86c86
parent1ba4497eb09acd56ccad75cbd3ab815ab818f150 (diff)
downloadrpm-setup-5f0aebe692304978a79a882601e4b8d8b07506a8.tar
rpm-setup-5f0aebe692304978a79a882601e4b8d8b07506a8.tar.gz
rpm-setup-5f0aebe692304978a79a882601e4b8d8b07506a8.tar.bz2
rpm-setup-5f0aebe692304978a79a882601e4b8d8b07506a8.tar.xz
rpm-setup-5f0aebe692304978a79a882601e4b8d8b07506a8.zip
Add macros.gnome
Introduce %url_ver and %tarball_version macros
-rw-r--r--NEWS1
-rw-r--r--macros.gnome22
2 files changed, 23 insertions, 0 deletions
diff --git a/NEWS b/NEWS
index d0cff12..79aaa64 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,4 @@
+- add macros.gnome to introduce %url_ver and %tarball_version macros
- rpm-spec-mode.el: fix compatibility with Emacs 28.1,
patch from https://github.com/stigbjorlykke/rpm-spec-mode/pull/17
diff --git a/macros.gnome b/macros.gnome
new file mode 100644
index 0000000..cb38bd0
--- /dev/null
+++ b/macros.gnome
@@ -0,0 +1,22 @@
+%tarball_version %{lua:
+ver = string.gsub(rpm.expand("%{version}"), "~", ".")
+print(ver)
+}
+
+%url_ver %{lua:
+ver = rpm.expand("%{version}")
+majmin, count1 = string.gsub(ver, "^(%d+%.%d+).*", "%1", 1)
+if count1 == 0 then
+ ver = string.gsub(ver, "~.*", "")
+ print(ver)
+ return
+end
+maj, count2 = string.gsub(majmin, "^(%d+).*", "%1", 1);
+if count2 == 0 then
+ print(majmin)
+elseif tonumber(majmin) < 40 then
+ print(majmin)
+else
+ print(maj)
+end
+}