MIME: added a tool to automatically generate the mime files based on es_systems and updated the actual mime file.

This commit is contained in:
XargonWan 2024-12-05 10:32:36 +09:00
parent c5d612809d
commit d62218c6e4
2 changed files with 392 additions and 142 deletions

View file

@ -1,145 +1,339 @@
<?xml version="1.0" encoding="UTF-8"?>
<mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info">
<mime-type type="application/retro-game">
<comment>Retro Game</comment>
<glob pattern="*.2d"/>
<glob pattern="*.2hd"/>
<glob pattern="*.2mg"/>
<glob pattern="*.32x"/>
<glob pattern="*.360"/>
<glob pattern="*.3ds"/>
<glob pattern="*.3dsen"/>
<glob pattern="*.3dsx"/>
<glob pattern="*.68k"/>
<glob pattern="*.7z"/>
<glob pattern="*.88d"/>
<glob pattern="*.98d"/>
<glob pattern="*.a26"/>
<glob pattern="*.a52"/>
<glob pattern="*.a78"/>
<glob pattern="*.abs"/>
<glob pattern="*.adf"/>
<glob pattern="*.adl"/>
<glob pattern="*.adm"/>
<glob pattern="*.ads"/>
<glob pattern="*.adz"/>
<glob pattern="*.agb"/>
<glob pattern="*.apd"/>
<glob pattern="*.app"/>
<glob pattern="*.arduboy"/>
<glob pattern="*.atr"/>
<glob pattern="*.atx"/>
<glob pattern="*.axf"/>
<glob pattern="*.bat"/>
<glob pattern="*.bbc"/>
<glob pattern="*.bin"/>
<glob pattern="*.bml"/>
<glob pattern="*.bms"/>
<glob pattern="*.bs"/>
<glob pattern="*.bsx"/>
<glob pattern="*.car"/>
<glob pattern="*.cas"/>
<glob pattern="*.cbn"/>
<glob pattern="*.ccd"/>
<glob pattern="*.cci"/>
<glob pattern="*.cdi"/>
<glob pattern="*.cdm"/>
<glob pattern="*.cdr"/>
<glob pattern="*.cdt"/>
<glob pattern="*.cgb"/>
<glob pattern="*.chai"/>
<glob pattern="*.chailove"/>
<glob pattern="*.chd"/>
<glob pattern="*.chf"/>
<glob pattern="*.ciso"/>
<glob pattern="*.cmd"/>
<glob pattern="*.cmt"/>
<glob pattern="*.cof"/>
<glob pattern="*.col"/>
<glob pattern="*.com"/>
<glob pattern="*.conf"/>
<glob pattern="*.cpr"/>
<glob pattern="*.cqi"/>
<glob pattern="*.cqm"/>
<glob pattern="*.crt"/>
<glob pattern="*.cso"/>
<glob pattern="*.csw"/>
<glob pattern="*.cue"/>
<glob pattern="*.cv"/>
<glob pattern="*.cxi"/>
<glob pattern="*.d2m"/>
<glob pattern="*.d4m"/>
<glob pattern="*.d64"/>
<glob pattern="*.d6z"/>
<glob pattern="*.d71"/>
<glob pattern="*.d77"/>
<glob pattern="*.d7z"/>
<glob pattern="*.d80"/>
<glob pattern="*.d81"/>
<glob pattern="*.d82"/>
<glob pattern="*.d88"/>
<glob pattern="*.d8z"/>
<glob pattern="*.d98"/>
<glob pattern="*.dat"/>
<glob pattern="*.ddp"/>
<glob pattern="*.dfi"/>c
<glob pattern="*.dim"/>
<glob pattern="*.dms"/>
<glob pattern="*.do"/>
<glob pattern="*.doom"/>
<glob pattern="*.dol"/>
<glob pattern="*.dosz"/>
<glob pattern="*.dsk"/>
<glob pattern="*.dump"/>
<glob pattern="*.dx1"/>
<glob pattern="*.easyrpg"/>
<glob pattern="*.ecm"/>
<glob pattern="*.elf"/>
<glob pattern="*.exe"/>
<glob pattern="*.fdi"/>
<glob pattern="*.gb"/>
<glob pattern="*.gba"/>
<glob pattern="*.gbc"/>
<glob pattern="*.gc"/>
<glob pattern="*.gen"/>
<glob pattern="*.gg"/>
<glob pattern="*.fds"/>
<glob pattern="*.gdi"/>
<glob pattern="*.hdf"/>
<glob pattern="*.hdz"/>
<glob pattern="*.img"/>
<glob pattern="*.ipf"/>
<glob pattern="*.iso"/>
<glob pattern="*.kcr"/>
<glob pattern="*.lha"/>
<glob pattern="*.m3u"/>
<glob pattern="*.md"/>
<glob pattern="*.mds"/>
<glob pattern="*.mdx"/>
<glob pattern="*.nes"/>
<glob pattern="*.ngc"/>
<glob pattern="*.ngp"/>
<glob pattern="*.ngpc"/>
<glob pattern="*.nsp"/>
<glob pattern="*.npc"/>
<glob pattern="*.nrg"/>
<glob pattern="*.psvita"/>
<glob pattern="*.pkg"/>
<glob pattern="*.rom"/>
<glob pattern="*.rp9"/>
<glob pattern="*.rvz"/>
<glob pattern="*.sg"/>
<glob pattern="*.sgd"/>
<glob pattern="*.smd"/>
<glob pattern="*.sms"/>
<glob pattern="*.sna"/>
<glob pattern="*.scummvm"/>
<glob pattern="*.tap"/>
<glob pattern="*.uae"/>
<glob pattern="*.voc"/>
<glob pattern="*.wad"/>
<glob pattern="*.wbfs"/>
<glob pattern="*.wua"/>
<glob pattern="*.zip"/>
</mime-type>
<mime-type type="application/retro-game">
<comment>Retro Game</comment>
<glob pattern="*.0"/>
<glob pattern="*.1dd"/>
<glob pattern="*.2d"/>
<glob pattern="*.2hd"/>
<glob pattern="*.2mg"/>
<glob pattern="*.32x"/>
<glob pattern="*.360"/>
<glob pattern="*.3ds"/>
<glob pattern="*.3dsen"/>
<glob pattern="*.3dsx"/>
<glob pattern="*.68k"/>
<glob pattern="*.7z"/>
<glob pattern="*.88d"/>
<glob pattern="*.98d"/>
<glob pattern="*.a26"/>
<glob pattern="*.a52"/>
<glob pattern="*.a78"/>
<glob pattern="*.abs"/>
<glob pattern="*.adf"/>
<glob pattern="*.adl"/>
<glob pattern="*.adm"/>
<glob pattern="*.ads"/>
<glob pattern="*.adz"/>
<glob pattern="*.agb"/>
<glob pattern="*.apd"/>
<glob pattern="*.app"/>
<glob pattern="*.arcadedef"/>
<glob pattern="*.arduboy"/>
<glob pattern="*.atr"/>
<glob pattern="*.atx"/>
<glob pattern="*.axf"/>
<glob pattern="*.bat"/>
<glob pattern="*.bbc"/>
<glob pattern="*.bin"/>
<glob pattern="*.bml"/>
<glob pattern="*.bms"/>
<glob pattern="*.bs"/>
<glob pattern="*.bsx"/>
<glob pattern="*.car"/>
<glob pattern="*.cas"/>
<glob pattern="*.cbn"/>
<glob pattern="*.ccc"/>
<glob pattern="*.ccd"/>
<glob pattern="*.cci"/>
<glob pattern="*.cdi"/>
<glob pattern="*.cdm"/>
<glob pattern="*.cdr"/>
<glob pattern="*.cdt"/>
<glob pattern="*.cgb"/>
<glob pattern="*.chai"/>
<glob pattern="*.chailove"/>
<glob pattern="*.chd"/>
<glob pattern="*.chf"/>
<glob pattern="*.ciso"/>
<glob pattern="*.cmd"/>
<glob pattern="*.cmt"/>
<glob pattern="*.cof"/>
<glob pattern="*.col"/>
<glob pattern="*.com"/>
<glob pattern="*.conf"/>
<glob pattern="*.cpr"/>
<glob pattern="*.cqi"/>
<glob pattern="*.cqm"/>
<glob pattern="*.crt"/>
<glob pattern="*.cso"/>
<glob pattern="*.csw"/>
<glob pattern="*.cue"/>
<glob pattern="*.cv"/>
<glob pattern="*.cxi"/>
<glob pattern="*.d2m"/>
<glob pattern="*.d4m"/>
<glob pattern="*.d64"/>
<glob pattern="*.d6z"/>
<glob pattern="*.d71"/>
<glob pattern="*.d77"/>
<glob pattern="*.d7z"/>
<glob pattern="*.d80"/>
<glob pattern="*.d81"/>
<glob pattern="*.d82"/>
<glob pattern="*.d88"/>
<glob pattern="*.d8z"/>
<glob pattern="*.d98"/>
<glob pattern="*.daphne"/>
<glob pattern="*.dat"/>
<glob pattern="*.ddp"/>
<glob pattern="*.desktop"/>
<glob pattern="*.dff"/>
<glob pattern="*.dfi"/>
<glob pattern="*.di1"/>
<glob pattern="*.di2"/>
<glob pattern="*.dim"/>
<glob pattern="*.dirksimple"/>
<glob pattern="*.dmg"/>
<glob pattern="*.dmk"/>
<glob pattern="*.dms"/>
<glob pattern="*.do"/>
<glob pattern="*.dol"/>
<glob pattern="*.doom"/>
<glob pattern="*.dosz"/>
<glob pattern="*.dsd"/>
<glob pattern="*.dsk"/>
<glob pattern="*.dump"/>
<glob pattern="*.dup"/>
<glob pattern="*.dx1"/>
<glob pattern="*.dx2"/>
<glob pattern="*.easyrpg"/>
<glob pattern="*.ecm"/>
<glob pattern="*.elf"/>
<glob pattern="*.exe"/>
<glob pattern="*.fd"/>
<glob pattern="*.fd1"/>
<glob pattern="*.fd2"/>
<glob pattern="*.fdd"/>
<glob pattern="*.fdi"/>
<glob pattern="*.fds"/>
<glob pattern="*.fig"/>
<glob pattern="*.fpt"/>
<glob pattern="*.g41"/>
<glob pattern="*.g4z"/>
<glob pattern="*.g64"/>
<glob pattern="*.g6z"/>
<glob pattern="*.gam"/>
<glob pattern="*.game"/>
<glob pattern="*.gb"/>
<glob pattern="*.gba"/>
<glob pattern="*.gbc"/>
<glob pattern="*.gcm"/>
<glob pattern="*.gcz"/>
<glob pattern="*.gd3"/>
<glob pattern="*.gd7"/>
<glob pattern="*.gdi"/>
<glob pattern="*.gen"/>
<glob pattern="*.gg"/>
<glob pattern="*.gz"/>
<glob pattern="*.hdd"/>
<glob pattern="*.hdf"/>
<glob pattern="*.hdi"/>
<glob pattern="*.hdm"/>
<glob pattern="*.hdn"/>
<glob pattern="*.hdz"/>
<glob pattern="*.hex"/>
<glob pattern="*.hfe"/>
<glob pattern="*.ima"/>
<glob pattern="*.imd"/>
<glob pattern="*.img"/>
<glob pattern="*.int"/>
<glob pattern="*.ipf"/>
<glob pattern="*.ipk3"/>
<glob pattern="*.iso"/>
<glob pattern="*.isz"/>
<glob pattern="*.iwad"/>
<glob pattern="*.j64"/>
<glob pattern="*.jag"/>
<glob pattern="*.jar"/>
<glob pattern="*.jfd"/>
<glob pattern="*.json"/>
<glob pattern="*.k7"/>
<glob pattern="*.kcr"/>
<glob pattern="*.lha"/>
<glob pattern="*.lnx"/>
<glob pattern="*.lst"/>
<glob pattern="*.lua"/>
<glob pattern="*.lutro"/>
<glob pattern="*.m3u"/>
<glob pattern="*.m5"/>
<glob pattern="*.m7"/>
<glob pattern="*.md"/>
<glob pattern="*.mdf"/>
<glob pattern="*.mds"/>
<glob pattern="*.mdx"/>
<glob pattern="*.mfi"/>
<glob pattern="*.mfm"/>
<glob pattern="*.mgd"/>
<glob pattern="*.mgt"/>
<glob pattern="*.mgw"/>
<glob pattern="*.min"/>
<glob pattern="*.minipsf"/>
<glob pattern="*.msa"/>
<glob pattern="*.mugen"/>
<glob pattern="*.mx1"/>
<glob pattern="*.mx2"/>
<glob pattern="*.n64"/>
<glob pattern="*.nbz"/>
<glob pattern="*.nca"/>
<glob pattern="*.ndd"/>
<glob pattern="*.nds"/>
<glob pattern="*.neo"/>
<glob pattern="*.nes"/>
<glob pattern="*.nex"/>
<glob pattern="*.ngage"/>
<glob pattern="*.ngc"/>
<glob pattern="*.ngp"/>
<glob pattern="*.ngpc"/>
<glob pattern="*.ngr"/>
<glob pattern="*.nhd"/>
<glob pattern="*.nib"/>
<glob pattern="*.npc"/>
<glob pattern="*.nrg"/>
<glob pattern="*.nro"/>
<glob pattern="*.nso"/>
<glob pattern="*.nsp"/>
<glob pattern="*.nx"/>
<glob pattern="*.o"/>
<glob pattern="*.ogv"/>
<glob pattern="*.ort"/>
<glob pattern="*.p"/>
<glob pattern="*.p00"/>
<glob pattern="*.p8"/>
<glob pattern="*.pak"/>
<glob pattern="*.pbp"/>
<glob pattern="*.pc2"/>
<glob pattern="*.pce"/>
<glob pattern="*.phd"/>
<glob pattern="*.pk3"/>
<glob pattern="*.pk4"/>
<glob pattern="*.png"/>
<glob pattern="*.po"/>
<glob pattern="*.pqa"/>
<glob pattern="*.prc"/>
<glob pattern="*.prg"/>
<glob pattern="*.prx"/>
<glob pattern="*.ps3"/>
<glob pattern="*.ps3dir"/>
<glob pattern="*.psexe"/>
<glob pattern="*.psf"/>
<glob pattern="*.psvita"/>
<glob pattern="*.psx"/>
<glob pattern="*.pwad"/>
<glob pattern="*.ri"/>
<glob pattern="*.rom"/>
<glob pattern="*.rp9"/>
<glob pattern="*.rpk"/>
<glob pattern="*.rpx"/>
<glob pattern="*.rvz"/>
<glob pattern="*.rzx"/>
<glob pattern="*.sad"/>
<glob pattern="*.sap"/>
<glob pattern="*.sbt"/>
<glob pattern="*.sc"/>
<glob pattern="*.scl"/>
<glob pattern="*.scummvm"/>
<glob pattern="*.sfc"/>
<glob pattern="*.sg"/>
<glob pattern="*.sgb"/>
<glob pattern="*.sgd"/>
<glob pattern="*.sgx"/>
<glob pattern="*.sh"/>
<glob pattern="*.singe"/>
<glob pattern="*.sis"/>
<glob pattern="*.sisx"/>
<glob pattern="*.smc"/>
<glob pattern="*.smd"/>
<glob pattern="*.sms"/>
<glob pattern="*.sna"/>
<glob pattern="*.solarus"/>
<glob pattern="*.ssd"/>
<glob pattern="*.st"/>
<glob pattern="*.stx"/>
<glob pattern="*.sv"/>
<glob pattern="*.svm"/>
<glob pattern="*.swc"/>
<glob pattern="*.swf"/>
<glob pattern="*.symbian"/>
<glob pattern="*.szx"/>
<glob pattern="*.t64"/>
<glob pattern="*.t77"/>
<glob pattern="*.t88"/>
<glob pattern="*.tap"/>
<glob pattern="*.tar"/>
<glob pattern="*.td0"/>
<glob pattern="*.tfd"/>
<glob pattern="*.tgc"/>
<glob pattern="*.thd"/>
<glob pattern="*.tic"/>
<glob pattern="*.tmd"/>
<glob pattern="*.toc"/>
<glob pattern="*.trd"/>
<glob pattern="*.tzx"/>
<glob pattern="*.u1"/>
<glob pattern="*.u88"/>
<glob pattern="*.uae"/>
<glob pattern="*.udi"/>
<glob pattern="*.uef"/>
<glob pattern="*.ufi"/>
<glob pattern="*.unf"/>
<glob pattern="*.unif"/>
<glob pattern="*.uze"/>
<glob pattern="*.v64"/>
<glob pattern="*.vb"/>
<glob pattern="*.vboy"/>
<glob pattern="*.vc"/>
<glob pattern="*.vec"/>
<glob pattern="*.vfl"/>
<glob pattern="*.voc"/>
<glob pattern="*.vpt"/>
<glob pattern="*.vpx"/>
<glob pattern="*.vsf"/>
<glob pattern="*.wad"/>
<glob pattern="*.wasm"/>
<glob pattern="*.wav"/>
<glob pattern="*.wbfs"/>
<glob pattern="*.wia"/>
<glob pattern="*.ws"/>
<glob pattern="*.wsc"/>
<glob pattern="*.wua"/>
<glob pattern="*.wud"/>
<glob pattern="*.wuhb"/>
<glob pattern="*.wux"/>
<glob pattern="*.x64"/>
<glob pattern="*.x6z"/>
<glob pattern="*.xbe"/>
<glob pattern="*.xci"/>
<glob pattern="*.xdf"/>
<glob pattern="*.xex"/>
<glob pattern="*.xfd"/>
<glob pattern="*.xsa"/>
<glob pattern="*.z"/>
<glob pattern="*.z1"/>
<glob pattern="*.z2"/>
<glob pattern="*.z3"/>
<glob pattern="*.z4"/>
<glob pattern="*.z5"/>
<glob pattern="*.z6"/>
<glob pattern="*.z64"/>
<glob pattern="*.z7"/>
<glob pattern="*.z8"/>
<glob pattern="*.z80"/>
<glob pattern="*.zar"/>
<glob pattern="*.zblorb"/>
<glob pattern="*.zip"/>
<glob pattern="*.zlb"/>
<glob pattern="*.znx"/>
<glob pattern="*.zso"/>
</mime-type>
</mime-info>

View file

@ -0,0 +1,56 @@
#!/bin/bash
# Input files
ES_SYSTEMS_FILE="../ES-DE/resources/systems/linux/es_systems.xml"
MIME_FILE="config/retrodeck/net.retrodeck.retrodeck.mime.xml"
# List of extensions to ignore
IGNORED_EXTENSIONS=". .appimage cue"
# Check if xmlstarlet is installed
if ! command -v xmlstarlet &> /dev/null; then
echo "Error: xmlstarlet is not installed."
echo "Please install it using your package manager (e.g., sudo apt install xmlstarlet)."
exit 1
fi
# Temporary files
EXTENSIONS_FILE=$(mktemp)
# Extract extensions from the <extension> field in es_systems.xml
grep -oP '<extension>\K.*?(?=</extension>)' "$ES_SYSTEMS_FILE" | \
tr ' ' '\n' | \
awk '{print tolower($0)}' | \
sort -u > "$EXTENSIONS_FILE"
# Create a new MIME file with the correct base structure
cat > "$MIME_FILE" << EOF
<?xml version="1.0" encoding="UTF-8"?>
<mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info">
<mime-type type="application/retro-game">
<comment>Retro Game</comment>
EOF
# Add new <glob> elements to the MIME file
while IFS= read -r ext; do
# Skip ignored extensions
if [[ "$IGNORED_EXTENSIONS" =~ (^|[[:space:]])"$ext"($|[[:space:]]) ]]; then
echo "Skipping ignored extension: $ext"
continue
fi
# Add the <glob> element for the extension
echo "Adding glob pattern for extension: $ext"
echo " <glob pattern=\"*$ext\"/>" >> "$MIME_FILE"
done < "$EXTENSIONS_FILE"
# Close the XML tags
echo " </mime-type>
</mime-info>" >> "$MIME_FILE"
# Ensure proper formatting using xmlstarlet
xmlstarlet fo --indent-tab "$MIME_FILE" > "$MIME_FILE.tmp" && mv "$MIME_FILE.tmp" "$MIME_FILE"
# Clean up temporary files
rm -f "$EXTENSIONS_FILE"
echo "MIME file updated successfully at $MIME_FILE"