]> Frank Brehm's Git Trees - pixelpark/pp-admin-tools.git/commitdiff
Adding get-rpm-release and get-rpm-version
authorFrank Brehm <frank.brehm@pixelpark.com>
Thu, 16 Dec 2021 10:12:59 +0000 (11:12 +0100)
committerFrank Brehm <frank.brehm@pixelpark.com>
Thu, 16 Dec 2021 10:12:59 +0000 (11:12 +0100)
get-rpm-release [new file with mode: 0755]
get-rpm-version [new file with mode: 0755]

diff --git a/get-rpm-release b/get-rpm-release
new file mode 100755 (executable)
index 0000000..fe7007b
--- /dev/null
@@ -0,0 +1,50 @@
+#!/bin/bash
+
+cd $( dirname $0 )
+
+VERSION=$( grep -P '^\s*__version__\b' lib/pp_admintools/__init__.py | \
+    grep -P '^\s*__version__\b' | \
+    awk -F= '{print $2}' | \
+    sed -e "s/^[       ]*'//" -e "s/'.*//" )
+
+REVISION=1
+
+VERSION_FILE=".rpm-version"
+if [[ -n "$1" ]] ; then
+    VERSION_FILE="${VERSION_FILE}-$1"
+fi
+
+OLD_VERSION_FULL=
+OLD_VERSION=
+OLD_REVISION=
+if [[ -f "${VERSION_FILE}" ]] ; then
+    OLD_VERSION_FULL=$( cat "${VERSION_FILE}" | \
+        grep -P -v '^\s*(#.*|$)' | \
+        head -n 1 | \
+        sed -e 's/[    ].*//' )
+fi
+
+if [[ -n "${OLD_VERSION_FULL}" ]] ; then
+
+    OLD_VERSION=$( echo "${OLD_VERSION_FULL}" | sed -e 's/-.*//' )
+    OLD_REVISION=$( echo "${OLD_VERSION_FULL}" | sed -e 's/^[^-]*-//' )
+
+    if [[ -z "${OLD_VERSION}" ]] ; then
+        OLD_VERSION="${DEBIAN_VERSION}"
+    fi
+
+    if [[ -z "${OLD_REVISION}" ]] ; then
+        OLD_REVISION="0"
+    fi
+
+    if [[ "${OLD_VERSION}" != "${VERSION}" ]] ; then
+        REVISION=1
+    else
+        REVISION=$(( ${OLD_REVISION} + 1 ))
+    fi
+
+fi
+
+echo "${REVISION}"
+
+# vim: ts=4 et list
diff --git a/get-rpm-version b/get-rpm-version
new file mode 100755 (executable)
index 0000000..0e4f658
--- /dev/null
@@ -0,0 +1,11 @@
+#!/bin/bash
+
+cd $( dirname $0 )
+VERSION=$( grep -P '^\s*__version__\b' lib/pp_admintools/__init__.py | \
+    grep -P '^\s*__version__\b' | \
+    awk -F= '{print $2}' | \
+    sed -e "s/^[       ]*'//" -e "s/'.*//" )
+
+echo "${VERSION}"
+
+# vim: ts=4 et list