source: CMT/HEAD/mgr/cmt_uninstall_action.sh @ 487

Last change on this file since 487 was 487, checked in by rybkin, 15 years ago

See C.L. 382

  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 3.2 KB
Line 
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
27source_dir=""
28file_name=""
29install_dir=""
30cmtpath=""
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
109dest_file_path=${install_dir}/${file_name}
110ref_file=${dest_file_path}.cmtref
111full_source_name=${source_dir}/${file_name}
112
113case `pwd -P` in
114    `(cd ${cmtpath}; pwd -P)`*) : ;;
115    *) echo "Current directory outside of the installation area. Cannot proceed";
116        exit 0 ;;
117esac
118
119if test ! -d ${install_dir}; then
120  echo "Cannot uninstall file ${file_name} from installation directory ${install_dir}"
121  exit 0
122fi
123
124if test -L ${dest_file_path}; then
125
126if test "${cmtmsg}"; then
127  echo "${CMTMSGPREFIX}" removing symbolic link ${file_name} from ${install_dir}
128fi
129if test "${makecmd}"; then set -v; fi
130  /bin/rm -f ${dest_file_path}
131if test "${makecmd}"; then set +v; fi
132
133elif test -d ${dest_file_path}; then
134
135if test "${cmtmsg}"; then
136  echo "${CMTMSGPREFIX}" removing directory ${file_name} from ${install_dir}
137fi
138if test "${makecmd}"; then set -v; fi
139  /bin/rm -rf ${dest_file_path}
140if test "${makecmd}"; then set +v; fi
141
142elif test -f ${dest_file_path}; then
143
144if test "${cmtmsg}"; then
145  echo "${CMTMSGPREFIX}" removing file ${file_name} from ${install_dir}
146fi
147if test "${makecmd}"; then set -v; fi
148  /bin/rm -f ${dest_file_path}
149if test "${makecmd}"; then set +v; fi
150
151fi
152
153if test -f ${ref_file}; then
154if test "${makecmd}"; then set -v; fi
155  /bin/rm -f ${ref_file}
156if test "${makecmd}"; then set +v; fi
157fi
Note: See TracBrowser for help on using the repository browser.