@@ -53,7 +53,7 @@ type index struct {
53
53
var systems = map [string ]string {
54
54
"linuxamd64" : "x86_64-linux-gnu" ,
55
55
"linux386" : "i686-linux-gnu" ,
56
- "darwinamd64" : "i386- apple-darwin11 " ,
56
+ "darwinamd64" : "apple-darwin " ,
57
57
"windows386" : "i686-mingw32" ,
58
58
}
59
59
@@ -71,15 +71,13 @@ func checkGPGSig(fileName string, sigFileName string) error {
71
71
if err != nil {
72
72
return err
73
73
}
74
-
75
74
defer sigFile .Close ()
76
75
77
76
// Get a Reader for the signature file
78
77
file , err := os .Open (fileName )
79
78
if err != nil {
80
79
return err
81
80
}
82
-
83
81
defer file .Close ()
84
82
85
83
publicKeyBin , err := hex .DecodeString (publicKeyHex )
@@ -179,7 +177,7 @@ func (t *Tools) Download(name, version, behaviour string) error {
179
177
180
178
// Find the url based on system
181
179
var correctSystem system
182
- max_similarity := 0.8
180
+ max_similarity := 0.7
183
181
184
182
for _ , s := range correctTool .Systems {
185
183
similarity := smetrics .Jaro (s .Host , systems [runtime .GOOS + runtime .GOARCH ])
@@ -252,7 +250,10 @@ func (t *Tools) Download(name, version, behaviour string) error {
252
250
return err
253
251
}
254
252
255
- t .installDrivers (location )
253
+ err = t .installDrivers (location )
254
+ if err != nil {
255
+ return err
256
+ }
256
257
257
258
// Ensure that the files are executable
258
259
t .Logger .Println ("Ensure that the files are executable" )
@@ -411,10 +412,9 @@ func extractTarGz(body []byte, location string) (string, error) {
411
412
}
412
413
413
414
file , err := os .OpenFile (path , os .O_CREATE | os .O_TRUNC | os .O_WRONLY , info .Mode ())
414
- if err ! = nil {
415
- //return location, err
415
+ if err = = nil {
416
+ defer file . Close ()
416
417
}
417
- defer file .Close ()
418
418
_ , err = io .Copy (file , tarReader )
419
419
if err != nil {
420
420
//return location, err
@@ -423,15 +423,26 @@ func extractTarGz(body []byte, location string) (string, error) {
423
423
return location , nil
424
424
}
425
425
426
- func (t * Tools ) installDrivers (location string ) {
426
+ func (t * Tools ) installDrivers (location string ) error {
427
427
if runtime .GOOS == "windows" {
428
428
if _ , err := os .Stat (filepath .Join (location , "post_install.bat" )); err == nil {
429
429
t .Logger .Println ("Installing drivers" )
430
- oscmd := exec .Command (filepath .Join (location , "post_install.bat" ))
431
- TellCommandNotToSpawnShell (oscmd )
432
- oscmd .Run ()
430
+ ok := MessageBox ("Installing drivers" , "We are about to install some drivers needed to use Arduino/Genuino boards\n Do you want to continue?" )
431
+ t .Logger .Println (ok )
432
+ if ok == 6 {
433
+ os .Chdir (location )
434
+ oscmd := exec .Command ("post_install.bat" )
435
+ TellCommandNotToSpawnShell (oscmd )
436
+ t .Logger .Println (oscmd )
437
+ err = oscmd .Run ()
438
+ t .Logger .Println (err )
439
+ return err
440
+ } else {
441
+ return errors .New ("Could not install drivers" )
442
+ }
433
443
}
434
444
}
445
+ return nil
435
446
}
436
447
437
448
func extractBz2 (body []byte , location string ) (string , error ) {
@@ -479,10 +490,9 @@ func extractBz2(body []byte, location string) (string, error) {
479
490
}
480
491
481
492
file , err := os .OpenFile (path , os .O_CREATE | os .O_TRUNC | os .O_WRONLY , info .Mode ())
482
- if err ! = nil {
483
- //return location, err
493
+ if err = = nil {
494
+ defer file . Close ()
484
495
}
485
- defer file .Close ()
486
496
_ , err = io .Copy (file , tarReader )
487
497
if err != nil {
488
498
//return location, err
0 commit comments