@@ -176,8 +176,15 @@ upgrade() {
176
176
curl -sL " $GVMURL " > .gvm.tmp
177
177
178
178
# shellcheck disable=SC2002
179
- DOWNLOADEDSUM=$( cat .gvm.tmp | shasum -a 256)
180
179
180
+ # Gitbash/Windows certutil with explit sha256 can be used
181
+ if [[ " $OSTYPE " == " msys" * ]]
182
+ then
183
+ DOWNLOADEDSUM=$( certutil -hashfile .gvm.tmp sha256 | tail -n2 | head -n1)
184
+ else
185
+ DOWNLOADEDSUM=$( cat .gvm.tmp | shasum -a 256)
186
+ fi
187
+
181
188
if [[ $DOWNLOADEDSUM != " $EXPECTEDSUM " ]]
182
189
then
183
190
printf " Checksum does not match new version of GVM [%s]\n" " $SCRIPTVERSION "
@@ -226,7 +233,17 @@ update() {
226
233
EXPECTEDSUM=$( curl -sL " $SUMPATH " )
227
234
228
235
# shellcheck disable=SC2086
229
- FILESUM=$( cat $0 | shasum -a 256)
236
+
237
+ if [[ " $OSTYPE " == " msys" * ]]
238
+ then
239
+ FILESUM=$( certutil -hashfile $0 sha256 | tail -n2 | head -n1)
240
+ EXPECTEDSUM=$( curl -sL " $SUMPATH " | sed ' s/ -//' ) # ⚠️ additional 2xspace + dash may also need to be addressed on unix installs
241
+ else
242
+ FILESUM=$( cat $0 | shasum -a 256)
243
+ EXPECTEDSUM=$( curl -sL " $SUMPATH " )
244
+ fi
245
+
246
+
230
247
231
248
if [[ " $EXPECTEDSUM " != " Not Found" ]]
232
249
then
294
311
fi
295
312
296
313
arch=" amd64"
314
+ extention=" .tar.gz"
297
315
if uname -a | grep " arm64" & > /dev/null
298
316
then
299
317
arch=" arm64"
@@ -306,6 +324,11 @@ then
306
324
elif [[ " $OSTYPE " == " linux" * ]]
307
325
then
308
326
os=" linux"
327
+ elif [[ " $OSTYPE " == " msys" * ]]
328
+ then
329
+ os=" windows"
330
+ arch=" amd64"
331
+ extention=" .zip"
309
332
elif [[ " $OSTYPE " == " freebsd" * ]]
310
333
then
311
334
os=" freebsd"
386
409
else
387
410
if [[ ! -d " $versionroot " ]]
388
411
then
389
- pkg=" go$version .$os -$arch .tar.gz"
412
+
413
+ pkg=" go$version .$os -$arch$extention "
390
414
url=" $dlroot$pkg "
391
415
pkgDir=" $gvmroot /$pkg "
392
416
@@ -407,10 +431,18 @@ else
407
431
fail " $( printf " Unable to create %s\n" " $versionroot " ) "
408
432
fi
409
433
410
- if ! tar -C " $versionroot " -xzf " $pkgDir "
411
- then
412
- fail " $( printf " Unable to extract %s\n" " $pkgDir " rm -rf " $versionroot " ) "
413
- fi
434
+ if [[ " $extention " == " .zip" ]]
435
+ then
436
+ if ! unzip -qd " $versionroot " " $pkgDir "
437
+ then
438
+ fail " $( printf " Unable to zip extract %s\n" " $pkgDir " rm -rf " $versionroot " ) "
439
+ fi
440
+ else
441
+ if ! tar -C " $versionroot " -xzf " $pkgDir "
442
+ then
443
+ fail " $( printf " Unable to tar extract %s\n" " $pkgDir " rm -rf " $versionroot " ) "
444
+ fi
445
+ fi
414
446
415
447
rm " $pkgDir "
416
448
fi
420
452
lnsrc=" $versionroot /go"
421
453
422
454
printf " Updating symlink %s => %s\n" " $lnsrc " " $gvmroot "
455
+
456
+ # Windows + Gitbash require an explicit delete of the previously linked folder
457
+ if [[ " $os " == " windows" ]]
458
+ then
459
+ printf " Removing %s/go if the directory exists\n" " $gvmroot "
460
+ rm -rf " $gvmroot /go"
461
+ fi
462
+
423
463
if ! ln -sf " $lnsrc " " $gvmroot "
424
464
then
425
465
fail " $( printf " Unable to symlink directory %s\n" " $lnsrc " ) "
461
501
fi
462
502
463
503
printf " Go %s Active\n" " $version "
464
- fi
504
+ fi
0 commit comments