summaryrefslogtreecommitdiffstats
path: root/redhat/build/get_installed_package_version.sh
blob: 609c88f0e027c3d70a68eba7e4bb33f6f502a147 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/bin/bash

# Sample package name: trinity-tdelibs-14.0.0-0_pre727+6be06b3d.mga3.opt

PKGNAME="${1##*/}"
[ -z "${PKGNAME}" ] && echo "You must specify a package name !" && exit 1

# Language package: install only French language package
case ${PKGNAME} in
  "k3b-i18n"|"koffice-i18n"|"tde-i18n") PKGNAME="trinity-${PKGNAME}-French";;
  "koffice") PKGNAME="${PKGNAME}-suite";;
  "trinity-"*) PKGNAME="${PKGNAME#trinity-}";;
  "qt3") [ -r /etc/mandriva-release ] && PKGNAME="qt3-common";;
  "curl") PKGNAME="trinity-libcurl";;
  "esound") PKGNAME="esound-libs";;
  "tqt3") PKGNAME="libtqt3-mt";;
  "tqtinterface") PKGNAME="libtqt4";;
esac

VERSION=$(LC_ALL=C rpm -q --qf "%{version}-%{release}" trinity-${PKGNAME} 2>/dev/null)
if [ -z "${VERSION}" ] || [[ "${VERSION}" =~ "not installed" ]]; then
	VERSION=$(LC_ALL=C rpm -q --qf "%{version}-%{release}" ${PKGNAME})
fi

VERSION=${VERSION/-*_/\~}
VERSION=${VERSION%-[0-9]}
VERSION=${VERSION%.opt}
VERSION=${VERSION%.[a-z]*}

echo $VERSION