Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

executable file 103 lines (79 sloc) 3.084 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103
#!/bin/bash

BASE="master"

DATENUM="`date +%Y%m%d`"

VERSTR="$1"
if [ "${VERSTR}" = "today" ]
then
VERSTR="${DATENUM}"
fi

FULLVERSTR="${BASE}_${VERSTR}"
if [[ "${VERSTR}" =~ ^[0-9.]{1,7}(_.*)$ ]]
then
FULLVERSTR="${BASE}.${VERSTR}"
fi

GITBRANCH="todo/${FULLVERSTR}"

A=$'\033[1m'
B=$'\033[0m'

ERROR=0

if [ "${VERSTR}" = "" ]
then
echo -ne "${A}Usage${B}:\n\n\tTo create a todo/${BASE}.3_beta15 branch:\n\t\t$0 3_beta15\n\n\tTo create a todo/${BASE}_${DATENUM} branch\n\t\t$0 today\n\n"
ERROR=1
fi

if ! git diff --quiet HEAD 2> /dev/null
then
echo -ne "${A}Error${B}:\n\tYour working copy is dirty. Afraid of messing\n\tsomething up, so commit anything that needs to\n\tbe committed, and revert anything that needs\n\tto be reverted, to make your working copy nice\n\tand clean.\n\n"
ERROR=1
fi

if [ ! -f po/Makefile ]
then
echo -ne "${A}Error${B}:\n\tThis seems not to be a build directory, which\n\tis needed for "\""make -Cpo"\"" update-po to work.\n\tChange to your favourite build directory and\n\trun this script from there.\n\n"
ERROR=1
fi

if ! GITROOT="`git rev-parse --show-cdup 2> /dev/null`"
then
echo -ne "${A}Error${B}:\n\tNot in a git repository.\n\n"
ERROR=1
fi

if [ "${VERSTR}" = "bunny" ]
then
echo -ne "${A}Error${B}:\n\t ${A}(\\_/)${B}\n\tSorry, ${A}(O.o)${B} is not a valid version number.\n\t ${A}(> <)${B}\n\n"
fi

if [ ${ERROR} -ne 0 ]
then
exit 1
fi

echo "${A}Creating ${GITBRANCH} branch.${B}"
if ! git checkout -b "${GITBRANCH}"
then
echo -ne "Error:\n\tCould not create branch ${GITBRANCH}.\n\n"
exit 1
fi


echo "${A}make -Cpo update-po${B}"
make -Cpo update-po
git commit -am "make -Cpo update-po"


echo "${A}Bumping version strings to ${FULLVERSTR} and netcode version to ${DATENUM}.${B}"

sed -i 's/\(AC_INIT(\[Warzone 2100\],\[\)'"${BASE}"'\(\],\[http:\/\/wz2100.net\/\],\[warzone2100\])\)/\1'"${FULLVERSTR}"'\2/;
s/\(\[ enable_debug=${enableval} \], \[ enable_debug=\)yes\( \])\)/\1no\2/
' "${GITROOT}"configure.ac
sed -i 's/\(static char const \*versionString = \).*\(;\)/\1"'"${FULLVERSTR}"'"\2/;
s/\(static int NETCODE_VERSION_MINOR = \)[0-9]*\(;\)/\1'"${DATENUM}"'\2/
' "${GITROOT}"lib/netplay/netplay.c*
sed -i 's/\(VALUE "FileVersion", "\)'"${BASE}"'\("\)/\1'"${FULLVERSTR}"'\2/;
s/\(VALUE "ProductVersion", "\)'"${BASE}"'\("\)/\1'"${FULLVERSTR}"'\2/;
' "${GITROOT}"win32/warzone2100.rc "${GITROOT}"win32/warzone2100.vs2k5.rc "${GITROOT}"win32/warzone2100.vs2k8.rc

git commit -am "Bumping version strings to ${FULLVERSTR} and netcode version to ${DATENUM}."


echo "${A}All done.${B}"

echo "${A}If you liked the result, you may also like:${B}"

if [ ! -d "${GITROOT}"build ]
then
echo $'\t'mkdir -p "${GITROOT}"build
fi
echo $'\t'cd "${GITROOT}"build
echo $'\t'../autogen.sh
echo $'\t'../configure --with-distributor="wz2100.net"
echo $'\t'make -j4
echo $'\t'make -j4 dist
echo $'\t'tar -xzf [whateverTheFileIsCalled].tar.gz
echo $'\t'cd [whateverTheDirectoryIsCalled]/win32
echo $'\t'./__BUILD_SCRIPT --enable-installer --with-distributor="wz2100.net"
Something went wrong with that request. Please try again.