source: packaging/CreateZIPs.sh@ 1080

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

packaging: CreateZIPs: Single directory in format qt-X.Y.Z-N in all ZIPs.

I.e. the prefix (develop, debuginfo) is removed from the directory name.
This allows to easily unpack everything to a single directory (as ti should
be).

File size: 7.9 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 [ -z "$out_base" -o -z "$out_base_sym" ] && \
80 die "create_zips: invalid arguments."
81
82 run mkdir -p "$out_base_sym/"
83
84 for f in $(cd "$out_base" && find -type f -name "*.sym"); do
85 local fd="${f%/*}"/
86 [ "$fp" = "$f/" ] && fd=
87 [ -d "$out_base_sym/$fd" ] || run mkdir -p "$out_base_sym/$fd"
88 run mv "$out_base/$f" "$out_base_sym/$fd"
89 done
90
91 run $cp "$script_dir/INSTALL.OS2.debuginfo" "$out_base_sym/"
92}
93
94create_zips()
95{
96 [ -z "$start_dir" -o -z "$out_dir" -o \
97 -z "$pkg_name" -o -z "$full_pkg_name" -o -z "$out_base" ] && \
98 die "create_zips: invalid arguments."
99
100 local out_base_sym="$out_dir/$full_pkg_name-debuginfo/$pkg_name-$ver_dots"
101
102 # .SYM files
103 split_out_sym "$out_base" "$out_base_sym"
104
105 local cwd=$(pwd)
106
107 run cd "$out_base/.."
108 run zip -SrX9 "$full_pkg_name-$ver_dots.zip" "$pkg_name-$ver_dots"
109 run mv "$full_pkg_name-$ver_dots.zip" "$start_dir/"
110
111 run cd "$out_base_sym/.."
112 run zip -SrX9 "$full_pkg_name-debuginfo-$ver_dots.zip" "$pkg_name-$ver_dots"
113 run mv "$full_pkg_name-debuginfo-$ver_dots.zip" "$start_dir/"
114
115 run cd "$cwd"
116}
117
118cmd_create()
119{
120 local inst_base="$1"
121 local build_num="$2"
122
123 [ -d "$inst_base" ] || die "'$inst_base' is not a directory."
124
125 local qconfig_pri="$inst_base/mkspecs/qconfig.pri"
126
127 [ -f "$qconfig_pri" ] || \
128 die "Could not find file '$qconfig_pri'."
129
130 local ver_major=$(sed -nre \
131 "s/^[[:space:]]*QT_MAJOR_VERSION[[:space:]]+=[[:space:]]+([0-9]+)[[:space:]]*$/\1/p" < "$qconfig_pri")
132 local ver_minor=$(sed -nre \
133 "s/^[[:space:]]*QT_MINOR_VERSION[[:space:]]+=[[:space:]]+([0-9]+)[[:space:]]*$/\1/p" < "$qconfig_pri")
134 local ver_patch=$(sed -nre \
135 "s/^[[:space:]]*QT_PATCH_VERSION[[:space:]]+=[[:space:]]+([0-9]+)[[:space:]]*$/\1/p" < "$qconfig_pri")
136
137 [ -z "$ver_major" -o -z "$ver_minor" -o -z "$ver_patch" ] && \
138 die "Could not determine Qt version number in '$qconfig_pri'."
139
140 local ver_dots="$ver_major.$ver_minor.$ver_patch"
141
142 echo "Found Qt version: $ver_dots"
143
144 [ -n "$build_num" ] && ver_dots="$ver_dots-$build_num"
145
146 echo "Full version ID: $ver_dots"
147
148 cmd_cleanup
149
150 #--------------------------------------------------------------------------
151 # commons
152 #--------------------------------------------------------------------------
153
154 local pkg_name="qt"
155
156 local designer_dlls="bin/QtDsg*.dll"
157 local designer_plugin_dirs="designer|qmltooling"
158
159 #--------------------------------------------------------------------------
160 # runtime package
161 #--------------------------------------------------------------------------
162
163 local full_pkg_name="qt"
164 local out_base="$out_dir/$full_pkg_name/$pkg_name-$ver_dots"
165
166 # Readmes
167 cp_files_inst_out "LGPL_EXCEPTION.txt"
168 cp_files_inst_out "LICENSE.*"
169 cp_files_inst_out "README"
170 cp_files_inst_out "changes-$ver_major.$ver_minor.$ver_patch"
171 cp_files_inst_out "README.OS2"
172 cp_files_inst_out "CHANGES.OS2"
173 run $cp "$script_dir/INSTALL.OS2" "$out_base/"
174
175 # DLLs
176 cp_exe_files_inst_out "bin/Qt*.dll" "$designer_dlls"
177
178 # Imports
179 cp_files_inst_out "imports"
180
181 # Plugins
182 for d in $inst_base/plugins/*; do
183 local dn=${d##*/}
184 eval "case $dn in $designer_plugin_dirs) continue;; esac"
185 cp_exe_files_inst_out "plugins/$dn/*.dll"
186 done
187
188 # Translations
189 cp_files_inst_out "translations/qt_*"
190 cp_files_inst_out "translations/qt_help_*"
191 cp_files_inst_out "translations/qtconfig_*"
192
193 # qt.conf
194 echo \
195"[Paths]
196Prefix = ..
197Settings = \$(ETC)/xdg
198Examples = examples
199Demos = demos" \
200 > "$out_base/bin/qt.conf"
201
202 create_zips
203
204 #--------------------------------------------------------------------------
205 # development package
206 #--------------------------------------------------------------------------
207
208 local full_pkg_name="qt-develop"
209 local out_base="$out_dir/$full_pkg_name/$pkg_name-$ver_dots"
210
211 # Readmes
212 cp_files_inst_out "LGPL_EXCEPTION.txt"
213 cp_files_inst_out "LICENSE.*"
214 cp_files_inst_out "README"
215 cp_files_inst_out "changes-$ver_major.$ver_minor.$ver_patch"
216 cp_files_inst_out "README.OS2"
217 cp_files_inst_out "CHANGES.OS2"
218 run $cp "$script_dir/INSTALL.OS2.develop" "$out_base/"
219
220 # EXEs & DLLs
221 cp_exe_files_inst_out "bin/*.exe"
222 cp_exe_files_inst_out "$designer_dlls"
223
224 # Demos
225 cp_files_inst_out "demos"
226
227 # Doc (no html, qch only)
228 cp_files_inst_out "doc/qch"
229 cp_files_inst_out "q3porting.xml"
230
231 # Examples
232 cp_files_inst_out "examples"
233
234 # Includes
235 cp_files_inst_out "include"
236
237 # Libraries
238 cp_files_inst_out "lib/*.prl"
239 cp_files_inst_out "lib/*.lib"
240
241 # Mkspecs
242 cp_files_inst_out "mkspecs"
243
244 # Phrasebooks
245 cp_files_inst_out "phrasebooks"
246
247 # Plugins
248 for d in $inst_base/plugins/*; do
249 local dn=${d##*/}
250 eval "case $dn in $designer_plugin_dirs) ;; *) continue;; esac"
251 cp_exe_files_inst_out "plugins/$dn/*.dll"
252 done
253
254 # Translations
255 cp_files_inst_out "translations/assistant_*"
256 cp_files_inst_out "translations/designer_*"
257 cp_files_inst_out "translations/linguist_*"
258
259 create_zips
260
261 cmd_cleanup
262
263 echo "ALL DONE."
264}
265
266#
267# Main
268#
269
270script_path=$(readlink -e $0)
271script_dir=${script_path%/*}
272script_name=$(basename $0)
273
274start_dir=$(pwd)
275
276[ -z "$out_dir" ] && out_dir="."
277out_dir=$(readlink -m "$out_dir")
278
279# Parse arguments
280
281cmd_help()
282{
283 echo \
284"
285Usage:
286 $script_name all [options] Create ZIPs.
287 $script_name cleanup Remove what this script creates (except ZIPs).
288
289Options:
290 <instdir> (*) Qt installation tree location
291 <bldnum> Build number [none]
292"
293}
294
295case "$1" in
296 cleanup) cmd_cleanup;;
297 all)
298 if [ -n "$2" ]; then
299 cmd_create $(echo "$2" | tr '\\' '/') "$3"
300 else
301 cmd_help
302 fi;;
303 -h|-?|--help|*) cmd_help;;
304esac
305
306# end of story
307
308exit 0
Note: See TracBrowser for help on using the repository browser.