From 368f5499a57efd41c63a3d7c0543747dcc1c188c Mon Sep 17 00:00:00 2001
From: rafael <rafael.ameijeiras@artica.es>
Date: Wed, 15 Feb 2023 10:36:49 +0100
Subject: [PATCH] 10216 adding check on pre to skip install if not
 Thread::Semaphore >= 2.13

---
 pandora_server/pandora_server.redhat.spec | 12 ++++++++++++
 pandora_server/pandora_server.spec        | 12 +++++++++++-
 2 files changed, 23 insertions(+), 1 deletion(-)

diff --git a/pandora_server/pandora_server.redhat.spec b/pandora_server/pandora_server.redhat.spec
index c647a51187..b85dd96ae3 100644
--- a/pandora_server/pandora_server.redhat.spec
+++ b/pandora_server/pandora_server.redhat.spec
@@ -109,6 +109,12 @@ rm -fr $RPM_BUILD_ROOT
 getent passwd pandora >/dev/null || \
     /usr/sbin/useradd -d %{prefix}/pandora_server -s /sbin/nologin -M -g 0 pandora
 
+current_ver=$(perl -le 'eval "require $ARGV[0]" and print $ARGV[0]->VERSION' Thread::Semaphore 2> /dev/null | cut -d '.' -f 2)
+if [ $((current_ver)) -lt 13 ] ; then
+        echo 'perl Thread::Semaphore should be installed on the system and shold be ver >= 2.13 '
+        exit 1
+fi
+
 exit 0
 
 %post
@@ -176,6 +182,12 @@ if [ "$1" = "1" ]; then
         exit 0
 fi
 
+current_ver=$(perl -le 'eval "require $ARGV[0]" and print $ARGV[0]->VERSION' Thread::Semaphore 2> /dev/null | cut -d '.' -f 2)
+if [ $((current_ver)) -lt 13 ] ; then
+        echo 'perl Thread::Semaphore should be installed on the system and shold be ver >= 2.13 '
+        exit 1
+fi
+
 /sbin/service pandora_server stop >/dev/null 2>&1 || :
 /sbin/service tentacle_serverd stop >/dev/null 2>&1 || :
 /sbin/chkconfig --del pandora_server
diff --git a/pandora_server/pandora_server.spec b/pandora_server/pandora_server.spec
index 1d4485a8bc..67ab299831 100644
--- a/pandora_server/pandora_server.spec
+++ b/pandora_server/pandora_server.spec
@@ -100,7 +100,11 @@ if [ "`id pandora | grep uid | wc -l`" = 0 ]
 then
 	/usr/sbin/useradd -d %{prefix}/pandora -s /bin/false -M -g 0 pandora
 fi
-exit 0
+current_ver=$(perl -le 'eval "require $ARGV[0]" and print $ARGV[0]->VERSION' Thread::Semaphore 2> /dev/null | cut -d '.' -f 2)
+if [ $((current_ver)) -lt 13 ] ; then
+        echo 'perl Thread::Semaphore should be installed on the system and shold be ver >= 2.13 '
+        exit 1
+fi
 
 %post
 if [ `command -v systemctl` ];
@@ -172,6 +176,12 @@ if [ "$1" = "1" ]; then
         exit 0
 fi
 
+current_ver=$(perl -le 'eval "require $ARGV[0]" and print $ARGV[0]->VERSION' Thread::Semaphore 2> /dev/null | cut -d '.' -f 2)
+if [ $((current_ver)) -lt 13 ] ; then
+        echo 'perl Thread::Semaphore should be installed on the system and shold be ver >= 2.13 '
+        exit 1
+fi
+
 /etc/init.d/pandora_server stop &>/dev/null
 /etc/init.d/tentacle_serverd stop &>/dev/null
 chkconfig --del pandora_server