svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.framework / org.gvsig.andami / src / main / resources-application / tools / make-portable @ 42759
History | View | Annotate | Download (8.75 KB)
1 |
#!/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 |
# - gvSIG-desktop*.online.zip |
10 |
# - gvSIG-desktop*-lin-x86.gvspkg |
11 |
# - gvSIG-desktop*-lin-x86_64.gvspkg |
12 |
# - gvSIG-desktop*-win-x86.gvspkg |
13 |
# - patchs |
14 |
# - patchs.sh (se ejecuta antes que los scripts de ant y zipear la instalacion) |
15 |
# - make-portable |
16 |
# |
17 |
# Y se ejecutara el archivo "make-portable" desde ese directorio. |
18 |
# |
19 |
# Al final se crean las carpetas y archivos: |
20 |
# |
21 |
# - target/gvsig-desktop-VERSION-lin-x86 |
22 |
# - target/gvsig-desktop-VERSION-lin-x86_64 |
23 |
# - target/gvsig-desktop-VERSION-win-x86 |
24 |
# |
25 |
# - target/gvsig-desktop-VERSION-lin-x86.zip |
26 |
# - target/gvsig-desktop-VERSION-lin-x86_64.zip |
27 |
# - target/gvsig-desktop-VERSION-win-x86.zip |
28 |
# |
29 |
############################################################################## |
30 |
|
31 |
#set -x |
32 |
|
33 |
#function handle_error() { |
34 |
# echo "FAILED: line $1, exit code $2" |
35 |
# exit 1 |
36 |
#} |
37 |
# |
38 |
#trap 'handle_error $LINENO $?' ERR |
39 |
|
40 |
set -e |
41 |
|
42 |
cd "$(dirname $0)" |
43 |
SCRIPT_NAME=$(basename $0) |
44 |
|
45 |
export BASEFOLDER="$PWD" |
46 |
export TARGET="$BASEFOLDER/target" |
47 |
export PATCHSFOLDER=$BASEFOLDER/patchs |
48 |
|
49 |
function logger_info() { |
50 |
echo $* |
51 |
} |
52 |
|
53 |
function logger_warn() { |
54 |
echo $* |
55 |
} |
56 |
|
57 |
function get_package_info() { |
58 |
PACKAGE_PATH="$1" |
59 |
PACKAGE_NAME="$(basename $PACKAGE_PATH)" |
60 |
PACKAGE_CODE=$(expr "$PACKAGE_NAME" : "gvSIG-desktop-[0-9.]*-\\([a-zA-Z0-9._]*\\)-") |
61 |
set +e |
62 |
PACKAGE_VERSION=$(expr "$PACKAGE_NAME" : "gvSIG-desktop-[0-9.]*-[a-zA-Z0-9._]*-\\([0-9.]*-[0-9]*\\)-") |
63 |
set -e |
64 |
if [ "X${PACKAGE_VERSION}X" == "XX" ] ; then |
65 |
PACKAGE_VERSION=$(expr "$PACKAGE_NAME" : "gvSIG-desktop-[0-9._]*-[a-zA-Z0-9._]*-\\([0-9.]*-[A-Z][.A-Za-z0-9_]*-[0-9]*\\)-") |
66 |
fi |
67 |
} |
68 |
|
69 |
function install_symbols() { |
70 |
INSTALL_FOLDER="$1" |
71 |
get_package_info $2 |
72 |
|
73 |
cd "$INSTALL_FOLDER" |
74 |
mkdir -p "home/gvSIG/plugins/org.gvsig.app.mainplugin/Symbols" |
75 |
cd "home/gvSIG/plugins/org.gvsig.app.mainplugin/Symbols" |
76 |
rm -rf "$PACKAGE_CODE" |
77 |
if include_package $PACKAGE_CODE ; then |
78 |
logger_info "Install symbols $PACKAGE_CODE $PACKAGE_VERSION" |
79 |
unzip -qq "$PACKAGE_PATH" 2>&1 | sed "/warning: stripped absolute path/d" |
80 |
else |
81 |
logger_info "Exclude symbols $PACKAGE_CODE" |
82 |
cp "$PACKAGE_PATH" "$INSTALL_FOLDER/install" |
83 |
fi |
84 |
} |
85 |
|
86 |
function install_jCRS_EPSG() { |
87 |
INSTALL_FOLDER="$1" |
88 |
get_package_info $2 |
89 |
|
90 |
cd "$INSTALL_FOLDER" |
91 |
mkdir -p "gvSIG/extensiones/org.gvsig.projection.app.jcrs/db/EPSG" |
92 |
cd "gvSIG/extensiones/org.gvsig.projection.app.jcrs/db/EPSG" |
93 |
rm -rf "$PACKAGE_CODE" |
94 |
if include_package $PACKAGE_CODE ; then |
95 |
logger_info "Install jCRS EPSG data base $PACKAGE_CODE $PACKAGE_VERSION" |
96 |
unzip -qq "$PACKAGE_PATH" 2>&1 | sed "/warning: stripped absolute path/d" |
97 |
else |
98 |
logger_info "Exclude jCRS EPSG data base $PACKAGE_CODE" |
99 |
cp "$PACKAGE_PATH" "$INSTALL_FOLDER/install" |
100 |
fi |
101 |
} |
102 |
|
103 |
function install_plugin() { |
104 |
INSTALL_FOLDER="$1" |
105 |
get_package_info $2 |
106 |
|
107 |
cd "$INSTALL_FOLDER/gvSIG/extensiones" |
108 |
rm -rf "$PACKAGE_CODE" |
109 |
if include_package $PACKAGE_CODE ; then |
110 |
logger_info "Install plugin $PACKAGE_CODE $PACKAGE_VERSION" |
111 |
unzip -qq "$PACKAGE_PATH" 2>&1 | sed "/warning: stripped absolute path/d" |
112 |
else |
113 |
logger_info "Exclude plugin $PACKAGE_CODE" |
114 |
cp "$PACKAGE_PATH" "$INSTALL_FOLDER/install" |
115 |
fi |
116 |
} |
117 |
|
118 |
function install_translations() { |
119 |
INSTALL_FOLDER="$1" |
120 |
get_package_info $2 |
121 |
|
122 |
cd "$INSTALL_FOLDER/i18n" |
123 |
rm -rf "$PACKAGE_CODE" |
124 |
if include_package $PACKAGE_CODE ; then |
125 |
logger_info "Install translations $PACKAGE_CODE $PACKAGE_VERSION" |
126 |
unzip -qq "$PACKAGE_PATH" 2>&1 | sed "/warning: stripped absolute path/d" |
127 |
else |
128 |
logger_info "Exclude translations $PACKAGE_CODE" |
129 |
cp "$PACKAGE_PATH" "$INSTALL_FOLDER/install" |
130 |
fi |
131 |
} |
132 |
|
133 |
function run_plugins_install_scripts() { |
134 |
INSTALL_FOLDER="$1" |
135 |
|
136 |
logger_info "" |
137 |
logger_info "Running plugins install scripts" |
138 |
cd "$INSTALL_FOLDER/gvSIG/extensiones" |
139 |
for PLUGIN_CODE in * |
140 |
do |
141 |
if [ -f "$INSTALL_FOLDER/gvSIG/extensiones/$PLUGIN_CODE/install/install.xml" ] ; then |
142 |
logger_info "Running custom install script of $PLUGIN_CODE" |
143 |
cd $INSTALL_FOLDER |
144 |
ant -Dgvsig_dir="$INSTALL_FOLDER" -Dextensions_dir="$INSTALL_FOLDER/gvSIG/extensiones" -f "$INSTALL_FOLDER/gvSIG/extensiones/$PLUGIN_CODE/install/install.xml" |
145 |
fi |
146 |
done |
147 |
} |
148 |
|
149 |
function install_packages() { |
150 |
INSTALL_FOLDER="$1" |
151 |
PACKAGES_FOLDER="$2" |
152 |
|
153 |
logger_info "" |
154 |
logger_info "Processing $(basename $PACKAGES_FOLDER) packages" |
155 |
for PACKAGE_PATH in $PACKAGES_FOLDER/*.gvspkg |
156 |
do |
157 |
if [ -f "$PACKAGE_PATH" ] ; then |
158 |
PACKAGE_NAME="$(basename $PACKAGE_PATH)" |
159 |
if expr "$PACKAGE_NAME" : "gvSIG-desktop-[0-9.]*-translations[.]" >/dev/null ; then |
160 |
install_translations "$INSTALL_FOLDER" "$PACKAGE_PATH" |
161 |
elif expr "$PACKAGE_NAME" : "gvSIG-desktop-[0-9.]*-symbols[.]" >/dev/null ; then |
162 |
install_symbols "$INSTALL_FOLDER" "$PACKAGE_PATH" |
163 |
elif expr "$PACKAGE_NAME" : "gvSIG-desktop-[0-9.]*-EPSG_" >/dev/null ; then |
164 |
install_jCRS_EPSG "$INSTALL_FOLDER" "$PACKAGE_PATH" |
165 |
else |
166 |
install_plugin "$INSTALL_FOLDER" "$PACKAGE_PATH" |
167 |
fi |
168 |
fi |
169 |
done |
170 |
} |
171 |
|
172 |
function include_package() { |
173 |
set +e |
174 |
egrep "^$1\$" "$BASEFOLDER/packages/excludes" >/dev/null |
175 |
FOUND=$? |
176 |
set -e |
177 |
if [ "$FOUND" == 1 ] ; then |
178 |
return 0 |
179 |
fi |
180 |
return 1 |
181 |
} |
182 |
|
183 |
|
184 |
function remove_excluded_packages() { |
185 |
logger_info "Checking plugins to remove" |
186 |
cd "$INSTALL_FOLDER/gvSIG/extensiones" |
187 |
while read line; do |
188 |
if [ -d "$line" ] ; then |
189 |
logger_info "Removing plugin $line" |
190 |
rm -rf "$line" |
191 |
fi |
192 |
done < "$BASEFOLDER/packages/excludes" |
193 |
} |
194 |
|
195 |
function install_portable_configuration_files() { |
196 |
logger_info "Install portable configuration file (gvSIG.config)" |
197 |
cp "$INSTALL_FOLDER/tools/gvSIG.config" "$INSTALL_FOLDER" |
198 |
chmod a+x "$INSTALL_FOLDER/gvSIG.sh" |
199 |
} |
200 |
|
201 |
function zipfolder() { |
202 |
echo zip -qyr9 "$1" "$2" |
203 |
if type zip >/dev/null 2>/dev/null |
204 |
then |
205 |
zip -qyr9 "$1" "$2" |
206 |
else |
207 |
echo " |
208 |
|
209 |
WARNING: zip command not found. |
210 |
$1 not compressed. |
211 |
|
212 |
" |
213 |
fi |
214 |
} |
215 |
|
216 |
function mkdist() { |
217 |
cd $BASEFOLDER/standard |
218 |
|
219 |
export PORTABLE_OS="$1" |
220 |
export PORTABLE_OSNAME="$2" |
221 |
export PORTABLE_PLATFORM="$3" |
222 |
export PORTABLE_VERSION=$(expr *${PORTABLE_OS}-${PORTABLE_PLATFORM}-online.zip : "gvSIG-desktop-\\([0-9.]*-[0-9]*\\)") |
223 |
export PORTABLE_STATUS=$(expr *${PORTABLE_OS}-${PORTABLE_PLATFORM}-online.zip : "gvSIG-desktop-[0-9.]*-[0-9]*-\\([a-zA-Z]*[0-9]*\)") |
224 |
export PORTABLE_NAME="gvsig-desktop-$PORTABLE_VERSION-${PORTABLE_STATUS}-${PORTABLE_OS}-${PORTABLE_PLATFORM}" |
225 |
|
226 |
export INSTALL_FOLDER="$TARGET/$PORTABLE_NAME" |
227 |
|
228 |
logger_info "Removing previous files" |
229 |
rm -rf "$TARGET/gvsig-desktop" |
230 |
rm -rf "$INSTALL_FOLDER" |
231 |
rm -f "$TARGET/${PORTABLE_NAME}.zip" |
232 |
rm -rf "$TARGET/packages-${PORTABLE_OS}-${PORTABLE_PLATFORM}" |
233 |
|
234 |
logger_info "Uncompressing ${PORTABLE_OSNAME} base files" |
235 |
cd $TARGET |
236 |
mkdir $PORTABLE_NAME |
237 |
cd $PORTABLE_NAME |
238 |
unzip -qq "$BASEFOLDER/standard/gvSIG-desktop-$PORTABLE_VERSION-$PORTABLE_STATUS-${PORTABLE_OS}-${PORTABLE_PLATFORM}-online.zip" |
239 |
#mv gvsig-desktop-${PORTABLE_VERSION} $PORTABLE_NAME |
240 |
|
241 |
logger_info "Uncompressing ${PORTABLE_OSNAME}-${PORTABLE_PLATFORM} package set" |
242 |
mkdir -p "$TARGET/packages-${PORTABLE_OS}-${PORTABLE_PLATFORM}" |
243 |
cd "$TARGET/packages-${PORTABLE_OS}-${PORTABLE_PLATFORM}" |
244 |
unzip -qq "$BASEFOLDER/standard/gvSIG-desktop-${PORTABLE_VERSION}-${PORTABLE_STATUS}-${PORTABLE_OS}-${PORTABLE_PLATFORM}.gvspks" |
245 |
|
246 |
install_packages "$INSTALL_FOLDER" "$TARGET/packages-${PORTABLE_OS}-${PORTABLE_PLATFORM}" |
247 |
|
248 |
install_packages "$INSTALL_FOLDER" "$BASEFOLDER/packages/custom" |
249 |
|
250 |
install_portable_configuration_files |
251 |
|
252 |
remove_excluded_packages |
253 |
|
254 |
if [ -f $PATCHSFOLDER/patchs.sh ] ; then |
255 |
chmod a+x $PATCHSFOLDER/patchs.sh |
256 |
logger_info "Appling patch to the instalation." |
257 |
source $PATCHSFOLDER/patchs.sh |
258 |
fi |
259 |
|
260 |
run_plugins_install_scripts $INSTALL_FOLDER |
261 |
|
262 |
logger_info "Compresing ${PORTABLE_OSNAME}-${PORTABLE_PLATFORM} portable (this take a moment)" |
263 |
cd "$TARGET" |
264 |
zipfolder "${PORTABLE_NAME}.zip" "${PORTABLE_NAME}" |
265 |
|
266 |
logger_info "Removing temporary package folder" |
267 |
rm -rf $TARGET/packages-${PORTABLE_OS}-${PORTABLE_PLATFORM} |
268 |
|
269 |
logger_info "${PORTABLE_OSNAME}-${PORTABLE_PLATFORM} portable created." |
270 |
} |
271 |
|
272 |
|
273 |
function main() { |
274 |
mkdist lin linux x86 |
275 |
mkdist lin linux x86_64 |
276 |
mkdist win windows x86 |
277 |
mkdist win windows x86_64 |
278 |
echo "Creation ended" |
279 |
} |
280 |
|
281 |
mkdir -p "$TARGET" |
282 |
main | tee "$TARGET/${SCRIPT_NAME}.log" |
283 |
|