forked from jgstew/jgstew-recipes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
check_setup_win.bat
335 lines (307 loc) · 13.3 KB
/
check_setup_win.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
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
@echo off
REM This script should be invoked with CMD
REM This script will not work properly if invoked with CMD from Git Bash
REM This script checks autopkg setup and development on Windows
echo.
echo.
echo Python location:
where python
REM check python install
echo.
echo Python Version: (Python for Windows)
python --version
REM check pip install (generally included in python install)
echo.
echo Pip Version: (Python for Windows)
pip --version
REM check GIT install
echo.
echo GIT Version: (GIT for Windows)
git --version
REM check ssh-keygen.exe exists:
REM if exist "%ProgramFiles%\Git\usr\bin\ssh-keygen.exe" (
FOR /F "tokens=2,*" %%I IN ('reg query HKEY_LOCAL_MACHINE\SOFTWARE\GitForWindows /v InstallPath') DO SET GITPATH=%%J
if exist "%GITPATH%\usr\bin\ssh-keygen.exe" (
REM file exists
) else (
REM file doesn't exist
echo ERROR: "%GITPATH%\usr\bin\ssh-keygen.exe" is missing
echo.
echo - Did you install GIT for Windows? -
echo.
pause
REM exit 2
)
REM check SSH keys (ssh-keygen included with GIT, but must be run)
REM must generate SSH keys
REM must copy public key to github
echo.
echo check ssh keys exist: (~\.ssh\id_rsa.pub)
if exist %UserProfile%\.ssh\id_rsa.pub (
REM file exists
echo ~\.ssh\id_rsa.pub file found!
) else (
REM file doesn't exist
echo ERROR: ~\.ssh\id_rsa.pub missing!
echo RUN: cmd /C "%GITPATH%\usr\bin\ssh-keygen.exe"
echo to generate ~\.ssh\id_rsa.pub
echo NOTE: just hit enter at "Enter file in which to save the key (/c/Users/_USER_/.ssh/id_rsa):" prompt
echo then copy the contents of ~\.ssh\id_rsa.pub to your GitHub account SSH keys at https://github.com/settings/keys
pause
REM exit 3
)
echo.
REM https://docs.github.com/en/github/authenticating-to-github/connecting-to-github-with-ssh/testing-your-ssh-connection
REM https://stackoverflow.com/a/28469910/861745
echo Test SSH connection to GitHub:
echo ssh -T -o StrictHostKeyChecking=no [email protected]
ssh -T -o StrictHostKeyChecking=no [email protected]
if errorlevel 1 (
echo - ssh test succeeded! exit code: %errorlevel%
) else if errorlevel 0 (
echo - ssh test succeeded! exit code: %errorlevel%
) else (
echo ERROR: ssh test failed! exit code: %errorlevel%
echo - Have you copied ssh keys to your github account?
echo.
type %UserProfile%\.ssh\id_rsa.pub
echo.
REM copy public key to clipboard? powershell -c [Windows.Forms.Clipboard]::SetText(???)
pause
REM exit %errorlevel%
)
REM check if autopkg config file exists
REM On Windows:
REM %UserProfile%\AppData\Local\AutoPkg\config.json
REM On Linux:
REM ~/.config/Autopkg/config.json
echo.
if exist %UserProfile%\AppData\Local\Autopkg\config.json (
REM file exists
echo Autopkg config found:
type %UserProfile%\AppData\Local\Autopkg\config.json
echo.
) else (
REM file doesn't exist
if not exist %UserProfile%\AppData\Local\Autopkg (
REM autopkg folder doesn't exist
echo creating missing Autopkg user config folder
mkdir %UserProfile%\AppData\Local\Autopkg
echo.
)
echo Autopkg config does not exist
echo creating blank Autopkg config
echo {} > %UserProfile%\AppData\Local\Autopkg\config.json
)
REM TODO: check visual studio build tools
REM VSWhere check:
REM .\vswhere.exe -all -legacy -products * -format json
REM WMI Relevance check:
REM selects "* from MSFT_VSInstance" of wmis
REM Install Powershell VSSetup module
REM powershell -ExecutionPolicy Bypass -command "Import-Module PowerShellGet ; Install-Module VSSetup -Scope CurrentUser -AcceptLicense -Confirm ; Get-VSSetupInstance"
REM powershell -ExecutionPolicy Bypass -command "Import-Module PowerShellGet ; Install-Module VSSetup -Scope CurrentUser -AcceptLicense -Confirm ; (Get-VSSetupInstance | Select-VSSetupInstance -Product *).packages"
REM Install command:
REM vs_BuildTools.exe --norestart --passive --downloadThenInstall --includeRecommended --add Microsoft.VisualStudio.Workload.VCTools --add Microsoft.VisualStudio.Workload.MSBuildTools
REM Relevance to generate relevance for folder check:
REM ("number of unique values of preceding texts of firsts %22,%22 of names of folders whose(name of it starts with %22" & it & "%22) of folders %22Microsoft\VisualStudio\Packages%22 of /* ProgramData */ csidl folders 35") of concatenations "%22 OR name of it starts with %22" of tuple string items of "Microsoft.VisualCpp.Redist.14, Microsoft.PythonTools.BuildCore, Microsoft.VisualStudio.Workload.MSBuildTools, Microsoft.VisualStudio.Workload.VCTools, Win10SDK"
REM Relevance to detect required vsbuildtools are missing:
REM 5 != number of unique values of preceding texts of firsts "," of names of folders whose(name of it starts with "Microsoft.VisualCpp.Redist.14.Latest" OR name of it starts with "Microsoft.PythonTools.BuildCore" OR name of it starts with "Microsoft.VisualStudio.Workload.MSBuildTools" OR name of it starts with "Microsoft.VisualStudio.Workload.VCTools" OR name of it starts with "Win10SDK") of folders "Microsoft\VisualStudio\Packages" of /* ProgramData */ csidl folders 35
REM distutils.errors.DistutilsPlatformError: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/
REM ParentFolder: C:\ProgramData\Microsoft\VisualStudio\Packages\
REM SubFolders:
REM Microsoft.VisualCpp.Redist.14*
REM Microsoft.Build*
REM Microsoft.PythonTools.BuildCore*
REM Microsoft.VisualStudio.PackageGroup.VC.Tools*
REM Microsoft.VisualStudio.Workload.MSBuildTools*
REM Microsoft.VisualStudio.Workload.VCTools*
REM Win10SDK*
FOR /F "tokens=2,*" %%I IN ('reg query HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\Setup /v CachePath') DO SET VSToolsPATH=%%J
REM set default path if query above doesn't work
IF "%VSToolsPATH%"=="" SET VSToolsPATH=%ProgramData%\Microsoft\VisualStudio\Packages
if not exist %VSToolsPATH%\Microsoft.Build* (
REM folder missing
echo.
echo ERROR: missing required Visual Studio Build Tools - Required for Python Pip installs
echo ERROR: missing folder %VSToolsPATH%\Microsoft.Build*
echo Install Command:
echo vs_BuildTools.exe --norestart --passive --downloadThenInstall --includeRecommended --add Microsoft.VisualStudio.Workload.VCTools --add Microsoft.VisualStudio.Workload.MSBuildTools
echo.
pause
exit 9
)
if not exist %VSToolsPATH%\Microsoft.PythonTools.BuildCore* (
REM folder missing
echo.
echo ERROR: missing required Visual Studio Build Tools - Required for Python Pip installs
echo ERROR: missing folder %VSToolsPATH%\Microsoft.PythonTools.BuildCore*
echo Install Command:
echo vs_BuildTools.exe --norestart --passive --downloadThenInstall --includeRecommended --add Microsoft.VisualStudio.Workload.VCTools --add Microsoft.VisualStudio.Workload.MSBuildTools
echo.
pause
exit 9
)
if not exist %VSToolsPATH%\Microsoft.VisualStudio.PackageGroup.VC.Tools* (
REM folder missing
echo.
echo ERROR: missing required Visual Studio Build Tools - Required for Python Pip installs
echo ERROR: missing folder %VSToolsPATH%\Microsoft.VisualStudio.PackageGroup.VC.Tools*
echo Install Command:
echo vs_BuildTools.exe --norestart --passive --downloadThenInstall --includeRecommended --add Microsoft.VisualStudio.Workload.VCTools --add Microsoft.VisualStudio.Workload.MSBuildTools
echo.
pause
exit 9
)
if not exist %VSToolsPATH%\Microsoft.VisualStudio.Workload.MSBuildTools* (
REM folder missing
echo.
echo ERROR: missing required Visual Studio Build Tools - Required for Python Pip installs
echo ERROR: missing folder %VSToolsPATH%\Microsoft.VisualStudio.Workload.MSBuildTools*
echo Install Command:
echo vs_BuildTools.exe --norestart --passive --downloadThenInstall --includeRecommended --add Microsoft.VisualStudio.Workload.VCTools --add Microsoft.VisualStudio.Workload.MSBuildTools
echo.
pause
exit 9
)
if not exist %VSToolsPATH%\Microsoft.VisualStudio.Workload.VCTools* (
REM folder missing
echo.
echo ERROR: missing required Visual Studio Build Tools - Required for Python Pip installs
echo ERROR: missing folder %VSToolsPATH%\Microsoft.VisualStudio.Workload.VCTools*
echo Install Command:
echo vs_BuildTools.exe --norestart --passive --downloadThenInstall --includeRecommended --add Microsoft.VisualStudio.Workload.VCTools --add Microsoft.VisualStudio.Workload.MSBuildTools
echo.
pause
exit 9
)
if not exist %VSToolsPATH%\Win10SDK* (
REM folder missing
echo.
echo ERROR: missing required Visual Studio Build Tools - Required for Python Pip installs
echo ERROR: missing folder %VSToolsPATH%\Win10SDK*
echo Install Command:
echo vs_BuildTools.exe --norestart --passive --downloadThenInstall --includeRecommended --add Microsoft.VisualStudio.Workload.VCTools --add Microsoft.VisualStudio.Workload.MSBuildTools
echo.
pause
exit 9
)
echo.
echo Upgrade pip:
echo python -m pip install --upgrade pip
python -m pip install --upgrade pip
echo.
echo NOTE: The following should be run from within the cloned git "recipes" folder:
if exist .git (
echo .git folder found
echo.
) else (
echo ERROR: .git folder not found!
echo Are you running this from the cloned git "recipes" folder?
echo NOTE: this error is expected if you are running this script independantly
echo to check intial setup. You should later run this from a cloned repo.
pause
exit 99
)
echo.
echo include repo .gitconfig:
echo git config --local include.path ../.gitconfig
git config --local include.path ../.gitconfig
echo.
echo Update Current Repo:
echo git pull
git pull
echo.
echo check pip install requirements for cloned recipes:
echo pip install -r .\requirements.txt --quiet --quiet
pip install -r .\requirements.txt --quiet --quiet
if errorlevel 0 (
echo - pip install for recipes succeeded! exit code: %errorlevel%
) else (
echo ERROR: pip install for recipes failed! exit code: %errorlevel%
echo - Have you installed visual studio build tools?
echo vs_BuildTools.exe --norestart --passive --downloadThenInstall --includeRecommended --add Microsoft.VisualStudio.Workload.NativeDesktop --add Microsoft.VisualStudio.Workload.VCTools --add Microsoft.VisualStudio.Workload.MSBuildTools
pause
exit %errorlevel%
)
REM https://stackoverflow.com/a/334890/861745
echo.
echo besapi python module version:
echo python -c "import besapi ; print(besapi.__version__)"
python -c "import besapi ; print(besapi.__version__)"
echo.
echo Check if besapi config file exists:
REM %UserProfile%\.besapi.conf
if exist %UserProfile%\.besapi.conf (
REM file exists
echo ~\.besapi.conf file found!
echo.
echo Test besapi config and login:
python -m besapi ls quit
) else (
echo ERROR: ~\.besapi.conf file does not exist!
echo copying blank besapi config
echo copy _setup\.besapi.conf %UserProfile%\.besapi.conf
copy _setup\.besapi.conf %UserProfile%\.besapi.conf
)
echo.
echo Check for ..\autopkg git repo folder:
if not exist ..\autopkg (
echo ERROR: autopkg git folder missing!
REM TODO: Consider attempt at automatic fix with the following:
REM CMD /C "cd .. && git clone https://github.com/jgstew/autopkg.git"
pause
exit 4
) else (
echo ..\autopkg folder found!
)
echo.
echo check autopkg on dev branch:
echo CMD /C "cd ..\autopkg && git checkout dev"
CMD /C "cd ..\autopkg && git checkout dev"
echo.
echo update autopkg repo:
echo CMD /C "cd ..\autopkg && git pull"
CMD /C "cd ..\autopkg && git pull"
echo.
echo check pip install requirements for AutoPkg:
echo pip install -r ..\autopkg\requirements.txt --quiet --quiet
pip install -r ..\autopkg\requirements.txt --quiet --quiet
if errorlevel 0 (
echo - pip install for autopkg succeeded! exit code: %errorlevel%
) else (
echo ERROR: pip install for autopkg failed! exit code: %errorlevel%
echo - Have you installed visual studio build tools?
echo vs_BuildTools.exe --norestart --passive --downloadThenInstall --includeRecommended --add Microsoft.VisualStudio.Workload.NativeDesktop --add Microsoft.VisualStudio.Workload.VCTools --add Microsoft.VisualStudio.Workload.MSBuildTools
pause
exit %errorlevel%
)
echo.
echo AutoPkg Version Check: (WARNINGS are expected on Windows)
REM this is assuming you ran check_setup_win.bat from within the recipes folder and that Autopkg is in a sibling folder
echo python ..\autopkg\Code\autopkg version
python ..\autopkg\Code\autopkg version
echo --- AutoPkg version (expected 2.3 or later)
echo.
echo Add/Update jgstew-recipes in AutoPkg
echo python ..\autopkg\Code\autopkg repo-add https://github.com/jgstew/jgstew-recipes
python ..\autopkg\Code\autopkg repo-add https://github.com/jgstew/jgstew-recipes
REM hansen-m-recipes
echo.
echo Add/Update hansen-m-recipes in AutoPkg
echo python ..\autopkg\Code\autopkg repo-add hansen-m-recipes
python ..\autopkg\Code\autopkg repo-add hansen-m-recipes
REM add pre-commit:
echo.
echo Add pre-commit hooks:
echo pre-commit install --install-hooks --allow-missing-config
pre-commit install --install-hooks --allow-missing-config
echo.
echo Run test recipe for 7zip:
echo python ..\autopkg\Code\autopkg run -v com.github.jgstew.test.FileExeVersionExtractor-Win
python ..\autopkg\Code\autopkg run -v com.github.jgstew.test.FileExeVersionExtractor-Win
echo Expected output `Found Version: 19.0.0.0`
echo.
echo Check the _setup folder for other items
echo.
pause