source: CMT/v1r19/mgr/cmt_uninstall_action.sh @ 1

Last change on this file since 1 was 1, checked in by arnault, 19 years ago

Import all tags

File size: 2.6 KB
Line 
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
14source_dir=""
15file_name=""
16install_dir=""
17install_command=""
18cmtpath=""
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
102dest_file_path=${install_dir}/${file_name}
103ref_file=${dest_file_path}.cmtref
104full_source_name=${source_dir}/${file_name}
105
106b=`(cd ${cmtpath}; /bin/pwd)`
107a=`/bin/pwd | grep -e "${b}"`
108if test "${a}" = ""; then
109  echo "Current directory outside of the installation area. Cannot proceed"
110  exit 0
111fi
112
113if test "${install_dir}" = "" ; then
114  exit 0
115fi
116
117if test ! -d ${install_dir}; then
118  echo "Cannot uninstall file ${file_name}, no installation directory specified"
119  exit 0
120fi
121
122if test -d ${dest_file_path}; then
123  echo Removing directory ${file_name} from ${install_dir}
124  /bin/rm -rf ${dest_file_path}
125elif test -f ${dest_file_path}; then
126  echo Removing file ${file_name} from ${install_dir}
127  /bin/rm -f ${dest_file_path}
128fi
129
130if test -f ${ref_file}; then
131  /bin/rm -f ${ref_file}
132fi
133
Note: See TracBrowser for help on using the repository browser.