-
Notifications
You must be signed in to change notification settings - Fork 47
/
ubuntu-setup.sh
executable file
·269 lines (233 loc) · 9.14 KB
/
ubuntu-setup.sh
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
#!/bin/bash
#
# Script to set up an Ubuntu 20.04+ server
# (with minimum 16GB RAM, 8 threads CPU) for android ROM compiling
#
# Sudo access is mandatory to run this script
#
# IMPORTANT NOTICE: This script sets my personal git config, update
# it with your details before you run this script!
#
# Usage:
# ./ubuntu-setup.sh
#
# Go to home dir
orig_dir=$(pwd)
cd $HOME
echo -e "Installing and updating APT packages...\n"
sudo apt update -qq
sudo apt full-upgrade -y -qq
sudo apt install -y -qq git-core gnupg flex bc bison build-essential zip curl zlib1g-dev gcc-multilib \
g++-multilib libc6-dev-i386 lib32ncurses5-dev x11proto-core-dev libx11-dev jq \
lib32z1-dev libgl1-mesa-dev libxml2-utils xsltproc unzip fontconfig imagemagick \
python2 python3 python3-pip python3-dev python-is-python3 schedtool ccache libtinfo5 \
libncurses5 lzop tmux libssl-dev neofetch patchelf dos2unix git-lfs default-jdk \
libxml-simple-perl ripgrep rclone
sudo apt autoremove -y -qq
sudo apt purge snapd -y -qq
pip3 install thefuck
echo -e "\nDone."
echo -e "\nInstalling git-repo..."
wget -q https://storage.googleapis.com/git-repo-downloads/repo
chmod a+x repo
sudo install repo /usr/local/bin/repo
rm repo
echo -e "Done."
echo -e "\nInstalling Android SDK platform tools..."
wget -q https://dl.google.com/android/repository/platform-tools-latest-linux.zip
unzip -qq platform-tools-latest-linux.zip
rm platform-tools-latest-linux.zip
echo -e "Done."
# echo -e "\nInstalling Google Drive CLI..."
# wget -q https://raw.githubusercontent.com/usmanmughalji/gdriveupload/master/gdrive
# chmod a+x gdrive
# sudo install gdrive /usr/local/bin/gdrive
# rm gdrive
# echo -e "Done."
if [[ $SHELL = *zsh* ]]; then
sh_rc=".zshrc"
else
sh_rc=".bashrc"
fi
echo -e "\nInstalling apktool and JADX..."
mkdir -p bin
wget -q https://bitbucket.org/iBotPeaches/apktool/downloads/apktool_2.10.0.jar -O bin/apktool.jar
echo 'alias apktool="java -jar $HOME/bin/apktool.jar"' >> $sh_rc
wget -q https://github.com/skylot/jadx/releases/download/v1.5.1/jadx-1.5.1.zip -O jadx.zip
unzip -qq jadx.zip -d jadx
rm jadx.zip
echo 'export PATH="$HOME/jadx/bin:$PATH"' >> $sh_rc
echo -e "Done."
echo -e "\nSetting up shell environment..."
cat <<'EOF' >> $sh_rc
# Super-fast repo sync
repofastsync() { time schedtool -B -e ionice -n 0 `which repo` sync -c --force-sync --optimized-fetch --no-tags --no-clone-bundle --retry-fetches=5 -j$(nproc --all) "$@"; }
# List lib dependencies of any lib/bin
list_blob_deps() { readelf -d $1 | grep "\(NEEDED\)" | sed -r "s/.*\[(.*)\]/\1/"; }
alias deps="list_blob_deps"
export TZ='Asia/Kolkata'
export USE_CCACHE=1
export CCACHE_EXEC=/usr/bin/ccache
function msg() {
echo -e "\e[1;32m$1\e[0m"
}
function helptree() {
if [[ -z $1 && -z $2 ]]; then
msg "Usage: helptree <tag> <add/pull>"
return
fi
kernel_version="$( cat Makefile | grep VERSION | head -n 1 | sed "s|.*=||1" | sed "s| ||g" )"
kernel_patchlevel="$( cat Makefile | grep PATCHLEVEL | head -n 1 | sed "s|.*=||1" | sed "s| ||g" )"
version=$kernel_version.$kernel_patchlevel
if [[ $version != "4.14" && $version != "5.4" ]]; then
msg "Kernel $version not supported! Only msm-5.4 and msm-4.14 are supported as of now."
return
fi
if [[ -z $3 ]]; then
spec=all
else
spec=$3
fi
if [[ $2 = "add" ]]; then
tree_status="Adding"
commit_status="Import from"
else
tree_status="Updating"
commit_status="Merge"
if [[ $spec = "all" ]]; then
msg "Merging kernel as of $1.."
git fetch https://git.codelinaro.org/clo/la/kernel/msm-$version $1 &&
git merge FETCH_HEAD -m "Merge tag '$1' of msm-$version"
fi
fi
if [[ $spec = "wifi" || $spec = "all" ]]; then
for i in qcacld-3.0 qca-wifi-host-cmn fw-api; do
msg "$tree_status $i subtree as of $1..."
git subtree $2 -P drivers/staging/$i -m "$i: $commit_status tag '$1'" \
https://git.codelinaro.org/clo/la/platform/vendor/qcom-opensource/wlan/$i $1
done
fi
if [[ $spec = "techpack" || $spec = "all" ]]; then
msg "$tree_status audio-kernel subtree as of $1..."
git subtree $2 -P techpack/audio -m "techpack: audio: $commit_status tag '$1'" \
https://git.codelinaro.org/clo/la/platform/vendor/opensource/audio-kernel $1
if [[ $version = "5.4" ]]; then
msg "$tree_status camera-kernel subtree as of $1..."
git subtree $2 -P techpack/camera -m "techpack: camera: $commit_status tag '$1'" \
https://git.codelinaro.org/clo/la/platform/vendor/opensource/camera-kernel $1
msg "$tree_status dataipa subtree as of $1..."
git subtree $2 -P techpack/dataipa -m "techpack: dataipa: $commit_status tag '$1'" \
https://git.codelinaro.org/clo/la/platform/vendor/opensource/dataipa $1
msg "$tree_status datarmnet subtree as of $1..."
git subtree $2 -P techpack/datarmnet -m "techpack: datarmnet: $commit_status tag '$1'" \
https://git.codelinaro.org/clo/la/platform/vendor/qcom/opensource/datarmnet $1
msg "$tree_status datarmnet-ext subtree as of $1..."
git subtree $2 -P techpack/datarmnet-ext -m "techpack: datarmnet-ext: $commit_status tag '$1'" \
https://git.codelinaro.org/clo/la/platform/vendor/qcom/opensource/datarmnet-ext $1
msg "$tree_status display-drivers subtree as of $1..."
git subtree $2 -P techpack/display -m "techpack: display: $commit_status tag '$1'" \
https://git.codelinaro.org/clo/la/platform/vendor/opensource/display-drivers $1
msg "$tree_status video-driver subtree as of $1..."
git subtree $2 -P techpack/video -m "techpack: video: $commit_status tag '$1'" \
https://git.codelinaro.org/clo/la/platform/vendor/opensource/video-driver $1
elif [[ $version = "4.14" ]]; then
if [[ $2 = "add" ]] || [ -d "techpack/data" ]; then
msg "$tree_status data-kernel as of $1..."
git subtree $2 -P techpack/data -m "techpack: data: $commit_status tag '$1'" \
https://git.codelinaro.org/clo/la/platform/vendor/qcom-opensource/data-kernel $1
fi
fi
fi
}
function addtree() {
if [[ -z $1 ]]; then
msg "Usage: addtree <tag> [optional: spec]"
return
fi
helptree $1 add $2
}
function updatetree() {
if [[ -z $1 ]]; then
msg "Usage: updatetree <tag> [optional: spec]"
return
fi
helptree $1 pull $2
}
export PATH="$HOME/.local/bin:$HOME/bin:$PATH"
eval $(thefuck --alias)
function f() {
if [ -z "$2" ]; then find | grep $1
elif [ "$1" = "-i" ]; then
if [ ! -z "$3" ]; then find $3 | grep -i $2
else find | grep -i $2; fi
else find $2 | grep $1; fi
}
# alias gup="gdrive upload --share"
function gup() {
[ -z "$1" ] && echo "Error: File not specified!" && return
rclone copy -P $1 gdrive: && rclone link gdrive:$(basename $1)
}
#### FILL IN PIXELDRAIN API KEY ####
PD_API_KEY=
####################################
function pdup() {
[ -z "$1" ] && echo "Error: File not specified!" && return
ID=$(curl --progress-bar -T "$1" -u :$PD_API_KEY https://pixeldrain.com/api/file/ | cat | grep -Po '(?<="id":")[^"]*')
echo -e "\nhttps://pixeldrain.com/u/$ID"
}
alias nnano=nano
alias Nano=nano
alias rgb="rg --binary"
alias wgetc="wget --content-disposition"
EOF
# Add android sdk to path
cat <<'EOF' >> .profile
# Add Android SDK platform tools to path
if [ -d "$HOME/platform-tools" ] ; then
PATH="$HOME/platform-tools:$PATH"
fi
EOF
# Unlimited history file
sed -i 's/HISTSIZE=.*/HISTSIZE=-1/g' $sh_rc
sed -i 's/HISTFILESIZE=.*/HISTFILESIZE=-1/g' $sh_rc
echo -e "Done."
# Increase tmux scrollback buffer size
echo "set-option -g history-limit 6000" >> .tmux.conf
# Increase maximum ccache size
ccache -M 50G
###
### IMPORTANT !!! REPLACE WITH YOUR PERSONAL DETAILS IF NECESSARY
###
# Configure git
echo -e "\nSetting up Git..."
if [[ $USER == "adithya" ]]; then
git config --global user.email "[email protected]"
git config --global user.name "Adithya R"
git config --global review.gerrit.aospa.co.username "ghostrider-reborn"
git config --global review.gerrit.libremobileos.com.username "ghostrider-reborn"
git config --global review.review.lineageos.org.username "ghostrider-reborn"
echo "export ARROW_GERRIT_USER=ghostrider_reborn" >> $sh_rc
fi
if [[ $USER == "panda" ]]; then
git config --global user.name "Jyotiraditya Panda"
git config --global user.email "[email protected]"
fi
git config --global alias.cp 'cherry-pick'
git config --global alias.c 'commit'
git config --global alias.f 'fetch'
git config --global alias.m 'merge'
git config --global alias.rb 'rebase'
git config --global alias.rs 'reset'
git config --global alias.ck 'checkout'
git config --global alias.rsh 'reset --hard'
git config --global alias.logp 'log --pretty=oneline --abbrev-commit'
git config --global alias.mlog 'merge --log=100'
git config --global credential.helper 'cache --timeout=99999999'
git config --global url."[email protected]:".insteadOf "https://github.com/"
git config --global push.autoSetupRemote true
echo "Done."
# Done!
echo -e "\nALL DONE. Now sync sauces & start baking!"
echo -e "Please relogin or run \`source ~/$sh_rc && source ~/.profile\` for environment changes to take effect."
# Go back to original dir
cd "$orig_dir"