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