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

Last change on this file since 591 was 591, checked in by rybkin, 13 years ago

See C.L. 468

  • 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    if [ -n "${CMTDEBUG:-}" ]; then
100      unset CMTDEBUG
101      set -x
102    fi
103    package=`cmt show macro_value package` || exit
104    cmtpath=`cmt show macro_value ${package}_cmtpath` || exit
105  fi
106
107  if test ! -d "${cmtpath}"; then
108    echo "cmt_uninstall_action.sh> no cmtpath"
109    exit 1
110  fi
111#}
112
113dest_file_path=${install_dir}/${file_name}
114ref_file=${dest_file_path}.cmtref
115full_source_name=${source_dir}/${file_name}
116
117case `pwd -P` in
118    `(cd ${cmtpath}; pwd -P)`*) : ;;
119    *) echo "Current directory outside of the installation area. Cannot proceed";
120        exit 0 ;;
121esac
122
123if test ! -d ${install_dir}; then
124  echo "Cannot uninstall file ${file_name} from installation directory ${install_dir}"
125  exit 0
126fi
127
128if test -L ${dest_file_path}; then
129
130if test "${cmtmsg}"; then
131  echo "${CMTMSGPREFIX}" removing symbolic link ${file_name} from ${install_dir}
132fi
133if test "${makecmd}"; then set -v; fi
134  /bin/rm -f ${dest_file_path}
135if test "${makecmd}"; then set +v; fi
136
137elif test -d ${dest_file_path}; then
138
139if test "${cmtmsg}"; then
140  echo "${CMTMSGPREFIX}" removing directory ${file_name} from ${install_dir}
141fi
142if test "${makecmd}"; then set -v; fi
143  /bin/rm -rf ${dest_file_path}
144if test "${makecmd}"; then set +v; fi
145
146elif test -f ${dest_file_path}; then
147
148if test "${cmtmsg}"; then
149  echo "${CMTMSGPREFIX}" removing file ${file_name} from ${install_dir}
150fi
151if test "${makecmd}"; then set -v; fi
152  /bin/rm -f ${dest_file_path}
153if test "${makecmd}"; then set +v; fi
154
155fi
156
157if test -f ${ref_file}; then
158if test "${makecmd}"; then set -v; fi
159  /bin/rm -f ${ref_file}
160if test "${makecmd}"; then set +v; fi
161fi
Note: See TracBrowser for help on using the repository browser.