1 | #! /bin/sh |
---|
2 | #+ |
---|
3 | # |
---|
4 | # NAME |
---|
5 | # ==== |
---|
6 | # |
---|
7 | # showpalettes.sh - show available palettes |
---|
8 | # |
---|
9 | # SYNOPSIS |
---|
10 | # ======== |
---|
11 | # |
---|
12 | # :: |
---|
13 | # |
---|
14 | # $ showpalettes.sh -i indir -idl_dir idl_dir -o outdir -t tempdir |
---|
15 | # |
---|
16 | # DESCRIPTION |
---|
17 | # =========== |
---|
18 | # |
---|
19 | # ``showpalettes.sh`` inspect ``indir`` and look for ``.cpt`` files. |
---|
20 | # |
---|
21 | # A XML/DocBook outdir/showpalette.xml is produced to present palettes usage and |
---|
22 | # building. |
---|
23 | # |
---|
24 | # By default, indir is the current directory. |
---|
25 | # |
---|
26 | # Log file is written on ${tempdir}/showpalette.log.\ *YYYYMMDDTHHMMSSZ* |
---|
27 | # |
---|
28 | # CAUTIONS |
---|
29 | # ======== |
---|
30 | # |
---|
31 | # SAXO_DIR must be set. The value should be the directory where |
---|
32 | # SAXO is available. |
---|
33 | # |
---|
34 | # for example, if you work at LOCEAN and work with default SAXO, |
---|
35 | # SAXO_DIR=/usr/home/smasson/SAXO_DIR. |
---|
36 | # |
---|
37 | # For working in progress, you should checkout SAXO on a personnal |
---|
38 | # directory and set SAXO_DIR to the working space. |
---|
39 | # |
---|
40 | # example for me : SAXO_DIR=/usr/lodyc/incas/fplod/SAXO_DIR_ws/ |
---|
41 | # |
---|
42 | # EXAMPLES |
---|
43 | # ======== |
---|
44 | # |
---|
45 | # For POST_IT in working space /usr/lodyc/incas/fplod/post_it_ws/ |
---|
46 | # with IDL 6.4 |
---|
47 | # |
---|
48 | # :: |
---|
49 | # |
---|
50 | # $ /usr/lodyc/incas/fplod/post_it_ws/SRC/Documentation/xmldoc/showpalettes.sh -i /usr/lodyc/incas/fplod/post_it_ws/ -idl_dir /usr/local_linux/idl/idl_6.4/idl/ -o /tmp/ -t /tmp/ |
---|
51 | # |
---|
52 | # For POST_IT in working space /usr/lodyc/incas/fplod/post_it_ws/ |
---|
53 | # with IDL 7.0 |
---|
54 | # |
---|
55 | # :: |
---|
56 | # |
---|
57 | # $ /usr/lodyc/incas/fplod/post_it_ws/SRC/Documentation/xmldoc/showpalettes.sh -i /usr/lodyc/incas/fplod/post_it_ws/ -idl_dir /usr/local_linux/idl/idl70/ -o /tmp/ -t /tmp/ |
---|
58 | # |
---|
59 | # TODO |
---|
60 | # ==== |
---|
61 | # |
---|
62 | # Some IDL files should be produced and processed to produce some plots (png files) |
---|
63 | # to be added in each ctp file. |
---|
64 | # |
---|
65 | # EVOLUTIONS |
---|
66 | # ========== |
---|
67 | # |
---|
68 | # $Id$ |
---|
69 | # |
---|
70 | # - fplod 20100120T090231Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
71 | # |
---|
72 | # * fix typo |
---|
73 | # * add outdir and tempdir parameters |
---|
74 | # |
---|
75 | # - fplod 20091207T112658Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
76 | # |
---|
77 | # * creation |
---|
78 | # |
---|
79 | system=$(uname) |
---|
80 | case "${system}" in |
---|
81 | AIX|IRIX64) |
---|
82 | echo " www : no specific posix checking" |
---|
83 | ;; |
---|
84 | *) |
---|
85 | set -o posix |
---|
86 | ;; |
---|
87 | esac |
---|
88 | command=$(basename ${0}) |
---|
89 | log_date=$(date -u +"%Y%m%dT%H%M%SZ") |
---|
90 | # |
---|
91 | usage=" Usage : ${command} -i indir -idl_dir idl_dir -o outdir -t tempdir" |
---|
92 | # |
---|
93 | minargcount=8 |
---|
94 | #echo " narg ${#}" |
---|
95 | if [ ${#} -lt ${minargcount} ] |
---|
96 | then |
---|
97 | echo "eee : not enought arguments (${#} vs ${minargcount})" |
---|
98 | echo "${usage}" |
---|
99 | exit 1 |
---|
100 | fi |
---|
101 | # |
---|
102 | # default |
---|
103 | # default IDL command and directory |
---|
104 | #idl_dir=/usr/local_linux/idl/idl64/ # overriding idl_dir for test ++ |
---|
105 | # |
---|
106 | # default indir directory |
---|
107 | indir=$(pwd) |
---|
108 | # default outdir directory |
---|
109 | outdir=/tmp/ |
---|
110 | # default tempdir directory |
---|
111 | tempdir=/tmp/ |
---|
112 | # |
---|
113 | # read parameters on command line |
---|
114 | while [ ! -z "${1}" ] |
---|
115 | do |
---|
116 | case ${1} in |
---|
117 | -i) |
---|
118 | indir=${2} |
---|
119 | shift |
---|
120 | ;; |
---|
121 | -idl_dir) |
---|
122 | idl_dir=${2} |
---|
123 | shift |
---|
124 | ;; |
---|
125 | -o) |
---|
126 | # directory for outputs choosen by user |
---|
127 | outdir=${2} |
---|
128 | shift |
---|
129 | ;; |
---|
130 | -t) |
---|
131 | # directory for temporary outputs choosen by user |
---|
132 | tempdir=${2} |
---|
133 | shift |
---|
134 | ;; |
---|
135 | -h) |
---|
136 | echo "${usage}" |
---|
137 | exit 0 |
---|
138 | ;; |
---|
139 | *) |
---|
140 | # other choice |
---|
141 | echo "${usage}" |
---|
142 | exit 1 |
---|
143 | ;; |
---|
144 | esac |
---|
145 | # next flag |
---|
146 | shift |
---|
147 | done |
---|
148 | # |
---|
149 | set -u |
---|
150 | # |
---|
151 | # test if ${indir} exist |
---|
152 | if [ ! -d ${indir} ] |
---|
153 | then |
---|
154 | echo "eee : ${indir} not found" |
---|
155 | exit 1 |
---|
156 | fi |
---|
157 | # |
---|
158 | # test if ${tempdir} exist |
---|
159 | if [ ! -d ${tempdir} ] |
---|
160 | then |
---|
161 | mkdir -p ${tempdir} |
---|
162 | echo "${command} : iii : creation of \${tempdir}" |
---|
163 | fi |
---|
164 | # |
---|
165 | # check for permission on ${tempdir} |
---|
166 | if [ ! -x ${tempdir} ] |
---|
167 | then |
---|
168 | echo " eee : ${tempdir} not reachable" |
---|
169 | exit 1 |
---|
170 | fi |
---|
171 | # |
---|
172 | # test if ${outdir} exist |
---|
173 | if [ ! -d ${outdir} ] |
---|
174 | then |
---|
175 | mkdir -p ${outdir} |
---|
176 | echo "${command} : iii : creation of \${outdir}" |
---|
177 | fi |
---|
178 | # |
---|
179 | # check for permission on ${outdir} |
---|
180 | if [ ! -x ${outdir} ] |
---|
181 | then |
---|
182 | echo " eee : ${outdir} not reachable" |
---|
183 | exit 1 |
---|
184 | fi |
---|
185 | # |
---|
186 | if [ ! -w ${outdir} ] |
---|
187 | then |
---|
188 | echo " eee : ${outdir} not writable" |
---|
189 | exit 1 |
---|
190 | fi |
---|
191 | # |
---|
192 | log=${tempdir}/$(basename ${command} .sh).log.${log_date} |
---|
193 | # |
---|
194 | # ++ test si IDL (car GDL inutilisable) |
---|
195 | application=${idl_dir}/bin/idl |
---|
196 | # |
---|
197 | # find cpt files |
---|
198 | list_cpt_files=$(find ${indir} \! \( -name '.svn' -prune \) -name "*.cpt") |
---|
199 | # |
---|
200 | # test if at least one found |
---|
201 | if [ "${list_cpt_files}" = "" ] |
---|
202 | then |
---|
203 | echo "iii : no cpt files found under ++" |
---|
204 | echo "iii : nothing to do !" |
---|
205 | exit 0 #++ 1 |
---|
206 | fi |
---|
207 | # |
---|
208 | # header of XML/DocBook file |
---|
209 | cat << EOF > ${tempdir}/showpalettes${log_date}.xml |
---|
210 | <?xml version="1.0" encoding="iso-8859-1"?> |
---|
211 | <!DOCTYPE article [ |
---|
212 | <!ENTITY promptidl "idl>"> |
---|
213 | ]> |
---|
214 | |
---|
215 | <article version="5.0" |
---|
216 | xmlns="http://docbook.org/ns/docbook" |
---|
217 | xmlns:xl="http://www.w3.org/1999/xlink" |
---|
218 | xml:lang="en" |
---|
219 | xml:id="palettes"> |
---|
220 | |
---|
221 | <title>Palettes</title> |
---|
222 | <para> |
---|
223 | Here are available palettes. |
---|
224 | </para> |
---|
225 | <sect1> |
---|
226 | <title>How to use ?</title> |
---|
227 | <para> |
---|
228 | ++ |
---|
229 | </para> |
---|
230 | </sect1> |
---|
231 | <sect1> |
---|
232 | <title>Available palettes</title> |
---|
233 | <para> |
---|
234 | ++ |
---|
235 | </para> |
---|
236 | <variablelist> |
---|
237 | EOF |
---|
238 | # |
---|
239 | # loop on palette files |
---|
240 | for cpt_file in ${list_cpt_files} |
---|
241 | do |
---|
242 | cpt_bfile=$(basename ${cpt_file}) |
---|
243 | cat << EOF >> ${tempdir}/showpalettes${log_date}.xml |
---|
244 | <varlistentry> |
---|
245 | <term><filename>${cpt_bfile}</filename></term> |
---|
246 | <listitem> |
---|
247 | <para> |
---|
248 | <mediaobject> |
---|
249 | <imageobject> |
---|
250 | <imagedata fileref="figpng/${cpt_bfile}.png"/> |
---|
251 | </imageobject> |
---|
252 | </mediaobject> |
---|
253 | </para> |
---|
254 | </listitem> |
---|
255 | </varlistentry> |
---|
256 | EOF |
---|
257 | done |
---|
258 | # |
---|
259 | # footer of XML/DocBook file |
---|
260 | cat << EOF >> ${tempdir}/showpalettes${log_date}.xml |
---|
261 | </variablelist> |
---|
262 | </sect1> |
---|
263 | <sect1> |
---|
264 | <title>How to build ?</title> |
---|
265 | <para> |
---|
266 | ++ |
---|
267 | </para> |
---|
268 | </sect1> |
---|
269 | </article> |
---|
270 | EOF |
---|
271 | # |
---|
272 | mv ${tempdir}/showpalettes${log_date}.xml ${outdir}/showpalettes.xml |
---|
273 | echo "iii : ${outdir}/showpalettes.xml can be processed" |
---|
274 | # |
---|
275 | # end |
---|
276 | exit 0 |
---|