aboutsummaryrefslogtreecommitdiff
path: root/games/warzone2100/files/patch-build__tools-autorevision
blob: 8030901d958743b83853cac7cd79037ba16ac0c8 (plain) (blame)
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
Update autorevision with latest, portable, version
--- build_tools/autorevision.orig	2013-01-15 03:54:06.000000000 +0400
+++ build_tools/autorevision	2013-01-21 20:38:26.811933361 +0400
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
 
 # Copyright (c) 2012 dak180
 # See http://opensource.org/licenses/bsd-license.php for licence terms
@@ -6,7 +6,7 @@
 # autorevision - extracts metadata about the head version from your repository.
 
 # Usage message.
-function arUsage {
+arUsage() {
 	cat > "/dev/stderr" << EOF
 usage: ./autorevision {-t output-type | -s symbol} [-o cache-file [-f] ] [-V]
 	Options include:
@@ -29,6 +29,8 @@
 	js			= javascript file
 	java			= Java file
 	javaprop		= Java properties file
+	tex			= (La)TeX file
+	m4			= m4 file
 
 The following are valid symbols:
 	VCS_TYPE
@@ -46,7 +48,7 @@
 }
 
 # Config
-ARVERSION="1.1"
+ARVERSION="1.4"
 TARGETFILE="/dev/stdout"
 while getopts ":t:o:s:Vf" OPTION; do
 	case "${OPTION}" in
@@ -73,14 +75,14 @@
 	esac
 done
 
-if [[ ! -z "${VAROUT}" ]] && [[ ! -z "${AFILETYPE}" ]]; then
+if [ ! -z "${VAROUT}" ] && [ ! -z "${AFILETYPE}" ]; then
 	# If both -s and -t are specified:
 	echo "error: Improper argument combination." 1>&2
 	exit 1
-elif [[ -z "${VAROUT}" ]] && [[ -z "${AFILETYPE}" ]]; then
+elif [ -z "${VAROUT}" ] && [ -z "${AFILETYPE}" ]; then
 	# If neither -s or -t are specified:
 	arUsage
-elif [[ -z "${CACHEFILE}" ]] && [[ "${CACHEFORCE}" = "1" ]]; then
+elif [ -z "${CACHEFILE}" ] && [ "${CACHEFORCE}" = "1" ]; then
 	# If -f is specified without -o:
 	arUsage
 fi
@@ -88,20 +90,20 @@
 
 # Functions to extract data from different repo types.
 # For git repos
-function gitRepo {
+gitRepo() {
 	cd "$(git rev-parse --show-toplevel)"
 
 	VCS_TYPE="git"
 
 	VCS_BASENAME="$(basename "${PWD}")"
 
-	# Is the working copy clean?
-	git diff --quiet HEAD &> /dev/null
+	 # Is the working copy clean?
+	test -z "$(git status -uno --porcelain)"
 	VCS_WC_MODIFIED="${?}"
 
 	# Enumeration of changesets
 	VCS_NUM="$(git rev-list --count HEAD 2>/dev/null)"
-	if [[ -z "${VCS_NUM}" ]]; then
+	if [ -z "${VCS_NUM}" ]; then
 		echo "warning: Counting the number of revisions may be slower due to an outdated git version less than 1.7.2.3. If something breaks, please update it." 1>&2
 		VCS_NUM="$(git rev-list HEAD | wc -l)"
 	fi
@@ -122,7 +124,7 @@
 	VCS_TAG="$(echo "${DESCRIPTION}" | sed -e "s:-g${VCS_SHORT_HASH}\$::" | sed -e 's:-[0-9]*$::')"
 
 	# Distance to last tag or an alias of VCS_NUM if there is no tag
-	if [[ ! -z "${DESCRIPTION}" ]]; then
+	if [ ! -z "${DESCRIPTION}" ]; then
 		VCS_TICK="$(echo "${DESCRIPTION}" | sed -e "s:${VCS_TAG}-::" -e "s:-g${VCS_SHORT_HASH}::")"
 	else
 		VCS_TICK="${VCS_NUM}"
@@ -133,7 +135,7 @@
 }
 
 # For hg repos
-function hgRepo {
+hgRepo() {
 	cd "$(hg root)"
 
 	VCS_TYPE="hg"
@@ -157,7 +159,7 @@
 	# or branch if no bookmark
 	VCS_BRANCH="$(hg id -B | cut -d ' ' -f 1)"
 	# Fall back to the branch if there are no bookmarks
-	if [[ -z "${VCS_BRANCH}" ]]; then
+	if [ -z "${VCS_BRANCH}" ]; then
 		VCS_BRANCH="$(hg id -b)"
 	fi
 
@@ -165,7 +167,7 @@
 	VCS_TAG="$(hg log -r "${VCS_NUM}" -l 1 --template '{latesttag}\n' 2>/dev/null | sed -e 's:qtip::' -e 's:tip::' -e 's:qbase::' -e 's:qparent::' -e "s:$(hg --config 'extensions.color=' --color never qtop 2>/dev/null)::" | cut -d ' ' -f 1)"
 
 	# Distance to last tag or an alias of VCS_NUM if there is no tag
-	if [[ ! -z "${VCS_TAG}" ]]; then
+	if [ ! -z "${VCS_TAG}" ]; then
 		VCS_TICK="$(hg log -r "${VCS_NUM}" -l 1 --template '{latesttagdistance}\n' 2>/dev/null)"
 	else
 		VCS_TICK="${VCS_NUM}"
@@ -176,7 +178,7 @@
 }
 
 # For bzr repos
-function bzrRepo {
+bzrRepo() {
 	cd "$(bzr root)"
 
 	VCS_TYPE="bzr"
@@ -194,7 +196,7 @@
 	VCS_FULL_HASH="$(bzr version-info --custom --template='{revision_id}\n')"
 
 	# The short hash
-	VCS_SHORT_HASH="$VCS_NUM"
+	VCS_SHORT_HASH="${VCS_NUM}"
 
 	# Nick of the current branch
 	VCS_BRANCH="$(bzr nick)"
@@ -203,7 +205,7 @@
 	VCS_TAG="$(bzr tags --sort=time | sed '/?$/d' | tail -n1 | cut -d ' ' -f1)"
 
 	# Distance to last tag or an alias of VCS_NUM if there is no tag
-	if [[ ! -z "${VCS_TAG}" ]]; then
+	if [ ! -z "${VCS_TAG}" ]; then
 		VCS_TICK="$(bzr log --line -r "tag:${VCS_TAG}.." | tail -n +2 | wc -l | sed -e 's:^ *::')"
 	else
 		VCS_TICK="${VCS_NUM}"
@@ -214,17 +216,17 @@
 }
 
 # For svn repos
-function svnRepo {
+svnRepo() {
 	VCS_TYPE="svn"
 
 	case "${PWD}" in
 	/*trunk*|/*branches*|/*tags*)
 		fn="${PWD}"
-		while [[ "$(basename "${fn}")" != 'trunk' ]] && [[ "$(basename "${fn}")" != 'branches' ]] && [[ "$(basename "${fn}")" != 'tags' ]] && [[ "$(basename "${fn}")" != '/' ]]; do
+		while [ "$(basename "${fn}")" != 'trunk' ] && [ "$(basename "${fn}")" != 'branches' ] && [ "$(basename "${fn}")" != 'tags' ] && [ "$(basename "${fn}")" != '/' ]; do
 			fn="$(dirname "${fn}")"
 		done
 		fn="$(dirname "${fn}")"
-		if [[ "${fn}" == '/' ]]; then
+		if [ "${fn}" = '/' ]; then
 			VCS_BASENAME="$(basename "${PWD}")"
 		else
 			VCS_BASENAME="$(basename "${fn}")"
@@ -250,7 +252,7 @@
 	VCS_FULL_HASH="${SVNVERSION}"
 
 	# The short hash
-	VCS_SHORT_HASH="$VCS_NUM"
+	VCS_SHORT_HASH="${VCS_NUM}"
 
 	# Current branch
 	case "${PWD}" in
@@ -260,13 +262,13 @@
 		while :
 		do
 			base="$(basename "${fn}")"
-			if [[ "$base" = 'trunk' ]]; then
+			if [ "${base}" = 'trunk' ]; then
 				VCS_BRANCH='trunk'
 				break
-			elif [[ "${base}" = 'branches' ]] || [[ "${base}" = 'tags' ]]; then
+			elif [ "${base}" = 'branches' ] || [ "${base}" = 'tags' ]; then
 				VCS_BRANCH="${lastbase}"
 				break
-			elif [[ "${base}" = '/' ]]; then
+			elif [ "${base}" = '/' ]; then
 				VCS_BRANCH=""
 				break
 			fi
@@ -290,7 +292,7 @@
 
 # Functions to output data in different formats.
 # For header output
-function hOutput {
+hOutput() {
 	cat > "${TARGETFILE}" << EOF
 /* Generated by autorevision - do not hand-hack! */
 #ifndef AUTOREVISION_H
@@ -316,7 +318,7 @@
 }
 
 # A header output for use with xcode to populate info.plist strings
-function xcodeOutput {
+xcodeOutput() {
 	cat > "${TARGETFILE}" << EOF
 /* Generated by autorevision - do not hand-hack! */
 #ifndef AUTOREVISION_H
@@ -342,7 +344,7 @@
 }
 
 # For bash output
-function shOutput {
+shOutput() {
 	cat > "${TARGETFILE}" << EOF
 # Generated by autorevision - do not hand-hack!
 
@@ -364,7 +366,7 @@
 }
 
 # For Python output
-function pyOutput {
+pyOutput() {
 	case "${VCS_WC_MODIFIED}" in
 		0) VCS_WC_MODIFIED="False" ;;
 		1) VCS_WC_MODIFIED="True" ;;
@@ -390,7 +392,7 @@
 }
 
 # For Perl output
-function plOutput {
+plOutput() {
 	cat << EOF
 # Generated by autorevision - do not hand-hack!
 
@@ -412,7 +414,7 @@
 }
 
 # For lua output
-function luaOutput {
+luaOutput() {
 	case "${VCS_WC_MODIFIED}" in
 		0) VCS_WC_MODIFIED="false" ;;
 		1) VCS_WC_MODIFIED="true" ;;
@@ -438,7 +440,7 @@
 }
 
 # For php output
-function phpOutput {
+phpOutput() {
 	case "${VCS_WC_MODIFIED}" in
 		0) VCS_WC_MODIFIED="false" ;;
 		1) VCS_WC_MODIFIED="true" ;;
@@ -466,7 +468,7 @@
 }
 
 # For ini output
-function iniOutput {
+iniOutput() {
 	case "${VCS_WC_MODIFIED}" in
 		0) VCS_WC_MODIFIED="false" ;;
 		1) VCS_WC_MODIFIED="true" ;;
@@ -489,7 +491,7 @@
 }
 
 # For javascript output
-function jsOutput {
+jsOutput() {
 	case "${VCS_WC_MODIFIED}" in
 		1) VCS_WC_MODIFIED="true" ;;
 		0) VCS_WC_MODIFIED="false" ;;
@@ -522,7 +524,7 @@
 }
 
 # For Java output
-function javaOutput {
+javaOutput() {
 	case "${VCS_WC_MODIFIED}" in
 		1) VCS_WC_MODIFIED="true" ;;
 		0) VCS_WC_MODIFIED="false" ;;
@@ -550,7 +552,7 @@
 }
 
 # For Java properties output
-function javapropOutput {
+javapropOutput() {
 	case "${VCS_WC_MODIFIED}" in
 		1) VCS_WC_MODIFIED="true" ;;
 		0) VCS_WC_MODIFIED="false" ;;
@@ -573,22 +575,61 @@
 EOF
 }
 
+# For m4 output
+m4Output() {
+	cat > "${TARGETFILE}" << EOF
+define(\`VCS_TYPE', \`${VCS_TYPE}')dnl
+define(\`VCS_BASENAME', \`${VCS_BASENAME}')dnl
+define(\`VCS_NUM', \`${VCS_NUM}')dnl
+define(\`VCS_DATE', \`${VCS_DATE}')dnl
+define(\`VCS_BRANCH', \`${VCS_BRANCH}')dnl
+define(\`VCS_TAG', \`${VCS_TAG}')dnl
+define(\`VCS_TICK', \`${VCS_TICK}')dnl
+define(\`VCS_FULLHASH', \`${VCS_FULL_HASH}')dnl
+define(\`VCS_SHIRTHASH', \`${VCS_SHORT_HASH}')dnl
+define(\`VCS_WC_MODIFIED', \`${VCS_WC_MODIFIED}')dnl
+EOF
+}
+
+# For (La)TeX output
+texOutput() {
+	case "${VCS_WC_MODIFIED}" in
+		0) VCS_WC_MODIFIED="false" ;;
+		1) VCS_WC_MODIFIED="true" ;;
+	esac
+	cat > "${TARGETFILE}" << EOF
+% Generated by autorevision - do not hand-hack!
+\def \vcsType {${VCS_TYPE}}
+\def \vcsBasename {${VCS_BASENAME}}
+\def \vcsNum {${VCS_NUM}}
+\def \vcsDate {${VCS_DATE}}
+\def \vcsBranch {${VCS_BRANCH}}
+\def \vcsTag {${VCS_TAG}}
+\def \vcsTick {${VCS_TICK}}
+\def \vcsFullHash {${VCS_FULL_HASH}}
+\def \vcsShortHash {${VCS_SHORT_HASH}}
+\def \vcsWCModified {${VCS_WC_MODIFIED}}
+\endinput
+EOF
+}
+
+
 
 # Detect and collect repo data.
-if [[ -f "${CACHEFILE}" ]] && [[ "${CACHEFORCE}" = "1" ]]; then
+if [ -f "${CACHEFILE}" ] && [ "${CACHEFORCE}" = "1" ]; then
 	# When requested only read from the cache to populate our symbols.
 	source "${CACHEFILE}"
-elif [[ ! -z "$(git rev-parse HEAD 2>/dev/null)" ]]; then
+elif [ ! -z "$(git rev-parse HEAD 2>/dev/null)" ]; then
 	gitRepo
-elif [[ ! -z "$(hg root 2>/dev/null)" ]]; then
+elif [ ! -z "$(hg root 2>/dev/null)" ]; then
 	hgRepo
-elif [[ ! -z "$(bzr root 2>/dev/null)" ]]; then
+elif [ ! -z "$(bzr root 2>/dev/null)" ]; then
 	bzrRepo
-elif [[ ! -z "$(svn info 2>/dev/null)" ]]; then
+elif [ ! -z "$(svn info 2>/dev/null)" ]; then
 	svnRepo
-elif [[ -f "${CACHEFILE}" ]]; then
+elif [ -f "${CACHEFILE}" ]; then
 	# We are not in a repo; try to use a previously generated cache to populate our symbols.
-	source "${CACHEFILE}"
+	. "${CACHEFILE}"
 else
 	echo "error: No repo or cache detected." 1>&2
 	exit 1
@@ -596,55 +637,59 @@
 
 
 # -s output is handled here.
-if [[ ! -z "${VAROUT}" ]]; then
-	if [[ "${VAROUT}" = "VCS_TYPE" ]]; then
+if [ ! -z "${VAROUT}" ]; then
+	if [ "${VAROUT}" = "VCS_TYPE" ]; then
 		echo "${VCS_TYPE}"
-	elif [[ "${VAROUT}" = "VCS_BASENAME" ]]; then
+	elif [ "${VAROUT}" = "VCS_BASENAME" ]; then
 		echo "${VCS_BASENAME}"
-	elif [[ "${VAROUT}" = "VCS_NUM" ]]; then
+	elif [ "${VAROUT}" = "VCS_NUM" ]; then
 		echo "${VCS_NUM}"
-	elif [[ "${VAROUT}" = "VCS_DATE" ]]; then
+	elif [ "${VAROUT}" = "VCS_DATE" ]; then
 		echo "${VCS_DATE}"
-	elif [[ "${VAROUT}" = "VCS_BRANCH" ]]; then
+	elif [ "${VAROUT}" = "VCS_BRANCH" ]; then
 		echo "${VCS_BRANCH}"
-	elif [[ "${VAROUT}" = "VCS_TAG" ]]; then
+	elif [ "${VAROUT}" = "VCS_TAG" ]; then
 		echo "${VCS_TAG}"
-	elif [[ "${VAROUT}" = "VCS_TICK" ]]; then
+	elif [ "${VAROUT}" = "VCS_TICK" ]; then
 		echo "${VCS_TICK}"
-	elif [[ "${VAROUT}" = "VCS_FULL_HASH" ]]; then
+	elif [ "${VAROUT}" = "VCS_FULL_HASH" ]; then
 		echo "${VCS_FULL_HASH}"
-	elif [[ "${VAROUT}" = "VCS_SHORT_HASH" ]]; then
+	elif [ "${VAROUT}" = "VCS_SHORT_HASH" ]; then
 		echo "${VCS_SHORT_HASH}"
-	elif [[ "${VAROUT}" = "VCS_WC_MODIFIED" ]]; then
+	elif [ "${VAROUT}" = "VCS_WC_MODIFIED" ]; then
 		echo "${VCS_WC_MODIFIED}"
 	fi
 fi
 
 
 # Detect requested output type and use it.
-if [[ ! -z "${AFILETYPE}" ]]; then
-	if [[ "${AFILETYPE}" = "h" ]]; then
+if [ ! -z "${AFILETYPE}" ]; then
+	if [ "${AFILETYPE}" = "h" ]; then
 		hOutput
-	elif [[ "${AFILETYPE}" = "xcode" ]]; then
+	elif [ "${AFILETYPE}" = "xcode" ]; then
 		xcodeOutput
-	elif [[ "${AFILETYPE}" = "sh" ]]; then
+	elif [ "${AFILETYPE}" = "sh" ]; then
 		shOutput
-	elif [[ "${AFILETYPE}" = "py" ]]; then
+	elif [ "${AFILETYPE}" = "py" ] || [ "${AFILETYPE}" = "python" ]; then
 		pyOutput
-	elif [[ "${AFILETYPE}" = "pl" ]]; then
+	elif [ "${AFILETYPE}" = "pl" ] || [ "${AFILETYPE}" = "perl" ]; then
 		plOutput
-	elif [[ "${AFILETYPE}" = "lua" ]]; then
+	elif [ "${AFILETYPE}" = "lua" ]; then
 		luaOutput
-	elif [[ "${AFILETYPE}" = "php" ]]; then
+	elif [ "${AFILETYPE}" = "php" ]; then
 		phpOutput
-	elif [[ "${AFILETYPE}" = "ini" ]]; then
+	elif [ "${AFILETYPE}" = "ini" ]; then
 		iniOutput
-	elif [[ "${AFILETYPE}" = "js" ]]; then
+	elif [ "${AFILETYPE}" = "js" ]; then
 		jsOutput
-	elif [[ "${AFILETYPE}" = "java" ]]; then
+	elif [ "${AFILETYPE}" = "java" ]; then
 		javaOutput
-	elif [[ "${AFILETYPE}" = "javaprop" ]]; then
+	elif [ "${AFILETYPE}" = "javaprop" ]; then
 		javapropOutput
+	elif [ "${AFILETYPE}" = "tex" ]; then
+		texOutput
+	elif [ "${AFILETYPE}" = "m4" ]; then
+		m4Output
 	else
 		echo "error: Not a valid output type." 1>&2
 		exit 1
@@ -653,7 +698,7 @@
 
 
 # If requested, make a cache file.
-if [[ ! -z "${CACHEFILE}" ]] && [[ ! "${CACHEFORCE}" = "1" ]]; then
+if [ ! -z "${CACHEFILE}" ] && [ ! "${CACHEFORCE}" = "1" ]; then
 	TARGETFILE="${CACHEFILE}"
 	shOutput
 fi