Files
RedBear-OS/local/scripts/cleanup-kf6-noop-seds-targeted.sh
T
vasilito ffbe098ef8 config: add tlc to redbear-mini and redbear-full; create recipe symlink
TLC (Twilight Commander) was missing from both ISO configs. Added
tlc = {} to [packages] in redbear-mini.toml and redbear-full.toml.
Created missing symlink: recipes/tui/tlc -> ../../local/recipes/tui/tlc.
2026-06-19 11:47:25 +03:00

107 lines
2.9 KiB
Bash
Executable File

#!/usr/bin/env bash
# Red Bear OS — C-7 targeted noop-sed cleanup
#
# For unclassified KF6 / Plasma / KDE recipes whose
# `ecm_install_po_files_as_qm` and `ki18n_install(po)`
# sed chains are dead (upstream 6.26.0 dropped the call)
# but which also have OTHER live sed chains, this script
# removes ONLY the ecm/ki18n chains. The other seds
# (e.g. `include(ECMQmlModule)`, `add_subdirectory(kdesu)`)
# are kept.
#
# Differs from cleanup-kf6-noop-seds.sh which removes
# ALL sed chains from a recipe — that script is for
# recipes whose entire sed chain is ecm/ki18n.
set -euo pipefail
cd "$(dirname "${BASH_SOURCE[0]}")/../.."
recipe_dirs=(
"local/recipes/kde/breeze"
"local/recipes/kde/kde-cli-tools"
"local/recipes/kde/kf6-kded6"
"local/recipes/kde/kglobalacceld"
"local/recipes/kde/plasma-desktop"
"local/recipes/kde/plasma-workspace"
)
# Only remove sed lines whose regex targets either
# `ecm_install_po_files_as_qm` or `ki18n_install(po)`.
# Other seds (`add_subdirectory(kdesu)`, `include(ECMQmlModule)`,
# `Environment=QT_QPA_PLATFORM=offscreen`, etc.) are left
# alone.
cleaned=0
skipped=0
failed=0
for recipe_dir in "${recipe_dirs[@]}"; do
name=$(basename "$recipe_dir")
recipe="$recipe_dir/recipe.toml"
if [ ! -e "$recipe" ]; then
echo "SKIP: $name (no recipe.toml)"
skipped=$((skipped+1))
continue
fi
cp "$recipe" "$recipe.bak.$(date +%s)"
python3 - "$recipe" <<'PY'
import sys
from pathlib import Path
recipe_path = Path(sys.argv[1])
text = recipe_path.read_text()
lines = text.splitlines(keepends=True)
out = []
i = 0
BS = chr(92)
NOOP_PATTERNS = ("ecm_install_po_files_as_qm", "ki18n_install(po)")
while i < len(lines):
line = lines[i]
stripped = line.strip()
if "sed -i" in line and any(p in line for p in NOOP_PATTERNS):
i += 1
just_consumed = line
while i < len(lines):
nxt_strip = lines[i].strip()
ends_with_bs = lines[i].rstrip().endswith(BS)
is_indented = lines[i].startswith(" ") or lines[i].startswith(chr(9))
if ends_with_bs or is_indented:
just_consumed = lines[i]
i += 1
continue
if nxt_strip.startswith("&&") and (" cd " in nxt_strip or nxt_strip.startswith("&&" + BS)):
just_consumed = lines[i]
i += 1
continue
break
continue
out.append(line)
i += 1
recipe_path.write_text("".join(out))
PY
n_remaining=$(grep -cE 'sed -i.*(ecm_install_po_files_as_qm|ki18n_install\(po\))' "$recipe" 2>/dev/null || true)
n_remaining=${n_remaining:-0}
if [ "$n_remaining" -ne 0 ]; then
echo "FAIL: $name still has $n_remaining ecm/ki18n sed lines"
failed=$((failed+1))
continue
fi
echo "CLEAN: $name"
cleaned=$((cleaned+1))
done
echo
echo "=== Summary ==="
echo "Cleaned: $cleaned"
echo "Skipped: $skipped"
echo "Failed: $failed"