]> Frank Brehm's Git Trees - pixelpark/pp-admin-tools.git/commitdiff
Fixing get-rpm-* for linter errors.
authorFrank Brehm <frank.brehm@pixelpark.com>
Mon, 2 Jan 2023 09:35:17 +0000 (10:35 +0100)
committerFrank Brehm <frank.brehm@pixelpark.com>
Mon, 2 Jan 2023 09:35:17 +0000 (10:35 +0100)
get-rpm-release
get-rpm-version

index fe7007bffad999e411444c37d93fefff0fc081ce..7681494acdbbca03ce56ade8fcae8a1c36aa5235 100755 (executable)
@@ -1,12 +1,8 @@
 #!/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/'.*//" )
+cd "$( dirname "$0" )" || exit 6
 
+VERSION=$( head -n 1 debian/changelog | sed -e "s/^[^(]*(//" -e "s/).*//" )
 REVISION=1
 
 VERSION_FILE=".rpm-version"
@@ -18,16 +14,16 @@ 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/[    ].*//' )
+    OLD_VERSION_FULL=$( grep -P -v '^\s*(#.*|$)' "${VERSION_FILE}" | 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/^[^-]*-//' )
+    # shellcheck disable=SC2001
+    {
+        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}"
@@ -40,11 +36,11 @@ if [[ -n "${OLD_VERSION_FULL}" ]] ; then
     if [[ "${OLD_VERSION}" != "${VERSION}" ]] ; then
         REVISION=1
     else
-        REVISION=$(( ${OLD_REVISION} + 1 ))
+        REVISION=$(( OLD_REVISION + 1 ))
     fi
 
 fi
 
 echo "${REVISION}"
 
-# vim: ts=4 et list
+# vim: ts=4 et
index 0e4f65886a9f688a31f0ede85fee9e2ccaa9a157..20f4726ad53704b7a6cf2f928d2cfddc0506acdb 100755 (executable)
@@ -1,11 +1,9 @@
 #!/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/'.*//" )
+cd "$( dirname "$0" )" || exit 6
+
+VERSION=$( head -n 1 debian/changelog | sed -e "s/^[^(]*(//" -e "s/).*//" )
 
 echo "${VERSION}"
 
-# vim: ts=4 et list
+# vim: ts=4 et