Skip to content

Commit eeba2ce

Browse files
authored
Merge pull request #270 from arduino/path_bugfix_win
[WE-168] Path bugfix win
2 parents 345f955 + 393c743 commit eeba2ce

File tree

367 files changed

+52354
-44880
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

367 files changed

+52354
-44880
lines changed

Gopkg.lock

+104-125
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Gopkg.toml

+6-111
Original file line numberDiff line numberDiff line change
@@ -27,76 +27,28 @@
2727

2828
[[constraint]]
2929
name = "github.com/Sirupsen/logrus"
30-
version = "1.0.6"
30+
version = "1.2.0"
3131

3232
[[constraint]]
3333
name = "github.com/blang/semver"
3434
version = "3.5.1"
3535

3636
[[constraint]]
37-
branch = "master"
38-
name = "github.com/creack/goselect"
39-
40-
[[constraint]]
41-
branch = "master"
42-
name = "github.com/getlantern/context"
43-
44-
[[constraint]]
45-
branch = "master"
46-
name = "github.com/getlantern/errors"
47-
48-
[[constraint]]
49-
branch = "master"
50-
name = "github.com/getlantern/filepersist"
51-
52-
[[constraint]]
53-
branch = "master"
54-
name = "github.com/getlantern/golog"
55-
56-
[[constraint]]
57-
branch = "master"
58-
name = "github.com/getlantern/hex"
59-
60-
[[constraint]]
61-
branch = "master"
62-
name = "github.com/getlantern/hidden"
63-
64-
[[constraint]]
65-
branch = "master"
66-
name = "github.com/getlantern/ops"
67-
68-
[[constraint]]
69-
name = "github.com/getlantern/stack"
70-
version = "1.5.1"
71-
72-
[[constraint]]
73-
branch = "master"
37+
revision = "89b3d9c45cc69f861868cc7f3159eba2b4cdfb22"
7438
name = "github.com/getlantern/systray"
7539

7640
[[constraint]]
7741
name = "github.com/gin-gonic/gin"
78-
version = "1.2.0"
42+
version = "1.3.0"
7943

8044
[[constraint]]
8145
name = "github.com/go-ini/ini"
82-
version = "1.38.1"
83-
84-
[[constraint]]
85-
branch = "master"
86-
name = "github.com/googollee/go-engine.io"
46+
version = "1.39.0"
8747

8848
[[constraint]]
8949
branch = "master"
9050
name = "github.com/googollee/go-socket.io"
9151

92-
[[constraint]]
93-
name = "github.com/gorilla/websocket"
94-
version = "1.2.0"
95-
96-
[[constraint]]
97-
branch = "filemode"
98-
name = "github.com/inconshreveable/go-update"
99-
10052
[[constraint]]
10153
name = "github.com/itsjamie/gin-cors"
10254
version = "1.0.0"
@@ -109,37 +61,13 @@
10961
name = "github.com/kr/binarydist"
11062
version = "0.1.0"
11163

112-
[[constraint]]
113-
name = "github.com/kr/fs"
114-
version = "0.1.0"
115-
116-
[[constraint]]
117-
branch = "master"
118-
name = "github.com/manucorporat/sse"
119-
120-
[[constraint]]
121-
name = "github.com/mattn/go-colorable"
122-
version = "0.0.9"
123-
124-
[[constraint]]
125-
name = "github.com/mattn/go-isatty"
126-
version = "0.0.3"
127-
128-
[[constraint]]
129-
name = "github.com/mattn/go-ole"
130-
version = "1.2.1"
131-
13264
[[constraint]]
13365
name = "github.com/mattn/go-shellwords"
13466
version = "1.0.3"
13567

13668
[[constraint]]
137-
name = "github.com/miekg/dns"
138-
version = "1.0.8"
139-
140-
[[constraint]]
141-
branch = "master"
14269
name = "github.com/mitchellh/go-homedir"
70+
version = "1.0.0"
14371

14472
[[constraint]]
14573
branch = "master"
@@ -149,10 +77,6 @@
14977
name = "github.com/pkg/errors"
15078
version = "0.8.0"
15179

152-
[[constraint]]
153-
name = "github.com/pkg/sftp"
154-
version = "1.8.0"
155-
15680
[[constraint]]
15781
branch = "master"
15882
name = "github.com/sfreiberg/simplessh"
@@ -161,18 +85,6 @@
16185
branch = "master"
16286
name = "github.com/skratchdot/open-golang"
16387

164-
[[constraint]]
165-
name = "github.com/smartystreets/goconvey"
166-
version = "1.6.3"
167-
168-
[[constraint]]
169-
name = "github.com/stretchr/testify"
170-
version = "1.2.2"
171-
172-
[[constraint]]
173-
branch = "master"
174-
name = "github.com/vharitonsky/iniflags"
175-
17688
[[constraint]]
17789
branch = "master"
17890
name = "github.com/xrash/smetrics"
@@ -185,27 +97,10 @@
18597
branch = "master"
18698
name = "golang.org/x/crypto"
18799

188-
[[constraint]]
189-
branch = "master"
190-
name = "golang.org/x/net"
191-
192-
[[constraint]]
193-
branch = "master"
194-
name = "golang.org/x/sys"
195-
196-
[[constraint]]
197-
name = "gopkg.in/bluesuncorp/validator.v5"
198-
version = "5.12.0"
199-
200100
[[constraint]]
201101
branch = "v0"
202102
name = "gopkg.in/inconshreveable/go-update.v0"
203103

204-
[[constraint]]
205-
name = "gopkg.in/ini.v1"
206-
version = "1.38.1"
207-
208104
[prune]
209-
non-go = true
210105
go-tests = true
211-
unused-packages = true
106+
unused-packages = true

main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ var homeTemplate = template.Must(template.New("home").Parse(homeTemplateHtml))
335335
const homeTemplateHtml = `<!DOCTYPE html>
336336
<html>
337337
<head>
338-
<title>Serial Port Example</title>
338+
<title>Arduino Create Agent Debug Console</title>
339339
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
340340
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/1.3.5/socket.io.min.js"></script>
341341
<script type="text/javascript">

tools/download.go

+44-37
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"encoding/hex"
1111
"encoding/json"
1212
"errors"
13+
"fmt"
1314
"io"
1415
"io/ioutil"
1516
"net/http"
@@ -226,7 +227,7 @@ func (t *Tools) Download(pack, name, version, behaviour string) error {
226227
// Decompress
227228
t.Logger("Unpacking tool " + name)
228229

229-
location := path.Join(dir(), pack, correctTool.Name, correctTool.Version)
230+
location := path.Join( dir(), pack, correctTool.Name, correctTool.Version)
230231
err = os.RemoveAll(location)
231232

232233
if err != nil {
@@ -240,12 +241,12 @@ func (t *Tools) Download(pack, name, version, behaviour string) error {
240241

241242
switch srcType {
242243
case "application/zip":
243-
location, err = extractZip(body, location)
244+
location, err = extractZip(t.Logger, body, location)
244245
case "application/x-bz2":
245246
case "application/octet-stream":
246-
location, err = extractBz2(body, location)
247+
location, err = extractBz2(t.Logger, body, location)
247248
case "application/x-gzip":
248-
location, err = extractTarGz(body, location)
249+
location, err = extractTarGz(t.Logger, body, location)
249250
default:
250251
return errors.New("Unknown extension for file " + correctSystem.URL)
251252
}
@@ -376,7 +377,7 @@ func removeStringFromSlice(s []string, r string) []string {
376377

377378
func findBaseDir(dirList []string) string {
378379
if len(dirList) == 1 {
379-
return filepath.Dir(dirList[0]) + "/"
380+
return path.Dir(dirList[0]) + "/"
380381
}
381382

382383
// https://github.com/backdrop-ops/contrib/issues/55#issuecomment-73814500
@@ -385,14 +386,14 @@ func findBaseDir(dirList []string) string {
385386
dirList = removeStringFromSlice(dirList, v)
386387
}
387388

388-
commonBaseDir := commonPrefix(os.PathSeparator, dirList)
389+
commonBaseDir := commonPrefix('/', dirList)
389390
if commonBaseDir != "" {
390391
commonBaseDir = commonBaseDir + "/"
391392
}
392393
return commonBaseDir
393394
}
394395

395-
func extractZip(body []byte, location string) (string, error) {
396+
func extractZip(log func(msg string) , body []byte, location string) (string, error) {
396397
path, err := utilities.SaveFileonTempDir("tooldownloaded.zip", bytes.NewReader(body))
397398
r, err := zip.OpenReader(path)
398399
if err != nil {
@@ -406,9 +407,11 @@ func extractZip(body []byte, location string) (string, error) {
406407
}
407408

408409
basedir := findBaseDir(dirList)
410+
log(fmt.Sprintf("selected baseDir %s from Zip Archive Content: %v", basedir, dirList))
409411

410412
for _, f := range r.File {
411413
fullname := filepath.Join(location, strings.Replace(f.Name, basedir, "", -1))
414+
log(fmt.Sprintf("generated fullname %s removing %s from %s", fullname, basedir, f.Name))
412415
if f.FileInfo().IsDir() {
413416
os.MkdirAll(fullname, f.FileInfo().Mode().Perm())
414417
} else {
@@ -439,7 +442,7 @@ func extractZip(body []byte, location string) (string, error) {
439442
return location, nil
440443
}
441444

442-
func extractTarGz(body []byte, location string) (string, error) {
445+
func extractTarGz(log func(msg string),body []byte, location string) (string, error) {
443446
bodyCopy := make([]byte, len(body))
444447
copy(bodyCopy, body)
445448
tarFile, _ := gzip.NewReader(bytes.NewReader(body))
@@ -456,6 +459,7 @@ func extractTarGz(body []byte, location string) (string, error) {
456459
}
457460

458461
basedir := findBaseDir(dirList)
462+
log(fmt.Sprintf("selected baseDir %s from TarGz Archive Content: %v", basedir, dirList))
459463

460464
tarFile, _ = gzip.NewReader(bytes.NewReader(bodyCopy))
461465
tarReader = tar.NewReader(tarFile)
@@ -502,36 +506,8 @@ func extractTarGz(body []byte, location string) (string, error) {
502506
return location, nil
503507
}
504508

505-
func (t *Tools) installDrivers(location string) error {
506-
OK_PRESSED := 6
507-
extension := ".bat"
508-
preamble := ""
509-
if runtime.GOOS != "windows" {
510-
extension = ".sh"
511-
// add ./ to force locality
512-
preamble = "./"
513-
}
514-
if _, err := os.Stat(filepath.Join(location, "post_install"+extension)); err == nil {
515-
t.Logger("Installing drivers")
516-
ok := MessageBox("Installing drivers", "We are about to install some drivers needed to use Arduino/Genuino boards\nDo you want to continue?")
517-
if ok == OK_PRESSED {
518-
os.Chdir(location)
519-
t.Logger(preamble + "post_install" + extension)
520-
oscmd := exec.Command(preamble + "post_install" + extension)
521-
if runtime.GOOS != "linux" {
522-
// spawning a shell could be the only way to let the user type his password
523-
TellCommandNotToSpawnShell(oscmd)
524-
}
525-
err = oscmd.Run()
526-
return err
527-
} else {
528-
return errors.New("Could not install drivers")
529-
}
530-
}
531-
return nil
532-
}
533509

534-
func extractBz2(body []byte, location string) (string, error) {
510+
func extractBz2(log func(msg string),body []byte, location string) (string, error) {
535511
bodyCopy := make([]byte, len(body))
536512
copy(bodyCopy, body)
537513
tarFile := bzip2.NewReader(bytes.NewReader(body))
@@ -548,6 +524,7 @@ func extractBz2(body []byte, location string) (string, error) {
548524
}
549525

550526
basedir := findBaseDir(dirList)
527+
log(fmt.Sprintf("selected baseDir %s from Bz2 Archive Content: %v", basedir, dirList))
551528

552529
tarFile = bzip2.NewReader(bytes.NewReader(bodyCopy))
553530
tarReader = tar.NewReader(tarFile)
@@ -596,6 +573,36 @@ func extractBz2(body []byte, location string) (string, error) {
596573
return location, nil
597574
}
598575

576+
577+
func (t *Tools) installDrivers(location string) error {
578+
OK_PRESSED := 6
579+
extension := ".bat"
580+
preamble := ""
581+
if runtime.GOOS != "windows" {
582+
extension = ".sh"
583+
// add ./ to force locality
584+
preamble = "./"
585+
}
586+
if _, err := os.Stat(filepath.Join(location, "post_install"+extension)); err == nil {
587+
t.Logger("Installing drivers")
588+
ok := MessageBox("Installing drivers", "We are about to install some drivers needed to use Arduino/Genuino boards\nDo you want to continue?")
589+
if ok == OK_PRESSED {
590+
os.Chdir(location)
591+
t.Logger(preamble + "post_install" + extension)
592+
oscmd := exec.Command(preamble + "post_install" + extension)
593+
if runtime.GOOS != "linux" {
594+
// spawning a shell could be the only way to let the user type his password
595+
TellCommandNotToSpawnShell(oscmd)
596+
}
597+
err = oscmd.Run()
598+
return err
599+
} else {
600+
return errors.New("Could not install drivers")
601+
}
602+
}
603+
return nil
604+
}
605+
599606
func makeExecutable(location string) error {
600607
location = path.Join(location, "bin")
601608
files, err := ioutil.ReadDir(location)

0 commit comments

Comments
 (0)