2020-06-16 15:37:14 +00:00
|
|
|
#!/usr/bin/bash
|
2021-05-14 16:52:38 +00:00
|
|
|
# SPDX-License-Identifier: MIT
|
2020-06-16 15:37:14 +00:00
|
|
|
#
|
2021-05-14 16:52:38 +00:00
|
|
|
# EmulationStation Desktop Edition
|
|
|
|
# mame_create_index_files.sh
|
2020-06-16 15:37:14 +00:00
|
|
|
#
|
2021-05-14 16:52:38 +00:00
|
|
|
# As input, this script takes the MAME driver information XML file from the official
|
|
|
|
# MAME release and generates the files mamebioses.xml, mamedevices.xml and mamenames.xml.
|
2020-06-16 15:37:14 +00:00
|
|
|
#
|
2021-05-14 16:52:38 +00:00
|
|
|
# There is not much error checking going on here, this script is not intended to be run
|
|
|
|
# by the end user.
|
2020-06-16 15:37:14 +00:00
|
|
|
#
|
2021-05-14 16:52:38 +00:00
|
|
|
# xmlstarlet must be installed or this script will fail.
|
2020-06-16 15:37:14 +00:00
|
|
|
#
|
2021-05-14 16:52:38 +00:00
|
|
|
# Download the driver file from here:
|
|
|
|
# https://www.mamedev.org/release.php
|
|
|
|
# It's enough to download the driver information, not the complete emulator.
|
2020-06-16 15:37:14 +00:00
|
|
|
#
|
2021-05-14 16:52:38 +00:00
|
|
|
# This script is only intended to be used on Linux systems.
|
2020-06-16 15:37:14 +00:00
|
|
|
#
|
|
|
|
|
|
|
|
if [ $# -ne 1 ]; then
|
|
|
|
echo "Usage: ./mame_create_index_files.sh <MAME driver file>"
|
|
|
|
echo "For example:"
|
|
|
|
echo "./mame_create_index_files.sh mame0221.xml"
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ ! -f $1 ]; then
|
2020-06-16 16:07:06 +00:00
|
|
|
echo "Can't find MAME driver file" $1
|
2020-06-16 15:37:14 +00:00
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
|
|
|
MAME_XML_FILE=$1
|
|
|
|
MAMEBIOSFILE=mamebioses.xml
|
|
|
|
MAMEDEVICEFILE=mamedevices.xml
|
|
|
|
MAMENAMEFILE=mamenames.xml
|
|
|
|
|
2020-06-16 16:07:06 +00:00
|
|
|
echo "<!-- Last updated with information from MAME driver file" $1 "-->" > $MAMEBIOSFILE
|
2020-06-16 15:37:14 +00:00
|
|
|
|
2020-06-16 16:07:06 +00:00
|
|
|
for bios in $(xmlstarlet sel -t -m "/mame/machine[@isbios=\"yes\"]" -v "@name" \
|
|
|
|
-n $MAME_XML_FILE); do
|
2020-06-16 15:37:14 +00:00
|
|
|
echo "<bios>"${bios}"</bios>" >> $MAMEBIOSFILE
|
|
|
|
done
|
|
|
|
|
2020-06-16 16:07:06 +00:00
|
|
|
echo "<!-- Last updated with information from MAME driver file" $1 "-->" > $MAMEDEVICEFILE
|
2020-06-16 15:37:14 +00:00
|
|
|
|
2020-06-16 16:07:06 +00:00
|
|
|
for device in $(xmlstarlet sel -t -m "/mame/machine[@isdevice=\"yes\"][rom]" \
|
|
|
|
-v "@name" -n $MAME_XML_FILE); do
|
2020-06-16 15:37:14 +00:00
|
|
|
echo "<device>"${device}"</device>" >> $MAMEDEVICEFILE
|
|
|
|
done
|
|
|
|
|
|
|
|
echo "<!-- Generated from MAME driver file" $1 "-->" > $MAMENAMEFILE
|
|
|
|
|
2020-06-16 16:07:06 +00:00
|
|
|
xmlstarlet sel -t -m "/mame/machine[not(@isbios=\"yes\")][not(@isdevice=\"yes\")][rom]" \
|
|
|
|
-v "@name" -o " " -v description -n $MAME_XML_FILE | \
|
2020-06-16 15:37:14 +00:00
|
|
|
awk '{ print "<mamename>" $1 "</mamename>"; print $1=""; print "<realname>" $0 "</realname>"}' | \
|
2020-06-16 16:07:06 +00:00
|
|
|
sed s/"realname> "/"realname>"/g | sed '/^[[:space:]]*$/d' | \
|
|
|
|
sed s/"<mamename"/"<game>\n\t<mamename"/g | sed s/"<realname"/"\t<realname"/g |
|
|
|
|
sed s/"<\/realname>"/"<\/realname>\n<\/game>"/g >> $MAMENAMEFILE
|