forked from nextcloud/client-building
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsingle-build-installer-msi.bat
186 lines (142 loc) Β· 5.86 KB
/
single-build-installer-msi.bat
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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
@echo off
setlocal EnableDelayedExpansion
cls
Rem ******************************************************************************************
rem "MSI installer - build setup for Windows 64-bit or 32-bit"
Rem ******************************************************************************************
call "%~dp0/common.inc.bat" %1 %2
Rem ******************************************************************************************
rem Reference: https://ss64.com/nt/setlocal.html
rem Reference: https://ss64.com/nt/start.html
echo "**** Build installer-msi for %BUILD_TYPE% %BUILD_ARCH% (%~nx0)."
Rem ******************************************************************************************
set "MY_REPO=%PROJECT_PATH%/desktop"
set "MY_BUILD_PATH=%MY_REPO%/build"
set "MY_INSTALL_PATH=%PROJECT_PATH%/install/%BUILD_TYPE%/%BUILD_ARCH%"
set "MY_COLLECT_PATH=%PROJECT_PATH%/collect/%BUILD_TYPE%/%BUILD_ARCH%"
set "MY_MSI_PATH=%MY_INSTALL_PATH%/msi"
echo "* BUILD_TYPE=%BUILD_TYPE%"
echo "* BUILD_ARCH=%BUILD_ARCH%"
echo "* PROJECT_PATH=%PROJECT_PATH%"
echo "* INSTALLER_OUTPUT_PATH=%INSTALLER_OUTPUT_PATH%"
echo "* Build date %BUILD_DATE%"
echo "* VERSION_SUFFIX %VERSION_SUFFIX%"
echo "* MY_REPO=%MY_REPO%"
echo "* MY_BUILD_PATH=%MY_BUILD_PATH%"
echo "* MY_INSTALL_PATH=%MY_INSTALL_PATH%"
echo "* MY_COLLECT_PATH=%MY_COLLECT_PATH%"
echo "* MY_MSI_PATH=%MY_MSI_PATH%"
echo "* PATH=%PATH%"
echo "* USE_CODE_SIGNING=%USE_CODE_SIGNING%"
echo "* UPLOAD_BUILD=%UPLOAD_BUILD%"
Rem ******************************************************************************************
rem "check for required environment variables"
Rem ******************************************************************************************
call :testEnv PROJECT_PATH
call :testEnv INSTALLER_OUTPUT_PATH
call :testEnv BUILD_TYPE
call :testEnv BUILD_ARCH
call :testEnv BUILD_DATE
if "%USE_CODE_SIGNING%" == "1" (
call :testEnv VCINSTALLDIR
call :testEnv APPLICATION_VENDOR
call :testEnv CERTIFICATE_FILENAME
call :testEnv CERTIFICATE_CSP
call :testEnv CERTIFICATE_KEY_CONTAINER_NAME
call :testEnv CERTIFICATE_PASSWORD
call :testEnv SIGN_FILE_DIGEST_ALG
call :testEnv SIGN_TIMESTAMP_URL
call :testEnv SIGN_TIMESTAMP_DIGEST_ALG
)
if %ERRORLEVEL% neq 0 goto onError
Rem ******************************************************************************************
rem "Test run?"
Rem ******************************************************************************************
if "%TEST_RUN%" == "1" (
echo "** TEST RUN - exit."
exit
)
Rem ******************************************************************************************
rem "build MSI installer"
Rem ******************************************************************************************
rem Reference: https://ss64.com/nt/setlocal.html
rem Reference: https://ss64.com/nt/start.html
Rem Create output directory for the Installer
if not exist "%INSTALLER_OUTPUT_PATH%" (
echo "* Create output directory for the Installer: %INSTALLER_OUTPUT_PATH% (recursive)."
start "mkdir %INSTALLER_OUTPUT_PATH%" /D "%PROJECT_PATH%/" /B /wait "%WIN_GIT_PATH%\usr\bin\mkdir.exe" -p "%INSTALLER_OUTPUT_PATH%"
)
if %ERRORLEVEL% neq 0 goto onError
if "%BUILD_ARCH%" == "Win32" (
set "BITNESS=32"
) else (
set "BITNESS=64"
)
Rem VC Environment Variables
echo "** Calling vcvars64.bat to get the VC env vars:"
call "%VCINSTALLDIR%\Auxiliary\Build\vcvars64.bat"
Rem ******************************************************************************************
rem "code signing"
Rem ******************************************************************************************
if "%USE_CODE_SIGNING%" == "0" (
echo "** Don't sign: Code signing is disabled by USE_CODE_SIGNING"
) else (
echo "** Trying to find signtool in the PATH (VC env vars):"
for %%i in (signtool.exe) do @set "SIGNTOOL=%%~$PATH:i"
if "!SIGNTOOL!" == "" (
echo "** Unable to find signtool.exe in the PATH."
goto onError
) else (
echo "** Found signtool.exe: !SIGNTOOL!"
)
echo "** Signing helper DLL:"
for %%G in (
"NCMsiHelper%BITNESS%.dll"
) do (
start "sign %%~G" /D "%PROJECT_PATH%/" /B /wait %~dp0/sign.bat "%MY_MSI_PATH%/%%~G"
if !ERRORLEVEL! neq 0 goto onError
)
echo "** Code signing ends."
)
echo "* Run MSI build script with parameter '%MY_COLLECT_PATH%' to create installer."
start "make-msi.bat" /D "%MY_MSI_PATH%" /B /wait call make-msi.bat "%MY_COLLECT_PATH%"
if %ERRORLEVEL% neq 0 goto onError
Rem Find MSI, get filename
for /f "delims=" %%a in ('dir /b "%MY_MSI_PATH%"\*.msi') do (
set "MSI_FILENAME=%%a"
)
if "%USE_CODE_SIGNING%" == "0" (
echo "** Don't sign: Code signing is disabled by USE_CODE_SIGNING"
) else (
echo "** Signing %MSI_FILENAME%:"
for %%G in (
"%MSI_FILENAME%"
) do (
start "sign %%~G" /D "%PROJECT_PATH%/" /B /wait %~dp0/sign.bat "%MY_MSI_PATH%/%%~G"
if !ERRORLEVEL! neq 0 goto onError
)
echo "** Code signing ends."
)
echo "* Move %MSI_FILENAME% to '%INSTALLER_OUTPUT_PATH%'."
start "move msi" /D "%MY_MSI_PATH%" /B /wait mv "%MSI_FILENAME%" "%INSTALLER_OUTPUT_PATH%"/
if %ERRORLEVEL% neq 0 goto onError
if "%UPLOAD_BUILD%" == "0" (
echo "** Don't upload: Uploading is disabled by UPLOAD_BUILD"
) else (
echo "* Upload %MSI_FILENAME%."
start "upload msi" /D "%PROJECT_PATH%" /B /wait %~dp0/upload.bat %INSTALLER_OUTPUT_PATH%/%MSI_FILENAME%
)
Rem ******************************************************************************************
echo "**** Finished Build: installer-msi %BUILD_TYPE% %BUILD_ARCH% (%~nx0)"
exit 0
:onError
echo "**** Build FAILED: installer-msi %BUILD_TYPE% %BUILD_ARCH% (%~nx0)"
if %ERRORLEVEL% neq 0 exit %ERRORLEVEL%
if !ERRORLEVEL! neq 0 exit !ERRORLEVEL!
exit 1
:testEnv
if "!%*!" == "" (
echo "Missing environment variable: %*"
exit /B 1
)
exit /B