Last active
January 22, 2026 10:20
-
-
Save neildavis/08176ee619c59a70d6145bb742391ad7 to your computer and use it in GitHub Desktop.
Script to install After Burner 2 outputs mod onto RetroPie 4.8
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| # Var for top level dir where we will build stuff | |
| BUILD_DIR="${BUILD_DIR:-${HOME}/aburner2}" | |
| # Var for mame2003-plus-libretro target platform | |
| MAME_PLATFORM="${MAME_PLATFORM:-rpi3}" | |
| # Var for mame2003-plus-libretro git REMOTE repo URL | |
| GIT_URL_MAME="${GIT_URL_MAME:-https://github.com/neildavis/mame2003-plus-libretro}" | |
| # Var for mame2003-plus-libretro git repo branch | |
| GIT_BRANCH_MAME="${GIT_BRANCH_MAME:-javi/aburner2}" | |
| # Var for mame2003-plus-libretro git LOCAL repo dir | |
| GIT_DIR_MAME="${GIT_DIR_MAME:-${BUILD_DIR}/mame2003-plus-libretro}" | |
| # Var for udd_rpi_lib git REMOTE repo URL | |
| GIT_URL_UDD="${GIT_URL_UDD:-https://github.com/neildavis/udd_rpi_lib}" | |
| # Var for udd_rpi_lib git repo branch | |
| GIT_BRANCH_UDD="${GIT_BRANCH_UDD:-dev-nd}" | |
| # Var for udd_rpi_lib git LOCAL repo dir | |
| GIT_DIR_UDD="${GIT_DIR_UDD:-${BUILD_DIR}/udd_rpi_lib}" | |
| # Var for alsa_volume_from_usb_hid git REMOTE repo URL | |
| GIT_URL_ALSA_VOL_HID="${GIT_URL_ALSA_VOL_HID:-https://github.com/neildavis/alsa_volume_from_usb_hid.git}" | |
| # Var for alsa_volume_from_usb_hid git repo branch | |
| GIT_BRANCH_ALSA_VOL_HID="${GIT_BRANCH_ALSA_VOL_HID:-main}" | |
| # Var for alsa_volume_from_usb_hid git LOCAL repo dir | |
| GIT_DIR_ALSA_VOL_HID="${GIT_DIR_ALSA_VOL_HID:-${BUILD_DIR}/alsa_volume_from_usb_hid}" | |
| # Var for RetroPie-Setup dir | |
| RETROPIE_SETUP_DIR="${RETROPIE_SETUP_DIR:-${HOME}/RetroPie-Setup}" | |
| # Var for where RetroPie stores libretro cores | |
| LIBRETRO_CORES_DIR="${LIBRETRO_CORES_DIR:-/opt/retropie/libretrocores}" | |
| # Debian verison file path | |
| DEB_VERSION_FILE="/etc/debian_version" | |
| # pigpiod systemd service config file | |
| PIGPIOD_SYSTEMD_SERVICE_FILE="/lib/systemd/system/pigpiod.service" | |
| # Func to clone or update a repo | |
| # $1 = git remote URL, $2 = branch, $3 = dest dir | |
| git_clone_or_pull() { | |
| echo "Git clone $1 at branch $2 into $3 ..." | |
| if [[ -d "$3" ]]; then | |
| # repo has already been cloned, just pull updates | |
| echo "Dir $3 already exists, pulling updates ..." | |
| cd $3 | |
| git fetch | |
| git checkout -f "$2" | |
| git pull | |
| else | |
| # repo has not yet been cloned. clone it | |
| echo "Cloning $1 at branch $2 into $3 ..." | |
| git clone -b "$2" "$1" "$3" | |
| fi | |
| } | |
| # We don't want retroarch running whilst the update proceeds so kill it if its running | |
| echo "Killing any instances of retroarch ..." | |
| killall retroarch 2> /dev/null || true | |
| sleep 1 | |
| # Let's get up to date! | |
| echo "Updating OS ..." | |
| # Buster is now legacy, so patch apt sources if we are on Buster | |
| if [[ -f "$DEB_VERSION_FILE" ]]; then | |
| if grep -q "^10\." "$DEB_VERSION_FILE"; then | |
| echo "Debian 10 (Buster) detected. Buster is now 'legacy' - updating apt sources..." | |
| sudo sed -i 's/raspbian.raspberrypi.org/legacy.raspbian.org/g' /etc/apt/sources.list | |
| echo "apt sources update done." | |
| else | |
| echo "Debian version is not 10.x (Buster) Found: $(cat $DEB_VERSION_FILE). No apt sources changes made." | |
| fi | |
| else | |
| echo "Error: Debian version file $DEB_VERSION_FILE not found." | |
| exit 1 | |
| fi | |
| # Update package repos index | |
| sudo apt update | |
| # Update OS | |
| sudo apt -y upgrade | |
| # Enable SPI if necessary | |
| spi_enabled=$(sudo raspi-config nonint get_spi) | |
| if [ $spi_enabled -eq 1 ]; then | |
| echo "Enabling SPI ..." | |
| sudo raspi-config nonint do_spi 0 | |
| else | |
| echo "SPI is already enabled" | |
| fi | |
| # Install build tools and dependencies | |
| echo "Installing build tools and dependencies ..." | |
| sudo apt -y install build-essential git wiringpi pigpio python3 python3-pip python3-venv python3-dev | |
| # Patch pigpiod systemd config to start pigpiod daemon using PWM hw clock | |
| echo "Ensuring pigpiod uses PWM clock ..." | |
| sudo sed -i '/ExecStart=\/usr\/bin\/pigpiod -l/ { /-t 0/! s/$/ -t 0/ }' "$PIGPIOD_SYSTEMD_SERVICE_FILE" | |
| echo "Reload systemd daemon config and enable & start pigpiod service..." | |
| sudo systemctl daemon-reload | |
| sudo systemctl enable pigpiod.service | |
| sudo systemctl start pigpiod | |
| # Use RetroPie-Setup to ensure that lr-mame2003 is NOT installed and lr-mame2003-plus IS installed | |
| echo "Checking RetroPie libretro cores setup ..." | |
| if [[ -d "${LIBRETRO_CORES_DIR}/lr-mame2003" ]]; then | |
| echo "lr-mame2003 core is installed in RetroPie. Removing ..." | |
| cd "${RETROPIE_SETUP_DIR}" | |
| sudo ./retropie_packages.sh lr-mame2003 remove | |
| else | |
| echo "lr-mame2003 core is NOT installed in RetroPie. Good!" | |
| fi | |
| if [[ ! -d "${LIBRETRO_CORES_DIR}/lr-mame2003-plus" ]]; then | |
| echo "lr-mame2003-plus core is NOT installed in RetroPie. Installing ..." | |
| cd "${RETROPIE_SETUP_DIR}" | |
| sudo ./retropie_packages.sh lr-mame2003-plus install_bin | |
| sudo ./retropie_packages.sh lr-mame2003-plus configure | |
| else | |
| echo "lr-mame2003-plus core IS installed in RetroPie. Good!" | |
| fi | |
| # Start to build stuff. Make the dir where we will clone code and build stuff | |
| mkdir -p "${BUILD_DIR}" | |
| # Clone the alsa_volume_from_usb_hid repo | |
| git_clone_or_pull "${GIT_URL_ALSA_VOL_HID}" "${GIT_BRANCH_ALSA_VOL_HID}" "${GIT_DIR_ALSA_VOL_HID}" | |
| # Clone the udd_rpi_lib repo | |
| git_clone_or_pull "${GIT_URL_UDD}" "${GIT_BRANCH_UDD}" "${GIT_DIR_UDD}" | |
| # Clone the mame2003-plus-libretro repo | |
| git_clone_or_pull "${GIT_URL_MAME}" "${GIT_BRANCH_MAME}" "${GIT_DIR_MAME}" | |
| # Build and install alsa_volume_from_usb_hid | |
| echo "Building and installing alsa_volume_from_usb_hid ..." | |
| cd "${GIT_DIR_ALSA_VOL_HID}" | |
| make install | |
| # Build udd_rpi_lib | |
| echo "Building udd_rpi_lib" | |
| cd "${GIT_DIR_UDD}" | |
| sudo make install | |
| # Build the lrmame2003osvr outputs server | |
| echo "Building lrmame2003osvr (outputs server)" | |
| cd "${GIT_DIR_MAME}/outputs" | |
| if [[ -f "$HOME/bin/lrmame2003osvr" ]]; then | |
| echo "Removing previous lrmame2003osvr install" | |
| make uninstall | |
| fi | |
| make BOOT_ROM=aburner2 install | |
| # Start the outputs server | |
| systemctl --user start lrmame2003osvr 2> /dev/null || true | |
| # Build mame2003-plus-libretro core | |
| echo "Building mame2003-plus-libretro.so ..." | |
| cd "${GIT_DIR_MAME}" | |
| make system_platform=unix platform="${MAME_PLATFORM}" -j$(nproc) | |
| # Replace RetroPie version of mame2003-plus-libretro.so with the one we just built | |
| echo "Replacing RetroPie installed version of mame2003_plus_libretro.so with modified version we built ..." | |
| RETROPIE_MAME_2003_PLUS_LIB="${LIBRETRO_CORES_DIR}/lr-mame2003-plus/mame2003_plus_libretro.so" | |
| RETROPIE_MAME_2003_PLUS_LIB_BAK="${RETROPIE_MAME_2003_PLUS_LIB}.bak" | |
| # Create a backup and symlink to redirect the original lib to our built version | |
| if [[ ! -L "${RETROPIE_MAME_2003_PLUS_LIB}" ]]; then | |
| # Backup the original | |
| if [[ ! -f "${RETROPIE_MAME_2003_PLUS_LIB_BAK}" ]]; then | |
| sudo mv "${RETROPIE_MAME_2003_PLUS_LIB}" "${RETROPIE_MAME_2003_PLUS_LIB_BAK}" | |
| echo "Made a backup of RetroPie installed version of mame2003_plus_libretro.so at ${RETROPIE_MAME_2003_PLUS_LIB_BAK}" | |
| fi | |
| sudo ln -fs "${GIT_DIR_MAME}/mame2003_plus_libretro.so" "${RETROPIE_MAME_2003_PLUS_LIB}" | |
| echo "Created symbolic link for mame2003_plus_libretro.so at ${RETROPIE_MAME_2003_PLUS_LIB}" | |
| else | |
| echo "Symbolic link for mame2003_plus_libretro.so already exists at ${RETROPIE_MAME_2003_PLUS_LIB}" | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment