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 | |
---|
15 | source_dir="" |
---|
16 | file_name="" |
---|
17 | install_dir="" |
---|
18 | install_command="" |
---|
19 | cmtpath="" |
---|
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 | |
---|
108 | dest_file_path=${install_dir}/${file_name} |
---|
109 | ref_file=${dest_file_path}.cmtref |
---|
110 | full_source_name=${source_dir}/${file_name} |
---|
111 | |
---|
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 |
---|
127 | |
---|
128 | if 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 |
---|
135 | fi |
---|
136 | |
---|
137 | echo "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} |
---|
142 | fi |
---|
143 | |
---|
144 | if test -f ${ref_file}; then |
---|
145 | /bin/rm -f ${ref_file} |
---|
146 | fi |
---|
147 | |
---|
148 | ${install_command} ${full_source_name} ${dest_file_path} |
---|
149 | echo ${full_source_name} >${ref_file} |
---|