Changeset - r16611:d11beffb7028
[Not reviewed]
master
0 3 0
rubidium - 14 years ago 2010-11-29 12:49:27
rubidium@openttd.org
(svn r21351) -Change: read some metadata from (official) source tarballs so you'll more likely get the right version/revision out-of-the-box
3 files changed with 28 insertions and 12 deletions:
0 comments (0 inline, 0 general)
config.lib
Show inline comments
 
@@ -1011,24 +1011,27 @@ check_params() {
 
			revision="`cat $ROOT_DIR/version`"
 

	
 
			log 1 "checking revision... $revision"
 
		elif [ -d "$ROOT_DIR/.svn" ] && [ -n "`svn help 2>/dev/null`" ]; then
 
			revision=""
 
			log 1 "checking revision... svn detection"
 
		elif [ -d "$ROOT_DIR/.git" ] && [ -n "`git help 2>/dev/null`" ]; then
 
			revision=""
 
			log 1 "checking revision... git detection"
 
		elif [ -d "$ROOT_DIR/.hg" ] && [ -n "`hg help 2>/dev/null`" ]; then
 
			revision=""
 
			log 1 "checking revision... hg detection"
 
		elif [ -f "$ROOT_DIR/.rev" ]; then
 
			revision=""
 
			log 1 "checking revision... source tarball"
 
		else
 
			revision=""
 
			log 1 "checking revision... no detection"
 
			log 1 "WARNING: there is no means to determine the version."
 
			log 1 "WARNING: please use a subversion, mercurial, or git checkout of OpenTTD."
 
			log 1 "WARNING: you can only join game servers that have been compiled without"
 
			log 1 "WARNING:   version detection."
 
			log 1 "WARNING: there is a great chance you desync."
 
			log 1 "WARNING: USE WITH CAUTION!"
 

	
 
			sleep 5
 
		fi
findversion.sh
Show inline comments
 
@@ -99,24 +99,28 @@ elif [ -d "$ROOT_DIR/.git" ]; then
 
		# No rev? Maybe it is a custom git-svn clone
 
		REV_NR=`LC_ALL=C git log --pretty=format:%b --grep="git-svn-id:.*@[0-9]*" -1 | sed "s@.*\@\([0-9]*\).*@\1@"`
 
	fi
 
elif [ -d "$ROOT_DIR/.hg" ]; then
 
	# We are a hg checkout
 
	if [ -n "`hg status | grep -v '^?'`" ]; then
 
		MODIFIED="2"
 
	fi
 
	HASH=`LC_ALL=C hg id -i | cut -c1-12`
 
	REV="h`echo $HASH | cut -c1-8`"
 
	BRANCH=`hg branch | sed 's@^default$@@'`
 
	REV_NR=`LC_ALL=C hg log -f -k "(svn r" -l 1 --template "{desc}\n" | head -n 1 | sed "s@.*(svn r\([0-9]*\)).*@\1@"`
 
elif [ -f "$ROOT_DIR/.ottdrev" ]; then
 
	# We are an exported source bundle
 
	cat $ROOT_DIR/.ottdrev
 
	exit
 
else
 
	# We don't know
 
	MODIFIED="1"
 
	BRANCH=""
 
	REV=""
 
	REV_NR=""
 
fi
 

	
 
if [ "$MODIFIED" -eq "2" ]; then
 
	REV="${REV}M"
 
fi
 

	
projects/determineversion.vbs
Show inline comments
 
@@ -26,26 +26,27 @@ Sub UpdateFile(modified, revision, versi
 
	FindReplaceInFile filename, "!!MODIFIED!!", modified
 
	FindReplaceInFile filename, "!!REVISION!!", revision
 
	FindReplaceInFile filename, "!!VERSION!!", version
 
	FindReplaceInFile filename, "!!DATE!!", cur_date
 
End Sub
 

	
 
Sub UpdateFiles(version)
 
	Dim modified, revision, cur_date
 
	cur_date = DatePart("D", Date) & "." & DatePart("M", Date) & "." & DatePart("YYYY", Date)
 

	
 
	If InStr(version, Chr(9)) Then
 
		revision = Mid(version, InStr(version, Chr(9)) + 1)
 
		modified = Mid(revision, InStr(revision, Chr(9)) + 1)
 
		revision = Mid(revision, 1, InStr(revision, Chr(9)) - 1)
 
		modified = Mid(version, InStrRev(version, Chr(9)) + 1)
 
		modified = Mid(modified, 1, InStr(modified, Chr(9)) - 1)
 
		version  = Mid(version, 1, InStr(version, Chr(9)) - 1)
 
	Else
 
		revision = 0
 
		modified = 1
 
	End If
 

	
 
	UpdateFile modified, revision, version, cur_date, "../src/rev.cpp"
 
	UpdateFile modified, revision, version, cur_date, "../src/os/windows/ottdres.rc"
 
End Sub
 

	
 
Function ReadRegistryKey(shive, subkey, valuename, architecture)
 
	Dim hiveKey, objCtx, objLocator, objServices, objReg, Inparams, Outparams
 
@@ -251,37 +252,45 @@ Function DetermineSVNVersion()
 

	
 
						Set oExec = WshShell.Exec("hg log -f -k " & Chr(34) & "(svn r" & Chr(34) & " -l 1 --template " & Chr(34) & "{desc}\n" & Chr(34) & " --cwd ../")
 
						If Err.Number = 0 Then
 
							revision = Mid(OExec.StdOut.ReadLine(), 7)
 
							revision = Mid(revision, 1, InStr(revision, ")") - 1)
 
						End If ' Err.Number = 0
 
					End If ' Err.Number = 0
 
				End If ' oExec.ExitCode = 0
 
			End If ' Err.Number = 0
 
		End If ' version = "norev000"
 
	End If ' version <> "norev000"
 

	
 
	If modified = 2 Then
 
		version = version & "M"
 
	End If
 
	Dim rev_file
 
	Set rev_file = FSO.OpenTextFile("../.ottdrev", 1, True, 0)
 
	If Not rev_file.atEndOfStream Then
 
		DetermineSVNVersion = rev_file.ReadLine()
 
	Else
 
		If modified = 2 Then
 
			version = version & "M"
 
		End If
 

	
 
	If branch <> "" Then
 
		version = version & "-" & branch
 
		clean_rev = version
 
		If branch <> "" Then
 
			version = version & "-" & branch
 
		End If
 

	
 
		If version <> "norev000" Then
 
			DetermineSVNVersion = version & Chr(9) & revision & Chr(9) & modified & Chr(9) & clean_rev
 
		Else
 
			DetermineSVNVersion = version
 
		End If
 
	End If
 

	
 
	If version <> "norev000" Then
 
		DetermineSVNVersion = version & Chr(9) & revision & Chr(9) & modified
 
	Else
 
		DetermineSVNVersion = version
 
	End If
 
	rev_file.close
 
End Function
 

	
 
Function IsCachedVersion(ByVal version)
 
	Dim cache_file, cached_version
 
	cached_version = ""
 
	Set cache_file = FSO.OpenTextFile("../config.cache.version", 1, True, 0)
 
	If Not cache_file.atEndOfStream Then
 
		cached_version = cache_file.ReadLine()
 
	End If
 
	cache_file.Close
 

	
 
	If InStr(version, Chr(9)) Then
0 comments (0 inline, 0 general)