-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinstall_sublime.sh
116 lines (101 loc) · 3.4 KB
/
install_sublime.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
if [ "$EUID" -ne 0 ]
then echo "Run as sudo"
exit
fi
if ! which subl
then
read -p "Sublime Text not installed. Install Sublime Text and continue? [yY/nN]: " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]
then
if ! apt -qq -y install wget apt-transport-https software-properties-common
then
echo "Failed to install dependencies. Exiting."
exit 1
fi
if ! wget -qO - https://download.sublimetext.com/sublimehq-pub.gpg | sudo apt-key add -
then
echo "Failed to install Sublime GPG key. Exiting."
exit 1
fi
if ! add-apt-repository "deb https://download.sublimetext.com/ apt/stable/"
then
echo "Failed to add Sublime Text apt repository. Exiting"
exit 1
fi
if ! apt -qq update
then
echo "apt update failed. Exiting."
exit 1
fi
if ! apt -qq -y install sublime-text
then
echo "Failed to install Sublime Text. Exiting."
exit 1
fi
else
echo "Exiting."
exit 1
fi
fi
if ! apt -qq -y install patchelf wget tar coreutils
then
echo "Failed to install dependencies. Exiting."
exit 1
fi
if ! tempdir=$(mktemp -d)
then
echo "Failed to create temporary directory. Exiting."
fi
if ! chmod 1777 "${tempdir}"
then
echo "Failed to set temporary directory permissions. Exiting."
rm -rf "${tempdir}"
exit 1
fi
echo "dir: $tempdir"
if ! wget -qO "${tempdir}/glibc2.28.tar.gz" https://github.com/lulle2007200/sublime_on_arm64_bionic/raw/master/glibc2.28.tar.gz
then
echo "Failed to download glibc2.27.tar.gz. Exiting."
exit 1
fi
if ! mkdir -p /opt/glibc2.28
then
echo "Failed to create glibc2.28 directory. Exiting."
rm -rf "${tempdir}"
exit 1
fi
if ! tar -zxf "${tempdir}/glibc2.28.tar.gz" -C /opt/glibc2.28
then
echo "Failed to extract glibc2.28. Exiting."
rm -rf "${tempdir}"
exit 1
fi
if ! cp /opt/sublime_text/{sublime_text,plugin_host-3.3,plugin_host-3.8,crash_handler} "${tempdir}/"
then
echo "Failed to copy Sublime Text binaries to temporary directory. Exiting."
rm -rf "${tempdir}"
exit 1
fi
if ! patchelf --remove-rpath "${tempdir}/sublime_text" || \
! patchelf --remove-rpath "${tempdir}/plugin_host-3.3" || \
! patchelf --remove-rpath "${tempdir}/plugin_host-3.8" || \
! patchelf --remove-rpath "${tempdir}/crash_handler" || \
! patchelf --force-rpath --set-rpath "/opt/glibc2.28/lib:/usr/lib/aarch64-linux-gnu:/lib/aarch64-linux-gnu:\$ORIGIN" --set-interpreter /opt/glibc2.28/lib/ld-linux-aarch64.so.1 "${tempdir}/sublime_text" || \
! patchelf --force-rpath --set-rpath "/opt/glibc2.28/lib:/usr/lib/aarch64-linux-gnu:/lib/aarch64-linux-gnu:\$ORIGIN" --set-interpreter /opt/glibc2.28/lib/ld-linux-aarch64.so.1 "${tempdir}/plugin_host-3.3" || \
! patchelf --force-rpath --set-rpath "/opt/glibc2.28/lib:/usr/lib/aarch64-linux-gnu:/lib/aarch64-linux-gnu:\$ORIGIN" --set-interpreter /opt/glibc2.28/lib/ld-linux-aarch64.so.1 "${tempdir}/plugin_host-3.8" || \
! patchelf --force-rpath --set-rpath "/opt/glibc2.28/lib:/usr/lib/aarch64-linux-gnu:/lib/aarch64-linux-gnu:\$ORIGIN" --set-interpreter /opt/glibc2.28/lib/ld-linux-aarch64.so.1 "${tempdir}/crash_handler"
then
echo "Failed to patch Sublime Text binaries. Exiting."
rm -rf "${tempdir}"
exit 1
fi
if ! \cp -f "${tempdir}/"{sublime_text,plugin_host-3.3,plugin_host-3.8,crash_handler} /opt/sublime_text/
then
echo "Failed to replace Sublime Text binaries. Exiting."
rm -rf "${tempdir}"
exit 1
fi
rm -rf "${tempdir}"
echo "Successfully installed Sublime Text."
exit 0