source: spec/trunk/SPECS/odin/CreateZIPs.sh@ 1194

Last change on this file since 1194 was 295, checked in by dmik, 14 years ago

spec: odin: Fix expanding wildcards.

File size: 5.0 KB
Line 
1#!/bih/sh
2
3#
4# Odin distribution ZIP archive creator.
5#
6# Project Odin Software License can be found in LICENSE.TXT
7#
8# NOTE: This script requires the basic set of unix tools such as cp, mkdir,
9# pwd, readlink, etc.
10#
11
12#
13# Defaults
14#
15
16out_dir="tmp/zip"
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_prg_file()
32{
33 # $1 file
34 # $2 dest dir (relative to $out_base[_sym])
35 # $out_base dest base
36 # $out_base_sym sym/map dest base
37
38 [ -z "$1" -o -z "$2" -o -z "$out_base" -o -z "$out_base_sym" ] && \
39 die "cp_prg_file: invalid arguments."
40
41 local fbase=${1%.*}
42 run cp -Rdp $1 "$out_base/$2"
43 # don't copy .map, it's not in the right place of the build tree any more
44# run cp -Rdp $fbase.sym "$fbase.map" "$out_base_sym/$2"
45 run cp -Rdp $fbase.sym "$out_base_sym/$2"
46
47 # lxlite it in release mode
48 if [ -z "$debug" ]; then
49 lxlite /B- "$out_base/$2${1##*/}"
50 fi
51}
52
53cmd_cleanup()
54{
55 [ -d "$out_dir" ] && \
56 run rm -rf "$out_dir"
57}
58
59cmd_create()
60{
61 # $1 mode (nonzero - debug, else release)
62
63 local name_base
64 local name_base_sym
65 local build_base
66
67 local debug
68 [ -n "$1" ] && debug="yes"
69
70 if [ -z "$debug" ]; then
71 name_base="odin-$ver_dots"
72 name_base_sym="odin-$ver_dots-debuginfo"
73 build_base="$odin_root-build/os2.x86/release"
74 else
75 name_base="odin-$ver_dots-debug"
76 name_base_sym="odin-$ver_dots-debug-debuginfo"
77 build_base="$odin_root-build/os2.x86/debug"
78 fi
79
80 local out_base="$out_dir/$name_base"
81 local out_base_sym="$out_dir/$name_base_sym"
82
83 cmd_cleanup
84
85 # directories
86 run mkdir -p "$out_base/system32/"
87 run mkdir -p "$out_base_sym/system32/"
88
89 # WGSS50
90 run cp -Rdp "$odin_root/bin/wgss50.dll" "$out_base/system32/"
91 run cp -Rdp "$odin_root/bin/wgss50.sym" "$out_base_sym/system32/"
92
93 # DLLs
94 cp_prg_file "$build_base/stage/bin/*.dll" "system32/"
95
96 # executables
97 cp_prg_file "$build_base/stage/bin/odininst.exe" "system32/"
98 cp_prg_file "$build_base/stage/bin/pe.exe" "system32/"
99 cp_prg_file "$build_base/stage/bin//pec.exe" "system32/"
100 cp_prg_file "$build_base/stage/bin/regsvr32.exe" "system32/"
101 cp_prg_file "$build_base/stage/bin/xx2lx.exe" "system32/"
102
103 # Win32k
104# cp_prg_file "$build_base/win32k.sys" "system32/"
105# run cp -Rdp "$build_base/win32k.ddp" "$out_base/system32/"
106# cp_prg_file "$build_base/win32kCC.exe" "system32/"
107# cp_prg_file "$build_base/kRx.exe" "system32/"
108
109 # docs
110 run cp -Rdp \
111 "$odin_root/ChangeLog" \
112 "$odin_root/LICENSE.TXT" \
113 "$odin_root/WGSS50.lic" \
114 "$out_base/"
115 run cp -Rdp \
116 "$odin_root/doc/ChangeLog-"* \
117 "$odin_root/doc/Readme.txt" \
118 "$odin_root/doc/ReportingBugs.txt" \
119 "$odin_root/doc/Logging.txt" \
120 "$odin_root/doc/Odin.ini.txt" \
121 "$odin_root/doc/odinuser.inf" \
122 "$out_base/"
123
124 # create ZIPs
125 run cd "$out_dir"
126 run zip -SrX9 "$name_base.zip" "$name_base"
127 run mv "$name_base.zip" "$script_dir/"
128 run zip -SrX9 "$name_base_sym.zip" "$name_base_sym"
129 run mv "$name_base_sym.zip" "$script_dir/"
130 run cd "$start_dir"
131
132 cmd_cleanup
133
134 echo "ALL DONE."
135}
136
137cmd_help()
138{
139 echo \
140"
141Usage:
142 $0 <command> <odin_root>
143
144<command> is one of:
145 release Create release ZIPs.
146 debug Create debug ZIPs.
147 all Do 'release' and 'debug' together.
148 cleanup Remove what is created by the above commands (except ZIPs).
149
150<odin_root> is the full path to the Odin source tree. Note that the build
151tree is expected to be found in the <odin_root>-build directory.
152"
153}
154
155#
156# Main
157#
158
159script_path=$(readlink -f $0)
160script_dir=${script_path%/*}
161
162start_dir=$(pwd)
163
164# Get Odin version number
165
166odin_root="$2"
167[ -n "$2" ] || { cmd_help; exit 0; }
168
169odinbuild_h="$odin_root/include/odinbuild.h"
170
171[ -f "$odinbuild_h" ] || \
172 die "Could not find file '$odinbuild_h'."
173
174ver_major=$(sed -nre \
175 "s/^#define ODIN32_VERSION_MAJOR[[:space:]]+([0-9]+).*$/\1/p" < "$odinbuild_h")
176ver_minor=$(sed -nre \
177 "s/^#define ODIN32_VERSION_MINOR[[:space:]]+([0-9]+).*$/\1/p" < "$odinbuild_h")
178ver_build=$(sed -nre \
179 "s/^#define ODIN32_BUILD_NR[[:space:]]+([0-9]+).*$/\1/p" < "$odinbuild_h")
180
181[ -z "$ver_major" -o -z "$ver_minor" -o -z "$ver_build" ] && \
182 die "Could not determine Odin version number in '$odinbuild_h.'"
183
184ver_dots="$ver_major.$ver_minor.$ver_build"
185
186# Parse arguments
187
188case $1 in
189 "--help" | "-?" | "-h" | "") cmd_help;;
190 "cleanup") cmd_cleanup;;
191 "release") cmd_create;;
192 "debug") cmd_create "debug";;
193 "all") cmd_create; cmd_create "debug";;
194 *) cmd_help;;
195esac
196
197# end of story
198
199exit 0
200
Note: See TracBrowser for help on using the repository browser.