source: CMT/v1r18p20041201/mgr/cmt_install_action.sh @ 1

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

Import all tags

File size: 3.0 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# -cmd=4      installation system command
11# -cmtpath=5  cmtpath of the package
12#
13#------------------------------------------------------------------------------
14
15source_dir=""
16file_name=""
17install_dir=""
18install_command=""
19cmtpath=""
20
21#handle_args $*
22#
23#------------------------------------------------------------------------------
24#handle_args ()
25#{
26  opt="-source"
27
28  while test "$#" -gt 0; do
29    arg=$1
30    shift
31
32    val=${arg}
33   
34    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        ;;
48    esac
49   
50    case ${opt} in
51      -source)
52        source_dir=${val};
53        opt="-name";
54        ;;
55      -name)
56        file_name=${val};
57        opt="-out";
58        ;;
59      -out)
60        install_dir=${val};
61        opt="-cmd";
62        ;;
63      -cmd)
64        install_command=${val};
65        opt="-cmtpath";
66        ;;
67      -cmtpath)
68        cmtpath=${val};
69        opt="";
70        ;;
71      *)
72        ;;
73    esac
74   
75  done
76   
77  if test "${source_dir}" = ""; then
78    echo "cmt_install_action.sh> no source directory"
79    exit 1
80  fi
81   
82  if test "${file_name}" = ""; then
83    echo "cmt_install_action.sh> no file name"
84    exit 1
85  fi
86   
87  if test "${install_dir}" = ""; then
88    echo "cmt_install_action.sh> no install dir"
89    exit 1
90  fi
91   
92  if test "${install_command}" = ""; then
93    echo "cmt_install_action.sh> no install command"
94    exit 1
95  fi
96   
97  if test "${cmtpath}" = ""; then
98    package=`cmt show macro_value package`
99    cmtpath=`cmt show macro_value ${package}_cmtpath`
100  fi
101
102  if test "${cmtpath}" = ""; then
103    echo "cmt_install_action.sh> no cmtpath"
104    exit 1
105  fi
106#}
107
108dest_file_path=${install_dir}/${file_name}
109ref_file=${dest_file_path}.cmtref
110full_source_name=${source_dir}/${file_name}
111
112if test "${cmtpath}" = "" ; then
113  echo "No installation directory specified"
114  exit 0
115fi
116
117b=`(cd ${cmtpath}; /bin/pwd)`
118a=`/bin/pwd | grep -e "${b}"`
119if test "${a}" = ""; then
120  echo "Current directory outside of the installation area. Cannot proceed"
121  exit 0
122fi
123
124if test "${install_dir}" = "" ; then
125  exit 0
126fi
127
128if test ! -d ${install_dir}; then
129  mkdir -p ${install_dir}
130fi
131
132if test ! -d ${install_dir}; then
133  echo "Cannot install file ${file_name}, no installation directory specified"
134  exit 0
135fi
136
137echo "Installing file ${file_name} into ${install_dir}"
138if test -L ${dest_file_path}; then
139  /bin/rm -f ${dest_file_path}
140elif test -f ${dest_file_path}; then
141  /bin/rm -f ${dest_file_path}
142fi
143
144if test -f ${ref_file}; then
145  /bin/rm -f ${ref_file}
146fi
147
148${install_command} ${full_source_name} ${dest_file_path}
149echo ${full_source_name} >${ref_file}
Note: See TracBrowser for help on using the repository browser.