1#
2# OpenBOR - http://www.LavaLit.com
3# -----------------------------------------------------------------------
4# Licensed under the BSD license, see LICENSE in OpenBOR root for details.
5#
6# Copyright (c) 2004 - 2011 OpenBOR Team
7#
8
9#!/bin/bash
10# Script acquires the verison number from SVN Repository and creates
11# a version.h as well as the environment variable to be used.
12
13check_svn_bin() {
14HOST_PLATFORM=$(uname -s)
15if [ `echo $HOST_PLATFORM | grep -o "windows"` ]; then
16  if [ ! -d "../tools/svn/bin" ]; then
17    echo "-------------------------------------------------------"
18    echo "           SVN - Not Found, Installing SVN!"
19    echo "-------------------------------------------------------"
20    7za x -y ../tools/svn/svn-win32-1.7.0.7z -o../tools/svn/
21    echo
22    echo "-------------------------------------------------------"
23    echo "           SVN - Installation Has Completed!"
24    echo "-------------------------------------------------------"
25  fi
26fi
27}
28
29# Support the Bazaar VCS as an alternative to SVN through the bzr-svn plugin
30get_revnum() {
31  if test -d "../.svn"; then
32    VERSION_BUILD=`svn info | grep "Last Changed Rev" | sed s/Last\ Changed\ Rev:\ //g`
33  elif test -d ".bzr"; then
34    VERSION_BUILD=`bzr version-info | grep "svn-revno" | sed 's/svn-revno: //g'`
35    if [ ! $VERSION_BUILD ]; then # use non-SVN revision number if "svn-revno" property not available
36      REVNO=`bzr version-info | grep "revno:" | sed 's/revno: //g'`
37      BRANCH=`bzr version-info | grep "branch-nick:" | sed 's/branch-nick: //g'`
38      VERSION_BUILD=$REVNO-bzr-$BRANCH
39    fi
40  fi
41}
42
43read_version() {
44check_svn_bin
45get_revnum
46VERSION_NAME="OpenBOR"
47VERSION_MAJOR=3
48VERSION_MINOR=0
49VERSION_DATE=`date '+%Y%m%d%H%M%S'`
50export VERSION="v$VERSION_MAJOR.$VERSION_MINOR Build $VERSION_BUILD"
51}
52
53write_version() {
54rm -rf version.h
55echo "/*
56 * OpenBOR - http://www.LavaLit.com
57 * -----------------------------------------------------------------------
58 * Licensed under the BSD license, see LICENSE in OpenBOR root for details.
59 *
60 * Copyright (c) 2004 - 2011 OpenBOR Team
61 */
62
63#ifndef VERSION_H
64#define VERSION_H
65
66#define VERSION_NAME \"$VERSION_NAME\"
67#define VERSION_MAJOR \"$VERSION_MAJOR\"
68#define VERSION_MINOR \"$VERSION_MINOR\"
69#define VERSION_BUILD \"$VERSION_BUILD\"
70#define VERSION \"v\"VERSION_MAJOR\".\"VERSION_MINOR\" Build \"VERSION_BUILD
71
72#endif" >> version.h
73
74rm -rf resources/meta.xml
75echo "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>
76<app version=\"1\">
77	<name>$VERSION_NAME</name>
78	<version>$VERSION_MAJOR.$VERSION_MINOR.$VERSION_BUILD</version>
79	<release_date>$VERSION_DATE</release_date>
80	<coder>Plombo, SX</coder>
81	<short_description>The Ultimate 2D Game Engine</short_description>
82	<long_description>OpenBOR is a highly advanced continuation of Senile Team's semi-2D game engine, Beats Of Rage.  Visit http://www.LavaLit.com for all news, events, and releases of the engine and game modules.
83</app>" >> resources/meta.xml
84
85rm -rf resources/Info.plist
86echo "<?xml version="1.0" encoding="UTF-8"?>
87<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
88<plist version="1.0">
89<dict>
90  <key>Author</key>
91  <string>SX</string>
92  <key>Description</key>
93  <string>The Ultimate 2D Game Engine</string>
94  <key>ExtendedDescription</key>
95  <string>OpenBOR is a highly advanced continuation of Senile Team's semi-2D game engine, Beats Of Rage.  Visit http://www.LavaLit.com for all news, events, and releases of the engine and game modules.</string>
96  <key>CFBundleIdentifier</key>
97  <string>com.lavalit.openbor</string>
98  <key>CFBundleShortVersionString</key>
99  <string>$VERSION_MAJOR.$VERSION_MINOR</string>
100  <key>NSHumanReadableCopyright</key>
101  <string>The Ultimate 2D Game Engine Presented by SX
102
103Beats of Rage © SenileTeam
104OpenBOR © LavaLit
105All Rights Reserved</string>
106  <key>CFBundlePackageType</key>
107  <string>APPL</string>
108  <key>CFBundleSignature</key>
109  <string>OBOR</string>
110  <key>CFBundleName</key>
111  <string>OpenBOR</string>
112  <key>CFBundleExecutable</key>
113  <string>OpenBOR</string>
114  <key>CFBundleVersion</key>
115  <string>$VERSION_BUILD</string>
116  <key>CFBundleDevelopmentRegion</key>
117  <string>English</string>
118  <key>CFBundleInfoDictionaryVersion</key>
119  <string>6.0</string>
120  <key>LSRequiresCarbon</key>
121  <true/>
122  <key>LSMinimumSystemVersion</key>
123  <string>10.5</string>
124  <key>LSMultipleInstancesProhibited</key>
125  <true/>
126  <key>CFBundleIconFile</key>
127  <string>OpenBOR</string>
128  <key>CFBundleDocumentTypes</key>
129  <array>
130    <dict>
131      <key>CFBundleTypeExtensions</key>
132      <array>
133        <string>pak</string>
134	<string>PAK</string>
135      </array>
136      <key>CFBundleTypeIconFile</key>
137      <string>OpenBOR.icns</string>
138      <key>CFBundleTypeName</key>
139      <string>PAK File</string>
140      <key>CFBundleTypeOSTypes</key>
141      <string>pak</string>
142      <key>CFBundleTypeRole</key>
143      <string>Viewer</string>
144    </dict>
145    <dict>
146      <key>CFBundleTypeExtensions</key>
147      <string>spk</string>
148      <key>CFBundleTypeIconFile</key>
149      <string>OpenBOR.icns</string>
150      <key>CFBundleTypeName</key>
151      <string>SPK File</string>
152      <key>CFBundleTypeOSTypes</key>
153      <string>spk</string>
154      <key>CFBundleTypeRole</key>
155      <string>Viewer</string>
156    </dict>
157  </array>
158</dict>
159</plist>" >> resources/Info.plist
160}
161
162archive_release() {
163svn log --verbose > ./releases/VERSION_INFO.txt
1647za a -t7z -mx9 -r -x!.svn "./releases/OpenBOR $VERSION.7z" ./releases/*
165}
166
167export LC_MESSAGES=en_US
168export LC_TIME=en_US
169
170case $1 in
1711)
172    read_version
173    echo ------------------------------------------------------
174    echo "      Creating Archive OpenBOR $VERSION.7z"
175    echo ------------------------------------------------------
176    archive_release
177    ;;
178*)
179    read_version
180    write_version
181    ;;
182esac
183
184