Index: scripts/make_existing_release.bat
===================================================================
diff -u -N -r6ee1dfea13b6871982655b160a571b78ff2e924e -r03340b954ead8138d669ee4f8df7124dc84c5612
--- scripts/make_existing_release.bat	(.../make_existing_release.bat)	(revision 6ee1dfea13b6871982655b160a571b78ff2e924e)
+++ scripts/make_existing_release.bat	(.../make_existing_release.bat)	(revision 03340b954ead8138d669ee4f8df7124dc84c5612)
@@ -1,17 +1,11 @@
 @echo off
 
+rem Script prepares all packages based on the source code in which this script is placed.
+
 rem Mark the changes as local ones
 setlocal ENABLEDELAYEDEXPANSION
 
-rem Check input parameter
-if [%1] == [] (
-	echo Usage: make_package.bat TextVersion
-	exit /b 1
-)
-
-SET TextVersion=%1
-
-echo --- Initializing  ----------------------------------------------
+echo --- Initializing ----------------------------------------------------
 call config.bat
 if errorlevel 1 (
 	exit /b 1
@@ -31,81 +25,64 @@
 	call "%VS90COMNTOOLS%\vsvars32.bat" >nul
 )
 
-SET VSInst=%ProgramFiles%
-if NOT "%ProgramFiles(x86)%" == "" SET VSInst=%ProgramFiles(x86)%
+set MainProjectDir=%CHRootDir%
 
-echo --- Preparing source package ----------------------------------------
-if "%TextVersion%" == "trunk" (
-	echo    * Retrieving source code from trunk...
-	svn co "%ReposCH%/trunk" "%MainProjectDir%" >"%TmpDir%\command.log" 2>"%TmpDir%\command-err.log"
-) else (
-	echo    * Retrieving tagged source code...
-	svn co "%ReposCH%/tags/%TextVersion%" "%MainProjectDir%" >"%TmpDir%\command.log" 2>"%TmpDir%\command-err.log"
-)
+rem Update the version string in the version.h for trunk
+echo    * Detecting current version information...
+call internal\detect_internal_version.bat "%MainProjectDir%"
 if errorlevel 1 (
-	echo ERROR: encountered a problem while exporting sources from repository. See the log below:
-	type "%TmpDir%\command-err.log"
 	goto error
 )
 
-SET _cmd=type "%TmpDir%\command-err.log"
-for /f %%a in ('%_cmd% ^|find "Error"') do SET Res=%%a
-if NOT "%Res%" == "" (
-	echo ERROR: Encountered some problems while checking out CH. See below for details:
-	type "%TmpDir%\command-err.log"
-	goto error
-)
-
-rem Update the version string in the version.h for trunk
-if "%TextVersion%" == "trunk" (
-	echo    * Detecting internal version information...
-	call internal\detect_internal_version.bat "%MainProjectDir%"
+if "%CHReleaseType%" == "internal" (
+	echo    * Updating version information in version.h for the internal release...
+	cscript //NoLogo internal\replace_version.vbs "%MainProjectDir%\src\common\version.h.template" "%MainProjectDir%\src\common\version.h" !CHMajorVersion! !CHMinorVersion! !CHSVNVersion! !CHCustomVersion! !CHTextVersion! >"%TmpDir%\command.log"
 	if errorlevel 1 (
-		goto error
-	)
-	
-	echo    * Updating version information...
-	cscript //NoLogo internal\replace_version.vbs "%MainProjectDir%\src\common\version.h.template" "%MainProjectDir%\src\common\version.h" !MajorVersion! !MinorVersion! !SVNVersion! !CustomVersion! !TextVersion! >"%TmpDir%\command.log"
-	if errorlevel 1 (
-		echo ERROR: encountered a problem while checking out copyhandler project. See the log below:
+		echo ERROR: encountered a problem while updating version information. See the log below:
 		type "%TmpDir%\command.log"
 		goto error
 	)
 )
 
-echo    * Create source package for version %TextVersion%...
-cd %MainProjectDir%
-7z a "%OutputDir%\chsrc-%TextVersion%.zip" -tzip -x^^!"scripts\*.bat" -xr^^!".svn" . >"%TmpDir%\command.log"
-if errorlevel 1 (
-	echo ERROR: Preparation of the sources failed. See the log below:
-	type "%TmpDir%\command.log"
-	goto error
-)
-
 echo --- Building solutions ----------------------------------------------
-echo    * Building win32...
+cd "%MainProjectDir%"
+echo    * Building win32 release solution...
 devenv ch.vc90.sln /rebuild "Release-Unicode|Win32"  >"%TmpDir%\command.log"
 if errorlevel 1 (
 	echo ERROR: Build process failed. See the log below:
 	type "%TmpDir%\command.log"
 	goto error
 )
 
-echo    * Building win64...
+echo    * Building win64 release solution...
 devenv ch.vc90.sln /rebuild "Release-Unicode|x64" >"%TmpDir%\command.log"
 if errorlevel 1 (
 	echo ERROR: Build process failed. See the log below:
 	type "%TmpDir%\command.log"
 	goto error
 )
 
-echo    * Embedding source server information to debug symbol files...
-cd %ScriptDir%
-call internal\embed_srcserver_info.bat
+echo --- Preparing packages ----------------------------------------------
+echo    * Create source package for version %CHTextVersion%...
+
+rem Export the current working copy to a separate directory to avoid including unnecessary files in the source archive
+SET CHSrcDir="%TmpDir%\ch-src"
+svn export "%MainProjectDir%" "%CHSrcDir%" >"%TmpDir%\command.log" 2>"%TmpDir%\command-err.log"
 if errorlevel 1 (
+	echo ERROR: encountered a problem while exporting local sources to a separate location. See the log below:
+	type "%TmpDir%\command-err.log"
 	goto error
 )
 
+cd %CHSrcDir%
+
+7z a "%OutputDir%\chsrc-%CHTextVersion%.zip" -tzip -x^^!"scripts\*.bat" -xr^^!".svn" . >"%TmpDir%\command.log"
+if errorlevel 1 (
+	echo ERROR: Preparation of the sources failed. See the log below:
+	type "%TmpDir%\command.log"
+	goto error
+)
+
 echo    * Preparing the symbols package...
 
 cd %MainProjectDir%
@@ -116,7 +93,17 @@
 
 cd %MainProjectDir%\bin\release
 
-7z a "%OutputDir%\ch_symbols-%TextVersion%.zip" -tzip "*.pdb"  >"%TmpDir%\command.log"
+if "%CHReleaseType%" == "tag" (
+	echo    * Embedding svn paths in the debug symbols...
+	call internal\embed_srcserver_info.bat %MainProjectDir%
+
+	if errorlevel 1 (
+		echo ERROR: encountered a problem while embedding source server information in debug symbols.
+		goto error
+	)
+)
+
+7z a "%OutputDir%\ch_symbols-%CHTextVersion%.zip" -tzip "*.pdb"  >"%TmpDir%\command.log"
 if errorlevel 1 (
 	echo ERROR: Could not create symbols archive. See the log below:
 	type "%TmpDir%\command.log"
@@ -151,9 +138,9 @@
 xcopy "bin\release\libchcore32u.dll" "%TmpDir%\zip32\" >>"%TmpDir%\command.log" || SET Res=1
 xcopy "bin\release\libictranslate32u.dll" "%TmpDir%\zip32\" >>"%TmpDir%\command.log" || SET Res=1
 xcopy "bin\release\ictranslate.exe" "%TmpDir%\zip32\" >>"%TmpDir%\command.log" || SET Res=1
-xcopy "%VSInst%\Microsoft Visual Studio 9.0\VC\redist\x86\Microsoft.VC90.CRT\*" "%TmpDir%\zip32\" >>"%TmpDir%\command.log" || SET Res=1
-xcopy "%VSInst%\Microsoft Visual Studio 9.0\VC\redist\x86\Microsoft.VC90.MFC\*" "%TmpDir%\zip32\" >>"%TmpDir%\command.log" || SET Res=1
-xcopy "%ProgramFiles%\Microsoft Visual Studio 9.0\Common7\IDE\Remote Debugger\x86\dbghelp.dll" "%TmpDir%\zip32\" >>"%TmpDir%\command.log" || SET Res=1
+xcopy "%VSInstallDirX86%\VC\redist\x86\Microsoft.VC90.CRT\*" "%TmpDir%\zip32\" >>"%TmpDir%\command.log" || SET Res=1
+xcopy "%VSInstallDirX86%\VC\redist\x86\Microsoft.VC90.MFC\*" "%TmpDir%\zip32\" >>"%TmpDir%\command.log" || SET Res=1
+xcopy "%VSInstallDirX64%\Common7\IDE\Remote Debugger\x86\dbghelp.dll" "%TmpDir%\zip32\" >>"%TmpDir%\command.log" || SET Res=1
 xcopy /E /I "bin\release\help" "%TmpDir%\zip32\help" >>"%TmpDir%\command.log" || SET Res=1
 xcopy /E /I "bin\release\langs" "%TmpDir%\zip32\langs" >>"%TmpDir%\command.log" || SET Res=1
 
@@ -164,9 +151,9 @@
 xcopy "bin\release\libchcore64u.dll" "%TmpDir%\zip64\" >>"%TmpDir%\command.log" || SET Res=1
 xcopy "bin\release\libictranslate64u.dll" "%TmpDir%\zip64\" >>"%TmpDir%\command.log" || SET Res=1
 xcopy "bin\release\ictranslate64.exe" "%TmpDir%\zip64\" >>"%TmpDir%\command.log" || SET Res=1
-xcopy "%VSInst%\Microsoft Visual Studio 9.0\VC\redist\x86\Microsoft.VC90.CRT\*" "%TmpDir%\zip64\" >>"%TmpDir%\command.log" || SET Res=1
-xcopy "%VSInst%\Microsoft Visual Studio 9.0\VC\redist\amd64\Microsoft.VC90.MFC\*" "%TmpDir%\zip64\" >>"%TmpDir%\command.log" || SET Res=1
-xcopy "%ProgramFiles%\Microsoft Visual Studio 9.0\Common7\IDE\Remote Debugger\x64\dbghelp.dll" "%TmpDir%\zip64\" >>"%TmpDir%\command.log" || SET Res=1
+xcopy "%VSInstallDirX86%\VC\redist\amd64\Microsoft.VC90.CRT\*" "%TmpDir%\zip64\" >>"%TmpDir%\command.log" || SET Res=1
+xcopy "%VSInstallDirX86%\VC\redist\amd64\Microsoft.VC90.MFC\*" "%TmpDir%\zip64\" >>"%TmpDir%\command.log" || SET Res=1
+xcopy "%VSInstallDirX64%\Common7\IDE\Remote Debugger\x64\dbghelp.dll" "%TmpDir%\zip64\" >>"%TmpDir%\command.log" || SET Res=1
 xcopy /E /I "bin\release\help" "%TmpDir%\zip64\help" >>"%TmpDir%\command.log" || SET Res=1
 xcopy /E /I "bin\release\langs" "%TmpDir%\zip64\langs" >>"%TmpDir%\command.log" || SET Res=1
 
@@ -178,7 +165,7 @@
 
 cd "%TmpDir%\"
 
-7z a -tzip "%OutputDir%\ch-%TextVersion%.zip" zip32 zip64 >"%TmpDir%\command.log"
+7z a -tzip "%OutputDir%\ch-%CHTextVersion%.zip" zip32 zip64 >"%TmpDir%\command.log"
 if errorlevel 1 (
 	echo ERROR: Could not create win32 zip archive. See the log below:
 	type "%TmpDir%\command.log"