Update source from tizen 2.3
[platform/core/base/rpm-installer.git] / backend / scripts / coretpk_rw_xml_converter.sh.in
1 #!/bin/sh
2 INPUT=$1
3 OUTPUT=$2
4 PKGID=$3
5 CLIENTID=$4
6 INSTALLLOCATION=0
7
8 if [ -z "$1" ] || [ -z "$2" ] || [ -z "$3" ]
9 then
10         echo "error!"
11         exit 2
12 fi
13
14 if [ $(grep -c " exec=\"/opt/" $INPUT) -gt 0 ] || [ $(grep -c "<icon>/opt/" $INPUT) -gt 0 ]
15 then
16         exit 44
17 fi
18
19 if [ $(grep -c "install-location=" $INPUT) -gt 0 ]
20 then
21         INSTALLLOCATION=1
22 fi
23
24
25 if [ -n "$4" ]
26 then
27         if [ $(grep -c "<service-application" $INPUT) -gt 0 ]
28         then
29                 if [ $INSTALLLOCATION -eq 1 ]
30                 then
31                         /bin/sed        -e      "s#<icon>#<icon>/opt/usr/apps/$PKGID/shared/res/#g" \
32                                                 -e      "s#exec=\"#exec=\"/opt/usr/apps/$PKGID/bin/#g" \
33                                                 -e "/<feature.*>/ d" -e "/<feature /,/<\/feature>/ d" \
34                                                 -e      "s#\(<manifest[^>]*\)>#\1 storeclient-id=\"$CLIENTID\">#" \
35                                                 -e "s#package=\"#type=\"coretpk\" package=\"#g" $INPUT > $OUTPUT
36                 else
37                         /bin/sed        -e      "s#<icon>#<icon>/opt/usr/apps/$PKGID/shared/res/#g" \
38                                                 -e      "s#exec=\"#exec=\"/opt/usr/apps/$PKGID/bin/#g" \
39                                                 -e "/<feature.*>/ d" -e "/<feature /,/<\/feature>/ d" \
40                                                 -e "s#\(<manifest[^>]*\)>#\1 install-location=\"internal-only\">#" \
41                                                 -e      "s#\(<manifest[^>]*\)>#\1 storeclient-id=\"$CLIENTID\">#" \
42                                                 -e "s#package=\"#type=\"coretpk\" package=\"#g" $INPUT > $OUTPUT
43                 fi
44         else
45                 if [ $INSTALLLOCATION -eq 1 ]
46                 then
47                         /bin/sed        -e      "s#<icon>#<icon>/opt/usr/apps/$PKGID/shared/res/#g" \
48                                                 -e      "s#exec=\"#exec=\"/opt/usr/apps/$PKGID/bin/#g" \
49                                                 -e "/<feature.*>/ d" -e "/<feature /,/<\/feature>/ d" \
50                                                 -e      "s#\(<manifest[^>]*\)>#\1 storeclient-id=\"$CLIENTID\">#" \
51                                                 -e "s#package=\"#type=\"coretpk\" package=\"#g" $INPUT > $OUTPUT
52                 else
53                         /bin/sed        -e      "s#<icon>#<icon>/opt/usr/apps/$PKGID/shared/res/#g" \
54                                                 -e      "s#exec=\"#exec=\"/opt/usr/apps/$PKGID/bin/#g" \
55                                                 -e "/<feature.*>/ d" -e "/<feature /,/<\/feature>/ d" \
56                                                 -e "s#\(<manifest[^>]*\)>#\1 install-location=\"auto\">#" \
57                                                 -e      "s#\(<manifest[^>]*\)>#\1 storeclient-id=\"$CLIENTID\">#" \
58                                                 -e "s#package=\"#type=\"coretpk\" package=\"#g" $INPUT > $OUTPUT
59                 fi
60         fi
61 else
62         if [ $(grep -c "<service-application" $INPUT) -gt 0 ]
63         then
64                 if [ $INSTALLLOCATION -eq 1 ]
65                 then
66                         /bin/sed        -e      "s#<icon>#<icon>/opt/usr/apps/$PKGID/shared/res/#g" \
67                                                 -e "/<feature.*>/ d" -e "/<feature /,/<\/feature>/ d" \
68                                                 -e      "s#exec=\"#exec=\"/opt/usr/apps/$PKGID/bin/#g" \
69                                                 -e "s#package=\"#type=\"coretpk\" package=\"#g" $INPUT > $OUTPUT
70                 else
71                         /bin/sed        -e      "s#<icon>#<icon>/opt/usr/apps/$PKGID/shared/res/#g" \
72                                                 -e      "s#exec=\"#exec=\"/opt/usr/apps/$PKGID/bin/#g" \
73                                                 -e "/<feature.*>/ d" -e "/<feature /,/<\/feature>/ d" \
74                                                 -e "s#\(<manifest[^>]*\)>#\1 install-location=\"internal-only\">#" \
75                                                 -e "s#package=\"#type=\"coretpk\" package=\"#g" $INPUT > $OUTPUT
76                 fi
77         else
78                 if [ $INSTALLLOCATION -eq 1 ]
79                 then
80                         /bin/sed        -e      "s#<icon>#<icon>/opt/usr/apps/$PKGID/shared/res/#g" \
81                                                 -e "/<feature.*>/ d" -e "/<feature /,/<\/feature>/ d" \
82                                                 -e      "s#exec=\"#exec=\"/opt/usr/apps/$PKGID/bin/#g" \
83                                                 -e "s#package=\"#type=\"coretpk\" package=\"#g" $INPUT > $OUTPUT
84                 else
85                         /bin/sed        -e      "s#<icon>#<icon>/opt/usr/apps/$PKGID/shared/res/#g" \
86                                                 -e      "s#exec=\"#exec=\"/opt/usr/apps/$PKGID/bin/#g" \
87                                                 -e "/<feature.*>/ d" -e "/<feature /,/<\/feature>/ d" \
88                                                 -e "s#\(<manifest[^>]*\)>#\1 install-location=\"auto\">#" \
89                                                 -e "s#package=\"#type=\"coretpk\" package=\"#g" $INPUT > $OUTPUT
90                 fi
91         fi
92 fi