summaryrefslogtreecommitdiffstats
path: root/src/pmdk/utils/pkg-common.sh
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-21 11:54:28 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-21 11:54:28 +0000
commite6918187568dbd01842d8d1d2c808ce16a894239 (patch)
tree64f88b554b444a49f656b6c656111a145cbbaa28 /src/pmdk/utils/pkg-common.sh
parentInitial commit. (diff)
downloadceph-e6918187568dbd01842d8d1d2c808ce16a894239.tar.xz
ceph-e6918187568dbd01842d8d1d2c808ce16a894239.zip
Adding upstream version 18.2.2.upstream/18.2.2
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--src/pmdk/utils/pkg-common.sh56
1 files changed, 56 insertions, 0 deletions
diff --git a/src/pmdk/utils/pkg-common.sh b/src/pmdk/utils/pkg-common.sh
new file mode 100644
index 000000000..f3711bc59
--- /dev/null
+++ b/src/pmdk/utils/pkg-common.sh
@@ -0,0 +1,56 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright 2014-2019, Intel Corporation
+
+#
+# pkg-common.sh - common functions and variables for building packages
+#
+
+export LC_ALL="C"
+
+function error() {
+ echo -e "error: $@"
+}
+
+function check_dir() {
+ if [ ! -d $1 ]
+ then
+ error "Directory '$1' does not exist."
+ exit 1
+ fi
+}
+
+function check_file() {
+ if [ ! -f $1 ]
+ then
+ error "File '$1' does not exist."
+ exit 1
+ fi
+}
+
+function check_tool() {
+ local tool=$1
+ if [ -z "$(which $tool 2>/dev/null)" ]
+ then
+ error "'${tool}' not installed or not in PATH"
+ exit 1
+ fi
+}
+
+function get_version() {
+ echo -n $1 | sed "s/-rc/~rc/"
+}
+
+function get_os() {
+ if [ -f /etc/os-release ]
+ then
+ local OS=$(cat /etc/os-release | grep -m1 -o -P '(?<=NAME=).*($)')
+ [[ "$OS" =~ SLES|openSUSE ]] && echo -n "SLES_like" ||
+ ([[ "$OS" =~ "Fedora"|"Red Hat"|"CentOS" ]] && echo -n "RHEL_like" || echo 1)
+ else
+ echo 1
+ fi
+}
+
+REGEX_DATE_AUTHOR="([a-zA-Z]{3} [a-zA-Z]{3} [0-9]{2} [0-9]{4})\s*(.*)"
+REGEX_MESSAGE_START="\s*\*\s*(.*)"
+REGEX_MESSAGE="\s*(\S.*)"