Update source from tizen 2.3
[platform/core/base/rpm-installer.git] / backend / scripts / query_rpm_package.sh.in
1 #!/bin/sh
2 E_RPM_NOT_INSTALLED=1
3 E_RPM_ALREADY_INSTALLED=2
4 E_WRONG_ARGS=17
5 E_FILE_NOT_FOUND=11
6
7 echo "find pakcage $1" >> /tmp/rpmscriptlog
8
9 CURDIR=`pwd`
10 echo $CURDIR >> /tmp/rpmscriptlog
11
12 debug () {
13         /bin/echo ">>$DEBUG" >> /tmp/rpmscriptlog
14 }
15
16 if [ $# -ne 1 ];then
17         DEBUG="Usage: query_package.sh PKG_FILE";debug
18         exit $E_WRONG_ARGS
19 fi
20
21 PKGNAME=$1
22 /bin/echo "pkg name = $PKGNAME" >> /tmp/rpmscriptlog
23
24 PKG_LOG_DIR=/var/pkgmgr/$PKGNAME
25 if [ ! -d $PKG_LOG_DIR ];then
26         DEBUG="$PKG_LOG_DIR not exist -> mkdir(ok)";debug
27         /bin/mkdir -p $PKG_LOG_DIR
28 fi
29
30 if [ -f $PKGNAME ]; then
31         /bin/rpm -qpi $PKGNAME
32         retval=$?
33 else
34         /bin/rpm -qi $PKGNAME
35         retval=$?
36 fi
37 echo "retval = $retval" >> /tmp/rpmscriptlog
38
39 if [ $retval -ne 0 ];then
40         DEBUG="pakcage not exist";debug
41         cd $CURDIR
42         exit $E_RPM_NOT_INSTALLED
43 else
44         exit $E_RPM_ALREADY_INSTALLED
45 fi