1 | #!/bin/sh -f |
---|
2 | |
---|
3 | ###set -x |
---|
4 | |
---|
5 | #------------------------------------------------------------------------------ |
---|
6 | # |
---|
7 | # -source=1 absolute source directory |
---|
8 | # -name=2 file name |
---|
9 | # -out=3 absolute installation directory |
---|
10 | # -cmtpath=4 cmtpath of the package |
---|
11 | # |
---|
12 | #------------------------------------------------------------------------------ |
---|
13 | |
---|
14 | source_dir="" |
---|
15 | file_name="" |
---|
16 | install_dir="" |
---|
17 | install_command="" |
---|
18 | cmtpath="" |
---|
19 | |
---|
20 | #handle_args $* |
---|
21 | # |
---|
22 | #------------------------------------------------------------------------------ |
---|
23 | #handle_args () |
---|
24 | #{ |
---|
25 | opt="-source" |
---|
26 | |
---|
27 | while test "$#" -gt 0; do |
---|
28 | arg=$1 |
---|
29 | shift |
---|
30 | |
---|
31 | val=${arg} |
---|
32 | |
---|
33 | case ${arg} in |
---|
34 | -*) |
---|
35 | if echo $arg | grep '=' 2>&1 >/dev/null; then |
---|
36 | opt=`echo ${arg} | sed -e 's#=.*##'` |
---|
37 | val=`echo ${arg} | sed -e 's#[^=]*=##'` |
---|
38 | else |
---|
39 | opt=${arg} |
---|
40 | val= |
---|
41 | if test "$#" -gt 0; then |
---|
42 | val=$1 |
---|
43 | shift |
---|
44 | fi |
---|
45 | fi |
---|
46 | ;; |
---|
47 | esac |
---|
48 | |
---|
49 | case ${opt} in |
---|
50 | -source) |
---|
51 | source_dir=${val}; |
---|
52 | opt="-name"; |
---|
53 | ;; |
---|
54 | -name) |
---|
55 | file_name=${val}; |
---|
56 | opt="-out"; |
---|
57 | ;; |
---|
58 | -out) |
---|
59 | install_dir=${val}; |
---|
60 | opt="-cmd"; |
---|
61 | ;; |
---|
62 | -cmd) |
---|
63 | install_command=${val}; |
---|
64 | opt="-cmtpath"; |
---|
65 | ;; |
---|
66 | -cmtpath) |
---|
67 | cmtpath=${val}; |
---|
68 | opt=""; |
---|
69 | ;; |
---|
70 | *) |
---|
71 | ;; |
---|
72 | esac |
---|
73 | |
---|
74 | done |
---|
75 | |
---|
76 | if test "${source_dir}" = ""; then |
---|
77 | echo "cmt_uninstall_action.sh> no source directory" |
---|
78 | exit 1 |
---|
79 | fi |
---|
80 | |
---|
81 | if test "${file_name}" = ""; then |
---|
82 | echo "cmt_uninstall_action.sh> no file name" |
---|
83 | exit 1 |
---|
84 | fi |
---|
85 | |
---|
86 | if test "${install_dir}" = ""; then |
---|
87 | echo "cmt_uninstall_action.sh> no install dir" |
---|
88 | exit 1 |
---|
89 | fi |
---|
90 | |
---|
91 | if test "${cmtpath}" = ""; then |
---|
92 | package=`cmt show macro_value package` |
---|
93 | cmtpath=`cmt show macro_value ${package}_cmtpath` |
---|
94 | fi |
---|
95 | |
---|
96 | if test "${cmtpath}" = ""; then |
---|
97 | echo "cmt_uninstall_action.sh> no cmtpath" |
---|
98 | exit 1 |
---|
99 | fi |
---|
100 | #} |
---|
101 | |
---|
102 | dest_file_path=${install_dir}/${file_name} |
---|
103 | ref_file=${dest_file_path}.cmtref |
---|
104 | full_source_name=${source_dir}/${file_name} |
---|
105 | |
---|
106 | b=`(cd ${cmtpath}; /bin/pwd)` |
---|
107 | a=`/bin/pwd | grep -e "${b}"` |
---|
108 | if test "${a}" = ""; then |
---|
109 | echo "Current directory outside of the installation area. Cannot proceed" |
---|
110 | exit 0 |
---|
111 | fi |
---|
112 | |
---|
113 | if test "${install_dir}" = "" ; then |
---|
114 | exit 0 |
---|
115 | fi |
---|
116 | |
---|
117 | if test ! -d ${install_dir}; then |
---|
118 | echo "Cannot uninstall file ${file_name}, no installation directory specified" |
---|
119 | exit 0 |
---|
120 | fi |
---|
121 | |
---|
122 | if test -d ${dest_file_path}; then |
---|
123 | echo Removing directory ${file_name} from ${install_dir} |
---|
124 | /bin/rm -rf ${dest_file_path} |
---|
125 | elif test -f ${dest_file_path}; then |
---|
126 | echo Removing file ${file_name} from ${install_dir} |
---|
127 | /bin/rm -f ${dest_file_path} |
---|
128 | fi |
---|
129 | |
---|
130 | if test -f ${ref_file}; then |
---|
131 | /bin/rm -f ${ref_file} |
---|
132 | fi |
---|
133 | |
---|