Browse Source

osal_package_getversion

Ernesto Nicolás Carrea 5 years ago
parent
commit
cef95e6318
2 changed files with 10 additions and 0 deletions
  1. 5 0
      func/osal_debian_based.sh
  2. 5 0
      func/osal_rhel_based.sh

+ 5 - 0
func/osal_debian_based.sh

@@ -98,6 +98,11 @@ OSAL_PATH_RUN=/var/run
 # Functions                                                         #
 # Functions                                                         #
 #-------------------------------------------------------------------#
 #-------------------------------------------------------------------#
 
 
+# osal_package_getversion 'package'
+osal_package_getversion() {
+   dpkg-query --showformat='${Version}\n' --show $1 | cut -d"~" -f1
+}
+
 # OS function wrappers
 # OS function wrappers
 
 
 # package_preinstall
 # package_preinstall

+ 5 - 0
func/osal_rhel_based.sh

@@ -97,6 +97,11 @@ OSAL_PATH_RUN=/var/run
 # Functions                                                         #
 # Functions                                                         #
 #-------------------------------------------------------------------#
 #-------------------------------------------------------------------#
 
 
+# osal_package_getversion 'package'
+osal_package_getversion() {
+    rpm --queryformat="%{VERSION}" -q $1 | cut -d"~" -f1
+}
+
 # OS function wrappers
 # OS function wrappers
 
 
 # package_preinstall
 # package_preinstall