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
|
@echo off
if exist "turnon_echo" (
@echo on
)
:: Reset working dir especially when using 'Run as administrator'
@cd /d "%~dp0"
echo This batch file can help you to create a packages for SMTube.
echo.
echo 1 - NSIS
echo 2 - NSIS [64-bit]
echo.
:: Relative directory of all the source files to this script
set TOP_LEVEL_DIR=..
set OUTPUT_DIR=%TOP_LEVEL_DIR%\output
:: Reset in case ran again in same command prompt instance
set ALL_PKG_VER=
set VER_MAJOR=
set VER_MINOR=
set VER_BUILD=
set VER_REVISION=
set VER_REV_CMD=
set MAKENSIS_EXE_PATH=
:: NSIS path
if exist "nsis_path" (
for /f "tokens=*" %%y in ('type nsis_path') do if exist %%y set MAKENSIS_EXE_PATH="%%y"
)
if not defined MAKENSIS_EXE_PATH (
for %%x in ("%PROGRAMFILES(X86)%\NSIS\Bin\makensis.exe" "%PROGRAMFILES%\NSIS\Bin\makensis.exe") do if exist %%x set MAKENSIS_EXE_PATH=%%x
)
if not defined MAKENSIS_EXE_PATH (
echo Warning: Unable to locate NSIS in the default path, create the file ^'nsis_path^' with the full correct path
echo to makensis.exe or the existing ^'nsis_path^' may be incorrect.
echo.
)
:: Works only in Vista+
REM where /q where.exe 2>NUL && (
REM where /q 7za.exe 2>NUL || (
REM echo Warning: 7za.exe not found in path or current directory!
REM echo.
REM )
REM )
:cmdline_parsing
if "%1" == "" goto reask
for %%w in (1 2) do (
if "%1" == "%%w" (
set USER_CHOICE=%%w
goto pkgver
)
)
echo Unknown option: "%1"
echo.
goto superend
:reask
set USER_CHOICE=
set /P USER_CHOICE="Choose an action: "
echo.
for %%z in (1 2) do if "%USER_CHOICE%" == "%%z" goto pkgver
if "%USER_CHOICE%" == "" goto superend
goto reask
:pkgver
if exist "pkg_version" (
for /f "tokens=*" %%i in ('type pkg_version') do set ALL_PKG_VER=%%i
goto parse_version
)
echo Format: VER_MAJOR.VER_MINOR.VER_BUILD[.VER_REVISION]
echo VER_REVISION is optional (set to 0 if blank)
:pkgver_manual
echo.
set ALL_PKG_VER=
set VER_MAJOR=
set VER_MINOR=
set VER_BUILD=
set VER_REVISION=
set VER_REV_CMD=
set /p ALL_PKG_VER="Version: "
echo.
:parse_version
for /f "tokens=1 delims=." %%j in ("%ALL_PKG_VER%") do set VER_MAJOR=%%j
for /f "tokens=2 delims=." %%k in ("%ALL_PKG_VER%") do set VER_MINOR=%%k
for /f "tokens=3 delims=." %%l in ("%ALL_PKG_VER%") do set VER_BUILD=%%l
for /f "tokens=4 delims=." %%m in ("%ALL_PKG_VER%") do set VER_REVISION=%%m
echo %VER_MAJOR%|findstr /r /c:"^[0-9][0-9]*$" >nul
if errorlevel 1 (
echo Invalid version string. VER_MAJOR is not defined or is not a number [#.x.x]
goto pkgver_manual & ver>nul
)
echo %VER_MINOR%|findstr /r /c:"^[0-9][0-9]*$" >nul
if errorlevel 1 (
echo Invalid version string. VER_MINOR is not defined or is not a number [x.#.x]
goto pkgver_manual & ver>nul
)
echo %VER_BUILD%|findstr /r /c:"^[0-9][0-9]*$" >nul
if errorlevel 1 (
echo Invalid version string. VER_BUILD is not defined or is not a number [x.x.#]
goto pkgver_manual & ver>nul
)
if defined VER_REVISION (
echo %VER_REVISION%|findstr /r /c:"^[0-9][0-9]*$" >nul
if errorlevel 1 (
echo Invalid version string. VER_REVISION is not a number [x.x.x.#]
goto pkgver_manual & ver>nul
) else (
set VER_REV_CMD=/DVER_REVISION=%VER_REVISION% & ver>nul
)
) else (
set VER_REV_CMD=
)
if "%USER_CHOICE%" == "1" goto nsispkg
if "%USER_CHOICE%" == "2" goto nsispkg64
:: Should not happen
goto end
:nsispkg
echo --- SMTube NSIS Package [32-bit] ---
echo.
%MAKENSIS_EXE_PATH% /V3 /DVER_MAJOR=%VER_MAJOR% /DVER_MINOR=%VER_MINOR% /DVER_BUILD=%VER_BUILD% %VER_REV_CMD% %TOP_LEVEL_DIR%\smtube.nsi
goto end
:nsispkg64
echo --- SMTube NSIS Package [64-bit] ---
echo.
%MAKENSIS_EXE_PATH% /V3 /DVER_MAJOR=%VER_MAJOR% /DVER_MINOR=%VER_MINOR% /DVER_BUILD=%VER_BUILD% %VER_REV_CMD% /DWIN64 %TOP_LEVEL_DIR%\smtube.nsi
goto end
:end
REM pause
:superend
set ALL_PKG_VER=
set VER_MAJOR=
set VER_MINOR=
set VER_BUILD=
set VER_REVISION=
|