diff --git a/community/mame/PKGBUILD b/community/mame/PKGBUILD index 5d4576f4e..b7cd117d5 100644 --- a/community/mame/PKGBUILD +++ b/community/mame/PKGBUILD @@ -10,7 +10,7 @@ highmem=1 pkgname=mame pkgver=0.203 -pkgrel=1 +pkgrel=2 pkgdesc="A port of the popular Multiple Arcade Machine Emulator using SDL with OpenGL support." url="http://mamedev.org/" license=(GPL2) @@ -21,7 +21,7 @@ conflicts=(sdlmame) replaces=(sdlmame) source=("https://github.com/mamedev/mame/archive/mame${pkgver/./}.tar.gz" mame.sh) sha256sums=('e17aa95f8897217d433e44e2f4b75ac7b5e13184549b7d14098d52652b7eb49a' - 'd089e182d3aadf3b9efb7948329923e24feedd64d107f9582f2550c2e3bb6d1d') + 'e97fc02ce0ea615a3a5017b2df7f6041365779319da8beab23d74e4067ce4fe6') prepare() { diff --git a/community/mame/mame.sh b/community/mame/mame.sh index e809a53ea..7b717ddc0 100644 --- a/community/mame/mame.sh +++ b/community/mame/mame.sh @@ -1,56 +1,51 @@ #!/bin/sh +mame=/usr/lib/mame/mame -# Create a variable equal to $HOME that will be used later in the ini creation -home=('$HOME') +mame_first_run() { + echo "Creating an ini file for MAME at $HOME/.mame/mame.ini" + echo "Modify this file for permanent changes to your MAME" + echo "options and paths before running MAME again." + + cd -- ~/.mame || exit -if [ "$1" != "" ] && [ "$1" = "--newini" ]; then - echo "Rebuilding the ini file at $HOME/.mame/mame.ini" - echo "Modify this file for permanent changes to your SDLMAME" - echo "options and paths before running SDLMAME again." - cd $HOME/.mame if [ -e mame.ini ]; then + mv mame.ini mameini.bak || exit echo "Your old ini file has been renamed to mameini.bak" - mv mame.ini mameini.bak fi - /usr/lib/mame/mame \ - -artpath "$home/.mame/artwork;artwork" \ - -ctrlrpath "$home/.mame/ctrlr;ctrlr" \ - -inipath $home/.mame/ini \ - -rompath $home/.mame/roms \ - -samplepath $home/.mame/samples \ - -cfg_directory $home/.mame/cfg \ - -comment_directory $home/.mame/comments \ - -diff_directory $home/.mame/diff \ - -input_directory $home/.mame/inp \ - -nvram_directory $home/.mame/nvram \ - -snapshot_directory $home/.mame/snap \ - -state_directory $home/.mame/sta \ + + # Note: the single quotes here are not a mistake; MAME will save these + # strings verbatim into its configuration file, and expand the variables when + # it is run in future. + "$mame" \ + -artpath '$HOME/.mame/artwork;artwork' \ + -ctrlrpath '$HOME/.mame/ctrlr;ctrlr' \ + -inipath '$HOME/.mame/ini' \ + -rompath '$HOME/.mame/roms' \ + -samplepath '$HOME/.mame/samples' \ + -cfg_directory '$HOME/.mame/cfg' \ + -comment_directory '$HOME/.mame/comments' \ + -diff_directory '$HOME/.mame/diff' \ + -input_directory '$HOME/.mame/inp' \ + -nvram_directory '$HOME/.mame/nvram' \ + -snapshot_directory '$HOME/.mame/snap' \ + -state_directory '$HOME/.mame/sta' \ -video opengl \ -createconfig -elif [ ! -e $HOME/.mame ]; then - echo "Running SDLMAME for the first time..." - echo "Creating an ini file for SDLMAME at $HOME/.mame/mame.ini" - echo "Modify this file for permanent changes to your SDLMAME" - echo "options and paths before running SDLMAME again." - mkdir $HOME/.mame - mkdir $HOME/.mame/{artwork,cfg,comments,ctrlr,diff,ini,inp,nvram,samples,snap,sta,roms} - cd $HOME/.mame - /usr/lib/mame/mame \ - -artpath "$home/.mame/artwork;artwork" \ - -ctrlrpath "$home/.mame/ctrlr;ctrlr" \ - -inipath $home/.mame/ini \ - -rompath $home/.mame/roms \ - -samplepath $home/.mame/samples \ - -cfg_directory $home/.mame/cfg \ - -comment_directory $home/.mame/comments \ - -diff_directory $home/.mame/diff \ - -input_directory $home/.mame/inp \ - -nvram_directory $home/.mame/nvram \ - -snapshot_directory $home/.mame/snap \ - -state_directory $home/.mame/sta \ - -video opengl \ - -createconfig -else - cd /usr/lib/mame - ./mame "$@" +} + +if [ "$1" = "--newini" ]; then + mame_first_run + exit +elif ! [ -e ~/.mame ]; then + echo "Running MAME for the first time..." + + mkdir -- ~/.mame + ( + cd -- ~/.mame || exit + mkdir artwork cfg comments ctrlr diff ini inp nvram samples snap sta roms + + mame_first_run + ) || exit fi + +exec "$mame" "$@"