Rockbox open source high quality audio player as a Music Player Daemon
mpris rockbox mpd libadwaita audio rust zig deno
2
fork

Configure Feed

Select the types of activity you want to include in your feed.

at master 272 lines 7.2 kB view raw
1#!/bin/bash 2 3set -e -o pipefail 4 5readonly MAGENTA="$(tput setaf 5 2>/dev/null || echo '')" 6readonly GREEN="$(tput setaf 2 2>/dev/null || echo '')" 7readonly CYAN="$(tput setaf 6 2>/dev/null || echo '')" 8readonly ORANGE="$(tput setaf 3 2>/dev/null || echo '')" 9readonly NO_COLOR="$(tput sgr0 2>/dev/null || echo '')" 10 11if ! command -v curl >/dev/null 2>&1; then 12 echo "Error: curl is required to install Rockbox." 13 exit 1 14fi 15 16if ! command -v tar >/dev/null 2>&1; then 17 echo "Error: tar is required to install Rockbox." 18 exit 1 19fi 20 21export PATH="$HOME/.local/bin:$PATH" 22 23# Define the release information 24RELEASE_URL="https://api.github.com/repos/tsirysndr/rockbox-zig/releases/latest" 25 26ASSET_NAME="" 27 28function detect_os() { 29 # Determine the operating system 30 OS=$(uname -s) 31 if [ "$OS" = "Linux" ]; then 32 # Determine the CPU architecture 33 ARCH=$(uname -m) 34 if [ "$ARCH" = "aarch64" ]; then 35 ASSET_NAME="_aarch64-linux.tar.gz" 36 elif [ "$ARCH" = "x86_64" ]; then 37 ASSET_NAME="_x86_64-linux.tar.gz" 38 else 39 echo "Unsupported architecture: $ARCH" 40 exit 1 41 fi 42 elif [ "$OS" = "Darwin" ]; then 43 # Determine the CPU architecture 44 ARCH=$(uname -m) 45 if [ "$ARCH" = "arm64" ]; then 46 ASSET_NAME="_aarch64-darwin.tar.gz" 47 elif [ "$ARCH" = "x86_64" ]; then 48 ASSET_NAME="_x86_64-darwin.tar.gz" 49 else 50 echo "Unsupported architecture: $ARCH" 51 exit 1 52 fi 53 else 54 echo "Unsupported operating system: $OS" 55 exit 1 56 fi; 57} 58 59# Install Rockbox CLI 60 61detect_os 62 63# Retrieve the download URL for the desired asset 64DOWNLOAD_URL=$(curl -sSL "$RELEASE_URL" | grep -o "browser_download_url.*rockbox_.*$ASSET_NAME\"" | cut -d ' ' -f 2) 65 66ASSET_NAME=$(basename $DOWNLOAD_URL) 67 68INSTALL_DIR="/usr/local/bin" 69 70DOWNLOAD_URL=`echo $DOWNLOAD_URL | tr -d '\"'` 71 72# Download the asset 73curl -SL $DOWNLOAD_URL -o /tmp/$ASSET_NAME 74 75# Extract the asset 76tar -xzf /tmp/$ASSET_NAME -C /tmp 77 78# Set the correct permissions for the binary 79chmod +x /tmp/rockbox 80 81if command -v sudo >/dev/null 2>&1; then 82 sudo mv /tmp/rockbox $INSTALL_DIR 83else 84 mv /tmp/rockbox $INSTALL_DIR 85fi 86 87if command -v apt-get >/dev/null 2>&1; then 88 if command -v sudo >/dev/null 2>&1; then 89 sudo apt-get install -y libusb-dev \ 90 libsdl2-dev \ 91 libfreetype6 \ 92 libunwind-dev \ 93 alsa-utils \ 94 libasound2-dev 95 else 96 apt-get install -y libusb-dev \ 97 libsdl2-dev \ 98 libfreetype6 \ 99 libunwind-dev \ 100 alsa-utils \ 101 libasound2-dev 102 fi 103elif command -v brew >/dev/null 2>&1; then 104 brew install sdl2 105elif command -v pacman >/dev/null 2>&1; then 106 if command -v sudo >/dev/null 2>&1; then 107 sudo pacman -S --noconfirm libusb \ 108 sdl \ 109 freetype2 \ 110 libunwind \ 111 alsa-lib 112 else 113 pacman -S --noconfirm libusb \ 114 sdl \ 115 freetype2 \ 116 libunwind \ 117 alsa-lib 118 fi 119elif command -v dnf >/dev/null 2>&1; then 120 if command -v sudo >/dev/null 2>&1; then 121 sudo dnf install -y libusb \ 122 SDL \ 123 freetype \ 124 libunwind \ 125 alsa-lib 126 else 127 dnf install -y libusb \ 128 SDL \ 129 freetype \ 130 libunwind \ 131 alsa-lib 132 fi 133elif command -v zypper >/dev/null 2>&1; then 134 if command -v sudo >/dev/null 2>&1; then 135 sudo zypper install -y libusb-1_0-0 \ 136 libSDL-1_2-0 \ 137 freetype2 \ 138 libunwind \ 139 alsa 140 else 141 zypper install -y libusb-1_0-0 \ 142 libSDL-1_2-0 \ 143 freetype2 \ 144 libunwind \ 145 alsa 146 fi 147elif command -v apk >/dev/null 2>&1; then 148 if command -v sudo >/dev/null 2>&1; then 149 sudo apk add libusb \ 150 sdl \ 151 freetype \ 152 libunwind \ 153 alsa-lib 154 else 155 apk add libusb \ 156 sdl \ 157 freetype \ 158 libunwind \ 159 alsa-lib 160 fi 161fi 162 163# Install Rockbox daemon 164 165detect_os 166 167DOWNLOAD_URL=$(curl -sSL $RELEASE_URL | grep -o "browser_download_url.*rockboxd_.*$ASSET_NAME\"" | cut -d ' ' -f 2) 168 169ASSET_NAME=$(basename $DOWNLOAD_URL) 170 171DOWNLOAD_URL=`echo $DOWNLOAD_URL | tr -d '\"'` 172 173# Download the asset 174curl -SL $DOWNLOAD_URL -o /tmp/$ASSET_NAME 175 176# Extract the asset 177tar -xzf /tmp/$ASSET_NAME -C /tmp 178 179# Set the correct permissions for the binary 180chmod +x /tmp/rockboxd 181 182if command -v sudo >/dev/null 2>&1; then 183 sudo mv /tmp/rockboxd $INSTALL_DIR 184else 185 mv /tmp/rockboxd $INSTALL_DIR 186fi 187 188# Install Rockbox assets 189 190detect_os 191 192ASSET_NAME=$(echo $ASSET_NAME | sed 's/_x86_64/-x86_64/') 193ASSET_NAME=$(echo $ASSET_NAME | sed 's/_aarch64/-aarch64/') 194 195DOWNLOAD_URL=$(curl -sSL $RELEASE_URL | grep -o "browser_download_url.*rockbox-assets.*$ASSET_NAME\"" | cut -d ' ' -f 2) 196 197ASSET_NAME=$(basename $DOWNLOAD_URL) 198 199DOWNLOAD_URL=`echo $DOWNLOAD_URL | tr -d '\"'` 200 201# Download the asset 202curl -SL $DOWNLOAD_URL -o /tmp/$ASSET_NAME 203 204 205# Extract the asset 206mkdir -p /tmp/rockbox-assets 207tar -xzf /tmp/$ASSET_NAME -C /tmp/rockbox-assets 208 209if command -v sudo >/dev/null 2>&1; then 210 sudo mkdir -p $INSTALL_DIR/../share/rockbox 211 sudo cp -r /tmp/rockbox-assets/* $INSTALL_DIR/../share/rockbox 212else 213 mkdir -p $INSTALL_DIR/../share/rockbox 214 cp -r /tmp/rockbox-assets/* $INSTALL_DIR/../share/rockbox 215fi 216 217# Install Rockbox Codecs 218 219detect_os 220 221ASSET_NAME=$(echo $ASSET_NAME | sed 's/_x86_64/-x86_64/') 222ASSET_NAME=$(echo $ASSET_NAME | sed 's/_aarch64/-aarch64/') 223 224DOWNLOAD_URL=$(curl -sSL $RELEASE_URL | grep -o "browser_download_url.*rockbox-codecs.*$ASSET_NAME\"" | cut -d ' ' -f 2) 225 226ASSET_NAME=$(basename $DOWNLOAD_URL) 227 228DOWNLOAD_URL=`echo $DOWNLOAD_URL | tr -d '\"'` 229 230# Download the asset 231curl -SL $DOWNLOAD_URL -o /tmp/$ASSET_NAME 232 233# Extract the asset 234tar -xzf /tmp/$ASSET_NAME -C /tmp 235 236if command -v sudo >/dev/null 2>&1; then 237 sudo mkdir -p $INSTALL_DIR/../lib/rockbox 238 sudo cp -r /tmp/codecs $INSTALL_DIR/../lib/rockbox 239 sudo cp -r /tmp/rocks $INSTALL_DIR/../lib/rockbox 240else 241 mkdir -p $INSTALL_DIR/../lib/rockbox 242 cp -r /tmp/codecs $INSTALL_DIR/../lib/rockbox 243 cp -r /tmp/rocks $INSTALL_DIR/../lib/rockbox 244fi 245 246cat <<EOF 247${ORANGE} 248 __________ __ ___. 249 Open \______ \ ____ ____ | | _\_ |__ _______ ___ 250 Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / 251 Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < 252 Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \\ 253 \/ \/ \/ \/ \/ 254${NO_COLOR} 255Welcome to Rockbox Zig! 🚀 256A fork of the original Rockbox project, with a focus on modernization and more features. 257 258${GREEN}https://github.com/tsirysndr/rockbox-zig${NO_COLOR} 259 260Please file an issue if you encounter any problems! 261 262=============================================================================== 263 264Installation completed! 🎉 265 266To get started, run: 267 268${CYAN}rockbox start${NO_COLOR} 269 270Stuck? Join our Discord ${MAGENTA}https://discord.gg/tXPrgcPKSt${NO_COLOR} 271 272EOF