source: packaging/CreateZIPs.sh@ 1041

Last change on this file since 1041 was 1041, checked in by Dmitry A. Kuminov, 14 years ago

packaging: Added script to create ZIP distribution archives.

The old WPI stuff is oudated and moved to the "unsupported"
subdirectory.

File size: 7.8 KB
Line 
1#!/bih/sh
2
3#
4# Qt4 distribution ZIP archive creator.
5#
6# NOTE: This script requires the basic set of unix tools such as cp, mkdir,
7# pwd, readlink, find etc.
8#
9
10#
11# Defaults
12#
13
14out_dir="tmp-zip"
15
16cp="cp -Rdp"
17
18#
19# Functions
20#
21
22die() { echo "ERROR: $@"; cd "$start_dir"; exit 1; }
23
24run()
25{
26 echo "$@"
27 "$@" || die \
28"Last command failed (exit status $?)."
29}
30
31cp_files()
32{
33 local src_base="$1" # source directory base
34 local out_base="$2" # output directory base
35 local path="$3" # file path relative to $src_base, may be glob
36 local exclude="$4" # exclude pattern (relative to $src_base),
37 # case syntax [optional]
38 local ext="$5" # additional extension of $path base to copy (e.g. .sym)
39 # [optional
40
41 [ -z "$src_base" -o -z "$out_base" -o -z "$path" ] && \
42 die "cp_files: invalid arguments."
43
44 local path_dir="${path%/*}/"
45 [ "$path_dir" = "$path/" ] && path_dir=
46
47 [ -d "$out_base/$path_dir" ] || run mkdir -p "$out_base/$path_dir"
48
49 # simple case?
50 if [ -z "$exclude" -a -z "$ext" ]; then
51 run $cp "$src_base/$path" "$out_base/$path_dir"
52 return
53 fi
54
55 # complex case with exclude pattern or with additional extension
56 for f in $src_base/$path; do
57 [ -z "$exclude" ] || \
58 eval "case ${f#$src_base/} in $exclude) continue;; esac"
59 run $cp "$f" "$out_base/$path_dir"
60 [ -z "$ext" ] || run $cp "${f%.*}.$ext" "$out_base/$path_dir"
61 done
62}
63
64cp_files_inst_out() cp_files "$inst_base" "$out_base" "$1" "$2" "$3"
65
66cp_exe_files_inst_out() cp_files "$inst_base" "$out_base" "$1" "$2" "sym"
67
68cmd_cleanup()
69{
70 [ -d "$out_dir" ] && \
71 run rm -rf "$out_dir"
72}
73
74split_out_sym()
75{
76 local out_base="$1"
77 local out_base_sym="$2"
78
79 run mkdir -p "$out_base_sym/"
80
81 for f in $(cd "$out_base" && find -type f -name "*.sym"); do
82 local fd="${f%/*}"/
83 [ "$fp" = "$f/" ] && fd=
84 [ -d "$out_base_sym/$fd" ] || run mkdir -p "$out_base_sym/$fd"
85 run mv "$out_base/$f" "$out_base_sym/$fd"
86 done
87
88 run $cp "$script_dir/INSTALL.OS2.debuginfo" "$out_base_sym/"
89}
90
91cmd_create()
92{
93 local inst_base="$1"
94
95 [ -d $inst_base ] || die "'$inst_base' is not a directory."
96
97 local qconfig_pri="$inst_base/mkspecs/qconfig.pri"
98
99 [ -f "$qconfig_pri" ] || \
100 die "Could not find file '$qconfig_pri'."
101
102 local ver_major=$(sed -nre \
103 "s/^[[:space:]]*QT_MAJOR_VERSION[[:space:]]+=[[:space:]]+([0-9]+)[[:space:]]*$/\1/p" < "$qconfig_pri")
104 local ver_minor=$(sed -nre \
105 "s/^[[:space:]]*QT_MINOR_VERSION[[:space:]]+=[[:space:]]+([0-9]+)[[:space:]]*$/\1/p" < "$qconfig_pri")
106 local ver_patch=$(sed -nre \
107 "s/^[[:space:]]*QT_PATCH_VERSION[[:space:]]+=[[:space:]]+([0-9]+)[[:space:]]*$/\1/p" < "$qconfig_pri")
108
109 [ -z "$ver_major" -o -z "$ver_minor" -o -z "$ver_patch" ] && \
110 die "Could not determine Qt version number in '$qconfig_pri'."
111
112 local ver_dots="$ver_major.$ver_minor.$ver_patch"
113
114 echo "Found Qt version $ver_dots."
115
116 cmd_cleanup
117
118 #--------------------------------------------------------------------------
119 # commons
120 #--------------------------------------------------------------------------
121
122 local designer_dlls="bin/QtDsg*.dll"
123 local designer_plugin_dirs="designer|qmltooling"
124
125 #--------------------------------------------------------------------------
126 # runtime package
127 #--------------------------------------------------------------------------
128
129 local out_base="$out_dir/qt-$ver_dots"
130 local out_base_sym="$out_dir/qt-debuginfo-$ver_dots"
131
132 # Readmes
133 cp_files_inst_out "LGPL_EXCEPTION.txt"
134 cp_files_inst_out "LICENSE.*"
135 cp_files_inst_out "README"
136 cp_files_inst_out "changes-$ver_major.$ver_minor.$ver_patch"
137 cp_files_inst_out "README.OS2"
138 cp_files_inst_out "CHANGES.OS2"
139 run $cp "$script_dir/INSTALL.OS2" "$out_base/"
140
141 # DLLs
142 cp_exe_files_inst_out "bin/Qt*.dll" "$designer_dlls"
143
144 # Imports
145 cp_files_inst_out "imports"
146
147 # Plugins
148 for d in $inst_base/plugins/*; do
149 local dn=${d##*/}
150 eval "case $dn in $designer_plugin_dirs) continue;; esac"
151 cp_exe_files_inst_out "plugins/$dn/*.dll"
152 done
153
154 # Translations
155 cp_files_inst_out "translations/qt_*"
156 cp_files_inst_out "translations/qt_help_*"
157 cp_files_inst_out "translations/qtconfig_*"
158
159 # qt.conf
160 echo \
161"[Paths]
162Prefix = ..
163Settings = \$(ETC)/xdg
164Examples = examples
165Demos = demos" \
166 > "$out_base/bin/qt.conf"
167
168 # .SYM files
169 split_out_sym "$out_base" "$out_base_sym"
170
171 # ZIPs
172 run cd "$out_base"
173 run zip -SrX9 "${out_base##*/}.zip" "."
174 run mv "${out_base##*/}.zip" "$start_dir/"
175 #
176 run cd "$out_base_sym"
177 run zip -SrX9 "${out_base_sym##*/}.zip" "."
178 run mv "${out_base_sym##*/}.zip" "$start_dir/"
179 #
180 run cd "$start_dir"
181
182 #--------------------------------------------------------------------------
183 # development package
184 #--------------------------------------------------------------------------
185
186 local out_base="$out_dir/qt-develop-$ver_dots"
187 local out_base_sym="$out_dir/qt-develop-debuginfo-$ver_dots"
188
189 # Readmes
190 cp_files_inst_out "LGPL_EXCEPTION.txt"
191 cp_files_inst_out "LICENSE.*"
192 cp_files_inst_out "README"
193 cp_files_inst_out "changes-$ver_major.$ver_minor.$ver_patch"
194 cp_files_inst_out "README.OS2"
195 cp_files_inst_out "CHANGES.OS2"
196 run $cp "$script_dir/INSTALL.OS2.develop" "$out_base/"
197
198 # EXEs & DLLs
199 cp_exe_files_inst_out "bin/*.exe"
200 cp_exe_files_inst_out "$designer_dlls"
201
202 # Demos
203 cp_files_inst_out "demos"
204
205 # Doc (no html, qch only)
206 cp_files_inst_out "doc/qch"
207 cp_files_inst_out "q3porting.xml"
208
209 # Examples
210 cp_files_inst_out "examples"
211
212 # Includes
213 cp_files_inst_out "include"
214
215 # Libraries
216 cp_files_inst_out "lib/*.prl"
217 cp_files_inst_out "lib/*.lib"
218
219 # Mkspecs
220 cp_files_inst_out "mkspecs"
221
222 # Phrasebooks
223 cp_files_inst_out "phrasebooks"
224
225 # Plugins
226 for d in $inst_base/plugins/*; do
227 local dn=${d##*/}
228 eval "case $dn in $designer_plugin_dirs) ;; *) continue;; esac"
229 cp_exe_files_inst_out "plugins/$dn/*.dll"
230 done
231
232 # Translations
233 cp_files_inst_out "translations/assistant_*"
234 cp_files_inst_out "translations/designer_*"
235 cp_files_inst_out "translations/linguist_*"
236
237 # .SYM files
238 split_out_sym "$out_base" "$out_base_sym"
239
240 # ZIPs
241 run cd "$out_base"
242 run zip -SrX9 "${out_base##*/}.zip" "."
243 run mv "${out_base##*/}.zip" "$start_dir/"
244 #
245 run cd "$out_base_sym"
246 run zip -SrX9 "${out_base_sym##*/}.zip" "."
247 run mv "${out_base_sym##*/}.zip" "$start_dir/"
248 #
249 run cd "$start_dir"
250
251 cmd_cleanup
252
253 echo "ALL DONE."
254}
255
256#
257# Main
258#
259
260script_path=$(readlink -e $0)
261script_dir=${script_path%/*}
262script_name=$(basename $0)
263
264start_dir=$(pwd)
265
266[ -z "$out_dir" ] && out_dir="."
267out_dir=$(readlink -m "$out_dir")
268
269# Parse arguments
270
271cmd_help()
272{
273 echo \
274"
275Usage:
276 $script_name -i <dir> Create all ZIPs.
277 $script_name cleanup Remove what this script creates (except ZIPs).
278
279Options:
280 -i <dir> Qt installation tree location
281"
282}
283
284while getopts h?i: OPT; do
285 case $OPT in
286 i) OPT_install_dir=$OPTARG;;
287 h | ?) OPT_help=1
288 esac
289done
290shift `expr $OPTIND - 1`
291
292case "$1" in
293 cleanup) cmd_cleanup;;
294 "")
295 if [ -n "$OPT_install_dir" ]; then
296 cmd_create $(echo "$OPT_install_dir" | tr '\\' '/')
297 else
298 cmd_help
299 fi;;
300 *)
301 if [ -n "$OPT_help" ]; then cmd_help
302 else die "Invalid command '$1'"
303 fi;;
304esac
305
306# end of story
307
308exit 0
Note: See TracBrowser for help on using the repository browser.