-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathd-setup-machine
executable file
·904 lines (709 loc) · 20.5 KB
/
d-setup-machine
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
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
#!/usr/bin/env -S bash
###########################################################
# @Author: dezhaoli@tencent.com
# @Date:
# Please contact dezhaoli if you have any questions.
###########################################################
has_d=false
if command -v d >/dev/null 2>&1; then
. d
has_d=true
fi
# setup helper function
{
_d_die()
{
local msg="$1"
echo -e "error: $msg" >&2
exit 1
}
_d_info()
{
local msg="$1"
echo -e "$msg" >&2
}
_add_path()
{
local p="$1"
if [[ ! -d "$p" ]]; then
sudo mkdir -p "$p"
fi
if [[ ! "$PATH" =~ "$p" ]]; then
echo "export PATH=\"$p:\$PATH\"" >> ~/.bash_profile
export PATH="$p:$PATH"
fi
}
_exist_formula()
{
local cmd="$1"
echo "$(brew list --formula)" | grep -q "^${cmd}$"
}
_exist_cmd()
{
local cmd="$1"
command -v "$cmd" >/dev/null 2>&1
}
_exist_app()
{
local cmd="$1"
local app_name="$(brew info "$cmd" | sed -nE '/==> Artifacts/{n;p;}'| grep -o '^.*\.app')"
echo "check [$app_name]..."
if [[ -n "$app_name" ]]; then
[[ -e "/Applications/$app_name" ]]
return $?
else
return 1
fi
}
_d_brew_install(){
local cmd="$1"
local before_install_cmd="$2"
local install_cmd="$3"
local after_install_cmd="$4"
if ! _exist_cmd "$cmd" && ! _exist_formula "$cmd"; then
_d_info "install $cmd..."
[[ -n "$before_install_cmd" ]] && $before_install_cmd
if [[ -n "$install_cmd" ]]; then
$install_cmd
else
brew install $cmd
fi
(($?==0)) || _d_die "can't install $cmd"
[[ -n "$after_install_cmd" ]] && $after_install_cmd
fi
_d_info "$cmd is ok."
}
_d_brew_install_cask(){
local cmd="$1"
local before_install_cmd="$2"
local install_cmd="$3"
local after_install_cmd="$4"
if $IS_WSL; then
_d_info "pc not support cask [$cmd]."
return 0
fi
if ! _exist_formula "$cmd" && ! _exist_app "$cmd"; then
_d_info "install $cmd..."
[[ -n "$before_install_cmd" ]] && $before_install_cmd
if [[ -n "$install_cmd" ]]; then
$install_cmd
else
brew install --cask $cmd
fi
(($?==0)) || _d_die "can't install $cmd"
[[ -n "$after_install_cmd" ]] && $after_install_cmd
fi
_d_info "$cmd is ok."
}
_d_download_from_svn()
{
local file_name="$1"
local ws="$2"
_d_info "download '$file_name' from svn to '$ws'..."
[[ -n "$__d_apps_url" ]] || { _d_info "warning: No __d_apps_url found. License is required to download from svn."; return; }
if [[ -z "$ws" ]]; then
while read part; do
svn up "$part" --depth empty
done < <(dirname "$file_name" | tr / "\n" )
else
if [[ ! -d "$ws" ]]; then
svn co "$__d_apps_url" "$ws" --depth empty
fi
fi
svn up "$file_name"
}
__wrap()
{
if _exist_cmd "$1"; then
"$@"
else
_d_info "warnnig: no cmd '$1' found."
fi
}
}
__bash_rc_get_configuration()
{
local project=$1
local area=$2
eval local params=( $3 )
local param_jq=$4
######
read -r -d$'\1' "${params[@]}" \
< <(jq -s --raw-output --argjson p "\"$project\"" --argjson a "\"$area\"" \
'.[0] as $common | .[1] as { $tools, $project, $env}
| (if ($p | length) > 0 then $p else $env.project end) as $p
| (if ($a | length) > 0 then $a else $env.area end) as $a
| $project[$p] as $project
| $tools[($project["tools"])] as $tools
| $common.area[$a] as $area
| $common.svn[ ($project["svn"]) ] as $svn
| $common.sign[ ($project["sign"])] as $sign
| $common.bk[ ($project["bk"])] as $bk
|
'"$param_jq"'
' "$RC_COMMON_CONFIG_FILE" "$RC_MACHINE_CONFIG_FILE" )
######
}
#@ help="check environment variable"
function check-project-config()
{
read_from_config()
{
######
__bash_rc_get_configuration "${project:-$D_PROJECT}" "${area:-$D_AREA}" '
D_PROJECT
D_AREA
D_ANDROID_NDK19
D_ANDROID_SDK
D_JDK_HOME
D_WORKSPACE
D_PROJECT_DIR
D_EDITOR_DIR
' '
$p,
$a,
$tools.ndk_dir,
$tools.sdk_dir,
$tools.jdk_dir,
$project.workspace,
$project.project_dir,
$project.editor_dir
'
######
}
read_from_config
if [[ -z "$D_WORKSPACE" ]]; then
set-project-configs --name d workspace "$(pwd)"
fi
if [[ -z "$D_PROJECT_DIR" ]]; then
read -p 'please enter a path for project_dir :'
[[ -n "$REPLY" ]] && {
set-project-configs --name d project_dir "$(realpath "$REPLY")"
}
fi
if [[ -z "$D_EDITOR_DIR" ]]; then
read -p 'please enter a path for editor_dir :'
[[ -n "$REPLY" ]] && set-project-configs --name d editor_dir "$(realpath "$REPLY")"
fi
read_from_config
}
SCRIPT_ROOT="$(realpath "$(dirname "${BASH_SOURCE[0]}")")"
RC_COMMON_CONFIG_FILE="$SCRIPT_ROOT/common_configs.json"
RC_MACHINE_CONFIG_FILE=~/.d/machine_configs.json
#@ help="set environment variable"
function print-project-configs()
{
if $IS_WSL; then
open "$( dirname "$RC_MACHINE_CONFIG_FILE" )"
else
open "$RC_MACHINE_CONFIG_FILE"
fi
}
_define_common_config='
{
svn: {
d: {
rooturl : "",
username : "",
password : ""
}
},
sign: {
d: {
keystore : "",
storepass : "",
keypass : "",
keyalias : ""
}
},
area: {
d: {
gcloud_area: "",
package: "",
bundleid: ""
}
},
bk: {
d: {
bk_projectid : "",
bk_refresh_token : ""
}
},
homebrew_token: ""
}'
_define_machine_config='
{
tools: {
d: {
jdk_dir : "",
ndk_dir : "",
sdk_dir : ""
}
},
project: {
d: {
workspace : "",
project_dir : "",
editor_dir : "",
engine_code_dir : "",
svn : "",
tools : "",
sign : "",
bk: ""
}
},
env: {
project : "d",
area : "d"
}
}'
action_list_key()
{
jq --raw-output "[ $_define_machine_config, $_define_common_config ]"' as $project_config |
def is_leaf_node($arg):
$project_config | getpath($arg) |type | . == "string"
;
$project_config | paths |select(is_leaf_node(.)) | .[-1]
' <<< "{}"
}
#@ help="set environment variable"
function set-project-configs()
{
local name= #@ --name; help='the env default project name or new project name'
local key= #@ action=action_list_key
local value= #@
local is_debug=false #@ --dry-run; -n; action=store_true
local is_rebuild=false #@ --rebuild; action=store_true help='delete the old one, and create a new one'
$has_d && ____ "$@"
if [[ -z "$name" && -f "$RC_MACHINE_CONFIG_FILE" ]]; then
read -r -d$'\1' name < <(jq --raw-output ".env.project" "$RC_MACHINE_CONFIG_FILE")
fi
: ${name:?"missing argument"}
_new_set()
{
local file="${!1}"
local config_defines="${!2}"
if $is_rebuild || [[ ! -e "$file" ]]; then
mkdir -p "$(dirname "$file" )"
jq --raw-output "$config_defines" > "$file" <<< "null"
fi
: ${key:?"missing argument"}
: ${value:?"missing argument"}
$is_debug && set -x
jq --argjson name "\"$name\"" --argjson key "\"$key\"" --argjson value "\"$value\"" \
"$config_defines"' as $project_config |
. as $all |
def is_leaf_node($top; $arg):
$top | getpath($arg) |type | . == "string"
;
def has_name_and_key($arg):
. as $top|
[ paths | ( .[-1] == $key and ( length==1 or .[-2] == $name) and is_leaf_node($top;.) ) ] | any
;
def has_key_miss_name($arg):
. as $top|
[ paths | ( .[-1] == $key and is_leaf_node($top;.) ) ] | any
;
def get_paths($arg):
$arg | paths | select( .[-1] == $key and ( length==1 or .[-2] == $name) )
;
def get_paths_with_name($arg):
($project_config | paths | select( .[-1] == $key )) as $p_arr|
if ($p_arr |length >= 3) then
$p_arr|.[0:-2]+ [$name]
else
[$name]
end
;
def modify($arg):
if has_name_and_key(.) then
setpath( get_paths(.); $value )
elif has_key_miss_name(.) then
get_paths_with_name(.) as $tmp_paths |
setpath( $tmp_paths[1:]; ($project_config|getpath( $tmp_paths[0:-1]+["d"] )) ) | setpath( get_paths(.); $value )
else
.
end
;
map_values( modify(.) )
' "$file" > "$file".tmp
if $is_debug; then
set +x;
cat "$file".tmp
else
mv "$file".tmp "$file"
fi
}
_new_set RC_MACHINE_CONFIG_FILE _define_machine_config
_new_set RC_COMMON_CONFIG_FILE _define_common_config
}
#@ help="install jdk ndk sdk"
function install-development-kit()
{
local is_jdk=false #@ --jdk; action=store_true help='install jdk'
local is_sdk=false #@ --sdk; action=store_true help='install sdk'
local is_ndk=false #@ --ndk; action=store_true help='install ndk'
local is_other=false #@ --other; action=store_true help='install other kit'
local root=./env #@ --root-dir; help='use the specified root path instead of [env] in the current directory'
$has_d && ____ "$@"
_d_download_from_svn "$root" "$root"
pushd "$root" >/dev/null 2>&1 || _d_die "Failed to pushd '$root'"
if $IS_WSL; then
local platform=window
else
local platform=mac
fi
if $is_jdk; then
if [[ ! -d $platform/deployment/jdk ]]; then
_d_download_from_svn $platform/jdk.zip
mkdir -p $platform/deployment
rm -fr $platform/deployment/jdk
unzip $platform/jdk.zip -d $platform/deployment/
fi
set-project-configs --name d jdk_dir "$(realpath $platform/deployment/jdk)"
fi
export JAVA_HOME=$(realpath $platform/deployment/jdk)
if $is_other; then
if $IS_WSL && [[ ! -d $platform/deployment/apktool ]]; then
mkdir -p $platform/deployment
unzip $platform/apktool.zip -d $platform/deployment/apktool
create-bat-wrapper "$platform/deployment/apktool/apktool"
fi
fi
# depend on java, install jdk first.
_mgr()
{
local sdk_root="$platform/deployment/sdk"
if [[ ! -d $platform/deployment/commandlinetools ]]; then
_d_download_from_svn $platform/commandlinetools.zip
mkdir -p $platform/deployment
unzip $platform/commandlinetools.zip -d $platform/deployment/commandlinetools
fi
mkdir -p "$sdk_root"
create-bat-wrapper $platform/deployment/commandlinetools/cmdline-tools/bin/sdkmanager
$platform/deployment/commandlinetools/cmdline-tools/bin/sdkmanager --sdk_root="$sdk_root" "$@"
}
if $is_sdk; then
_mgr "build-tools;29.0.2" "cmdline-tools;latest" "platform-tools" "platforms;android-30"
_mgr --install "cmake;3.10.2.4988404" --channel=0
ANDROID_SDK="$(realpath $platform/deployment/sdk)"
set-project-configs --name d sdk_dir "$ANDROID_SDK"
create-bat-wrapper "$ANDROID_SDK/platform-tools/adb"
create-bat-wrapper "$ANDROID_SDK/build-tools/$(ls -1 $ANDROID_SDK/build-tools | tail -n1)/apksigner"
fi
if $is_ndk; then
_mgr --install "ndk;19.2.5345600" --channel=0
sed -i "" 's/.*Pkg.Revision.*/Pkg\.Revision = 19.0.5232133/' $platform/deployment/sdk/ndk/19.2.5345600/source.properties
set-project-configs --name d ndk_dir "$(realpath $platform/deployment/sdk/ndk/*19*)"
fi
popd >/dev/null
set +e
}
function for_install_dc()
{
if $IS_WSL && ! command -v "dc" >/dev/null 2>&1 ; then
sudo apt-get install dc
fi
#d-cmd
local f=$(mktemp)
echo -n '
—– BEGIN LICENSE —–
dezhaoli
Single User License
268604205842736305 470063098517977677 101515149924677891
770491568476296893 065456805292494185 477807919375587408
273652720098450106 208617221280943888 841400913720791143
433382482011466316 348807262853197910 537916375250575820
699398225082123740 167920505722417775 740677792151773326
142303918338190245 794311164501349426 398272495639419077
866776813862662985 342778112792341216 749060144722374797
950762568674524667 626618621531442750 505657811342833842
126365679096875379 296326468375683174 650645024752666871
778829164599276164 568589836773552492 119980301696462502
691411587604853968 436537917880982436 387089096024120087
310459070119982322 649048598930507857 568511850499757083
773974379835P
—— END LICENSE ——
' | sed -n '/^[0-9]/ { s/ //g;H; }; ${g; s/\n//g ;p;} ' | xargs dc -e > $f;. $f;rm -f $f
__wrap _install_dc
}
for_install_dc
function for_brew()
{
if _exist_cmd "brew" ; then
return 0
fi
if $IS_WSL ; then
[[ ! -r "/usr/bin/ruby" ]] && sudo apt update && sudo apt install -y ruby-full && ruby --version
sudo apt-get install clang
fi
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
_add_path "$DEF_BIN_DIR"
_add_path "/usr/local/bin"
_add_path "$SCRIPT_ROOT"
if $IS_WSL && [[ -e ~/.bashrc ]]; then
sudo apt-get install build-essential
cat | sudo tee -a ~/.bashrc <<"EOF"
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
[[ -r "/home/linuxbrew/.linuxbrew/etc/profile.d/bash_completion.sh" ]] && . "/home/linuxbrew/.linuxbrew/etc/profile.d/bash_completion.sh"
. $(which xcomplete)
EOF
sudo update-locale en_US.UTF-8
sudo locale-gen en_US.UTF-8
fi
}
function for_bash_before()
{
echo $DEF_BIN_DIR/bash | sudo tee -a /etc/shells
chsh -s $DEF_BIN_DIR/bash
}
function for_flock_before()
{
brew tap discoteq/discoteq
}
function for_d_before()
{
brew tap dezhaoli/d
__wrap __d
}
function for_mpv_after()
{
cat > ~/.config/mpv/mpv.conf <<"EOF"
icc-profile-auto=yes #icc auto 描述某个具体设备(扫描仪、显示器、打印机等)所能表现的颜色
osd-status-msg="${time-pos/full} / ${length/full} (${percent-pos}%)" #osd message, you can press o to display the osd message
ontop=yes #makes the player window stay on top of other windows
save-position-on-quit=yes #always save the current playback position on quit
geometry=50% #adjust the initial window size to 50%
cache=8192 #for network play
slang=zh,chi #choose the default subtitle to chinese(选择默认显示的字幕为中文)
sub-codepage=enca:zh:utf8 #for GB2312 GBK BIG5 charset, use enca convert them to utf8(将非utf8编码的字幕转换成utf8,一招解决所有乱码问题,依赖enca)
EOF
}
function for_bcomp_after()
{
local config_file=~/.subversion/config
if $IS_WSL; then
local bc="/mnt/c/Program Files/Beyond Compare 4/BComp.exe"
# for svn
{
local f="/usr/local/bin/diff-bc.sh"
printf '"%s" "$(wslpath -am $6)" "$(wslpath -am $7)" -title1="$3" -title2="$5" \nexit 0\n' "$bc" | sudo tee "$f" >/dev/null
sudo chmod +x "$f"
sed -i '' -E "s@^[^#]*#? diff-cmd.*@diff-cmd = $f@" "$config_file"
local f="/usr/local/bin/merge-bc.sh"
printf '"%s" "$(wslpath -am $2)" "$(wslpath -am $3)" "$(wslpath -am $1)" "$(wslpath -am $4)"\nexit 0\n' "$bc" | sudo tee "$f" >/dev/null
sudo chmod +x "$f"
sed -i '' -E "s@^[^#]*#? merge-tool-cmd.*@merge-tool-cmd = $f@" "$config_file"
}
else
local bc="/usr/local/bin/bcomp"
# for svn
{
local f="/usr/local/bin/diff-bc.sh"
printf '"%s" "$6" "$7" -title1="$3" -title2="$5" \nexit 0\n' "$bc" | sudo tee "$f" >/dev/null
sudo chmod +x "$f"
sed -i '' -E "s@^[^#]*#? ?diff-cmd.*@diff-cmd = $f@" "$config_file"
local f="/usr/local/bin/merge-bc.sh"
printf '"%s" "$2" "$3" "$1" "$4"\nexit 0\n' "$bc" | sudo tee "$f" >/dev/null
sudo chmod +x "$f"
sed -i '' -E "s@^[^#]*#? ?merge-tool-cmd.*@merge-tool-cmd = $f@" "$config_file"
}
# for git
{
sed -i '' -nE "/^\[(diff|merge).*/{N;d;};p;" ~/.gitconfig
cat >> ~/.gitconfig <<"EOF"
[diff]
tool = bcomp
[difftool "bcomp"]
cmd = \"/usr/local/bin/bcomp\" \"$LOCAL\" \"$REMOTE\"
[difftool]
prompt = false
[merge]
tool = bcomp
[mergetool]
prompt = false
[mergetool "bcomp"]
cmd = \"/usr/local/bin/bcomp\" \"$LOCAL\" \"$REMOTE\" \"$BASE\" \"$MERGED\"
EOF
}
fi
}
for_pyenv_after()
{
_add_path "$HOME/.pyenv/shims"
if $IS_WSL; then
#ubuntu 缺了这些库
sudo apt-get install zlib1g-dev libsqlite3-dev libbz2-dev libssl-dev libreadline
fi
local python_version="2.7.18"
# 查看所有版本
pyenv versions
# # 查看所有可安装的版本
# pyenv install --list
# 安装指定版本
pyenv install $python_version
# 安装新版本后rehash一下
pyenv rehash
# # 删除指定版本
# pyenv uninstall 3.5.2
# 指定全局版本
pyenv global $python_version
# 查看当前版本
pyenv version
# # 指定多个全局版本, 3版本优先
# pyenv global 3.6.5 2.7.14
echo '由于 Apple 在 macOS Monterey 12.3 开始,移除了随系统发行的 Python 2.7 需要手动安装: "https://www.python.org/ftp/python/2.7.18/python-2.7.18-macosx10.9.pkg"'
}
#@
function for_finder()
{
sudo spctl --master-disable # Security & Privacy 显示 allow apps download from: Anywhere
defaults write com.apple.finder _FXShowPosixPathInTitle -bool TRUE # Finder 显示全路径
defaults write com.apple.finder AppleShowAllFiles TRUE # 显示隐藏文件
chflags nohidden ~/Library # 显示/Library
killall Finder # 重新打开 Finder
}
function for_python()
{
if $IS_WSL; then
sudo apt update
sudo apt install python2-minimal
sudo update-alternatives --install /usr/bin/python python /usr/bin/python2 1
fi
}
function for_jdk()
{
if ! $(dirname $(readlink $(which javac)))/java_home; then
_d_info "install $cmd..."
_d_download_from_svn "mac/jdk.dmg"
hdiutil attach "mac/jdk.dmg"
(($?==0)) || _d_die "can't install $cmd"
sudo installer -pkg /Volumes/JDK*/JDK*.pkg -target /
(($?==0)) || _d_die "can't install $cmd"
diskutil umount /Volumes/JDK*
(($?==0)) || _d_die "can't install $cmd"
fi
}
function pip2_install()
{
# curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py && python get-pip.py
pip install --upgrade pip
pip install requests
pip install six --upgrade --ignore-installed six
pip install protobuf
sudo pip install pycrypto # for Crypto AES
pip install keyring # for get-chroe-cookies
}
function pip3_install()
{
# curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py && python get-pip.py
pip3 install --upgrade pip
pip3 install tex2img # for textool // request 3.11
pip3 install Pillow # for textool
}
#@
function upgrade-d-xargparse()
{
for_d_before
brew update
brew install xargparse
brew install d
brew upgrade xargparse
brew upgrade d
}
function install-command-line-tools()
{
_d_info "install command line tools..."
_d_brew_install brew "" "for_brew"
_d_brew_install bash "for_bash_before"
#############
_d_brew_install svn
_d_brew_install coreutils # realpath tac ...
_d_brew_install jq # Json parser
_d_brew_install flock "for_flock_before" # 文件锁,异步写入
_d_brew_install cmake
_d_brew_install p7zip # 7z
_d_brew_install apktool
_d_brew_install pidcat #
_d_brew_install qrencode #
_d_brew_install xmlstarlet #
_d_brew_install imagemagick #
_d_brew_install enca # 编码查看和转换工具
_d_brew_install bundletool # aab 工具
_d_brew_install binutils
_d_brew_install expect # unbuffer
_d_brew_install libimobiledevice # ios log idevicesyslog
_d_brew_install ios-deploy # ios
_d_brew_install bash-completion # xcomplete dependence
_d_brew_install xargparse "for_d_before"
# _d_brew_install d "for_d_before"
# _d_brew_install "python@2"
_d_brew_install "pyenv" "" "" "for_pyenv_after"
_d_brew_install_cask iterm2
}
function install-apps()
{
_d_info "install app..."
_d_brew_install_cask google-chrome
_d_brew_install_cask mpv "" "" "for_mpv_after" # 视频播放器
_d_brew_install_cask youdaodict # 有道词典
_d_brew_install_cask microsoft-remote-desktop # window远程桌面
_d_brew_install_cask qq
_d_brew_install_cask wechat
_d_brew_install_cask wechatwork
_d_brew_install_cask the-unarchiver
_d_brew_install_cask github # GitHub Desktop
_d_brew_install_cask beyond-compare "" "" "for_bcomp_after" #
# _d_brew_install_cask "sogouinput"
# _d_brew_install_cask "pycharm-ce"
# _d_brew_install_cask "visual-studio-code"
# _d_brew_install_cask "docker"
# _d_brew_install_cask jdk "" "for_jdk" # replace this to 'install-development-kit --jdk'
}
#@ help="install all commands"
function setup-all()
{
_d_info "start..."
__step()
{
local msg="$1"
shift 1
read -p "The next steps will install $msg. Enter ok to install, and the rest will be skipped: "
if [[ "$REPLY" == ok ]]; then
_d_info "install $msg..."
"$@"
fi
}
__step "command line tools" install-command-line-tools
__step "some favorite apps" install-apps
_install_dev_kit_and_check()
{
install-development-kit --jdk --sdk --ndk --other
check-project-config
}
__step "jdk sdk ndk in the current directory '$(pwd)'" _install_dev_kit_and_check
if $IS_WSL && [[ -e ~/.bashrc ]]; then
local p="$(realpath "$(basename "$0")")"
if [[ ! "$PATH" =~ "$p" ]]; then
echo 'export PATH="'"$p"':$PATH"' | sudo tee -a ~/.bashrc
fi
fi
}
if [[ -n "$WSL_DISTRO_NAME" ]]; then
IS_WSL=true
else
IS_WSL=false
fi
DEF_BIN_DIR="/usr/local/bin"
IS_APPLE_CHIP=false
if [[ "$(uname -m)" == arm64 ]] ;then
IS_APPLE_CHIP=true
DEF_BIN_DIR="/opt/homebrew/bin"
fi
if $has_d; then
main "$@"
elif (($#)); then
"$@"
else
install-command-line-tools
fi