| 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 |
|
|---|
| 16 | out_dir="tmp/zip"
|
|---|
| 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_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 | run cp -Rdp "$fbase.sym" "$fbase.map" "$out_base_sym/$2"
|
|---|
| 44 | }
|
|---|
| 45 |
|
|---|
| 46 | cmd_cleanup()
|
|---|
| 47 | {
|
|---|
| 48 | [ -d "$out_dir" ] && \
|
|---|
| 49 | run rm -rf "$out_dir"
|
|---|
| 50 | }
|
|---|
| 51 |
|
|---|
| 52 | cmd_create()
|
|---|
| 53 | {
|
|---|
| 54 | # $1 mode (nonzero - debug, else release)
|
|---|
| 55 |
|
|---|
| 56 | local name_base
|
|---|
| 57 | local name_base_sym
|
|---|
| 58 | local build_base
|
|---|
| 59 |
|
|---|
| 60 | if [ -z "$1" ]; then
|
|---|
| 61 | name_base="odin-$ver_dots"
|
|---|
| 62 | name_base_sym="odin-$ver_dots-debuginfo"
|
|---|
| 63 | build_base="$odin_root/bin/release"
|
|---|
| 64 | else
|
|---|
| 65 | name_base="odin-$ver_dots-debug"
|
|---|
| 66 | name_base_sym="odin-$ver_dots-debug-debuginfo"
|
|---|
| 67 | build_base="$odin_root/bin/debug"
|
|---|
| 68 | fi
|
|---|
| 69 |
|
|---|
| 70 | local out_base="$out_dir/$name_base"
|
|---|
| 71 | local out_base_sym="$out_dir/$name_base_sym"
|
|---|
| 72 |
|
|---|
| 73 | cmd_cleanup
|
|---|
| 74 |
|
|---|
| 75 | # directories
|
|---|
| 76 | run mkdir -p "$out_base/system32/"
|
|---|
| 77 | run mkdir -p "$out_base_sym/system32/"
|
|---|
| 78 |
|
|---|
| 79 | # WGSS50
|
|---|
| 80 | run cp -Rdp "$odin_root/bin/wgss50.dll" "$out_base/system32/"
|
|---|
| 81 | run cp -Rdp "$odin_root/bin/wgss50.sym" "$out_base_sym/system32/"
|
|---|
| 82 |
|
|---|
| 83 | # DLLs
|
|---|
| 84 | cp_prg_file "$build_base/*.dll" "system32/"
|
|---|
| 85 |
|
|---|
| 86 | # executables
|
|---|
| 87 | cp_prg_file "$build_base/odininst.exe" "system32/"
|
|---|
| 88 | cp_prg_file "$build_base/pe.exe" "system32/"
|
|---|
| 89 | cp_prg_file "$build_base/pec.exe" "system32/"
|
|---|
| 90 | cp_prg_file "$build_base/regsvr32.exe" "system32/"
|
|---|
| 91 | cp_prg_file "$build_base/xx2lx.exe" "system32/"
|
|---|
| 92 |
|
|---|
| 93 | # Win32k
|
|---|
| 94 | cp_prg_file "$build_base/win32k.sys" "system32/"
|
|---|
| 95 | run cp -Rdp "$build_base/win32k.ddp" "$out_base/system32/"
|
|---|
| 96 | cp_prg_file "$build_base/win32kCC.exe" "system32/"
|
|---|
| 97 | cp_prg_file "$build_base/kRx.exe" "system32/"
|
|---|
| 98 |
|
|---|
| 99 | # docs
|
|---|
| 100 | run cp -Rdp \
|
|---|
| 101 | "$odin_root/ChangeLog" \
|
|---|
| 102 | "$odin_root/LICENSE.TXT" \
|
|---|
| 103 | "$odin_root/WGSS50.lic" \
|
|---|
| 104 | "$out_base/"
|
|---|
| 105 | run cp -Rdp \
|
|---|
| 106 | "$odin_root/doc/ChangeLog-*" \
|
|---|
| 107 | "$odin_root/doc/Readme.txt" \
|
|---|
| 108 | "$odin_root/doc/ReportingBugs.txt" \
|
|---|
| 109 | "$odin_root/doc/Logging.txt" \
|
|---|
| 110 | "$odin_root/doc/Odin.ini.txt" \
|
|---|
| 111 | "$odin_root/doc/odinuser.inf" \
|
|---|
| 112 | "$out_base/"
|
|---|
| 113 |
|
|---|
| 114 | # create ZIPs
|
|---|
| 115 | run cd "$out_dir"
|
|---|
| 116 | run zip -SrX9 "$name_base.zip" "$name_base"
|
|---|
| 117 | run mv "$name_base.zip" "$script_dir/"
|
|---|
| 118 | run zip -SrX9 "$name_base_sym.zip" "$name_base_sym"
|
|---|
| 119 | run mv "$name_base_sym.zip" "$script_dir/"
|
|---|
| 120 | run cd "$start_dir"
|
|---|
| 121 |
|
|---|
| 122 | cmd_cleanup
|
|---|
| 123 |
|
|---|
| 124 | echo "ALL DONE."
|
|---|
| 125 | }
|
|---|
| 126 |
|
|---|
| 127 | cmd_help()
|
|---|
| 128 | {
|
|---|
| 129 | echo \
|
|---|
| 130 | "
|
|---|
| 131 | Usage:
|
|---|
| 132 | $0 release Create release ZIPs.
|
|---|
| 133 | $0 debug Create debug ZIPs.
|
|---|
| 134 | $0 all Do 'release' and 'debug' together.
|
|---|
| 135 | $0 cleanup Remove what is created by the above commands (except ZIPs).
|
|---|
| 136 | "
|
|---|
| 137 | }
|
|---|
| 138 |
|
|---|
| 139 | #
|
|---|
| 140 | # Main
|
|---|
| 141 | #
|
|---|
| 142 |
|
|---|
| 143 | script_path=$(readlink -f $0)
|
|---|
| 144 | script_dir=${script_path%/*}
|
|---|
| 145 |
|
|---|
| 146 | start_dir=$(pwd)
|
|---|
| 147 |
|
|---|
| 148 | # Get Odin version number
|
|---|
| 149 |
|
|---|
| 150 | odin_root="$script_dir/../.."
|
|---|
| 151 |
|
|---|
| 152 | odinbuild_h="$odin_root/include/odinbuild.h"
|
|---|
| 153 |
|
|---|
| 154 | [ -f "$odinbuild_h" ] || \
|
|---|
| 155 | die "Could not find file '$odinbuild_h'."
|
|---|
| 156 |
|
|---|
| 157 | ver_major=$(sed -nre \
|
|---|
| 158 | "s/^#define ODIN32_VERSION_MAJOR[[:space:]]+([0-9]+).*$/\1/p" < "$odinbuild_h")
|
|---|
| 159 | ver_minor=$(sed -nre \
|
|---|
| 160 | "s/^#define ODIN32_VERSION_MINOR[[:space:]]+([0-9]+).*$/\1/p" < "$odinbuild_h")
|
|---|
| 161 | ver_build=$(sed -nre \
|
|---|
| 162 | "s/^#define ODIN32_BUILD_NR[[:space:]]+([0-9]+).*$/\1/p" < "$odinbuild_h")
|
|---|
| 163 |
|
|---|
| 164 | [ -z "$ver_major" -o -z "$ver_minor" -o -z "$ver_build" ] && \
|
|---|
| 165 | die "Could not determine Odin version number in '$odinbuild_h.'"
|
|---|
| 166 |
|
|---|
| 167 | ver_dots="$ver_major.$ver_minor.$ver_build"
|
|---|
| 168 |
|
|---|
| 169 | # Parse arguments
|
|---|
| 170 |
|
|---|
| 171 | case $1 in
|
|---|
| 172 | "--help" | "-?" | "-h" | "") cmd_help;;
|
|---|
| 173 | "cleanup") cmd_cleanup;;
|
|---|
| 174 | "release") cmd_create;;
|
|---|
| 175 | "debug") cmd_create "debug";;
|
|---|
| 176 | "all") cmd_create; cmd_create "debug";;
|
|---|
| 177 | esac
|
|---|
| 178 |
|
|---|
| 179 | # end of story
|
|---|
| 180 |
|
|---|
| 181 | exit 0
|
|---|
| 182 |
|
|---|