aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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
+}