-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathsetup.sh
168 lines (153 loc) · 7.25 KB
/
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
#!/bin/bash
#
# Copyright (C) 2022 Orel6505
#
# SPDX-License-Identifier: GNU General Public License v3.0
#
export MY_DIR=$(pwd)
if [ "$EUID" -ne 0 ]; then
echo "Please run as root"
exit 1
fi
Setup_Ubuntu () {
case $1 in
*"23.04"*)
sudo apt install git repo adb fastboot curl openssh-client sshpass -y bc bison build-essential flex g++-multilib gcc-multilib gnupg gperf imagemagick lib32ncurses5-dev lib32z1-dev liblz4-tool libncurses5-dev libsdl1.2-dev libxml2 libxml2-utils lunzip lzop pngcrush schedtool squashfs-tools xsltproc zip zlib1g-dev openjdk-8-jdk python3 perl git git-lfs libncurses5 xmlstarlet virtualenv xz-utils rr jq ruby gem ccache libssl-dev ucommon-utils protobuf-compiler
;;
*"22.10"*)
sudo apt install git repo adb fastboot curl openssh-client sshpass -y bc bison build-essential flex g++-multilib gcc-multilib gnupg gperf imagemagick lib32ncurses5-dev lib32z1-dev liblz4-tool libncurses5-dev libsdl1.2-dev libwxgtk3.0-gtk3-dev libxml2 libxml2-utils lunzip lzop pngcrush schedtool squashfs-tools xsltproc zip zlib1g-dev openjdk-8-jdk python2 python3 perl git git-lfs libncurses5 xmlstarlet virtualenv xz-utils rr jq ruby gem ccache libssl-dev ucommon-utils protobuf-compiler
;;
*"21.04"* | *"21.10"* | *"22.04"*)
sudo apt install git repo adb fastboot curl openssh-client sshpass -y bc bison build-essential flex g++-multilib gcc-multilib gnupg gperf imagemagick lib32ncurses5-dev lib32z1-dev liblz4-tool libncurses5-dev libsdl1.2-dev libwxgtk3.0-gtk3-dev libxml2 libxml2-utils lunzip lzop pngcrush schedtool squashfs-tools xsltproc zip zlib1g-dev openjdk-8-jdk python perl git git-lfs libncurses5 xmlstarlet virtualenv xz-utils rr jq ruby gem ccache libssl-dev ucommon-utils protobuf-compiler
;;
*"20.04"*)
sudo apt-get install openssh-client sshpass coreutils ucommon-utils git ccache lzop bison build-essential zip curl zlib1g-dev g++-multilib libxml2-utils bzip2 libbz2-dev libghc-bzlib-dev squashfs-tools pngcrush liblz4-tool optipng libc6-dev-i386 gcc-multilib libssl-dev gnupg flex lib32ncurses-dev x11proto-core-dev libx11-dev lib32z1-dev libgl1-mesa-dev xsltproc unzip libffi-dev libxml2-dev libxslt1-dev libjpeg8-dev fontconfig libncurses5-dev libncurses5 libncurses5:i386 python-is-python3 protobuf-compiler
Setup_Repo
;;
*)
sudo apt-get install openssh-client sshpass coreutils ucommon-utils git ccache lzop bison build-essential zip curl zlib1g-dev g++-multilib libxml2-utils bzip2 libbz2-dev libghc-bzlib-dev squashfs-tools pngcrush liblz4-tool optipng libc6-dev-i386 gcc-multilib libssl-dev gnupg flex lib32ncurses-dev x11proto-core-dev libx11-dev lib32z1-dev libgl1-mesa-dev xsltproc unzip libffi-dev libxml2-dev libxslt1-dev libjpeg8-dev fontconfig libncurses5-dev libncurses5 libncurses5:i386 python-is-python3 protobuf-compiler
Setup_Repo
;;
esac
}
Setup_Debian () {
sudo apt install git repo adb fastboot curl openssh-client sshpass -y bc bison build-essential flex g++-multilib gcc-multilib gnupg gperf imagemagick lib32ncurses5-dev lib32z1-dev liblz4-tool libncurses5-dev libsdl1.2-dev libwxgtk3.0-gtk3-dev libxml2 libxml2-utils lunzip lzop pngcrush schedtool squashfs-tools xsltproc zip zlib1g-dev openjdk-8-jdk python perl git git-lfs libncurses5 xmlstarlet virtualenv xz-utils rr jq ruby gem ccache libssl-dev ucommon-utils protobuf-compiler
}
Setup_Arch () {
if ! grep -q "\[multilib\]" /etc/pacman.conf ; then
sed -i '/\[multilib\]/,/^Include/ s/^#//' /etc/pacman.conf
fi
pacman -Syyu --noconfirm --needed multilib-devel coreutils sshpass
DEFAULT_USER=$(who | cut -f1 -d " ")
for PACKAGE in "aosp-devel lineageos-devel xml2 ffmpeg imagemagick lzop ninja gradle maven protobuf"; do
git clone https://aur.archlinux.org/"${PACKAGE}".git
cd "${PACKAGE}"
su "${DEFAULT_USER}" -c "makepkg -si --skippgpcheck --noconfirm --needed"
cd ..
rm -rf "${PACKAGE}"
done
Setup_Repo
}
Setup_Fedora () {
sudo dnf update -y
sudo dnf install -y \
@development-tools \
android-tools \
automake \
bc \
bison \
bzip2 \
bzip2-libs \
ccache \
curl \
dpkg-dev \
gcc-c++ \
git \
gperf \
hostname \
ImageMagick-devel.x86_64 \
ImageMagick-c++-devel.x86_64 \
java-1.8.0-openjdk \
libstdc++.i686 \
libxml2-devel \
lz4-libs \
lzop \
make \
maven \
ncurses-compat-libs \
optipng \
pngcrush \
python \
python3 \
python3-mako \
python-mako \
python-networkx \
rsync \
sshpass \
schedtool \
squashfs-tools \
syslinux-devel \
zip \
zlib-devel \
zlib-devel.i686
Setup_Repo
curl -OL https://github.com/protocolbuffers/protobuf/releases/download/v21.1/protoc-21.1-linux-x86_64.zip
sudo unzip -o protoc-21.1-linux-x86_64.zip -d /usr/local bin/protoc
sudo unzip -o protoc-21.1-linux-x86_64.zip -d /usr/local 'include/*'
rm -f protoc-21.1-linux-x86_64.zip
}
Setup_Repo () {
if [ -d /bin ]
mkdir ~/bin
fi
curl http://commondatastorage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
chmod a+x ~/bin/repo
}
Setup_GH () {
if [[ "${OS_NAME}" == *"Ubuntu"* ]] || [[ "${OS_NAME2}" == *"Ubuntu"* ]]; then
sudo apt install gh
elif [[ "${OS_NAME}" == *"Fedora"* ]] || [[ "${OS_NAME2}" == *"Fedora"* ]]; then
sudo dnf config-manager --add-repo https://cli.github.com/packages/rpm/gh-cli.repo
sudo dnf install gh
elif [[ "${OS_NAME}" == *"Arch"* ]] || [[ "${OS_NAME2}" == *"Arch"* ]]; then
git clone https://aur.archlinux.org/github-cli-git
cd github-cli-git
makepkg -si --skippgpcheck --noconfirm --needed
cd ..
rm -rf github-cli-git
fi
gh auth login
}
Setup_SF () {
echo -n "Please enter your SourceForge username: "
read SF_USER
echo -n "After connecting, please run exit."
sftp "${SF_USER}"@frs.sourceforge.net
}
cat /etc/os-release > .KNOX
OS_NAME=$(awk '/ID=/' .KNOX | sed '/VERSION_ID/d' | cut -f2 -d '=')
OS_NAME2=$(awk '/NAME=/' .KNOX | sed '/PRETTY/d' | sed '/CODENAME/d' | cut -f2 -d '=')
OS_DISTRO=$(awk '/ID_LIKE=/' .KNOX | cut -f2 -d '=')
if [[ "${OS_NAME}" == *"ubuntu"* ]] || [[ "${OS_NAME2}" == *"ubuntu"* ]]; then
UBUNTU_VERSION=$(awk '/VERSION_ID=/' .KNOX | cut -f2 -d '=')
Setup_Ubuntu "$UBUNTU_VERSION"
elif [[ "${OS_NAME}" == *"Debian"* ]] || [[ "${OS_NAME2}" == *"Debian"* ]] || [[ "${OS_DISTRO}" == *"Debian"* ]]; then
Setup_Debian
elif [[ "${OS_NAME}" == *"Arch"* ]] || [[ "${OS_NAME2}" == *"Arch"* ]]; then
Setup_Arch
elif [[ "${OS_NAME}" == *"Fedora"* ]] || [[ "${OS_NAME2}" == *"Fedora"* ]]; then
Setup_Fedora
else
echo "unknown"
exit 1
fi
echo -n "Do you want to setup Github releases?: "
read SETUP_GH
if [ "${SETUP_GH}" = "Yes" ] || [ "${SETUP_GH}" = "yes" ] || [ "${SETUP_GH}" = "Y" ] || [ "${SETUP_GH}" = "y" ]; then
Setup_GH
fi
echo -n "Do you want to setup SourceForge?: "
read SETUP_SF
if [ "${SETUP_SF}" = "Yes" ] || [ "${SETUP_SF}" = "yes" ] || [ "${SETUP_SF}" = "Y" ] || [ "${SETUP_GH}" = "y" ]; then
Setup_SF
fi