[1041] | 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 |
|
---|
[1096] | 14 | out_dir_base="."
|
---|
[1041] | 15 |
|
---|
| 16 | cp="cp -Rdp"
|
---|
| 17 |
|
---|
| 18 | #
|
---|
| 19 | # Functions
|
---|
| 20 | #
|
---|
| 21 |
|
---|
| 22 | die() { echo "ERROR: $@"; cd "$start_dir"; exit 1; }
|
---|
| 23 |
|
---|
| 24 | run()
|
---|
| 25 | {
|
---|
| 26 | echo "$@"
|
---|
| 27 | "$@" || die \
|
---|
| 28 | "Last command failed (exit status $?)."
|
---|
| 29 | }
|
---|
| 30 |
|
---|
| 31 | cp_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
|
---|
[1093] | 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),
|
---|
[1041] | 40 | # case syntax [optional]
|
---|
[1093] | 41 | local ext="$6" # additional extension of $path base to copy (e.g. .sym)
|
---|
| 42 | # [optional]
|
---|
[1041] | 43 |
|
---|
| 44 | [ -z "$src_base" -o -z "$out_base" -o -z "$path" ] && \
|
---|
| 45 | die "cp_files: invalid arguments."
|
---|
| 46 |
|
---|
[1093] | 47 | local path_dir="${path%/*}"
|
---|
| 48 | [ "$path_dir" = "$path" ] && path_dir=.
|
---|
| 49 | local path_file="${path##*/}"
|
---|
[1041] | 50 |
|
---|
[1093] | 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
|
---|
[1041] | 60 |
|
---|
[1093] | 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 |
|
---|
[1041] | 68 | # simple case?
|
---|
| 69 | if [ -z "$exclude" -a -z "$ext" ]; then
|
---|
[1131] | 70 | run $cp $src_base/$path "$out_base/$tgt_path_dir/$tgt_path_file"
|
---|
[1041] | 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"
|
---|
[1093] | 78 | run $cp "$f" "$out_base/$tgt_path_dir/"
|
---|
| 79 | [ -z "$ext" ] || run $cp "${f%.*}.$ext" "$out_base/$tgt_path_dir/"
|
---|
[1041] | 80 | done
|
---|
| 81 | }
|
---|
| 82 |
|
---|
[1093] | 83 | cp_files_inst_out() cp_files "$inst_base" "$out_base" "$1" "$2" "$3" "$4"
|
---|
[1041] | 84 |
|
---|
[1093] | 85 | cp_exe_files_inst_out() cp_files "$inst_base" "$out_base" "$1" "$2" "$3" "sym"
|
---|
[1041] | 86 |
|
---|
| 87 | split_out_sym()
|
---|
| 88 | {
|
---|
| 89 | local out_base="$1"
|
---|
| 90 | local out_base_sym="$2"
|
---|
| 91 |
|
---|
[1060] | 92 | [ -z "$out_base" -o -z "$out_base_sym" ] && \
|
---|
| 93 | die "create_zips: invalid arguments."
|
---|
| 94 |
|
---|
[1041] | 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%/*}"/
|
---|
[1093] | 99 | [ "$fd" = "$f/" ] && fd=
|
---|
[1041] | 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 |
|
---|
[1093] | 107 | parse_version()
|
---|
| 108 | {
|
---|
| 109 | local spec_file="$start_dir/qt4.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"
|
---|
[1132] | 128 | [ "$os2_release" != "0" ] && ver_full_spec="$ver_full_spec.$os2_release"
|
---|
[1093] | 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 |
|
---|
[1060] | 135 | create_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 |
|
---|
[1093] | 141 | local out_base_sym="$out_dir/$full_pkg_name-debuginfo/$pkg_name-$ver_full"
|
---|
[1060] | 142 |
|
---|
| 143 | # .SYM files
|
---|
| 144 | split_out_sym "$out_base" "$out_base_sym"
|
---|
| 145 |
|
---|
| 146 | local cwd=$(pwd)
|
---|
| 147 |
|
---|
| 148 | run cd "$out_base/.."
|
---|
[1093] | 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/.."
|
---|
[1060] | 151 |
|
---|
| 152 | run cd "$out_base_sym/.."
|
---|
[1093] | 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/.."
|
---|
[1060] | 155 |
|
---|
| 156 | run cd "$cwd"
|
---|
| 157 | }
|
---|
| 158 |
|
---|
[1041] | 159 | cmd_create()
|
---|
| 160 | {
|
---|
| 161 | local inst_base="$1"
|
---|
[1096] | 162 | local build_num="$2"
|
---|
[1041] | 163 |
|
---|
[1060] | 164 | [ -d "$inst_base" ] || die "'$inst_base' is not a directory."
|
---|
[1096] | 165 | [ -d "$out_dir_base" ] || die "'$out_dir_base' is not a directory."
|
---|
[1041] | 166 |
|
---|
[1093] | 167 | parse_version
|
---|
| 168 | [ -z "$ver_full" ] && die "Version is not defined."
|
---|
[1041] | 169 |
|
---|
[1093] | 170 | echo "Spec version: $ver_full_spec"
|
---|
| 171 | echo "Full version: $ver_full"
|
---|
[1041] | 172 |
|
---|
[1096] | 173 | local out_dir="$out_dir_base/tmp-zip-qt4-$ver_full"
|
---|
[1041] | 174 |
|
---|
[1096] | 175 | run rm -rf "$out_dir"
|
---|
[1041] | 176 |
|
---|
| 177 | #--------------------------------------------------------------------------
|
---|
| 178 | # commons
|
---|
| 179 | #--------------------------------------------------------------------------
|
---|
| 180 |
|
---|
[1093] | 181 | local pkg_name="qt4"
|
---|
[1060] | 182 |
|
---|
[1093] | 183 | local designer_dlls="QtDsg*.dll"
|
---|
| 184 | local designer_plugin_dirs="designer"
|
---|
[1041] | 185 |
|
---|
[1093] | 186 | usr="@unixroot/usr"
|
---|
| 187 |
|
---|
[1041] | 188 | #--------------------------------------------------------------------------
|
---|
| 189 | # runtime package
|
---|
| 190 | #--------------------------------------------------------------------------
|
---|
| 191 |
|
---|
[1093] | 192 | local full_pkg_name="qt4"
|
---|
| 193 | local out_base="$out_dir/$full_pkg_name/$pkg_name-$ver_full"
|
---|
[1041] | 194 |
|
---|
| 195 | # Readmes
|
---|
[1093] | 196 | cp_files_inst_out "$usr/share/doc/qt4/LGPL_EXCEPTION.txt" "./"
|
---|
| 197 | cp_files_inst_out "$usr/share/doc/qt4/LICENSE.*" "./"
|
---|
| 198 | cp_files_inst_out "$usr/share/doc/qt4/README" "./"
|
---|
| 199 | cp_files_inst_out "$usr/share/doc/qt4/changes-$ver_major.$ver_minor.$ver_patch" "./"
|
---|
| 200 | cp_files_inst_out "$usr/share/doc/qt4/README.OS2" "./"
|
---|
| 201 | cp_files_inst_out "$usr/share/doc/qt4/CHANGES.OS2" "./"
|
---|
[1041] | 202 | run $cp "$script_dir/INSTALL.OS2" "$out_base/"
|
---|
| 203 |
|
---|
| 204 | # DLLs
|
---|
[1093] | 205 | cp_exe_files_inst_out "$usr/lib/Qt*.dll" "bin/" "$usr/lib/$designer_dlls"
|
---|
[1041] | 206 |
|
---|
| 207 | # Imports
|
---|
[1093] | 208 | cp_files_inst_out "$usr/lib/qt4/imports" "./"
|
---|
[1041] | 209 |
|
---|
| 210 | # Plugins
|
---|
[1093] | 211 | for d in $inst_base/$usr/lib/qt4/plugins/*; do
|
---|
[1041] | 212 | local dn=${d##*/}
|
---|
| 213 | eval "case $dn in $designer_plugin_dirs) continue;; esac"
|
---|
[1093] | 214 | cp_exe_files_inst_out "$usr/lib/qt4/plugins/$dn/*.dll" "plugins/$dn/"
|
---|
[1041] | 215 | done
|
---|
| 216 |
|
---|
| 217 | # Translations
|
---|
[1093] | 218 | cp_files_inst_out "$usr/share/qt4/translations/qt_??.qm" "translations/"
|
---|
| 219 | cp_files_inst_out "$usr/share/qt4/translations/qt_??_??.qm" "translations/"
|
---|
| 220 | cp_files_inst_out "$usr/share/qt4/translations/qt_help_??.qm" "translations/"
|
---|
| 221 | cp_files_inst_out "$usr/share/qt4/translations/qt_help_??_??.qm" "translations/"
|
---|
[1041] | 222 |
|
---|
| 223 | # qt.conf
|
---|
| 224 | echo \
|
---|
| 225 | "[Paths]
|
---|
| 226 | Prefix = ..
|
---|
| 227 | Settings = \$(ETC)/xdg
|
---|
| 228 | Examples = examples
|
---|
| 229 | Demos = demos" \
|
---|
| 230 | > "$out_base/bin/qt.conf"
|
---|
| 231 |
|
---|
[1060] | 232 | create_zips
|
---|
[1041] | 233 |
|
---|
| 234 | #--------------------------------------------------------------------------
|
---|
| 235 | # development package
|
---|
| 236 | #--------------------------------------------------------------------------
|
---|
| 237 |
|
---|
[1093] | 238 | local full_pkg_name="qt4-devel-kit"
|
---|
| 239 | local out_base="$out_dir/$full_pkg_name/$pkg_name-$ver_full"
|
---|
[1041] | 240 |
|
---|
| 241 | # Readmes
|
---|
[1093] | 242 | cp_files_inst_out "$usr/share/doc/qt4/LGPL_EXCEPTION.txt" "./"
|
---|
| 243 | cp_files_inst_out "$usr/share/doc/qt4/LICENSE.*" "./"
|
---|
| 244 | cp_files_inst_out "$usr/share/doc/qt4/README" "./"
|
---|
| 245 | cp_files_inst_out "$usr/share/doc/qt4/changes-$ver_major.$ver_minor.$ver_patch" "./"
|
---|
| 246 | cp_files_inst_out "$usr/share/doc/qt4/README.OS2" "./"
|
---|
| 247 | cp_files_inst_out "$usr/share/doc/qt4/CHANGES.OS2" "./"
|
---|
[1041] | 248 | run $cp "$script_dir/INSTALL.OS2.develop" "$out_base/"
|
---|
| 249 |
|
---|
| 250 | # EXEs & DLLs
|
---|
[1093] | 251 | cp_exe_files_inst_out "$usr/lib/qt4/bin/*.exe" "bin/" "$usr/lib/qt4/bin/qmake.exe"
|
---|
| 252 | cp_exe_files_inst_out "$usr/bin/*.exe" "bin/"
|
---|
| 253 | cp_exe_files_inst_out "$usr/lib/$designer_dlls" "bin/"
|
---|
[1041] | 254 |
|
---|
| 255 | # Demos
|
---|
[1093] | 256 | cp_files_inst_out "$usr/lib/qt4/demos" "./"
|
---|
[1041] | 257 |
|
---|
| 258 | # Doc (no html, qch only)
|
---|
[1093] | 259 | cp_files_inst_out "$usr/share/qt4/doc/qch" "doc/"
|
---|
| 260 | cp_files_inst_out "$usr/share/qt4/q3porting.xml" "./"
|
---|
[1041] | 261 |
|
---|
| 262 | # Examples
|
---|
[1093] | 263 | cp_files_inst_out "$usr/lib/qt4/examples" "./"
|
---|
[1041] | 264 |
|
---|
| 265 | # Includes
|
---|
[1093] | 266 | cp_files_inst_out "$usr/include" "./"
|
---|
[1041] | 267 |
|
---|
| 268 | # Libraries
|
---|
[1093] | 269 | cp_files_inst_out "$usr/lib/Qt*.prl" "lib/"
|
---|
| 270 | cp_files_inst_out "$usr/lib/Qt*.lib" "lib/"
|
---|
[1041] | 271 |
|
---|
| 272 | # Mkspecs
|
---|
[1093] | 273 | cp_files_inst_out "$usr/share/qt4/mkspecs" "./"
|
---|
[1041] | 274 |
|
---|
| 275 | # Phrasebooks
|
---|
[1093] | 276 | cp_files_inst_out "$usr/share/qt4/phrasebooks" "./"
|
---|
[1041] | 277 |
|
---|
| 278 | # Plugins
|
---|
[1093] | 279 | for d in $inst_base/$usr/lib/qt4/plugins/*; do
|
---|
[1041] | 280 | local dn=${d##*/}
|
---|
| 281 | eval "case $dn in $designer_plugin_dirs) ;; *) continue;; esac"
|
---|
[1093] | 282 | cp_exe_files_inst_out "$usr/lib/qt4/plugins/$dn/*.dll" "plugins/$dn/"
|
---|
[1041] | 283 | done
|
---|
| 284 |
|
---|
| 285 | # Translations
|
---|
[1093] | 286 | cp_files_inst_out "$usr/share/qt4/translations/assistant_??.qm" "translations/"
|
---|
| 287 | cp_files_inst_out "$usr/share/qt4/translations/assistant_??_??.qm" "translations/"
|
---|
| 288 | cp_files_inst_out "$usr/share/qt4/translations/designer_??.qm" "translations/"
|
---|
| 289 | cp_files_inst_out "$usr/share/qt4/translations/designer_??_??.qm" "translations/"
|
---|
| 290 | cp_files_inst_out "$usr/share/qt4/translations/linguist_??.qm" "translations/"
|
---|
| 291 | cp_files_inst_out "$usr/share/qt4/translations/linguist_??_??.qm" "translations/"
|
---|
[1041] | 292 |
|
---|
[1060] | 293 | create_zips
|
---|
[1041] | 294 |
|
---|
[1096] | 295 | run rm -rf "$out_dir"
|
---|
[1041] | 296 |
|
---|
| 297 | echo "ALL DONE."
|
---|
| 298 | }
|
---|
| 299 |
|
---|
| 300 | #
|
---|
| 301 | # Main
|
---|
| 302 | #
|
---|
| 303 |
|
---|
| 304 | script_path=$(readlink -e $0)
|
---|
| 305 | script_dir=${script_path%/*}
|
---|
| 306 | script_name=$(basename $0)
|
---|
| 307 |
|
---|
| 308 | start_dir=$(pwd)
|
---|
| 309 |
|
---|
[1096] | 310 | [ -z "$out_dir_base" ] && out_dir_base="."
|
---|
| 311 | out_dir_base=$(readlink -m "$out_dir_base")
|
---|
[1041] | 312 |
|
---|
| 313 | # Parse arguments
|
---|
| 314 |
|
---|
| 315 | cmd_help()
|
---|
| 316 | {
|
---|
| 317 | echo \
|
---|
| 318 | "
|
---|
| 319 | Usage:
|
---|
[1060] | 320 | $script_name all [options] Create ZIPs.
|
---|
[1041] | 321 |
|
---|
| 322 | Options:
|
---|
[1060] | 323 | <instdir> (*) Qt installation tree location
|
---|
[1096] | 324 | <outdir> Destination directory for ZIPs [$out_dir_base]
|
---|
[1060] | 325 | <bldnum> Build number [none]
|
---|
[1041] | 326 | "
|
---|
| 327 | }
|
---|
| 328 |
|
---|
| 329 | case "$1" in
|
---|
[1060] | 330 | all)
|
---|
| 331 | if [ -n "$2" ]; then
|
---|
[1096] | 332 | [ -n "$3" ] && out_dir_base=$(echo "$3" | tr '\\' '/')
|
---|
| 333 | cmd_create $(echo "$2" | tr '\\' '/') "$4"
|
---|
[1041] | 334 | else
|
---|
| 335 | cmd_help
|
---|
| 336 | fi;;
|
---|
[1060] | 337 | -h|-?|--help|*) cmd_help;;
|
---|
[1041] | 338 | esac
|
---|
| 339 |
|
---|
| 340 | # end of story
|
---|
| 341 |
|
---|
| 342 | exit 0
|
---|