Subversion Repositories Games.Chess Giants

Rev

Rev 192 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
123 pmbaty 1
@echo off
194 pmbaty 2
setlocal enableextensions enabledelayedexpansion
3
rem // change directory to the script's path, in case we are started as Administrator
4
cd /d %~dp0
123 pmbaty 5
 
6
set PRODUCT_NAME=Chess Giants
192 pmbaty 7
set OUTPUT_FILE=Z:\Documents\Mes projets\www.pmbaty.com\chess\Chess Giants Installer.exe
194 pmbaty 8
rem // NOTE NO DASH v----- HERE IN THE FIRST NAME! THE CERTIFICATE WAS ISSUED BY GLOBALSIGN WITHOUT IT!
9
set PUBLISHER=Pierre Marie Baty
10
rem // NOTE NO DASH ^----- HERE IN THE FIRST NAME! THE CERTIFICATE WAS ISSUED BY GLOBALSIGN WITHOUT IT!
11
set PUBLISHER_WEBSITE=https://www.pmbaty.com/chess/
123 pmbaty 12
 
194 pmbaty 13
set OSSLSIGNCODE=%~dp0osslsigncode.Win32-x64.exe
14
set OSSLSIGNCODE_SIGN_FLAGS=-pkcs11module IDPrimePKCS1164.dll -pass 0000 -key "pkcs11:object=%PUBLISHER%;type=private" -certs "%PUBLISHER%+Verokey Secure Code+DigiCert Trusted Root G4.pem" -ts http://timestamp.digicert.com
15
 
16
if not exist "%OSSLSIGNCODE%" echo osslsigncode not found - Please fix the path in this installer script!&& goto :error
17
del *.log > nul 2>&1
18
 
19
rem ////////////////////////////////////
20
rem // create the Chess Giants installer
21
 
22
rem // sign the main executable if it's not signed already
23
set BINARY=..\Chess Giants.exe
24
set DESCRIPTION=%PRODUCT_NAME% executable
25
set URL=%PUBLISHER_WEBSITE%
26
"%OSSLSIGNCODE%" verify "%BINARY%" > nul && (
27
        echo Already signed: %BINARY%
28
) || (
29
        echo Signing %BINARY%...
30
        "%OSSLSIGNCODE%" sign %OSSLSIGNCODE_SIGN_FLAGS% -n "%DESCRIPTION%" -i "%URL%" -in "%BINARY%" >> codesigning.log || goto :error
31
)
32
 
33
rem // sign the game engines if they're not signed already
34
for /f "usebackq delims=|" %%e in (`dir /b ..\engines`) do (
35
        set ENGINE_SUBDIR=%%e
36
        for /f "usebackq delims=|" %%f in (`dir /b ^"..\engines\^!ENGINE_SUBDIR^!\^"*.exe ^"..\engines\^!ENGINE_SUBDIR^!\^"*.dll`) do (
37
                "%OSSLSIGNCODE%" verify "..\engines\!ENGINE_SUBDIR!\%%f" > nul && (
38
                        echo Already signed: ..\engines\!ENGINE_SUBDIR!\%%f
39
                ) || (
40
                        echo Signing ..\engines\!ENGINE_SUBDIR!\%%f...
41
                        "%OSSLSIGNCODE%" sign %OSSLSIGNCODE_SIGN_FLAGS% -n "Chess engine for %PRODUCT% by %PUBLISHER%" -i "%PUBLISHER_WEBSITE%" -in "..\engines\!ENGINE_SUBDIR!\%%f" >> codesigning.log || goto :error
42
                )
43
        )
44
)
45
 
46
rem // reset the config file
153 pmbaty 47
echo Backing up config file...
194 pmbaty 48
if not exist .\config.ini.bak (
49
        if exist ..\config.ini move ..\config.ini .\config.ini.bak
50
        copy ..\config-DEFAULT.ini ..\config.ini
51
) > nul
153 pmbaty 52
 
194 pmbaty 53
rem // create the NSIS install package
126 pmbaty 54
echo Creating the installer...
194 pmbaty 55
"%ProgramFiles(x86)%\NSIS\makensis.exe" "/XOutFile \"%OUTPUT_FILE%\"" installer.nsi > installer.nsi.log || goto :error
123 pmbaty 56
 
132 pmbaty 57
rem // some time is needed for antiviruses etc to release the newly created file
58
ping 127.0.0.1 > nul
59
 
194 pmbaty 60
rem // sign the installer
61
set BINARY=%OUTPUT_FILE%
62
set DESCRIPTION=%PRODUCT_NAME% installer
63
set URL=%PUBLISHER_WEBSITE%
123 pmbaty 64
echo Signing the installer...
194 pmbaty 65
"%OSSLSIGNCODE%" sign %OSSLSIGNCODE_SIGN_FLAGS% -n "%DESCRIPTION%" -i "%URL%" -in "%BINARY%" >> codesigning.log || goto :error
123 pmbaty 66
 
194 pmbaty 67
:success
153 pmbaty 68
echo Restoring configuration...
194 pmbaty 69
if exist .\config.ini.bak del ..\config.ini > nul && move .\config.ini.bak ..\config.ini > nul
123 pmbaty 70
echo Finished.
132 pmbaty 71
pause > nul
144 pmbaty 72
exit /b 0
73
 
194 pmbaty 74
:error
75
if exist .\config.ini.bak del ..\config.ini > nul && move .\config.ini.bak ..\config.ini > nul
76
echo An error occured.
144 pmbaty 77
pause > nul
78
exit /b 1