wolf: fix TI-99/4A ES-DE command line never actually updating on re-run

Confirmed live: the command-line fix from an earlier commit (cd into
emulators/ before launching ti99sim-sdl) never reached the user's actual
es_systems.xml, because the write step's guard was "skip entirely if a
ti994a entry already exists" — which it did, with the old pre-fix
command line still in it. The check only asked whether an entry existed,
never whether its content matched the current template.

Now always strips any existing ti994a <system> block and re-adds the
current one fresh on every run, via a small python3 rewrite (regex block
removal + re-append) instead of a blind append-once guard. Tested against
a stand-in file matching the real stale content, and for idempotency
(second run doesn't duplicate the block), before pushing.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VLX1yYKJExGSXmgUhxKQG6
This commit is contained in:
Claude
2026-09-02 19:28:28 +00:00
parent 0fe0c74235
commit b4ac5a4de0
+23 -13
View File
@@ -966,12 +966,22 @@ UDEV
if [[ "$_GET_TI99" =~ ^[Yy]$ ]]; then
mkdir -p "$GAME_STORAGE_DIR/esde-custom-systems" "$GAME_STORAGE_DIR/roms/ti994a"
local _TI99_XML="$GAME_STORAGE_DIR/esde-custom-systems/es_systems.xml"
if [ ! -f "$_TI99_XML" ] || ! grep -q '<name>ti994a</name>' "$_TI99_XML" 2>/dev/null; then
backup_if_exists "$_TI99_XML"
[ -f "$_TI99_XML" ] || echo '<systemList>' > "$_TI99_XML"
sed -i 's#</systemList>##' "$_TI99_XML" 2>/dev/null
cat >> "$_TI99_XML" << 'XMLEOF'
<system>
backup_if_exists "$_TI99_XML"
# Always strip and re-add the ti994a block rather than "skip if
# already present" — confirmed live: that check left a stale
# <command> line in place across a real fix to it, since existing
# was already "present" and the check never looked at whether its
# content matched the current template.
python3 - "$_TI99_XML" << 'TI99XMLPY'
import re, sys
path = sys.argv[1]
try:
with open(path) as f:
content = f.read()
except FileNotFoundError:
content = '<systemList>\n</systemList>\n'
content = re.sub(r'[ \t]*<system>\s*<name>ti994a</name>.*?</system>\s*\n?', '', content, flags=re.DOTALL)
block = ''' <system>
<name>ti994a</name>
<fullname>Texas Instruments TI-99/4A</fullname>
<path>%ROMPATH%/ti994a</path>
@@ -980,13 +990,13 @@ UDEV
<platform>ti99</platform>
<theme>ti99</theme>
</system>
</systemList>
XMLEOF
chown "$ACTUAL_USER:$ACTUAL_USER" "$_TI99_XML"
log_success "TI-99/4A added as an ES-DE system (roms/ti994a/, custom_systems/es_systems.xml)"
else
log_info "TI-99/4A system definition already present — left as-is."
fi
'''
content = content.replace('</systemList>', block + '</systemList>')
with open(path, 'w') as f:
f.write(content)
TI99XMLPY
chown "$ACTUAL_USER:$ACTUAL_USER" "$_TI99_XML"
log_success "TI-99/4A ES-DE system definition written/refreshed (roms/ti994a/, custom_systems/es_systems.xml)"
echo ""
if [ ! -x "$GAME_STORAGE_DIR/emulators/ti99sim-sdl" ]; then
# Build inside a container running the EXACT SAME image ES-DE