1@echo OFF 2 3rem 4rem This file is part of nzbget 5rem 6rem Copyright (C) 2013-2019 Andrey Prygunkov <hugbug@users.sourceforge.net> 7rem 8rem This program is free software; you can redistribute it and/or modify 9rem it under the terms of the GNU General Public License as published by 10rem the Free Software Foundation; either version 2 of the License, or 11rem (at your option) any later version. 12rem 13rem This program is distributed in the hope that it will be useful, 14rem but WITHOUT ANY WARRANTY; without even the implied warranty of 15rem MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16rem GNU General Public License for more details. 17rem 18rem You should have received a copy of the GNU General Public License 19rem along with this program. If not, see <http://www.gnu.org/licenses/>. 20rem 21 22rem ####################### CONFIG SECTION ####################### 23 24set BUILD_DEBUG=1 25set BUILD_RELEASE=1 26set BUILD_32=1 27set BUILD_64=1 28 29rem expression "%~dp0" means the location of an executing batch file 30set ROOTDIR=%~dp0 31rem remove trailing slash from ROOTDIR 32set ROOTDIR=%ROOTDIR:~0,-1% 33set LIBDIR=%ROOTDIR%\lib 34set ZIP=%ROOTDIR%\tools\7-Zip\7z.exe 35set SED=%ROOTDIR%\tools\GnuWin32\bin\sed.exe 36set CURL=%ROOTDIR%\tools\curl\src\curl.exe 37set NSIS=%ROOTDIR%\tools\nsis 38set VCVARS="C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" 39set BUILD_SETUP=1 40 41rem ####################### END OF CONFIG SECTION ####################### 42 43title Building NZBGet 44cd %ROOTDIR% 45set UseEnv=true 46echo Building nzbget 47 48if exist tmp (rmdir /S /Q tmp) 49if errorlevel 1 goto BUILD_FAILED 50mkdir tmp 51if errorlevel 1 goto BUILD_FAILED 52 53rem Search source distribution archive 54 55set SRCTAR= 56for /R "%ROOTDIR%" %%f in (nzbget-*.tar.gz) do ( 57 set SRCTAR=%%~nf 58) 59 60if not exist %SRCTAR%.gz ( 61 echo Cannot find NZBGet source code archive. Put nzbget-version-src.tar.gz into '%ROOTDIR%' and retry 62 goto BUILD_FAILED 63) 64 65rem Determine program version (from source distribution archive file name) 66 67echo Using source file: %SRCTAR%.gz 68 69set FULLVERSION=%SRCTAR:~7,-4% 70if [%FULLVERSION:~-4%]==[-src] (set FULLVERSION=%FULLVERSION:~0,-4%) 71set VERSION=%FULLVERSION% 72if [%VERSION:~12,2%]==[-r] (set VERSION=%VERSION:~0,-6%) 73 74echo Version: [%VERSION%]/[%FULLVERSION%] 75 76if not exist image ( 77 echo Cannot find extra files for setup. Create directory '%ROOTDIR%\image' and put all extra files there: unrar.exe, etc. 78 goto BUILD_FAILED 79) 80 81rem Unpack source distribution archive 82%ZIP% x -otmp %SRCTAR%.gz 83if errorlevel 1 goto BUILD_FAILED 84%ZIP% x -otmp tmp\%SRCTAR% 85if errorlevel 1 goto BUILD_FAILED 86 87rem Prepare output directory 88if exist output (rmdir /S /Q output) 89if errorlevel 1 goto BUILD_FAILED 90mkdir output 91if errorlevel 1 goto BUILD_FAILED 92 93rem Update ca root certificates 94echo Updating root certificates 95cd image 96%CURL% --remote-name --time-cond cacert.pem https://curl.se/ca/cacert.pem 97if errorlevel 1 goto BUILD_FAILED 98cd .. 99 100cd tmp\nzbget-%VERSION% 101 102rem Activate revision info (using code_revision.cpp) 103%SED% -e ":a;N;$!ba;s|void Util::Init()\n{\n#ifndef WIN32|void Util::Init()\n{\n#ifndef WIN32DISABLED|" -i daemon\util\Util.cpp 104%SED% -e ":a;N;$!ba;s|#ifndef WIN32\n// function|#ifndef WIN32DISABLED\n// function|" -i daemon\util\Util.cpp 105%SED% -e "s|<ClCompile Include=\d034daemon\\util\\Util.cpp\d034 />|<ClCompile Include=\d034daemon\\util\\Util.cpp\d034 /><ClCompile Include=\d034code_revision.cpp\d034 />|" -i nzbget.vcxproj 106 107:TARGET_DEBUG 108rem Build debug binaries 109if %BUILD_DEBUG%==0 goto TARGET_RELEASE 110cd nzbget-%VERSION% 111call:PrepareFiles 112if %BUILD_32%==1 ( call:BuildTarget Debug x86 x86 32 ) 113if %BUILD_64%==1 ( call:BuildTarget Debug x64 amd64 64 ) 114cd .. 115 116if %BUILD_SETUP%==1 ( 117 rem Build debug setup 118 cd distrib 119 call:BuildSetup 120 if errorlevel 1 goto BUILD_FAILED 121 move nzbget-setup.exe ..\..\output\nzbget-%FULLVERSION%-bin-windows-debug-setup.exe 122 cd .. 123) 124 125:TARGET_RELEASE 126rem Build release binaries 127if %BUILD_RELEASE%==0 goto END 128cd nzbget-%VERSION% 129call:PrepareFiles 130if %BUILD_32%==1 ( call:BuildTarget Release x86 x86 32 ) 131if %BUILD_64%==1 ( call:BuildTarget Release x64 amd64 64 ) 132cd .. 133 134if %BUILD_SETUP%==1 ( 135 rem Build release setup 136 cd distrib 137 call:BuildSetup 138 if errorlevel 1 goto BUILD_FAILED 139 move nzbget-setup.exe ..\..\output\nzbget-%FULLVERSION%-bin-windows-setup.exe 140 cd .. 141) 142 143goto END 144 145 146:BUILD_FAILED 147echo ******************************** 148echo Build failed 149echo ******************************** 150 151:END 152 153pause 154exit 1 155 156rem END OF SCRIPT 157 158 159rem Build one binary (fro specified configuration and platofrm) 160:BuildTarget 161echo ***** Building %~1 %~2 (%~3 %~4) 162if exist ..\bin (rmdir /S /Q ..\bin) 163set INCLUDE= 164set LIB= 165call %VCVARS% %~3 166set INCLUDE=%LIBDIR%\include;%INCLUDE% 167set LIB=%LIBDIR%\%~2;%LIB% 168msbuild.exe nzbget.vcxproj /t:Rebuild /p:Configuration=%~1 /p:Platform=%~2 169if errorlevel 1 goto BUILD_FAILED 170copy ..\bin\nzbget.exe ..\distrib\NZBGet\%~4 171if errorlevel 1 goto BUILD_FAILED 172if %~1==Debug ( 173 copy ..\bin\nzbget.pdb ..\distrib\NZBGet\%~4 174 if errorlevel 1 goto BUILD_FAILED 175) 176GOTO:EOF 177 178 179rem Prepare files for setup 180:PrepareFiles 181if exist ..\distrib (rmdir /S /Q ..\distrib) 182mkdir ..\distrib\NZBGet 183 184mkdir ..\distrib\NZBGet\32 185mkdir ..\distrib\NZBGet\64 186if %BUILD_32%==0 ( 187 echo This test setup doesn't include binaries for 32 bit platform > ..\distrib\NZBGet\32\README-WARNING.txt 188) 189if %BUILD_64%==0 ( 190 echo This test setup doesn't include binaries for 64 bit platform > ..\distrib\NZBGet\64\README-WARNING.txt 191) 192 193copy windows\nzbget-command-shell.bat ..\distrib\NZBGet 194if errorlevel 1 goto BUILD_FAILED 195copy windows\install-update.bat ..\distrib\NZBGet 196if errorlevel 1 goto BUILD_FAILED 197copy windows\README-WINDOWS.txt ..\distrib\NZBGet 198if errorlevel 1 goto BUILD_FAILED 199copy ChangeLog ..\distrib\NZBGet 200if errorlevel 1 goto BUILD_FAILED 201copy README ..\distrib\NZBGet 202if errorlevel 1 goto BUILD_FAILED 203copy COPYING ..\distrib\NZBGet 204if errorlevel 1 goto BUILD_FAILED 205 206mkdir ..\distrib\NZBGet\webui 207xcopy /E webui ..\distrib\NZBGet\webui 208if errorlevel 1 goto BUILD_FAILED 209 210copy windows\package-info.json ..\distrib\NZBGet\webui 211if errorlevel 1 goto BUILD_FAILED 212 213rem Adjust config file 214set CONFFILE=..\distrib\NZBGet\nzbget.conf.template 215copy nzbget.conf %CONFFILE% 216if errorlevel 1 goto BUILD_FAILED 217%SED% -e "s|MainDir=.*|MainDir=${AppDir}\\downloads|" -i %CONFFILE% 218%SED% -e "s|DestDir=.*|DestDir=${MainDir}\\complete|" -i %CONFFILE% 219%SED% -e "s|InterDir=.*|InterDir=${MainDir}\\intermediate|" -i %CONFFILE% 220%SED% -e "s|ScriptDir=.*|ScriptDir=${MainDir}\\scripts|" -i %CONFFILE% 221%SED% -e "s|LogFile=.*|LogFile=${MainDir}\\nzbget.log|" -i %CONFFILE% 222%SED% -e "s|AuthorizedIP=.*|AuthorizedIP=127.0.0.1|" -i %CONFFILE% 223%SED% -e "s|UnrarCmd=.*|UnrarCmd=${AppDir}\\unrar.exe|" -i %CONFFILE% 224%SED% -e "s|SevenZipCmd=.*|SevenZipCmd=${AppDir}\\7za.exe|" -i %CONFFILE% 225%SED% -e "s|ArticleCache=.*|ArticleCache=250|" -i %CONFFILE% 226%SED% -e "s|ParBuffer=.*|ParBuffer=250|" -i %CONFFILE% 227%SED% -e "s|WriteBuffer=.*|WriteBuffer=1024|" -i %CONFFILE% 228%SED% -e "s|CertStore=.*|CertStore=${AppDir}\\cacert.pem|" -i %CONFFILE% 229%SED% -e "s|CertCheck=.*|CertCheck=yes|" -i %CONFFILE% 230%SED% -e "s|DirectRename=.*|DirectRename=yes|" -i %CONFFILE% 231%SED% -e "s|DirectUnpack=.*|DirectUnpack=yes|" -i %CONFFILE% 232rem Hide certain options from web-interface settings page 233%SED% -e "s|WebDir=.*|# WebDir=${AppDir}\\webui|" -i %CONFFILE% 234%SED% -e "s|LockFile=.*|# LockFile=|" -i %CONFFILE% 235%SED% -e "s|ConfigTemplate=.*|# ConfigTemplate=${AppDir}\\nzbget.conf.template|" -i %CONFFILE% 236%SED% -e "s|DaemonUsername=.*|# DaemonUsername=|" -i %CONFFILE% 237%SED% -e "s|UMask=.*|# UMask=|" -i %CONFFILE% 238 239mkdir ..\distrib\NZBGet\scripts 240xcopy /E scripts ..\distrib\NZBGet\scripts 241if errorlevel 1 goto BUILD_FAILED 242 243copy ..\..\image\* ..\distrib\NZBGet 244copy ..\..\image\32\* ..\distrib\NZBGet\32 245copy ..\..\image\64\* ..\distrib\NZBGet\64 246if errorlevel 1 goto BUILD_FAILED 247 248del /S ..\distrib\NZBGet\_*.* 249 250GOTO:EOF 251 252 253rem Build one setup for current configuration (debug or release) 254:BuildSetup 255if not exist resources ( 256 mkdir resources 257 xcopy /E ..\nzbget-%VERSION%\windows\resources resources 258 if errorlevel 1 goto BUILD_FAILED 259) 260 261copy ..\nzbget-%VERSION%\windows\nzbget-setup.nsi . 262if errorlevel 1 goto BUILD_FAILED 263 264%NSIS%\makensis.exe nzbget-setup.nsi 265if errorlevel 1 goto BUILD_FAILED 266 267GOTO:EOF 268