source: CMT/v1r21/mgr/cmt_install_action.sh

Last change on this file was 446, checked in by rybkin, 16 years ago

See C.L. 350

  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 3.0 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# -cmd=4      installation system command
10# -cmtpath=5  cmtpath of the package
11#
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
27#------------------------------------------------------------------------------
28: ${CMTMSGPREFIX:=$0:}
29
30source_dir=""
31file_name=""
32install_dir=""
33install_command=""
34cmtpath=""
35
36#handle_args $*
37#
38#------------------------------------------------------------------------------
39#handle_args ()
40#{
41  opt="-source"
42
43  while test $# -gt 0; do
44    arg=$1
45    shift
46
47    val=${arg}
48   
49    case ${arg} in
50        -?*=*)
51            opt=${arg%%"="*}
52            val=${arg#"${opt}="}
53            ;;
54        -?*)
55            opt=${arg}
56            val=
57            if test $# -gt 0; then
58                val=$1
59                shift
60            fi
61            ;;
62    esac
63   
64    case ${opt} in
65      -source)
66        source_dir=${val};
67        opt="-name";
68        ;;
69      -name)
70        file_name=${val};
71        opt="-out";
72        ;;
73      -out)
74        install_dir=${val};
75        opt="-cmd";
76        ;;
77      -cmd)
78        install_command=${val};
79        opt="-cmtpath";
80        ;;
81      -cmtpath)
82        cmtpath=${val};
83        opt="";
84        ;;
85      *)
86        ;;
87    esac
88   
89  done
90   
91  if test "${source_dir}" = ""; then
92    echo "cmt_install_action.sh> no source directory"
93    exit 1
94  fi
95   
96  if test "${file_name}" = ""; then
97    echo "cmt_install_action.sh> no file name"
98    exit 1
99  fi
100   
101  if test "${install_dir}" = ""; then
102    echo "cmt_install_action.sh> no install dir"
103    exit 1
104  fi
105   
106  if test "${install_command}" = ""; then
107    echo "cmt_install_action.sh> no install command"
108    exit 1
109  fi
110   
111  if test "${cmtpath}" = ""; then
112    package=`cmt show macro_value package`
113    cmtpath=`cmt show macro_value ${package}_cmtpath`
114  fi
115
116  if test ! -d "${cmtpath}"; then
117    echo "cmt_install_action.sh> no cmtpath"
118    exit 1
119  fi
120#}
121
122dest_file_path=${install_dir}/${file_name}
123ref_file=${dest_file_path}.cmtref
124full_source_name=${source_dir}/${file_name}
125
126case `pwd -P` in
127    `(cd ${cmtpath}; pwd -P)`*) : ;;
128    *) echo "Current directory outside of the installation area. Cannot proceed";
129        exit 0 ;;
130esac
131
132if test ! -d ${install_dir}; then
133    mkdir -p ${install_dir} ||
134    { echo "Cannot install file ${file_name} into installation directory ${install_dir}"; exit 0; }
135fi
136
137if test -L ${dest_file_path} -o -f ${dest_file_path}; then
138    /bin/rm -f ${dest_file_path}
139fi
140
141if test -f ${ref_file}; then
142  /bin/rm -f ${ref_file}
143fi
144
145if test "${cmtmsg}"; then
146echo "${CMTMSGPREFIX}" "installing file ${file_name} into ${install_dir}"
147fi
148if test "${makecmd}"; then set -v; fi
149eval ${install_command} ${full_source_name} ${dest_file_path}
150echo ${full_source_name} >${ref_file}
151if test "${makecmd}"; then set +v; fi
Note: See TracBrowser for help on using the repository browser.