forked from Rockbox/rockbox
-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
install.sh
executable file
·259 lines (203 loc) · 6.61 KB
/
install.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
#!/bin/bash
set -e -o pipefail
readonly MAGENTA="$(tput setaf 5 2>/dev/null || echo '')"
readonly GREEN="$(tput setaf 2 2>/dev/null || echo '')"
readonly CYAN="$(tput setaf 6 2>/dev/null || echo '')"
readonly ORANGE="$(tput setaf 3 2>/dev/null || echo '')"
readonly NO_COLOR="$(tput sgr0 2>/dev/null || echo '')"
if ! command -v curl >/dev/null 2>&1; then
echo "Error: curl is required to install Rockbox."
exit 1
fi
if ! command -v tar >/dev/null 2>&1; then
echo "Error: tar is required to install Rockbox."
exit 1
fi
export PATH="$HOME/.local/bin:$PATH"
# Define the release information
RELEASE_URL="https://api.github.com/repos/tsirysndr/rockbox-zig/releases/latest"
ASSET_NAME=""
function detect_os() {
# Determine the operating system
OS=$(uname -s)
if [ "$OS" = "Linux" ]; then
# Determine the CPU architecture
ARCH=$(uname -m)
if [ "$ARCH" = "aarch64" ]; then
ASSET_NAME="_aarch64-linux.tar.gz"
elif [ "$ARCH" = "x86_64" ]; then
ASSET_NAME="_x86_64-linux.tar.gz"
else
echo "Unsupported architecture: $ARCH"
exit 1
fi
else
echo "Unsupported operating system: $OS"
exit 1
fi;
}
# Install Rockbox CLI
detect_os
# Retrieve the download URL for the desired asset
DOWNLOAD_URL=$(curl -sSL "$RELEASE_URL" | grep -o "browser_download_url.*rockbox_.*$ASSET_NAME\"" | cut -d ' ' -f 2)
ASSET_NAME=$(basename $DOWNLOAD_URL)
INSTALL_DIR="/usr/local/bin"
DOWNLOAD_URL=`echo $DOWNLOAD_URL | tr -d '\"'`
# Download the asset
curl -SL $DOWNLOAD_URL -o /tmp/$ASSET_NAME
# Extract the asset
tar -xzf /tmp/$ASSET_NAME -C /tmp
# Set the correct permissions for the binary
chmod +x /tmp/rockbox
if command -v sudo >/dev/null 2>&1; then
sudo mv /tmp/rockbox $INSTALL_DIR
else
mv /tmp/rockbox $INSTALL_DIR
fi
if command -v apt-get >/dev/null 2>&1; then
if command -v sudo >/dev/null 2>&1; then
sudo apt-get install -y libusb-dev \
libsdl1.2-dev \
libfreetype6 \
libunwind-dev \
alsa-utils \
libasound2
else
apt-get install -y libusb-dev \
libsdl1.2-dev \
libfreetype6 \
libunwind-dev \
alsa-utils \
libasound2
fi
elif command -v pacman >/dev/null 2>&1; then
if command -v sudo >/dev/null 2>&1; then
sudo pacman -S --noconfirm libusb \
sdl \
freetype2 \
libunwind \
alsa-lib
else
pacman -S --noconfirm libusb \
sdl \
freetype2 \
libunwind \
alsa-lib
fi
elif command -v dnf >/dev/null 2>&1; then
if command -v sudo >/dev/null 2>&1; then
sudo dnf install -y libusb \
SDL \
freetype \
libunwind \
alsa-lib
else
dnf install -y libusb \
SDL \
freetype \
libunwind \
alsa-lib
fi
elif command -v zypper >/dev/null 2>&1; then
if command -v sudo >/dev/null 2>&1; then
sudo zypper install -y libusb-1_0-0 \
libSDL-1_2-0 \
freetype2 \
libunwind \
alsa
else
zypper install -y libusb-1_0-0 \
libSDL-1_2-0 \
freetype2 \
libunwind \
alsa
fi
elif command -v apk >/dev/null 2>&1; then
if command -v sudo >/dev/null 2>&1; then
sudo apk add libusb \
sdl \
freetype \
libunwind \
alsa-lib
else
apk add libusb \
sdl \
freetype \
libunwind \
alsa-lib
fi
fi
# Install Rockbox daemon
detect_os
DOWNLOAD_URL=$(curl -sSL $RELEASE_URL | grep -o "browser_download_url.*rockboxd_.*$ASSET_NAME\"" | cut -d ' ' -f 2)
ASSET_NAME=$(basename $DOWNLOAD_URL)
DOWNLOAD_URL=`echo $DOWNLOAD_URL | tr -d '\"'`
# Download the asset
curl -SL $DOWNLOAD_URL -o /tmp/$ASSET_NAME
# Extract the asset
tar -xzf /tmp/$ASSET_NAME -C /tmp
# Set the correct permissions for the binary
chmod +x /tmp/rockboxd
if command -v sudo >/dev/null 2>&1; then
sudo mv /tmp/rockboxd $INSTALL_DIR
else
mv /tmp/rockboxd $INSTALL_DIR
fi
# Install Rockbox assets
detect_os
ASSET_NAME=$(echo $ASSET_NAME | sed 's/_x86_64/-x86_64/')
ASSET_NAME=$(echo $ASSET_NAME | sed 's/_aarch64/-aarch64/')
DOWNLOAD_URL=$(curl -sSL $RELEASE_URL | grep -o "browser_download_url.*rockbox-assets.*$ASSET_NAME\"" | cut -d ' ' -f 2)
ASSET_NAME=$(basename $DOWNLOAD_URL)
DOWNLOAD_URL=`echo $DOWNLOAD_URL | tr -d '\"'`
# Download the asset
curl -SL $DOWNLOAD_URL -o /tmp/$ASSET_NAME
# Extract the asset
mkdir -p /tmp/rockbox-assets
tar -xzf /tmp/$ASSET_NAME -C /tmp/rockbox-assets
if command -v sudo >/dev/null 2>&1; then
sudo mkdir -p $INSTALL_DIR/../share/rockbox
sudo cp -r /tmp/rockbox-assets/* $INSTALL_DIR/../share/rockbox
else
mkdir -p $INSTALL_DIR/../share/rockbox
cp -r /tmp/rockbox-assets/* $INSTALL_DIR/../share/rockbox
fi
# Install Rockbox Codecs
detect_os
ASSET_NAME=$(echo $ASSET_NAME | sed 's/_x86_64/-x86_64/')
ASSET_NAME=$(echo $ASSET_NAME | sed 's/_aarch64/-aarch64/')
DOWNLOAD_URL=$(curl -sSL $RELEASE_URL | grep -o "browser_download_url.*rockbox-codecs.*$ASSET_NAME\"" | cut -d ' ' -f 2)
ASSET_NAME=$(basename $DOWNLOAD_URL)
DOWNLOAD_URL=`echo $DOWNLOAD_URL | tr -d '\"'`
# Download the asset
curl -SL $DOWNLOAD_URL -o /tmp/$ASSET_NAME
# Extract the asset
tar -xzf /tmp/$ASSET_NAME -C /tmp
if command -v sudo >/dev/null 2>&1; then
sudo mkdir -p $INSTALL_DIR/../lib/rockbox
sudo cp -r /tmp/codecs $INSTALL_DIR/../lib/rockbox
sudo cp -r /tmp/rocks $INSTALL_DIR/../lib/rockbox
else
mkdir -p $INSTALL_DIR/../lib/rockbox
cp -r /tmp/codecs $INSTALL_DIR/../lib/rockbox
cp -r /tmp/rocks $INSTALL_DIR/../lib/rockbox
fi
cat <<EOF
${ORANGE}
__________ __ ___.
Open \______ \ ____ ____ | | _\_ |__ _______ ___
Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \\
\/ \/ \/ \/ \/
${NO_COLOR}
Welcome to Rockbox Zig! 🚀
A fork of the original Rockbox project, with a focus on modernization and more features.
${GREEN}https://github.com/tsirysndr/rockbox-zig${NO_COLOR}
Please file an issue if you encounter any problems!
===============================================================================
Installation completed! 🎉
To get started, run:
${CYAN}rockbox start${NO_COLOR}
Stuck? Join our Discord ${MAGENTA}https://discord.gg/tXPrgcPKSt${NO_COLOR}
EOF