[2] | 1 | #!/bin/sh -f |
---|
| 2 | |
---|
| 3 | #------------------------------------------------------------------------------ |
---|
[440] | 4 | # Arguments: |
---|
[2] | 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 | # |
---|
[440] | 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 |
---|
[2] | 24 | #------------------------------------------------------------------------------ |
---|
[446] | 25 | : ${CMTMSGPREFIX:=$0:} |
---|
[2] | 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 | |
---|
[440] | 39 | while test $# -gt 0; do |
---|
[2] | 40 | arg=$1 |
---|
| 41 | shift |
---|
| 42 | |
---|
| 43 | val=${arg} |
---|
| 44 | |
---|
| 45 | case ${arg} in |
---|
[440] | 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 | ;; |
---|
[2] | 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 |
---|
[591] | 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 |
---|
[2] | 105 | fi |
---|
| 106 | |
---|
[440] | 107 | if test ! -d "${cmtpath}"; then |
---|
[2] | 108 | echo "cmt_uninstall_action.sh> no cmtpath" |
---|
| 109 | exit 1 |
---|
| 110 | fi |
---|
| 111 | #} |
---|
| 112 | |
---|
| 113 | dest_file_path=${install_dir}/${file_name} |
---|
| 114 | ref_file=${dest_file_path}.cmtref |
---|
| 115 | full_source_name=${source_dir}/${file_name} |
---|
| 116 | |
---|
[440] | 117 | case `pwd -P` in |
---|
| 118 | `(cd ${cmtpath}; pwd -P)`*) : ;; |
---|
| 119 | *) echo "Current directory outside of the installation area. Cannot proceed"; |
---|
| 120 | exit 0 ;; |
---|
| 121 | esac |
---|
[2] | 122 | |
---|
| 123 | if test ! -d ${install_dir}; then |
---|
[440] | 124 | echo "Cannot uninstall file ${file_name} from installation directory ${install_dir}" |
---|
[2] | 125 | exit 0 |
---|
| 126 | fi |
---|
| 127 | |
---|
[487] | 128 | if test -L ${dest_file_path}; then |
---|
| 129 | |
---|
[442] | 130 | if test "${cmtmsg}"; then |
---|
[487] | 131 | echo "${CMTMSGPREFIX}" removing symbolic link ${file_name} from ${install_dir} |
---|
| 132 | fi |
---|
| 133 | if test "${makecmd}"; then set -v; fi |
---|
| 134 | /bin/rm -f ${dest_file_path} |
---|
| 135 | if test "${makecmd}"; then set +v; fi |
---|
| 136 | |
---|
| 137 | elif test -d ${dest_file_path}; then |
---|
| 138 | |
---|
| 139 | if test "${cmtmsg}"; then |
---|
[446] | 140 | echo "${CMTMSGPREFIX}" removing directory ${file_name} from ${install_dir} |
---|
[442] | 141 | fi |
---|
| 142 | if test "${makecmd}"; then set -v; fi |
---|
[2] | 143 | /bin/rm -rf ${dest_file_path} |
---|
[442] | 144 | if test "${makecmd}"; then set +v; fi |
---|
[487] | 145 | |
---|
[2] | 146 | elif test -f ${dest_file_path}; then |
---|
[487] | 147 | |
---|
[442] | 148 | if test "${cmtmsg}"; then |
---|
[446] | 149 | echo "${CMTMSGPREFIX}" removing file ${file_name} from ${install_dir} |
---|
[442] | 150 | fi |
---|
| 151 | if test "${makecmd}"; then set -v; fi |
---|
[2] | 152 | /bin/rm -f ${dest_file_path} |
---|
[442] | 153 | if test "${makecmd}"; then set +v; fi |
---|
[487] | 154 | |
---|
[2] | 155 | fi |
---|
| 156 | |
---|
| 157 | if test -f ${ref_file}; then |
---|
[442] | 158 | if test "${makecmd}"; then set -v; fi |
---|
[2] | 159 | /bin/rm -f ${ref_file} |
---|
[442] | 160 | if test "${makecmd}"; then set +v; fi |
---|
[2] | 161 | fi |
---|