svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.framework / org.gvsig.andami / src / main / resources-application / tools / make-portable @ 42993
History | View | Annotate | Download (11.7 KB)
1 | 41792 | jjdelcerro | #!/bin/bash |
---|---|---|---|
2 | ############################################################################# |
||
3 | # Require la siguiente estructura de carpetas: |
||
4 | # |
||
5 | # - packages |
||
6 | # - custom (carpeta con los paquetes adicionales a incluir en la portable) |
||
7 | # - exclude (fichero con los codigos de paquetes a excluir) |
||
8 | # - standard |
||
9 | 42767 | jjdelcerro | # - gvSIG-desktop*-lin-x86-online.zip |
10 | # - gvSIG-desktop*-lin-x86_64-online.zip |
||
11 | # - gvSIG-desktop*-win-x86-online.zip |
||
12 | # - gvSIG-desktop*-win-x86_64-online.zip |
||
13 | 41792 | jjdelcerro | # - gvSIG-desktop*-lin-x86.gvspkg |
14 | # - gvSIG-desktop*-lin-x86_64.gvspkg |
||
15 | # - gvSIG-desktop*-win-x86.gvspkg |
||
16 | 42767 | jjdelcerro | # - gvSIG-desktop*-win-x86_64.gvspkg |
17 | 42759 | jjdelcerro | # - patchs |
18 | 41792 | jjdelcerro | # - patchs.sh (se ejecuta antes que los scripts de ant y zipear la instalacion) |
19 | # - make-portable |
||
20 | # |
||
21 | # Y se ejecutara el archivo "make-portable" desde ese directorio. |
||
22 | # |
||
23 | # Al final se crean las carpetas y archivos: |
||
24 | # |
||
25 | # - target/gvsig-desktop-VERSION-lin-x86 |
||
26 | # - target/gvsig-desktop-VERSION-lin-x86_64 |
||
27 | # - target/gvsig-desktop-VERSION-win-x86 |
||
28 | # |
||
29 | # - target/gvsig-desktop-VERSION-lin-x86.zip |
||
30 | # - target/gvsig-desktop-VERSION-lin-x86_64.zip |
||
31 | # - target/gvsig-desktop-VERSION-win-x86.zip |
||
32 | # |
||
33 | ############################################################################## |
||
34 | |||
35 | 42948 | jjdelcerro | #set -x |
36 | 41792 | jjdelcerro | |
37 | #function handle_error() { |
||
38 | # echo "FAILED: line $1, exit code $2" |
||
39 | # exit 1 |
||
40 | #} |
||
41 | # |
||
42 | 42759 | jjdelcerro | #trap 'handle_error $LINENO $?' ERR |
43 | 41792 | jjdelcerro | |
44 | set -e |
||
45 | |||
46 | cd "$(dirname $0)" |
||
47 | SCRIPT_NAME=$(basename $0) |
||
48 | |||
49 | export BASEFOLDER="$PWD" |
||
50 | export TARGET="$BASEFOLDER/target" |
||
51 | export PATCHSFOLDER=$BASEFOLDER/patchs |
||
52 | |||
53 | function logger_info() { |
||
54 | 42992 | jjdelcerro | echo "$*" |
55 | 41792 | jjdelcerro | } |
56 | |||
57 | function logger_warn() { |
||
58 | 42992 | jjdelcerro | echo "$*" |
59 | 41792 | jjdelcerro | } |
60 | |||
61 | function get_package_info() { |
||
62 | 42947 | jjdelcerro | PACKAGE_PATH="$1" |
63 | |||
64 | # |
||
65 | # A veces en el zip los archivos comienzan por "/" y otras no. |
||
66 | # Asi que lo primero que hacemos es comprobar eso. |
||
67 | # |
||
68 | local prefix="" |
||
69 | local line="" |
||
70 | # El flag -Z1 muestra los ficheros unicamente, similar a -l pero |
||
71 | # sin ningun tipo de cabezaras, resumenes o informacion adicional |
||
72 | # por cada fichero. Solo el nombre con ruta de cada fichero. |
||
73 | local x=$(unzip -Z1 "$PACKAGE_PATH" "*/package.info") |
||
74 | if [ "${x:0:1}" == "/" ] ; then |
||
75 | prefix="/" |
||
76 | fi |
||
77 | # |
||
78 | # Usamos una redireccion y no un pipe ya que los elementos de un pipe se |
||
79 | # ejecutan en un subshell separado y la asignacion a las variables dentro del |
||
80 | # while solo tendria efecto en ese subshell. |
||
81 | # |
||
82 | # Atencion al parametro W del unzip, ya que si lo quitamos y en el zip hay |
||
83 | # mas de un "package.info" nos los sacaria todos, y los resultados no serian |
||
84 | # los esperados. Solo tenemos que leer el "package.info" que hay en el primer |
||
85 | # subdirectorio del zip. |
||
86 | # Con el tr intentamos eliminar lo \r ya que algunos package.info generados |
||
87 | # desde windows tienen \r. |
||
88 | # |
||
89 | PACKE_INFO_CONTENTS=$(unzip -lpWc "$PACKAGE_PATH" "${prefix}*/package.info" | tr -d '\r') |
||
90 | while read line ; do |
||
91 | case "$line" in |
||
92 | type=*) |
||
93 | PACKAGE_TYPE=${line#type=} |
||
94 | ;; |
||
95 | version=*) |
||
96 | PACKAGE_VERSION=${line#version=} |
||
97 | ;; |
||
98 | code=*) |
||
99 | PACKAGE_CODE=${line#code=} |
||
100 | ;; |
||
101 | esac |
||
102 | done <<END_OF_PACKAGE_INFO_CONTENTS |
||
103 | $PACKE_INFO_CONTENTS |
||
104 | END_OF_PACKAGE_INFO_CONTENTS |
||
105 | 41792 | jjdelcerro | } |
106 | |||
107 | 42947 | jjdelcerro | |
108 | 41792 | jjdelcerro | function install_symbols() { |
109 | INSTALL_FOLDER="$1" |
||
110 | |||
111 | cd "$INSTALL_FOLDER" |
||
112 | mkdir -p "home/gvSIG/plugins/org.gvsig.app.mainplugin/Symbols" |
||
113 | cd "home/gvSIG/plugins/org.gvsig.app.mainplugin/Symbols" |
||
114 | rm -rf "$PACKAGE_CODE" |
||
115 | 42934 | jjdelcerro | logger_info "Install symbols $PACKAGE_CODE $PACKAGE_VERSION" |
116 | unzip -qq "$PACKAGE_PATH" 2>&1 | sed "/warning: stripped absolute path/d" |
||
117 | 41792 | jjdelcerro | } |
118 | |||
119 | 42934 | jjdelcerro | function install_script() { |
120 | INSTALL_FOLDER="$1" |
||
121 | |||
122 | cd "$INSTALL_FOLDER" |
||
123 | mkdir -p "home/gvSIG/plugins/org.gvsig.scripting.app.mainplugin/scripts/addons" |
||
124 | cd "home/gvSIG/plugins/org.gvsig.scripting.app.mainplugin/scripts/addons" |
||
125 | rm -rf "$PACKAGE_CODE" |
||
126 | logger_info "Install script $PACKAGE_CODE $PACKAGE_VERSION" |
||
127 | unzip -qq "$PACKAGE_PATH" 2>&1 | sed "/warning: stripped absolute path/d" |
||
128 | } |
||
129 | |||
130 | 41792 | jjdelcerro | function install_jCRS_EPSG() { |
131 | INSTALL_FOLDER="$1" |
||
132 | |||
133 | cd "$INSTALL_FOLDER" |
||
134 | mkdir -p "gvSIG/extensiones/org.gvsig.projection.app.jcrs/db/EPSG" |
||
135 | cd "gvSIG/extensiones/org.gvsig.projection.app.jcrs/db/EPSG" |
||
136 | rm -rf "$PACKAGE_CODE" |
||
137 | 42934 | jjdelcerro | logger_info "Install jCRS EPSG data base $PACKAGE_CODE $PACKAGE_VERSION" |
138 | unzip -qq "$PACKAGE_PATH" 2>&1 | sed "/warning: stripped absolute path/d" |
||
139 | 41792 | jjdelcerro | } |
140 | |||
141 | function install_plugin() { |
||
142 | INSTALL_FOLDER="$1" |
||
143 | |||
144 | cd "$INSTALL_FOLDER/gvSIG/extensiones" |
||
145 | rm -rf "$PACKAGE_CODE" |
||
146 | 42934 | jjdelcerro | logger_info "Install plugin $PACKAGE_CODE $PACKAGE_VERSION" |
147 | unzip -qq "$PACKAGE_PATH" 2>&1 | sed "/warning: stripped absolute path/d" |
||
148 | 41792 | jjdelcerro | } |
149 | |||
150 | function install_translations() { |
||
151 | INSTALL_FOLDER="$1" |
||
152 | |||
153 | cd "$INSTALL_FOLDER/i18n" |
||
154 | rm -rf "$PACKAGE_CODE" |
||
155 | 42934 | jjdelcerro | logger_info "Install translations $PACKAGE_CODE $PACKAGE_VERSION" |
156 | unzip -qq "$PACKAGE_PATH" 2>&1 | sed "/warning: stripped absolute path/d" |
||
157 | 41792 | jjdelcerro | } |
158 | |||
159 | function run_plugins_install_scripts() { |
||
160 | INSTALL_FOLDER="$1" |
||
161 | 42759 | jjdelcerro | |
162 | 41792 | jjdelcerro | logger_info "" |
163 | logger_info "Running plugins install scripts" |
||
164 | cd "$INSTALL_FOLDER/gvSIG/extensiones" |
||
165 | for PLUGIN_CODE in * |
||
166 | do |
||
167 | if [ -f "$INSTALL_FOLDER/gvSIG/extensiones/$PLUGIN_CODE/install/install.xml" ] ; then |
||
168 | logger_info "Running custom install script of $PLUGIN_CODE" |
||
169 | cd $INSTALL_FOLDER |
||
170 | ant -Dgvsig_dir="$INSTALL_FOLDER" -Dextensions_dir="$INSTALL_FOLDER/gvSIG/extensiones" -f "$INSTALL_FOLDER/gvSIG/extensiones/$PLUGIN_CODE/install/install.xml" |
||
171 | fi |
||
172 | done |
||
173 | } |
||
174 | |||
175 | function install_packages() { |
||
176 | INSTALL_FOLDER="$1" |
||
177 | PACKAGES_FOLDER="$2" |
||
178 | 42759 | jjdelcerro | |
179 | 41792 | jjdelcerro | logger_info "" |
180 | logger_info "Processing $(basename $PACKAGES_FOLDER) packages" |
||
181 | for PACKAGE_PATH in $PACKAGES_FOLDER/*.gvspkg |
||
182 | do |
||
183 | 41933 | jjdelcerro | if [ -f "$PACKAGE_PATH" ] ; then |
184 | PACKAGE_NAME="$(basename $PACKAGE_PATH)" |
||
185 | 42947 | jjdelcerro | get_package_info $PACKAGE_PATH |
186 | 42934 | jjdelcerro | if include_package $PACKAGE_CODE ; then |
187 | case $PACKAGE_TYPE in |
||
188 | plugin) |
||
189 | install_plugin "$INSTALL_FOLDER" |
||
190 | ;; |
||
191 | jCRS_EPSG) |
||
192 | install_jCRS_EPSG "$INSTALL_FOLDER" |
||
193 | ;; |
||
194 | symbols) |
||
195 | install_symbols "$INSTALL_FOLDER" |
||
196 | ;; |
||
197 | Script) |
||
198 | install_script "$INSTALL_FOLDER" |
||
199 | ;; |
||
200 | translations) |
||
201 | install_translations "$INSTALL_FOLDER" |
||
202 | ;; |
||
203 | 42935 | jjdelcerro | *) |
204 | echo "ERROR: Type of package $PACKAGE_TYPE of $PACKAGE_NAME not supported." |
||
205 | exit 1 |
||
206 | ;; |
||
207 | 42934 | jjdelcerro | esac |
208 | 41933 | jjdelcerro | else |
209 | 42934 | jjdelcerro | logger_info "Exclude package $PACKAGE_CODE" |
210 | cp "$PACKAGE_PATH" "$INSTALL_FOLDER/install" |
||
211 | 41933 | jjdelcerro | fi |
212 | 41792 | jjdelcerro | fi |
213 | done |
||
214 | } |
||
215 | |||
216 | function include_package() { |
||
217 | set +e |
||
218 | egrep "^$1\$" "$BASEFOLDER/packages/excludes" >/dev/null |
||
219 | FOUND=$? |
||
220 | set -e |
||
221 | if [ "$FOUND" == 1 ] ; then |
||
222 | return 0 |
||
223 | fi |
||
224 | return 1 |
||
225 | } |
||
226 | |||
227 | |||
228 | function remove_excluded_packages() { |
||
229 | logger_info "Checking plugins to remove" |
||
230 | cd "$INSTALL_FOLDER/gvSIG/extensiones" |
||
231 | while read line; do |
||
232 | 42759 | jjdelcerro | if [ -d "$line" ] ; then |
233 | 41792 | jjdelcerro | logger_info "Removing plugin $line" |
234 | rm -rf "$line" |
||
235 | fi |
||
236 | done < "$BASEFOLDER/packages/excludes" |
||
237 | } |
||
238 | |||
239 | 42759 | jjdelcerro | function install_portable_configuration_files() { |
240 | 41792 | jjdelcerro | logger_info "Install portable configuration file (gvSIG.config)" |
241 | 42973 | jjdelcerro | cp "$INSTALL_FOLDER/tools/gvSIG.config" "$INSTALL_FOLDER" |
242 | 41792 | jjdelcerro | chmod a+x "$INSTALL_FOLDER/gvSIG.sh" |
243 | } |
||
244 | |||
245 | 41933 | jjdelcerro | function zipfolder() { |
246 | echo zip -qyr9 "$1" "$2" |
||
247 | if type zip >/dev/null 2>/dev/null |
||
248 | then |
||
249 | 42767 | jjdelcerro | zip -qyr9 "$1" "$2" |
250 | 41933 | jjdelcerro | else |
251 | echo " |
||
252 | 42759 | jjdelcerro | |
253 | 42767 | jjdelcerro | WARNING: zip command not found. |
254 | $1 not compressed. |
||
255 | 42759 | jjdelcerro | |
256 | 41933 | jjdelcerro | " |
257 | fi |
||
258 | } |
||
259 | |||
260 | 42952 | jjdelcerro | function expandsVarsOnFile() { |
261 | sed 's/\${INSTALL_DRIVE}/./ |
||
262 | s/\${INSTALL_PATH}/./' "$1" >"$1.tmp" |
||
263 | mv "$1.tmp" "$1" |
||
264 | } |
||
265 | |||
266 | 41792 | jjdelcerro | function mkdist() { |
267 | cd $BASEFOLDER/standard |
||
268 | |||
269 | 42947 | jjdelcerro | # OS code (lin/win/darwin) + distribution + version |
270 | 41792 | jjdelcerro | export PORTABLE_OS="$1" |
271 | 42947 | jjdelcerro | |
272 | 42992 | jjdelcerro | # OS family code (lin/win/darwin) |
273 | export PORTABLE_OSFAMILY="${PORTABLE_OS/_*/}" |
||
274 | |||
275 | 42947 | jjdelcerro | # OS name (linux/windows/darwin) for show only |
276 | 42932 | jjdelcerro | export PORTABLE_OSNAME="$2" |
277 | 42947 | jjdelcerro | |
278 | # Architectute X86, x86_64 |
||
279 | 42932 | jjdelcerro | export PORTABLE_PLATFORM="$3" |
280 | 42912 | fdiaz | |
281 | 42947 | jjdelcerro | # OS used to locate the online zip |
282 | export ONLINE_OS |
||
283 | 42992 | jjdelcerro | case "$PORTABLE_OSFAMILY" in |
284 | 42947 | jjdelcerro | darwin) |
285 | ONLINE_OS="lin" |
||
286 | ;; |
||
287 | 42992 | jjdelcerro | lin) |
288 | 42947 | jjdelcerro | ONLINE_OS="lin" |
289 | ;; |
||
290 | 42992 | jjdelcerro | win) |
291 | 42947 | jjdelcerro | ONLINE_OS="win" |
292 | ;; |
||
293 | *) |
||
294 | ONLINE_OS="$PORTABLE_OS" |
||
295 | ;; |
||
296 | esac |
||
297 | 42912 | fdiaz | |
298 | export PORTABLE_VERSION=$(expr *${ONLINE_OS}-${PORTABLE_PLATFORM}-online.zip : "gvSIG-desktop-\\([0-9.]*-[0-9]*\\)") |
||
299 | export PORTABLE_STATUS=$(expr *${ONLINE_OS}-${PORTABLE_PLATFORM}-online.zip : "gvSIG-desktop-[0-9.]*-[0-9]*-\\([a-zA-Z]*[0-9]*\)") |
||
300 | 42769 | jjdelcerro | export PORTABLE_NAME="gvSIG-desktop-$PORTABLE_VERSION-${PORTABLE_STATUS}-${PORTABLE_OS}-${PORTABLE_PLATFORM}" |
301 | 42759 | jjdelcerro | |
302 | 41792 | jjdelcerro | export INSTALL_FOLDER="$TARGET/$PORTABLE_NAME" |
303 | |||
304 | 42992 | jjdelcerro | logger_info " |
305 | = |
||
306 | = Creating portable for ${PORTABLE_OSNAME} (${PORTABLE_OSFAMILY}/${PORTABLE_OS}/${PORTABLE_PLATFORM} - online os ${ONLINE_OS}) |
||
307 | = |
||
308 | " |
||
309 | 41792 | jjdelcerro | logger_info "Removing previous files" |
310 | rm -rf "$TARGET/gvsig-desktop" |
||
311 | rm -rf "$INSTALL_FOLDER" |
||
312 | rm -f "$TARGET/${PORTABLE_NAME}.zip" |
||
313 | rm -rf "$TARGET/packages-${PORTABLE_OS}-${PORTABLE_PLATFORM}" |
||
314 | 42759 | jjdelcerro | |
315 | 42992 | jjdelcerro | logger_info "Uncompressing ${PORTABLE_OSNAME} (${ONLINE_OS}) base files" |
316 | 41792 | jjdelcerro | cd $TARGET |
317 | 42759 | jjdelcerro | mkdir $PORTABLE_NAME |
318 | cd $PORTABLE_NAME |
||
319 | 42912 | fdiaz | unzip -qq "$BASEFOLDER/standard/gvSIG-desktop-$PORTABLE_VERSION-$PORTABLE_STATUS-${ONLINE_OS}-${PORTABLE_PLATFORM}-online.zip" |
320 | 42769 | jjdelcerro | #mv gvSIG-desktop-${PORTABLE_VERSION} $PORTABLE_NAME |
321 | 41792 | jjdelcerro | |
322 | logger_info "Uncompressing ${PORTABLE_OSNAME}-${PORTABLE_PLATFORM} package set" |
||
323 | mkdir -p "$TARGET/packages-${PORTABLE_OS}-${PORTABLE_PLATFORM}" |
||
324 | cd "$TARGET/packages-${PORTABLE_OS}-${PORTABLE_PLATFORM}" |
||
325 | unzip -qq "$BASEFOLDER/standard/gvSIG-desktop-${PORTABLE_VERSION}-${PORTABLE_STATUS}-${PORTABLE_OS}-${PORTABLE_PLATFORM}.gvspks" |
||
326 | 42759 | jjdelcerro | |
327 | 42767 | jjdelcerro | echo Removing package "$TARGET/packages-${PORTABLE_OS}-${PORTABLE_PLATFORM}/gvSIG-desktop-2.3.0-org.gvsig.gdal.app.mainplugin-"*-all-all-j1_7.gvspkg |
328 | rm -f "$TARGET/packages-${PORTABLE_OS}-${PORTABLE_PLATFORM}/gvSIG-desktop-2.3.0-org.gvsig.gdal.app.mainplugin-"*-all-all-j1_7.gvspkg |
||
329 | 42912 | fdiaz | |
330 | 41792 | jjdelcerro | install_packages "$INSTALL_FOLDER" "$TARGET/packages-${PORTABLE_OS}-${PORTABLE_PLATFORM}" |
331 | |||
332 | install_packages "$INSTALL_FOLDER" "$BASEFOLDER/packages/custom" |
||
333 | |||
334 | 42759 | jjdelcerro | install_portable_configuration_files |
335 | 41792 | jjdelcerro | |
336 | remove_excluded_packages |
||
337 | 42759 | jjdelcerro | |
338 | 41792 | jjdelcerro | if [ -f $PATCHSFOLDER/patchs.sh ] ; then |
339 | chmod a+x $PATCHSFOLDER/patchs.sh |
||
340 | logger_info "Appling patch to the instalation." |
||
341 | source $PATCHSFOLDER/patchs.sh |
||
342 | fi |
||
343 | 42759 | jjdelcerro | |
344 | 41792 | jjdelcerro | run_plugins_install_scripts $INSTALL_FOLDER |
345 | 42759 | jjdelcerro | |
346 | 42992 | jjdelcerro | case "$PORTABLE_OSFAMILY" in |
347 | 42952 | jjdelcerro | darwin) |
348 | 42932 | jjdelcerro | mkdir "$INSTALL_FOLDER/Contents" |
349 | mkdir "$INSTALL_FOLDER/Contents/MacOS" |
||
350 | echo '#!/bin/bash |
||
351 | x=$(dirname $0) |
||
352 | x=$(dirname $x) |
||
353 | x=$(dirname $x) |
||
354 | exec "$x/gvSIG.sh" |
||
355 | ' >"$INSTALL_FOLDER/Contents/MacOS/${PORTABLE_NAME}" |
||
356 | chmod a+x "$INSTALL_FOLDER/Contents/MacOS/${PORTABLE_NAME}" |
||
357 | mv "$INSTALL_FOLDER" "${INSTALL_FOLDER}.app" |
||
358 | INSTALL_FOLDER="${INSTALL_FOLDER}.app" |
||
359 | PORTABLE_NAME="${PORTABLE_NAME}.app" |
||
360 | 42952 | jjdelcerro | ;; |
361 | win) |
||
362 | 42970 | fdiaz | expandsVarsOnFile "${INSTALL_FOLDER}/gvsig-desktop.vbs" |
363 | expandsVarsOnFile "${INSTALL_FOLDER}/gvsig-desktop.cmd" |
||
364 | expandsVarsOnFile "${INSTALL_FOLDER}/gvsig-package-installer.cmd" |
||
365 | 42952 | jjdelcerro | ;; |
366 | esac |
||
367 | 42970 | fdiaz | |
368 | 41792 | jjdelcerro | logger_info "Compresing ${PORTABLE_OSNAME}-${PORTABLE_PLATFORM} portable (this take a moment)" |
369 | cd "$TARGET" |
||
370 | 41933 | jjdelcerro | zipfolder "${PORTABLE_NAME}.zip" "${PORTABLE_NAME}" |
371 | 42759 | jjdelcerro | |
372 | 41792 | jjdelcerro | logger_info "Removing temporary package folder" |
373 | rm -rf $TARGET/packages-${PORTABLE_OS}-${PORTABLE_PLATFORM} |
||
374 | 42759 | jjdelcerro | |
375 | 42992 | jjdelcerro | logger_info " |
376 | |||
377 | Portable ${PORTABLE_OSNAME}-${PORTABLE_PLATFORM} created. |
||
378 | |||
379 | " |
||
380 | 41792 | jjdelcerro | } |
381 | |||
382 | |||
383 | function main() { |
||
384 | 42992 | jjdelcerro | mkdist darwin_macos_10.11 darwin x86_64 |
385 | 42947 | jjdelcerro | mkdist win windows x86 |
386 | mkdist lin_ubuntu_16.04 linux x86_64 |
||
387 | 41792 | jjdelcerro | mkdist lin linux x86 |
388 | 42759 | jjdelcerro | mkdist lin linux x86_64 |
389 | mkdist win windows x86_64 |
||
390 | 41792 | jjdelcerro | echo "Creation ended" |
391 | } |
||
392 | |||
393 | mkdir -p "$TARGET" |
||
394 | 42993 | jjdelcerro | main | tee "$TARGET/${SCRIPT_NAME}.log" |