1#
2# OpenBOR - http://www.ChronoCrash.com
3# -----------------------------------------------------------------------
4# All rights reserved. See LICENSE in OpenBOR root for details.
5#
6# Copyright (c) 2004 - 2014 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" || 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  elif git svn info >/dev/null 2>&1; then
41    VERSION_BUILD=`git svn info | grep "Last Changed Rev" | sed s/Last\ Changed\ Rev:\ //g`
42  fi
43}
44
45read_version() {
46check_svn_bin
47get_revnum
48VERSION_NAME="OpenBOR"
49VERSION_MAJOR=3
50VERSION_MINOR=0
51VERSION_DATE=`date '+%Y%m%d%H%M%S'`
52export VERSION="v$VERSION_MAJOR.$VERSION_MINOR Build $VERSION_BUILD"
53}
54
55write_version() {
56rm -rf version.h
57echo "/*
58 * OpenBOR - http://www.ChronoCrash.com
59 * -----------------------------------------------------------------------
60 * All rights reserved, see LICENSE in OpenBOR root for details.
61 *
62 * Copyright (c) 2004 - 2014 OpenBOR Team
63 */
64
65#ifndef VERSION_H
66#define VERSION_H
67
68#define VERSION_NAME \"$VERSION_NAME\"
69#define VERSION_MAJOR \"$VERSION_MAJOR\"
70#define VERSION_MINOR \"$VERSION_MINOR\"
71#define VERSION_BUILD \"$VERSION_BUILD\"
72#define VERSION \"v\"VERSION_MAJOR\".\"VERSION_MINOR\" Build \"VERSION_BUILD
73
74#endif" >> version.h
75
76rm -rf resources/meta.xml
77echo "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>
78<app version=\"1\">
79	<name>$VERSION_NAME</name>
80	<version>$VERSION_MAJOR.$VERSION_MINOR.$VERSION_BUILD</version>
81	<release_date>$VERSION_DATE</release_date>
82	<coder>Damon Caskey, Plombo, SX, Utunnels, White Dragon</coder>
83	<short_description>The Ultimate 2D Game Engine</short_description>
84	<long_description>OpenBOR is a highly advanced continuation of Senile Team's semi-2D game engine, Beats Of Rage.  Visit http://www.ChronoCrash.com for all news, events, and releases of the engine and game modules.</long_description>
85</app>" >> resources/meta.xml
86
87rm -rf resources/Info.plist
88echo "<?xml version="1.0" encoding="UTF-8"?>
89<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
90<plist version="1.0">
91<dict>
92  <key>Author</key>
93  <string>Damon Caskey</string>
94  <key>Description</key>
95  <string>The Ultimate 2D Game Engine</string>
96  <key>ExtendedDescription</key>
97  <string>OpenBOR is a highly advanced continuation of Senile Team's semi-2D game engine, Beats Of Rage.  Visit http://www.ChronoCrash.com for all news, events, and releases of the engine and game modules.</string>
98  <key>CFBundleIdentifier</key>
99  <string>com.ChronoCrash.openbor</string>
100  <key>CFBundleShortVersionString</key>
101  <string>$VERSION_MAJOR.$VERSION_MINOR</string>
102  <key>NSHumanReadableCopyright</key>
103  <string>The Ultimate 2D Game Engine. Presented by Damon V. Caskey.
104
105Beats of Rage © SenileTeam
106OpenBOR © ChronoCrash
107All Rights Reserved</string>
108  <key>CFBundlePackageType</key>
109  <string>APPL</string>
110  <key>CFBundleSignature</key>
111  <string>OBOR</string>
112  <key>CFBundleName</key>
113  <string>OpenBOR</string>
114  <key>CFBundleExecutable</key>
115  <string>OpenBOR</string>
116  <key>CFBundleVersion</key>
117  <string>$VERSION_BUILD</string>
118  <key>CFBundleDevelopmentRegion</key>
119  <string>English</string>
120  <key>CFBundleInfoDictionaryVersion</key>
121  <string>6.0</string>
122  <key>LSRequiresCarbon</key>
123  <true/>
124  <key>LSMinimumSystemVersion</key>
125  <string>10.5</string>
126  <key>LSMultipleInstancesProhibited</key>
127  <true/>
128  <key>CFBundleIconFile</key>
129  <string>OpenBOR</string>
130  <key>CFBundleDocumentTypes</key>
131  <array>
132    <dict>
133      <key>CFBundleTypeExtensions</key>
134      <array>
135        <string>pak</string>
136        <string>spk</string>
137      </array>
138      <key>CFBundleTypeIconFile</key>
139      <string>OpenBOR.icns</string>
140      <key>CFBundleTypeName</key>
141      <string>PAK File</string>
142      <key>CFBundleTypeOSTypes</key>
143        <array>
144          <string>pak</string>
145          <string>spk</string>
146        </array>
147      <key>CFBundleTypeRole</key>
148      <string>Viewer</string>
149    </dict>
150    <dict>
151      <key>CFBundleTypeIconFile</key>
152      <string>OpenBOR.icns</string>
153      <key>CFBundleTypeName</key>
154      <string>SPK File</string>
155      <key>CFBundleTypeRole</key>
156      <string>Viewer</string>
157    </dict>
158  </array>
159</dict>
160</plist>" >> resources/Info.plist
161}
162
163archive_release() {
164TRIMMED_URL=`svn info | grep "URL:" | sed s/URL:\ svn\+ssh//g`
165if test -n $TRIMMED_URL;  then
166  TRIMMED_URL="svn"$TRIMMED_URL
167fi
168svn log  $TRIMMED_URL --verbose > ./releases/VERSION_INFO.txt
1697za a -t7z -mx9 -r -x!.svn "./releases/OpenBOR $VERSION.7z" ./releases/*
170}
171
172export LC_MESSAGES=en_US.UTF-8
173export LC_TIME=en_US.UTF-8
174export LC_ALL=en_US.UTF-8
175
176case $1 in
1771)
178    read_version
179    echo ------------------------------------------------------
180    echo "      Creating Archive OpenBOR $VERSION.7z"
181    echo ------------------------------------------------------
182    archive_release
183    ;;
184*)
185    read_version
186    write_version
187    ;;
188esac
189
190