-
Notifications
You must be signed in to change notification settings - Fork 1
/
setuptheos.sh
118 lines (109 loc) · 3.42 KB
/
setuptheos.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
#!/bin/sh
# setuptheos.sh
# brooklyn
#
# Created by EthanRDoesMC on 2/13/21.
#
CLEAR='\033[0m'
RED='\033[0;31m'
function usage() {
if [ -n "$1" ]; then
echo -e "${RED}$1${CLEAR}";
fi
echo "Platforms (-p): Linux/WSL/macOS"
exit 1
}
while [[ "$#" > 0 ]]; do case $1 in
-p|--platform) PLATFORM_NAME="$2"; shift;shift;;
*) usage "Unknown parameter passed: $1"; shift; shift;;
esac; done
printf "
\e[38;5;208m____\e[39m
\e[38;5;202m/ __ ) __ ___ ____ ___ _____\e[39m
\e[38;5;204m</ __ / _ \/ _ \/ __ \/ _ \/ ___/\e[39m
\e[38;5;165m/ /_/ / __/ __/ /_/ / __/ /\e[39m
\e[38;5;129m</_____/\___/\___/ .___/\___/_/\e[39m
\e[38;5;57m/_/\e[39m
"
if [ -z "$PLATFORM_NAME" ]; then
echo "What platform are you using?"
select lwm in "Linux" "WSL" "macOS"; do
case $lwm in
Linux ) PLATFORM_NAME="Linux"; break;;
WSL ) PLATFORM_NAME="WSL"; break;;
macOS ) PLATFORM_NAME="macOS"; break;;
esac
done
fi
if [ "$PLATFORM_NAME" != "Linux" ] && [ "$PLATFORM_NAME" != "WSL" ] && [ "$PLATFORM_NAME" != "macOS" ]; then
echo "$PLATFORM_NAME is an unsupported or invalid platform name. What platform are you using?"
select lwm in "Linux" "WSL" "macOS"; do
case $lwm in
Linux ) PLATFORM_NAME="Linux"; break;;
WSL ) PLATFORM_NAME="WSL"; break;;
macOS ) PLATFORM_NAME="macOS"; break;;
esac
done
fi
if [ "$PLATFORM_NAME" = "Linux" ] || [ "$PLATFORM_NAME" = "WSL" ]; then
if [ -z "$THEOS" ]; then
echo "Preparing installation for Linux..."
echo "Downloading LLVM..."
sudo bash -c "$(wget -O - https://apt.llvm.org/llvm.sh)"
echo "Updating apt..."
sudo apt-get update
echo "Installing build-related packages..."
sudo apt-get install -y fakeroot git perl clang build-essential unzip zip libtinfo5
if [ "$PLATFORM_NAME" = "WSL" ]; then
echo "Setting WSL flag for fakeroot..."
sudo update-alternatives --set fakeroot /usr/bin/fakeroot-tcp
fi
echo "Adding THEOS to your shell..."
echo "export THEOS=~/theos" >> ~/.profile
THEOS=~/theos
git clone --recursive https://github.com/theos/theos.git $THEOS
curl -LO https://github.com/sbingner/llvm-project/releases/download/v10.0.0-1/linux-ios-arm64e-clang-toolchain.tar.lzma
TMP=$(mktemp -d)
tar --lzma -xvf linux-ios-arm64e-clang-toolchain.tar.lzma -C $TMP
mkdir -p $THEOS/toolchain/linux/iphone
mv $TMP/ios-arm64e-clang-toolchain/* $THEOS/toolchain/linux/iphone/
rm -r $TMP linux-ios-arm64e-clang-toolchain.tar.lzma
curl -LO https://github.com/theos/sdks/archive/master.zip
TMP=$(mktemp -d)
unzip master.zip -d $TMP
mv $TMP/sdks-master/*.sdk $THEOS/sdks
rm -r master.zip $TMP
fi
curl -LO https://github.com/EthanRDoesMC/sdks/archive/main.zip
TMP=$(mktemp -d)
unzip main.zip -d $TMP
mv $TMP/sdks-main/*.sdk $THEOS/sdks
rm -r main.zip $TMP
echo "Done! Make sure to restart your shell."
fi
if [ "$PLATFORM_NAME" = "macOS" ]; then
echo "Ensure Xcode is installed. Seriously."
if [ -z "$THEOS" ]; then
which -s brew
if [[ $? != 0 ]] ; then
# Install Homebrew
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
else
brew update
fi
brew install ldid xz
echo "export THEOS=~/theos" >> ~/.profile
echo "export THEOS=~/theos" >> ~/.zprofile
THEOS=~/theos
curl -LO https://github.com/theos/sdks/archive/master.zip
TMP=$(mktemp -d)
unzip master.zip -d $TMP
mv $TMP/sdks-master/*.sdk $THEOS/sdks
rm -r master.zip $TMP
fi
curl -LO https://github.com/EthanRDoesMC/sdks/archive/main.zip
TMP=$(mktemp -d)
unzip main.zip -d $TMP
mv $TMP/sdks-main/*.sdk $THEOS/sdks
rm -r main.zip $TMP
fi