#!/bin/bash # Gets the latest cores and checks all the directories # in the current for any changes to the cores. # The directories MUST match the ones in the mist-binaries/cores so just create # the directories of the cores you want. #Define this if using Mistica for specific cores #MISTICA=Y LOGFILE=update_cores.log date >$LOGFILE echo >>$LOGFILE BASEDIR=_temp SRCDIR=${BASEDIR}/git/mist-binaries/cores # clone git repo if it doesn't exist if [[ ! -d $SRCDIR ]]; then mkdir -p ${BASEDIR}/git (cd ${BASEDIR}/git; git clone https://github.com/mist-devel/mist-binaries.git) #Set timestamps on git files to match repository commit dates (cd $SRCDIR; git ls-files | sed "s/'/\\\'/g" | xargs -I{} bash -c 'touch "{}" --date=@$(git log -n1 --pretty=format:%ct -- "{}")') fi echo $SRCDIR # Update the cores from github (cd $SRCDIR; git pull) #Check for firmware updates SRC=`ls -Lt "${SRCDIR}"/../firmware/*.upg 2>/dev/null | head -1` DST=_firmware/`basename "$SRC"` mkdir -p _firmware if [[ ! -f $DST ]]; then cp -p "$SRC" "$DST" echo ================== echo FIRMWARE UPDATED!!! $DST | tee -a $LOGFILE echo ================== echo fi echo #Check all the cores in git with current matching directories for FILE in `find . -maxdepth 1 -type d | egrep -v '_temp'` do DIR=${FILE:2} DST="${DIR}/core.rbf" if [[ $DIR = "spectrum" ]];then DST="${DIR}/zxspectrum.rbf" fi SRC=`ls -Lt ${SRCDIR}/$DIR/*.rbf 2>/dev/null | head -1` # Mistica currently has core specific SNES if [[ $DIR = "snes" && ! -z "$MISTICA" ]]; then SRC=`ls -Lt ${SRCDIR}/$DIR/snes_mist_*.rbf 2>/dev/null | head -1` if [[ ! -z "$MISTICA" ]]; then SRC=`ls -Lt ${SRCDIR}/$DIR/snes_mistica*.rbf 2>/dev/null | head -1` fi fi if [[ $DIR = "plus_too" ]]; then SRC=`ls -Lt ${SRCDIR}/$DIR/plusToo_*.rbf 2>/dev/null | head -1` fi if [[ $DIR = "zxn" ]]; then SRC=`ls -Lt ${SRCDIR}/$DIR/ZXN_*.rbf 2>/dev/null | head -1` fi if [[ -z $SRC || -z $DST ]]; then continue fi if [[ -f $SRC && ! -f $DST ]]; then cp -p "$SRC" "$DST" echo Update CORE $DST | tee -a $LOGFILE else if [[ $SRC -nt $DST ]]; then cp -p "$SRC" "$DST" echo Update CORE $DST | tee -a $LOGFILE echo else #Check checksum MD5SRC=`md5sum "$SRC" | awk '{print $1}'` MD5DST=`md5sum "$DST" | awk '{print $1}'` if [[ $MD5SRC != $MD5DST ]]; then cp -p "$SRC" "$DST" echo Update CORE $DST | tee -a $LOGFILE echo fi fi fi #Copy special ROMS [[ $DIR = "atari800" ]] && cp -pvu ${SRCDIR}/${DIR}/*.ROM ${DIR}/ [[ $DIR = "bbc" ]] && cp -pvu ${SRCDIR}/${DIR}/bbc.rom ${DIR}/ [[ $DIR = "c16" ]] && cp -pvu ${SRCDIR}/${DIR}/c16.rom ${DIR}/ [[ $DIR = "fpga64" ]] && cp -pvu ${SRCDIR}/${DIR}/*.rom ${SRCDIR}/${DIR}/C64GS.ARC ${DIR}/ [[ $DIR = "ht1080z" ]] && cp -pvu ${SRCDIR}/${DIR}/HT1080Z.ROM ${DIR}/ [[ $DIR = "ql" ]] && cp -pvu ${SRCDIR}/${DIR}/ql.rom ${DIR}/ [[ $DIR = "samcoupe" ]] && cp -pvu ${SRCDIR}/${DIR}/samcoupe.rom ${DIR}/ [[ $DIR = "spectrum" ]] && cp -pvu ${SRCDIR}/${DIR}/spectrum.rom ${DIR}/ [[ $DIR = "ti994a" ]] && cp -pvu ${SRCDIR}/${DIR}/TI994A.ROM ${DIR}/ [[ $DIR = "vic20" ]] && cp -pvu ${SRCDIR}/${DIR}/vic20.rom ${DIR}/ #Move ZXN to spectrum [[ $DIR = "zxn" ]] && cp -pvu zxn/core.rbf spectrum/ done