4
4
"fmt"
5
5
"io/ioutil"
6
6
"os"
7
+ "path/filepath"
7
8
"strings"
8
9
)
9
10
@@ -15,7 +16,17 @@ func GetThrustDirectory() string {
15
16
return base + "/vendor/darwin/x64/v" + thrustVersion
16
17
}
17
18
18
- func GetAppDirectory () string {
19
+ /*
20
+ GetDownloadPath gets the download or extract directory for Thrust
21
+ */
22
+ func GetDownloadPath () string {
23
+ return strings .Replace (filepath .Join (base , "$V" ), "$V" , thrustVersion , 1 )
24
+ }
25
+
26
+ /*
27
+ Get the path to the .app directory (only OSX)
28
+ */
29
+ func getAppDirectory () string {
19
30
return base + "/vendor/darwin/x64/v" + thrustVersion + "/" + ApplicationName + ".app"
20
31
}
21
32
@@ -28,18 +39,18 @@ func GetExecutablePath() string {
28
39
}
29
40
30
41
/*
31
- GetDownloadUrl returns the interpolatable version of the Thrust download url
42
+ GetDownloadURL returns the interpolatable version of the Thrust download url
32
43
Differs between builds based on OS
33
44
*/
34
- func GetDownloadUrl () string {
45
+ func GetDownloadURL () string {
35
46
return "https://github.com/breach/thrust/releases/download/v$V/thrust-v$V-darwin-x64.zip"
36
47
}
37
48
38
49
/*
39
50
SetThrustApplicationTitle sets the title in the Info.plist. This method only exists on Darwin.
40
51
*/
41
52
func Bootstrap () error {
42
- if executableNotExist () == true {
53
+ if ExecutableNotExist () == true {
43
54
var err error
44
55
if err = prepareExecutable (); err != nil {
45
56
return err
@@ -55,14 +66,15 @@ func Bootstrap() error {
55
66
}
56
67
57
68
/*
58
- executableNotExist checks if the executable does not exist
69
+ ExecutableNotExist checks if the executable does not exist
59
70
*/
60
- func executableNotExist () bool {
71
+ func ExecutableNotExist () bool {
61
72
_ , err := os .Stat (GetExecutablePath ())
73
+ fmt .Println (err )
62
74
return os .IsNotExist (err )
63
75
}
64
76
65
- func pathNotExist (path string ) bool {
77
+ func PathNotExist (path string ) bool {
66
78
_ , err := os .Stat (path )
67
79
return os .IsNotExist (err )
68
80
}
@@ -71,19 +83,23 @@ func pathNotExist(path string) bool {
71
83
prepareExecutable dowloads, unzips and does alot of other magic to prepare our thrust core build.
72
84
*/
73
85
func prepareExecutable () error {
74
- path , err := downloadFromUrl (GetDownloadUrl (), base + "/$V" , thrustVersion )
86
+ path , err := downloadFromUrl (GetDownloadURL (), base + "/$V" , thrustVersion )
75
87
if err != nil {
76
88
return err
77
89
}
78
- if err = unzip (path , GetThrustDirectory ()); err != nil {
90
+
91
+ return UnzipExecutable (path )
92
+ }
93
+
94
+ func UnzipExecutable (path string ) error {
95
+ if err := unzip (path , GetThrustDirectory ()); err != nil {
79
96
return err
80
97
}
81
98
os .Rename (GetThrustDirectory ()+ "/ThrustShell.app/Contents/MacOS/ThrustShell" , GetThrustDirectory ()+ "/ThrustShell.app/Contents/MacOS/" + ApplicationName )
82
99
os .Rename (GetThrustDirectory ()+ "/ThrustShell.app" , GetThrustDirectory ()+ "/" + ApplicationName + ".app" )
83
100
84
- if err = applySymlinks (); err != nil {
101
+ if err : = applySymlinks (); err != nil {
85
102
panic (err )
86
- return err
87
103
}
88
104
89
105
return nil
@@ -95,88 +111,88 @@ ApplySymLinks exists because our unzip utility does not respect deferred symlink
95
111
func applySymlinks () error {
96
112
fmt .Println ("Removing bad symlinks" )
97
113
var err error
98
- if pathNotExist ( GetAppDirectory ()+ "/Contents/Frameworks/ThrustShell Framework.framework/Versions/Current" ) == false {
99
- if err = os .Remove (GetAppDirectory () + "/Contents/Frameworks/ThrustShell Framework.framework/Versions/Current" ); err != nil {
114
+ if PathNotExist ( getAppDirectory ()+ "/Contents/Frameworks/ThrustShell Framework.framework/Versions/Current" ) == false {
115
+ if err = os .Remove (getAppDirectory () + "/Contents/Frameworks/ThrustShell Framework.framework/Versions/Current" ); err != nil {
100
116
return err
101
117
}
102
118
}
103
119
104
- if pathNotExist ( GetAppDirectory ()+ "/Contents/Frameworks/ThrustShell Framework.framework/Frameworks" ) == false {
105
- if err = os .Remove (GetAppDirectory () + "/Contents/Frameworks/ThrustShell Framework.framework/Frameworks" ); err != nil {
120
+ if PathNotExist ( getAppDirectory ()+ "/Contents/Frameworks/ThrustShell Framework.framework/Frameworks" ) == false {
121
+ if err = os .Remove (getAppDirectory () + "/Contents/Frameworks/ThrustShell Framework.framework/Frameworks" ); err != nil {
106
122
return err
107
123
}
108
124
}
109
125
110
- if pathNotExist ( GetAppDirectory ()+ "/Contents/Frameworks/ThrustShell Framework.framework/Libraries" ) == false {
111
- if err = os .Remove (GetAppDirectory () + "/Contents/Frameworks/ThrustShell Framework.framework/Libraries" ); err != nil {
126
+ if PathNotExist ( getAppDirectory ()+ "/Contents/Frameworks/ThrustShell Framework.framework/Libraries" ) == false {
127
+ if err = os .Remove (getAppDirectory () + "/Contents/Frameworks/ThrustShell Framework.framework/Libraries" ); err != nil {
112
128
return err
113
129
}
114
130
}
115
131
116
- if pathNotExist ( GetAppDirectory ()+ "/Contents/Frameworks/ThrustShell Framework.framework/Resources" ) == false {
117
- if err = os .Remove (GetAppDirectory () + "/Contents/Frameworks/ThrustShell Framework.framework/Resources" ); err != nil {
132
+ if PathNotExist ( getAppDirectory ()+ "/Contents/Frameworks/ThrustShell Framework.framework/Resources" ) == false {
133
+ if err = os .Remove (getAppDirectory () + "/Contents/Frameworks/ThrustShell Framework.framework/Resources" ); err != nil {
118
134
return err
119
135
}
120
136
}
121
137
122
- if pathNotExist ( GetAppDirectory ()+ "/Contents/Frameworks/ThrustShell Framework.framework/ThrustShell Framework" ) == false {
123
- if err = os .Remove (GetAppDirectory () + "/Contents/Frameworks/ThrustShell Framework.framework/ThrustShell Framework" ); err != nil {
138
+ if PathNotExist ( getAppDirectory ()+ "/Contents/Frameworks/ThrustShell Framework.framework/ThrustShell Framework" ) == false {
139
+ if err = os .Remove (getAppDirectory () + "/Contents/Frameworks/ThrustShell Framework.framework/ThrustShell Framework" ); err != nil {
124
140
return err
125
141
}
126
142
}
127
143
128
- if pathNotExist ( GetAppDirectory ()+ "/Contents/Frameworks/ThrustShell Framework.framework/Versions/Current/Libraries" ) == false {
129
- if err = os .Remove (GetAppDirectory () + "/Contents/Frameworks/ThrustShell Framework.framework/Versions/Current/Libraries" ); err != nil {
144
+ if PathNotExist ( getAppDirectory ()+ "/Contents/Frameworks/ThrustShell Framework.framework/Versions/Current/Libraries" ) == false {
145
+ if err = os .Remove (getAppDirectory () + "/Contents/Frameworks/ThrustShell Framework.framework/Versions/Current/Libraries" ); err != nil {
130
146
return err
131
147
}
132
148
}
133
149
134
150
fmt .Println ("Applying Symlinks" )
135
151
136
- if pathNotExist ( GetAppDirectory ()+ "/Contents/Frameworks/ThrustShell Framework.framework/Versions/Current" ) == true {
152
+ if PathNotExist ( getAppDirectory ()+ "/Contents/Frameworks/ThrustShell Framework.framework/Versions/Current" ) == true {
137
153
if err = os .Symlink (
138
- GetAppDirectory ()+ "/Contents/Frameworks/ThrustShell Framework.framework/Versions/A" ,
139
- GetAppDirectory ()+ "/Contents/Frameworks/ThrustShell Framework.framework/Versions/Current" ); err != nil {
154
+ getAppDirectory ()+ "/Contents/Frameworks/ThrustShell Framework.framework/Versions/A" ,
155
+ getAppDirectory ()+ "/Contents/Frameworks/ThrustShell Framework.framework/Versions/Current" ); err != nil {
140
156
return err
141
157
}
142
158
}
143
159
144
- if pathNotExist ( GetAppDirectory ()+ "/Contents/Frameworks/ThrustShell Framework.framework/Frameworks" ) == true {
160
+ if PathNotExist ( getAppDirectory ()+ "/Contents/Frameworks/ThrustShell Framework.framework/Frameworks" ) == true {
145
161
if err = os .Symlink (
146
- GetAppDirectory ()+ "/Contents/Frameworks/ThrustShell Framework.framework/Versions/Current/Frameworks" ,
147
- GetAppDirectory ()+ "/Contents/Frameworks/ThrustShell Framework.framework/Frameworks" ); err != nil {
162
+ getAppDirectory ()+ "/Contents/Frameworks/ThrustShell Framework.framework/Versions/Current/Frameworks" ,
163
+ getAppDirectory ()+ "/Contents/Frameworks/ThrustShell Framework.framework/Frameworks" ); err != nil {
148
164
return err
149
165
}
150
166
}
151
167
152
- if pathNotExist ( GetAppDirectory ()+ "/Contents/Frameworks/ThrustShell Framework.framework/Libraries" ) == true {
168
+ if PathNotExist ( getAppDirectory ()+ "/Contents/Frameworks/ThrustShell Framework.framework/Libraries" ) == true {
153
169
if err = os .Symlink (
154
- GetAppDirectory ()+ "/Contents/Frameworks/ThrustShell Framework.framework/Versions/Current/Libraries" ,
155
- GetAppDirectory ()+ "/Contents/Frameworks/ThrustShell Framework.framework/Libraries" ); err != nil {
170
+ getAppDirectory ()+ "/Contents/Frameworks/ThrustShell Framework.framework/Versions/Current/Libraries" ,
171
+ getAppDirectory ()+ "/Contents/Frameworks/ThrustShell Framework.framework/Libraries" ); err != nil {
156
172
return err
157
173
}
158
174
}
159
175
160
- if pathNotExist ( GetAppDirectory ()+ "/Contents/Frameworks/ThrustShell Framework.framework/Resources" ) == true {
176
+ if PathNotExist ( getAppDirectory ()+ "/Contents/Frameworks/ThrustShell Framework.framework/Resources" ) == true {
161
177
if err = os .Symlink (
162
- GetAppDirectory ()+ "/Contents/Frameworks/ThrustShell Framework.framework/Versions/Current/Resources" ,
163
- GetAppDirectory ()+ "/Contents/Frameworks/ThrustShell Framework.framework/Resources" ); err != nil {
178
+ getAppDirectory ()+ "/Contents/Frameworks/ThrustShell Framework.framework/Versions/Current/Resources" ,
179
+ getAppDirectory ()+ "/Contents/Frameworks/ThrustShell Framework.framework/Resources" ); err != nil {
164
180
return err
165
181
}
166
182
}
167
183
168
- if pathNotExist ( GetAppDirectory ()+ "/Contents/Frameworks/ThrustShell Framework.framework/ThrustShell Framework" ) == true {
184
+ if PathNotExist ( getAppDirectory ()+ "/Contents/Frameworks/ThrustShell Framework.framework/ThrustShell Framework" ) == true {
169
185
if err = os .Symlink (
170
- GetAppDirectory ()+ "/Contents/Frameworks/ThrustShell Framework.framework/Versions/Current/ThrustShell Framework" ,
171
- GetAppDirectory ()+ "/Contents/Frameworks/ThrustShell Framework.framework/ThrustShell Framework" ); err != nil {
186
+ getAppDirectory ()+ "/Contents/Frameworks/ThrustShell Framework.framework/Versions/Current/ThrustShell Framework" ,
187
+ getAppDirectory ()+ "/Contents/Frameworks/ThrustShell Framework.framework/ThrustShell Framework" ); err != nil {
172
188
return err
173
189
}
174
190
}
175
191
176
- if pathNotExist ( GetAppDirectory ()+ "/Contents/Frameworks/ThrustShell Framework.framework/Versions/Current/Libraries" ) == true {
192
+ if PathNotExist ( getAppDirectory ()+ "/Contents/Frameworks/ThrustShell Framework.framework/Versions/Current/Libraries" ) == true {
177
193
if err = os .Symlink (
178
- GetAppDirectory ()+ "/Contents/Frameworks/ThrustShell Framework.framework/Versions/A/Libraries/Libraries" ,
179
- GetAppDirectory ()+ "/Contents/Frameworks/ThrustShell Framework.framework/Versions/Current/Libraries" ); err != nil {
194
+ getAppDirectory ()+ "/Contents/Frameworks/ThrustShell Framework.framework/Versions/A/Libraries/Libraries" ,
195
+ getAppDirectory ()+ "/Contents/Frameworks/ThrustShell Framework.framework/Versions/Current/Libraries" ); err != nil {
180
196
return err
181
197
}
182
198
}
0 commit comments