source: spec/trunk/SPECS/qtcreator/CreateZIPs.sh

Last change on this file was 214, checked in by dmik, 14 years ago

Qt Creator: Spec for release 2.2.1-1.

File size: 7.4 KB
Line 
1#!/bih/sh
2
3#
4# Qt Creator 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_base="."
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 tgt_path="$4" # target path if differs from path, if ends with slash
37 # only the dir part of path is changed
38 # [optional]
39 local exclude="$5" # exclude pattern (relative to $src_base),
40 # case syntax [optional]
41 local ext="$6" # additional extension of $path base to copy (e.g. .sym)
42 # [optional]
43
44 [ -z "$src_base" -o -z "$out_base" -o -z "$path" ] && \
45 die "cp_files: invalid arguments."
46
47 local path_dir="${path%/*}"
48 [ "$path_dir" = "$path" ] && path_dir=.
49 local path_file="${path##*/}"
50
51 if [ -n "$tgt_path" ]; then
52 local tgt_path_dir="${tgt_path%/*}"
53 [ "$tgt_path_dir" = "$tgt_path" ] && path_dir=.
54 local tgt_path_file="${tgt_path##*/}"
55 [ -z "$tgt_path_file" ] && tgt_path_file="$path_file"
56 else
57 local tgt_path_dir="$path_dir"
58 local tgt_path_file="$path_file"
59 fi
60
61 [ -d "$out_base/$tgt_path_dir" ] || run mkdir -p "$out_base/$tgt_path_dir"
62
63 # if path_file is a mask, reset tgt_path_file (to cp to just tgt_path_dir)
64 case "$path_file" in
65 *"*"*|*"?"*) tgt_path_file=;;
66 esac
67
68 # simple case?
69 if [ -z "$exclude" -a -z "$ext" ]; then
70 run $cp "$src_base/$path" "$out_base/$tgt_path_dir/$tgt_path_file"
71 return
72 fi
73
74 # complex case with exclude pattern or with additional extension
75 for f in $src_base/$path; do
76 [ -z "$exclude" ] || \
77 eval "case ${f#$src_base/} in $exclude) continue;; esac"
78 run $cp "$f" "$out_base/$tgt_path_dir/"
79 [ -z "$ext" ] || run $cp "${f%.*}.$ext" "$out_base/$tgt_path_dir/"
80 done
81}
82
83cp_files_inst_out() cp_files "$inst_base" "$out_base" "$1" "$2" "$3" "$4"
84
85cp_exe_files_inst_out() cp_files "$inst_base" "$out_base" "$1" "$2" "$3" "sym"
86
87split_out_sym()
88{
89 local out_base="$1"
90 local out_base_sym="$2"
91
92 [ -z "$out_base" -o -z "$out_base_sym" ] && \
93 die "create_zips: invalid arguments."
94
95 run mkdir -p "$out_base_sym/"
96
97 for f in $(cd "$out_base" && find -type f -name "*.sym"); do
98 local fd="${f%/*}"/
99 [ "$fd" = "$f/" ] && fd=
100 [ -d "$out_base_sym/$fd" ] || run mkdir -p "$out_base_sym/$fd"
101 run mv "$out_base/$f" "$out_base_sym/$fd"
102 done
103
104 run $cp "$script_dir/INSTALL.OS2.debuginfo" "$out_base_sym/"
105}
106
107parse_version()
108{
109 local spec_file="$start_dir/qtcreator.spec"
110
111 # get the version info from .spec
112 ver_major=$(sed -nre \
113 "s/^%define ver_major[[:space:]]+([0-9]+).*$/\1/p" < "$spec_file")
114 ver_minor=$(sed -nre \
115 "s/^%define ver_minor[[:space:]]+([0-9]+).*$/\1/p" < "$spec_file")
116 ver_patch=$(sed -nre \
117 "s/^%define ver_patch[[:space:]]+([0-9]+).*$/\1/p" < "$spec_file")
118 os2_release=$(sed -nre \
119 "s/^%define os2_release[[:space:]]+([0-9]+).*$/\1/p" < "$spec_file")
120 rpm_release=$(sed -nre \
121 "s/^%define rpm_release[[:space:]]+([0-9]+).*$/\1/p" < "$spec_file")
122
123 [ -z "$ver_major" -o -z "$ver_minor" -o -z "$ver_patch" -o \
124 -z "$os2_release" -o -z "$rpm_release" ] && \
125 die "Could not determine version number in '$spec_file'."
126
127 ver_full_spec="$ver_major.$ver_minor.$ver_patch"
128 [ "$os2_release" != "0" ] && ver_full_spec="ver_full_spec.$os2_release"
129 ver_full_spec="$ver_full_spec-$rpm_release"
130
131 ver_full="$ver_full_spec"
132 [ -n "$build_num" ] && ver_full="${ver_full}_${build_num}"
133}
134
135create_zips()
136{
137 [ -z "$start_dir" -o -z "$out_dir" -o \
138 -z "$pkg_name" -o -z "$full_pkg_name" -o -z "$out_base" ] && \
139 die "create_zips: invalid arguments."
140
141 local out_base_sym="$out_dir/$full_pkg_name-debuginfo/$pkg_name-$ver_full"
142
143 # .SYM files
144 split_out_sym "$out_base" "$out_base_sym"
145
146 local cwd=$(pwd)
147
148 run cd "$out_base/.."
149 run zip -SrX9 "$full_pkg_name-$ver_full.zip" "$pkg_name-$ver_full"
150 run mv "$full_pkg_name-$ver_full.zip" "$out_dir/.."
151
152 run cd "$out_base_sym/.."
153 run zip -SrX9 "$full_pkg_name-debuginfo-$ver_full.zip" "$pkg_name-$ver_full"
154 run mv "$full_pkg_name-debuginfo-$ver_full.zip" "$out_dir/.."
155
156 run cd "$cwd"
157}
158
159cmd_create()
160{
161 local inst_base="$1"
162 local build_num="$2"
163
164 [ -d "$inst_base" ] || die "'$inst_base' is not a directory."
165 [ -d "$out_dir_base" ] || die "'$out_dir_base' is not a directory."
166
167 parse_version
168 [ -z "$ver_full" ] && die "Version is not defined."
169
170 echo "Spec version: $ver_full_spec"
171 echo "Full version: $ver_full"
172
173 local out_dir="$out_dir_base/tmp-zip-qt4-$ver_full"
174
175 run rm -rf "$out_dir"
176
177 #--------------------------------------------------------------------------
178 # commons
179 #--------------------------------------------------------------------------
180
181 local pkg_name="qtcreator"
182
183 local designer_dlls="QtDsg*.dll"
184 local designer_plugin_dirs="designer"
185
186 usr="@unixroot/usr"
187
188 #--------------------------------------------------------------------------
189 # main package
190 #--------------------------------------------------------------------------
191
192 local full_pkg_name="qtcreator"
193 local out_base="$out_dir/$full_pkg_name/$pkg_name-$ver_full"
194
195 # Readmes
196 cp_files_inst_out "$usr/share/doc/qtcreator/LGPL_EXCEPTION.TXT" "./"
197 cp_files_inst_out "$usr/share/doc/qtcreator/LICENSE.LGPL" "./"
198 cp_files_inst_out "$usr/share/doc/qtcreator/README" "./"
199 run $cp "$script_dir/INSTALL.OS2" "$out_base/"
200
201 # Everything (see notes in .spec in the %install section)
202 cp_exe_files_inst_out "$usr/lib/qtcreator/bin/*.exe" "bin/"
203 cp_exe_files_inst_out "$usr/lib/qtcreator/bin/*.dll" "bin/"
204 cp_exe_files_inst_out "$usr/lib/qtcreator/lib/qtcreator/plugins/Nokia/*.dll" "lib/qtcreator/plugins/Nokia/"
205 cp_files_inst_out "$usr/lib/qtcreator/lib/qtcreator/plugins/Nokia/*" "lib/qtcreator/plugins/Nokia/" "*.dll"
206 cp_files_inst_out "$usr/lib/qtcreator/share/" "./"
207
208 create_zips
209
210 run rm -rf "$out_dir"
211
212 echo "ALL DONE."
213}
214
215#
216# Main
217#
218
219script_path=$(readlink -e $0)
220script_dir=${script_path%/*}
221script_name=$(basename $0)
222
223start_dir=$(pwd)
224
225[ -z "$out_dir_base" ] && out_dir_base="."
226out_dir_base=$(readlink -m "$out_dir_base")
227
228# Parse arguments
229
230cmd_help()
231{
232 echo \
233"
234Usage:
235 $script_name all [options] Create ZIPs.
236
237Options:
238 <instdir> (*) Qt installation tree location
239 <outdir> Destination directory for ZIPs [$out_dir_base]
240 <bldnum> Build number [none]
241"
242}
243
244case "$1" in
245 all)
246 if [ -n "$2" ]; then
247 [ -n "$3" ] && out_dir_base=$(echo "$3" | tr '\\' '/')
248 cmd_create $(echo "$2" | tr '\\' '/') "$4"
249 else
250 cmd_help
251 fi;;
252 -h|-?|--help|*) cmd_help;;
253esac
254
255# end of story
256
257exit 0
Note: See TracBrowser for help on using the repository browser.