-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathgopei
executable file
·363 lines (335 loc) · 17.8 KB
/
gopei
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
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
#!/usr/bin/env bash
# golang programming environment installer
# Copyright (C) 2014-2022 <[email protected]>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
set -e
GOPEI_LONG_NAME="Golang Programming Environment Installer"
GOPEI_CODE_NAME=""
GOPEI_AUTHOR="[email protected]"
GOPEI_COPYRIGHT="Copyright (C) 2014-2022 $GOPEI_AUTHOR"
GOPEI_VERSION=2.9.0
GOPEI_STAGE="release"
GOPEI_ROOT=`dirname $0`
GOPEI_NAME=`basename $0`
#-------------------------------------------------------------------------------
COMPILER_VERSION=1.18.2
IDE_VERSION=38.0
LINUX_QT_VERSION=5.5.1
MACOS_QT_VERSION=5.15.2
#-------------------------------------------------------------------------------
GOROOT=$HOME/go
GOPATH=$HOME
PATH=$PATH:$GOROOT/bin
IDEROOT=$HOME/liteide
#-------------------------------------------------------------------------------
#get host computer arch (e.g. i686|x86_64|armv6l)
case $(uname -m) in
i686)
MACHINE_TYPE=386;;
x86_64|amd64)
MACHINE_TYPE=amd64;;
armv6l|armv7l)
IS_ARM=1
MACHINE_TYPE=armv6l;;
*) echo "Unknown architecture" && exit;;
esac
#get host computer LONG_BIT (e.g 32|64)
MACHINE_BITS=$(getconf LONG_BIT)
#get kernel name (e.g. linux|darwin|freebsd)
KERNEL_NAME=$(uname -s | tr '[:upper:]' '[:lower:]')
#tricky build IS_$(KERNEL_NAME) flag
export IS_$(echo $KERNEL_NAME | tr '[:lower:]' '[:upper:]')=1
#-------------------------------------------------------------------------------
COMPILER_NAME=go$COMPILER_VERSION.$KERNEL_NAME-$MACHINE_TYPE.tar.gz
case $KERNEL_NAME in
linux)
IDE_NAME=liteidex$IDE_VERSION.$KERNEL_NAME$MACHINE_BITS-qt$LINUX_QT_VERSION.tar.gz
IDE_RESOURCES=$IDEROOT/share/liteide
IDE_ENVIRON=$KERNEL_NAME$MACHINE_BITS
IDE_FONT_FAMILY='family=FreeMono'
IDE_FONT_SIZE='fontsize=12'
IDE_GEOMETRY='geometry=@ByteArray(\x1\xd9\xd0\xcb\0\x2\0\0\0\0\0\x9b\0\0\0s\0\0\x3\xba\0\0\x2\xe8\0\0\0\x9b\0\0\0\x91\0\0\x3\xba\0\0\x2\xe8\0\0\0\0\0\0\0\0\x5V)'
IDE_STATE='state="@ByteArray(\0\0\0\xff\0\0\0\0\xfd\0\0\0\x2\0\0\0\0\0\0\x1\0\0\0\x2\x2\xfc\x2\0\0\0\a\xfb\0\0\0&\0s\0i\0\x64\0\x65\0_\0\x64\0o\0\x63\0k\0_\0x\0_\0\x46\0o\0l\0\x64\0\x65\0r\0s\0\0\0\0\0\xff\xff\xff\xff\0\0\0\x1f\0\xff\xff\xff\xfb\0\0\0,\0s\0i\0\x64\0\x65\0_\0\x64\0o\0\x63\0k\0_\0x\0_\0O\0p\0\x65\0n\0\x45\0\x64\0i\0t\0o\0r\0\0\0\0\0\xff\xff\xff\xff\0\0\0\x1f\0\xff\xff\xff\xfb\0\0\0.\0s\0i\0\x64\0\x65\0_\0\x64\0o\0\x63\0k\0_\0x\0_\0G\0o\0\x43\0l\0\x61\0s\0s\0V\0i\0\x65\0w\0\0\0\0\0\xff\xff\xff\xff\0\0\0\x1f\0\xff\xff\xff\xfb\0\0\0*\0s\0i\0\x64\0\x65\0_\0\x64\0o\0\x63\0k\0_\0x\0_\0G\0o\0O\0u\0t\0l\0i\0n\0\x65\0\0\0\0\0\xff\xff\xff\xff\0\0\0\x1f\0\xff\xff\xff\xfb\0\0\0\x38\0s\0i\0\x64\0\x65\0_\0\x64\0o\0\x63\0k\0_\0x\0_\0G\0o\0P\0\x61\0\x63\0k\0\x61\0g\0\x65\0\x42\0r\0o\0w\0s\0\x65\0r\0\0\0\0\0\xff\xff\xff\xff\0\0\0\x1f\0\xff\xff\xff\xfb\0\0\0,\0s\0i\0\x64\0\x65\0_\0\x64\0o\0\x63\0k\0_\0x\0_\0\x46\0i\0l\0\x65\0S\0y\0s\0t\0\x65\0m\x1\0\0\0\x33\0\0\x2\x2\0\0\0\x84\0\xff\xff\xff\xfb\0\0\0*\0s\0i\0\x64\0\x65\0_\0\x64\0o\0\x63\0k\0_\0x\0_\0\x42\0o\0o\0k\0m\0\x61\0r\0k\0s\0\0\0\0\0\xff\xff\xff\xff\0\0\0\x1f\0\xff\xff\xff\0\0\0\x3\0\0\0\0\0\0\0\0\xfc\x1\0\0\0\x1\xfb\0\0\0\x16\0s\0i\0\x64\0\x65\0_\0\x64\0o\0\x63\0k\0_\0\x38\0\0\0\0\0\xff\xff\xff\xff\0\0\0S\0\xff\xff\xff\0\0\x1\xfc\0\0\x2\x2\0\0\0\x4\0\0\0\x4\0\0\0\x1\0\0\0\x2\xfc\0\0\0\x3\0\0\0\0\0\0\0\x1\0\0\0\x16\0s\0i\0\x64\0\x65\0_\0t\0o\0o\0l\0_\0\x31\x3\0\0\0\0\xff\xff\xff\xff\0\0\0\0\0\0\0\0\0\0\0\x1\0\0\0\x1\0\0\0\x16\0s\0i\0\x64\0\x65\0_\0t\0o\0o\0l\0_\0\x32\x2\0\0\0\0\xff\xff\xff\xff\0\0\0\0\0\0\0\0\0\0\0\x2\0\0\0\x3\0\0\0\x16\0t\0o\0o\0l\0\x62\0\x61\0r\0/\0s\0t\0\x64\0\0\0\0\0\xff\xff\xff\xff\0\0\0\0\0\0\0\0\0\0\0\x16\0t\0o\0o\0l\0\x62\0\x61\0r\0/\0\x65\0n\0v\x1\0\0\0\0\xff\xff\xff\xff\0\0\0\0\0\0\0\0\0\0\0\x1a\0t\0o\0o\0l\0\x62\0\x61\0r\0/\0\x62\0u\0i\0l\0\x64\x1\0\0\0\xc0\xff\xff\xff\xff\0\0\0\0\0\0\0\0)"'
#---
PROFILE_FILE=$HOME/.bashrc
test -f ${XDG_CONFIG_HOME:-~/.config}/user-dirs.dirs && source ${XDG_CONFIG_HOME:-~/.config}/user-dirs.dirs;;
darwin)
IDE_NAME=liteidex$IDE_VERSION.macos-qt$MACOS_QT_VERSION.zip
IDE_RESOURCES=$IDEROOT/liteide/LiteIDE.app/Contents/Resources/
IDE_ENVIRON=$KERNEL_NAME$MACHINE_BITS-home
IDE_FONT_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ff\0\0\0\0\0\0\0\0\0\0\0\x2\0\0\0\x3\0\0\0\x16\0t\0o\0o\0l\0\x62\0\x61\0r\0/\0s\0t\0\x64\0\0\0\0\0\xff\xff\xff\xff\0\0\0\0\0\0\0\0\0\0\0\x16\0t\0o\0o\0l\0\x62\0\x61\0r\0/\0\x65\0n\0v\x1\0\0\0\0\xff\xff\xff\xff\0\0\0\0\0\0\0\0\0\0\0\x1a\0t\0o\0o\0l\0\x62\0\x61\0r\0/\0\x62\0u\0i\0l\0\x64\x1\0\0\0\xe5\xff\xff\xff\xff\0\0\0\0\0\0\0\0)"'
#---
PROFILE_FILE=$HOME/.bash_profile
LAUNCHER=$(defaults read com.apple.dock | grep _CFURLString\"| awk '/LiteIDE/ {print NR-1}');;
freebsd)
#---
PROFILE_FILE=$HOME/.bashrc
IS_SERVER=1;;
esac
#-------------------------------------------------------------------------------
help() {
echo $GOPEI_LONG_NAME
echo "Usage: $GOPEI_NAME [options]"
echo "Options:"
echo "-c enable classroom mode (Linux only)"
echo "-g enable git suppport"
echo "-h show this help message and exit"
echo "-k show key fingerprint"
echo "-s server mode, install golang only"
echo "-u uninstall"
echo "-U uninstall including .gitconfig file and .ssh folder"
echo "-q [name] set theme (eg. -q webstorm)"
echo "-x [name] set color scheme (eg. -x sublime)"
echo "-v version"
exit
}
while getopts ":cgkhsuUr :q:x:v" OPTION; do
case $OPTION in
c) CLASSROOM_MODE=1;;
g) GITSERVER=github.com;;
h) help;;
k) ssh-add -l -E md5
exit;;
s) IS_SERVER=1;;
u|U)
#common to all operating systems
rm -rf $GOROOT
rm -rf $HOME/gocache/
rm -rf $IDEROOT
#rm -rf $HOME/.dlv/
rm -rf $HOME/.config/liteide/
#Ubuntu specific
rm -rf $HOME/.config/gocode/
rm -rf $HOME/.local/share/applications/liteide.desktop
#Linux specific
rm -f $XDG_DESKTOP_DIR/liteide.desktop
if [ $IS_DARWIN ] && [ $LAUNCHER ]; then
/usr/libexec/PlistBuddy -c "Delete persistent-apps:$LAUNCHER" ~/Library/Preferences/com.apple.dock.plist
killall Dock
fi
if [ $OPTION == U ]; then
rm -rf $HOME/.ssh/
rm -f $HOME/.gitconfig
fi
#restore original profile file
[ -e $PROFILE_FILE ] && sed -i.bk '/. ~\/.go_profile/d' $PROFILE_FILE
rm -f $HOME/.go_profile
rm -f $PROFILE_FILE.bk
echo "Uninstalled." && exit;;
q) IDE_QSS='Qss='$OPTARG'.qss';;
x) IDE_STYLE='style='$OPTARG'.xml';;
v) echo "$GOPEI_VERSION-$GOPEI_STAGE" && exit;;
*) echo "Unimplemented option: -$OPTARG" && help;;
esac
done
clear && echo -e "$GOPEI_LONG_NAME\n$GOPEI_COPYRIGHT"
#-------------------------------------------------------------------------------
echo "Installing $COMPILER_NAME..."
curl -fsSLkOz $COMPILER_NAME storage.googleapis.com/golang/$COMPILER_NAME || exit
tar -x -C $HOME -f $COMPILER_NAME
echo "Create GOPATH"
echo 'GOROOT=${HOME}/go
GOPATH=${HOME}
PATH=$PATH:/${GOROOT}/bin:${GOPATH}/bin
export PATH GOPATH GOROOT' > $HOME/.go_profile
grep -sq '. ~/.go_profile' $PROFILE_FILE || echo '. ~/.go_profile' >> $PROFILE_FILE
echo "Create helloworld program"
mkdir -p $GOPATH/src/helloworld && cp -r $GOROOT/test/helloworld.go $GOPATH/src/helloworld
#-------------------------------------------------------------------------------
if [ $GITSERVER ]; then
echo "Add git support..."
#create git configuration if not exist, otherwise use existent (~/.gitconfig)
if [ -f $HOME/.gitconfig ]; then
GITUSER=`awk 'NR==2 {print $3}' $HOME/.gitconfig`
GITEMAIL=`awk 'NR==3 {print $3}' $HOME/.gitconfig`
else
echo "Setup git"
echo -n "Git user ";read GITUSER
echo -n "Git email [ENTER for $GITUSER@gmail.com] ";read GITEMAIL
#try to guess git email
if [ -z "$GITEMAIL" ]; then GITEMAIL="$GITUSER@gmail.com"; fi
git config --global user.name "$GITUSER"
git config --global user.email "$GITEMAIL"
fi
#generate ssh keys if not exist, otherwise use existent (https://help.github.com/articles/generating-ssh-keys/)
KEYTYPE="rsa"
if [ ! -f $HOME/.ssh/id_$KEYTYPE ]; then
ssh-keygen -qt $KEYTYPE -C "$GITEMAIL" -f $HOME/.ssh/id_$KEYTYPE
#add a new deploy key on github with api (https://developer.github.com/v3/)
KEY=`cat $HOME/.ssh/id_$KEYTYPE.pub`
echo -n "Token:" && read -s GITTOKEN
curl -s -X POST -H 'Authorization: token '$GITTOKEN https://api.$GITSERVER/user/keys -d '{"key":"'"${KEY}"'"}'| awk '/message/ { gsub(/^[\t ]+|[\",]/,"");print }'
fi
#bug workaround https://help.github.com/articles/error-permission-denied-publickey
eval `ssh-agent -s` > /dev/null
echo "Checking the keys..."
#workaround: if ssh result is false (Permission denied (publickey).) set -e will stop the script
#prevent this by changing result code to true and let the script to continue
ssh -o StrictHostKeyChecking=no -o LogLevel=error -T git@$GITSERVER || true
#create github.com in $GOPATH
mkdir -p $GOPATH/src/$GITSERVER/$GITUSER
echo "Add cloud tools..."
cp $GOPEI_ROOT/tools/* $GOROOT/bin
fi
#-------------------------------------------------------------------------------
if [ $IS_SERVER ] || [ $IS_ARM ]; then
echo "Done." && exit
fi
#-------------------------------------------------------------------------------
echo "Installing $IDE_NAME..."
curl -fsSLkOz $IDE_NAME sourceforge.net/projects/liteide/files/x$IDE_VERSION/$IDE_NAME || exit
case $KERNEL_NAME in
linux)
tar -x -C $HOME -f $IDE_NAME;;
darwin)
mkdir -p $IDEROOT && unzip -q -o $IDE_NAME -d $IDEROOT;;
esac
#-------------------------------------------------------------------------------
echo "Create liteide.ini.mini"
mkdir -p $HOME/.config/liteide && echo '[FileBrowser]
root='$HOME'/src
synceditor=false
[%General]
Language=en_US
WelcomePageVisible=false
[LitApp]
'$IDE_QSS'
[LiteApp]
ShowEditToolbar=false
FolderShowHidenFiles=true
AutoLoadLastSession=true
SplashVisible=false
[editor]
'$IDE_FONT_FAMILY'
'$IDE_FONT_SIZE'
'$IDE_STYLE'
navbar_visible=false
toolbar_visible=false
[golangdoc]
goroot='$GOROOT'
[liteapp]
family='$IDE_GEOMETRY'
'$IDE_STATE'
[liteenv]
currentenvid='$IDE_ENVIRON'
[liteide]
gopath='$GOPATH'
[output]
'$IDE_FONT_FAMILY'
'$IDE_FONT_SIZE'
' > $HOME/.config/liteide/liteide.ini
#-------------------------------------------------------------------------------
echo "Create some useful resources"
cp -r $GOPEI_ROOT/gopher/ $GOROOT/doc
cp -R $GOPEI_ROOT/template/* $IDE_RESOURCES/liteapp/template/
echo >> $IDE_RESOURCES/liteapp/template/project.sub
for project in $GOPEI_ROOT/template/*; do
#add custom resources as project folder only
echo `basename $project` >> $IDE_RESOURCES/liteapp/template/project.sub
done
#add custom theme and colors
cp $GOPEI_ROOT/theme/* $IDE_RESOURCES/liteapp/qss/
#add custom snippets
cp $GOPEI_ROOT/go.snippet.json $IDE_RESOURCES/packages/go/
[ $GITSERVER ] && CLOUD_TOOLS="\ngithub\ncloud"
#make the scripts available to ide
echo -e "git add *
git commit -m \"-\" -a
git push
git reset --hard HEAD^
git push origin -f
git pull$CLOUD_TOOLS
go get golang.org/x/tools/cmd/present
go get -u github.com/derekparker/delve/cmd/dlv" > $IDE_RESOURCES/litebuild/command/go.api
#-------------------------------------------------------------------------------
echo "Create smart launcher"
case $KERNEL_NAME in
linux)
if [ $CLASSROOM_MODE ]; then
cp $HOME/.config/liteide/liteide.ini $HOME/.config/liteide/liteide.ini.mini
#add restore command
RESTORE_INI_MINI_COMMAND="cp $HOME/.config/liteide/liteide.ini.mini $HOME/.config/liteide/liteide.ini;"
fi
#create generic .desktop file on desktop
echo -e "\
\r[Desktop Entry]
\rVersion=1.0
\rName=LiteIDE
\rComment=LiteIDE is a simple, open source, cross-platform Go IDE.
\rExec=sh -c 'eval \`ssh-agent -s\`;$RESTORE_INI_MINI_COMMAND$HOME/liteide/bin/liteide'
\rIcon=$GOROOT/doc/gopher/gophercolor.png
\rType=Application" > ${XDG_DESKTOP_DIR}/liteide.desktop
case $DESKTOP_SESSION in
ubuntu*)
#extend .desktop file with some nice options
if [ $GITSERVER ]; then
GITACTION="$GITSERVER;"
GITDESKTOPACTION="[Desktop Action $GITSERVER]
\rName=$GITSERVER/$GITUSER
\rExec=xdg-open http://$GITSERVER/$GITUSER"
fi
echo -e "\
\rActions=golang;http;gopath;$GITACTION
\r\n[Desktop Action golang]
\rName=golang.org
\rExec=xdg-open http://golang.org/pkg
\r\n[Desktop Action http]
\rName=HTTP server (localhost:8080)
\rExec=xdg-open http://localhost:8080
\r\n[Desktop Action gopath]
\rName=GOPATH
\rExec=xdg-open ${GOPATH}/src
\r\n$GITDESKTOPACTION" >> ${XDG_DESKTOP_DIR}/liteide.desktop
#create directory for liteide.desktop
mkdir -p $HOME/.local/share/applications/
#add .desktop file to dash and integrate with unity
mv ${XDG_DESKTOP_DIR}/liteide.desktop $HOME/.local/share/applications
#already obsolete Unity interface support
if [[ $XDG_CURRENT_DESKTOP =~ "Unity" ]]; then
#get the current launcher favorites list
LAUNCHER=$(gsettings get com.canonical.Unity.Launcher favorites)
#skip update if liteide launcher already exists
if ! [[ $LAUNCHER =~ "liteide.desktop" ]]; then
LAUNCHER=${LAUNCHER/]/, \'liteide.desktop\']} && sleep 1
#update the launcher favorites list,in unity changes are shwown immediately.
gsettings set com.canonical.Unity.Launcher favorites "$LAUNCHER"
fi
fi;;
#generic desktop environment have only a desktop shortcut
*) chmod +x ${XDG_DESKTOP_DIR}/liteide.desktop;;
esac;;
darwin)
if [ -z $LAUNCHER ]; then
#OS X Dock management
#defaults read com.apple.dock persistent-apps
#defaults delete com.apple.dock
defaults write com.apple.dock persistent-apps -array-add '
<dict>
<key>tile-data</key>
<dict>
<key>file-data</key>
<dict>
<key>_CFURLString</key><string>'$IDEROOT'/liteide/LiteIDE.app</string>
<key>_CFURLStringType</key><integer>0</integer>
</dict>
</dict>
</dict>'
killall Dock
fi;;
esac
#-------------------------------------------------------------------------------
echo "Done."