fix: defensive ServiceProvider (class_exists guards), fixed install.sh apply_patch logic

This commit is contained in:
2026-06-11 21:05:57 -05:00
parent 338dc52f76
commit d413bca7e9
3 changed files with 103 additions and 45 deletions

View File

@@ -133,15 +133,22 @@ apply_patch() {
local REPLACE="$3"
local LABEL="$4"
if grep -qF "$SEARCH" "$FILE"; then
# Check if the injected content is already present (not the anchor)
if grep -qF "$REPLACE" "$FILE"; then
warn "Patch '${LABEL}' already applied — skipping."
return 0
fi
if ! grep -qF "$REPLACE" "$FILE"; then
# Use python for reliable multiline sed (available on most Linux)
python3 -c "
if ! grep -qF "$SEARCH" "$FILE"; then
warn "Anchor '${SEARCH}' not found in ${FILE} — skipping patch '${LABEL}'."
return 0
fi
python3 -c "
import sys
content = open('$FILE').read()
if '''$REPLACE''' in content:
sys.exit(0)
if '''$SEARCH''' not in content:
sys.stderr.write('WARN: anchor not found in $FILE\n')
sys.exit(0)
@@ -149,7 +156,6 @@ content = content.replace('''$SEARCH''', '''$SEARCH\n$REPLACE''', 1)
open('$FILE','w').write(content)
"
success "Patch applied: ${LABEL}"
fi
}
# Patch 1: AppServiceProvider — register addon