A modern Music Player Daemon based on Rockbox open source high quality audio player
libadwaita audio rust zig deno mpris rockbox mpd
at master 120 lines 2.9 kB view raw
1#!/bin/sh 2 3 4###################################################################### 5# __________ __ ___. 6# Open \______ \ ____ ____ | | _\_ |__ _______ ___ 7# Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / 8# Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < 9# Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ 10# \/ \/ \/ \/ \/ 11# 12# * Script to patch an unpacked Samsung YP-R0 firmware file */ 13# Copyright (C) 2011 Thomas Martitz 14# Copyright (C) 2013 Lorenzo Miori 15###################################################################### 16# bail out early 17set -e 18 19if [ $# -lt 1 ] || [ $# -gt 2 ]; then 20 echo "Usage: $0 <files path> [path to unpacked rom]" 21 echo "\t<files path> is expected to have a special resources and rootfs layout" 22 exit 1 23fi 24 25MODEL="unknown" 26FILES=${1%/} 27FILES=${FILES:-"/"} 28COMMON_FILES="$FILES/common" 29DIR=${2:-"."} 30DIR=${DIR%/} 31ROOTFS=$DIR/rootfs 32CRAMFS=$DIR/cramfs-fsl.rom 33 34# sanity checks 35 36for subdir in common r0 r1 37do 38 if [ ! -d "$FILES/$subdir" ] 39 then 40 echo "Missing $FILES/$subdir. Invalid $FILES layout." 41 exit 1 42 fi 43done 44 45if [ ! -e "$FILES/r1/etc/safemode/cable_detect" ] 46then 47 echo "Couldn't find cable_detect binary (try 'make' or select a valid layout directory)" 48 exit 1 49fi 50 51for image in pre_smode.raw post_smode.raw safemode.raw 52do 53 if [ ! -e "$FILES/r1/etc/safemode/$image" ] 54 then 55 echo "Missing r1 .raw image file (try 'make'): $image" 56 exit 1 57 fi 58 if [ ! -e "$FILES/r0/etc/safemode/$image" ] 59 then 60 echo "Missing r0 .raw image file (try 'make'): $image" 61 exit 1 62 fi 63done 64 65# this needs to be run as root! 66if [ $(whoami) != "root" ] 67then 68 echo "This needs to be run as root" 69 exit 1 70fi 71 72if [ ! -e $1 ] || [ ! -e $2 ]; then 73 echo "$1 or $2 does not exist" 74 exit 1 75fi 76 77if [ -z $ROOTFS ] || [ -z $FILES ]; then 78 echo "Invalid input directories" 79 exit 1 80fi 81 82if [ ! -e $CRAMFS ]; then 83 echo "Cramfs image not found (did you extract the firmware?)" 84 exit 1 85fi 86 87echo "Extracting cramfs image" 88 89[ ! -e $ROOTFS ] || rm -R $ROOTFS 90cramfs-1.1/cramfsck -x $ROOTFS $CRAMFS 91 92# now we can detect player version 93# NOTE: order is important here, since ironically 94# r1's ROM contains also r0's executables 95if [ -e "$ROOTFS/usr/local/bin/r1" ] 96then 97 MODEL="r1" 98else 99 if [ -e "$ROOTFS/usr/local/bin/r0" ] 100 then 101 MODEL="r0" 102 fi 103fi 104 105echo "$MODEL ROM found." 106 107echo "Patching rootfs (common files)" 108echo "cp -r $COMMON_FILES/* $ROOTFS/" 109cp -r $COMMON_FILES/.rockbox $ROOTFS/ 110cp -r $COMMON_FILES/* $ROOTFS/ 111 112echo "Patching rootfs ($MODEL files)" 113MODEL_FILES="$FILES/$MODEL" 114echo "cp -r $MODEL_FILES/* $ROOTFS/" 115cp -r $MODEL_FILES/* $ROOTFS/ 116rm -rf $ROOTFS/dev/ttyGS0 117mknod $ROOTFS/dev/ttyGS0 c 127 0 118 119echo "Packing new cramfs image" 120cramfs-1.1/mkcramfs $ROOTFS $CRAMFS