-
Notifications
You must be signed in to change notification settings - Fork 0
/
android_bootstrap
executable file
·91 lines (75 loc) · 3.28 KB
/
android_bootstrap
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
#!/usr/bin/env bash
# Sets up termux on my android device
# setup zsh files
# delete default files if they exist
original_files=("${HOME}/.zshenv" "${HOME}/.zshrc" "${HOME}/.zsh_history")
for file in "${original_files[@]}"; do
rm -rf "${file}"
done
# bash will typically source ~/.profile on shell launch
# if we haven't switched to zsh, a shell restart should
# cause this to be sourced
echo 'Setting up zsh profile...'
# shellcheck disable=SC2016
echo 'source "${HOME}/.profile"; export TERM=xterm-256color' >"${HOME}/.zshenv"
# check if we have access to the my directories
# on my $PATH, to see if zsh has been properly configured
if [[ ! "$(command -v havecmd)" ]]; then
printf "Issue finding 'havecmd', environment is not setup properly\n"
printf "Try restarting the shell and making sure ~/.profile is getting sourced\n"
exit 1
fi
# set zsh as shell
if ! echo "${SHELL}" | grep -q '/zsh'; then
havecmd zsh || apt install zsh
chsh -s zsh # seems to be different on termux?
abort "Restart shell so that zsh environment is setup. Then re-run 'yadm bootstrap'"
else
echo "zsh is already set as your default shell"
fi
declare -rx TERMUX_PACKAGES="${PACKAGE_DIR}/android_packages.txt"
# Install spkglist so I can parse package lists
set -e
havecmd go || apt install golang
install_go_cmds
set +e
for lib in $(spkglist "${TERMUX_PACKAGES}"); do
if ! dpkg-query -W -f='${Status}' "${lib}" | grep -q "ok installed"; then # if package isn't installed
yes | apt install "${lib}"
fi
done
# setup some additional directories
set -u
[[ ! -d "${HOME}/storage" ]] && termux-setup-storage
mkdir -vp "${REPOS}"
[[ ! -e "${HOME}/data" ]] && ln -vs "${HPIDATA}" "${HOME}/data"
[[ ! -e "${HOME}/shared" ]] && ln -vs "${HOME}/storage/shared" "${HOME}/shared"
set +u
# dont want to go through all the cargo/golang package lists
# I use on computers, since a lot of them aren't useful here
# manually install some commands
havecmd cargo || exit $? # needed to build some packages
havecmd evry || cargo install evry # task scheduling
havecmd wait-for-internet || cargo install wait-for-internet
havecmd eza || cargo install eza
CARGO_INSTALLED_PACKAGES="$(cargo install --list | sed -E -e '/^\s+/d; s|\s.*||')"
grep -q 'cargo-update' <<<"$CARGO_INSTALLED_PACKAGES" || cargo install cargo-update
havecmd shfmt || GO111MODULE=on go install mvdan.cc/sh/v3/cmd/shfmt@latest
havecmd arctee || python3 -m pip install git+https://github.com/karlicoss/arctee
havecmd todo.sh || basher install todotxt/todo.txt-cli
# manually build some python packages which have C extensions
INSTALLED_PYTHON_PACKAGES="$(python3 -m pip list --format=freeze | cut -d'=' -f1)"
# grep -xqi 'numpy' <<<"${INSTALLED_PYTHON_PACKAGES}" || LDFLAGS=" -lm -lcompiler_rt" pip install numpy --verbose
grep -xqi 'cython' <<<"${INSTALLED_PYTHON_PACKAGES}" || LDFLAGS=" -lcompiler_rt" pip install cython --verbose
# grep -xqi 'pandas' <<<"${INSTALLED_PYTHON_PACKAGES}" || CFLAGS="-Wno-deprecated-declarations -Wno-unreachable-code" pip install pandas --verbose
# Install zsh plugins manually
ZSH_PLUGINS="${XDG_DATA_HOME}/zsh_plugins"
mkdir -p "$ZSH_PLUGINS"
cd "$ZSH_PLUGINS"
AUTOSUGGESTIONS="${ZSH_PLUGINS}/zsh-autosuggestions"
if [[ -d "${AUTOSUGGESTIONS}" ]]; then
(cd "${AUTOSUGGESTIONS}" && git pull)
else
git clone 'https://github.com/zsh-users/zsh-autosuggestions'
fi
cd