Changeset 440 for CMT/HEAD/mgr


Ignore:
Timestamp:
Feb 11, 2008, 2:23:17 PM (16 years ago)
Author:
rybkin
Message:

See C.L. 344

Location:
CMT/HEAD/mgr
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • CMT/HEAD/mgr/cmt_install_action.sh

    r28 r440  
    11#!/bin/sh -f
    22
    3 ###set -x
    4 
    53#------------------------------------------------------------------------------
     4# Arguments:
    65#
    76# -source=1   absolute source directory
     
    1110# -cmtpath=5  cmtpath of the package
    1211#
     12#           OR
     13#
     14# -source 1   absolute source directory
     15# -name 2     file name
     16# -out 3      absolute installation directory
     17# -cmd 4      installation system command
     18# -cmtpath 5  cmtpath of the package
     19#
     20#           OR
     21#
     22# 1   absolute source directory
     23# 2   file name
     24# 3   absolute installation directory
     25# 4   installation system command
     26# 5   cmtpath of the package
    1327#------------------------------------------------------------------------------
    1428
     
    2640  opt="-source"
    2741
    28   while test "$#" -gt 0; do
     42  while test $# -gt 0; do
    2943    arg=$1
    3044    shift
     
    3347   
    3448    case ${arg} in
    35       -*)
    36         if echo $arg | grep '=' 2>&1 >/dev/null; then
    37           opt=`echo ${arg} | sed -e 's#=.*##'`
    38           val=`echo ${arg} | sed -e 's#[^=]*=##'`
    39         else
    40           opt=${arg}
    41           val=
    42           if test "$#" -gt 0; then
    43             val=$1
    44             shift
    45           fi
    46         fi
    47         ;;
     49        -?*=*)
     50            opt=${arg%%"="*}
     51            val=${arg#"${opt}="}
     52            ;;
     53        -?*)
     54            opt=${arg}
     55            val=
     56            if test $# -gt 0; then
     57                val=$1
     58                shift
     59            fi
     60            ;;
    4861    esac
    4962   
     
    100113  fi
    101114
    102   if test "${cmtpath}" = ""; then
     115  if test ! -d "${cmtpath}"; then
    103116    echo "cmt_install_action.sh> no cmtpath"
    104117    exit 1
     
    110123full_source_name=${source_dir}/${file_name}
    111124
    112 if test "${cmtpath}" = "" ; then
    113   echo "No installation directory specified"
    114   exit 0
    115 fi
    116 
    117 b=`(cd ${cmtpath}; /bin/pwd)`
    118 a=`/bin/pwd | grep -e "${b}"`
    119 if test "${a}" = ""; then
    120   echo "Current directory outside of the installation area. Cannot proceed"
    121   exit 0
    122 fi
    123 
    124 if test "${install_dir}" = "" ; then
    125   exit 0
    126 fi
     125case `pwd -P` in
     126    `(cd ${cmtpath}; pwd -P)`*) : ;;
     127    *) echo "Current directory outside of the installation area. Cannot proceed";
     128        exit 0 ;;
     129esac
    127130
    128131if test ! -d ${install_dir}; then
    129   mkdir -p ${install_dir}
    130 fi
    131 
    132 if test ! -d ${install_dir}; then
    133   echo "Cannot install file ${file_name}, no installation directory specified"
    134   exit 0
     132    mkdir -p ${install_dir} ||
     133    { echo "Cannot install file ${file_name} into installation directory ${install_dir}"; exit 0; }
    135134fi
    136135
    137136echo "Installing file ${file_name} into ${install_dir}"
    138 if test -L ${dest_file_path}; then
    139   /bin/rm -f ${dest_file_path}
    140 elif test -f ${dest_file_path}; then
    141   /bin/rm -f ${dest_file_path}
     137if test -L ${dest_file_path} -o -f ${dest_file_path}; then
     138    /bin/rm -f ${dest_file_path}
    142139fi
    143140
     
    146143fi
    147144
    148 ${install_command} ${full_source_name} ${dest_file_path}
     145eval ${install_command} ${full_source_name} ${dest_file_path}
    149146echo ${full_source_name} >${ref_file}
  • CMT/HEAD/mgr/cmt_uninstall_action.sh

    r28 r440  
    11#!/bin/sh -f
    22
    3 ###set -x
    4 
    53#------------------------------------------------------------------------------
     4# Arguments:
    65#
    76# -source=1   absolute source directory
     
    109# -cmtpath=4  cmtpath of the package
    1110#
     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
    1224#------------------------------------------------------------------------------
    1325
     
    1527file_name=""
    1628install_dir=""
    17 install_command=""
    1829cmtpath=""
    1930
     
    2536  opt="-source"
    2637
    27   while test "$#" -gt 0; do
     38  while test $# -gt 0; do
    2839    arg=$1
    2940    shift
     
    3243   
    3344    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         ;;
     45        -?*=*)
     46            opt=${arg%%"="*}
     47            val=${arg#"${opt}="}
     48            ;;
     49        -?*)
     50            opt=${arg}
     51            val=
     52            if test $# -gt 0; then
     53                val=$1
     54                shift
     55            fi
     56            ;;
    4757    esac
    4858   
     
    5868      -out)
    5969        install_dir=${val};
    60         opt="-cmd";
    61         ;;
    62       -cmd)
    63         install_command=${val};
    6470        opt="-cmtpath";
    6571        ;;
     
    94100  fi
    95101
    96   if test "${cmtpath}" = ""; then
     102  if test ! -d "${cmtpath}"; then
    97103    echo "cmt_uninstall_action.sh> no cmtpath"
    98104    exit 1
     
    104110full_source_name=${source_dir}/${file_name}
    105111
    106 b=`(cd ${cmtpath}; /bin/pwd)`
    107 a=`/bin/pwd | grep -e "${b}"`
    108 if test "${a}" = ""; then
    109   echo "Current directory outside of the installation area. Cannot proceed"
    110   exit 0
    111 fi
    112 
    113 if test "${install_dir}" = "" ; then
    114   exit 0
    115 fi
     112case `pwd -P` in
     113    `(cd ${cmtpath}; pwd -P)`*) : ;;
     114    *) echo "Current directory outside of the installation area. Cannot proceed";
     115        exit 0 ;;
     116esac
    116117
    117118if test ! -d ${install_dir}; then
    118   echo "Cannot uninstall file ${file_name}, no installation directory specified"
     119  echo "Cannot uninstall file ${file_name} from installation directory ${install_dir}"
    119120  exit 0
    120121fi
     
    131132  /bin/rm -f ${ref_file}
    132133fi
    133 
Note: See TracChangeset for help on using the changeset viewer.