ffbe098ef8
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.
174 lines
5.0 KiB
Bash
Executable File
174 lines
5.0 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Red Bear OS — C-7 recipe edit
|
|
#
|
|
# For each recipe that has a migration patch in
|
|
# local/patches/<name>/, this script:
|
|
# 1. Identifies the sed chains in the recipe's
|
|
# [build].script that produced the migration patch
|
|
# (these are the chains the patch was captured from).
|
|
# 2. Replaces those sed chains with a single
|
|
# `cookbook_apply_patches` call.
|
|
# 3. Leaves any other sed chains (real Red Bear edits
|
|
# NOT in the migration patch) alone.
|
|
#
|
|
# This is the C-7 step 2: migrate the recipe's build
|
|
# script from inline sed hacks to the durable external
|
|
# patch helper. After this runs, the inline sed is gone
|
|
# and the cookbook's idempotency check makes the patch
|
|
# apply-once-only.
|
|
|
|
set -euo pipefail
|
|
|
|
cd "$(dirname "${BASH_SOURCE[0]}")/../.."
|
|
|
|
# All recipes with a 01-initial-migration.patch in
|
|
# local/patches/<name>/. The order matches the order
|
|
# they were migrated.
|
|
recipe_dirs=(
|
|
"local/recipes/kde/breeze"
|
|
"local/recipes/kde/kde-cli-tools"
|
|
"local/recipes/kde/kdecoration"
|
|
"local/recipes/kde/kf6-karchive"
|
|
"local/recipes/kde/kf6-kauth"
|
|
"local/recipes/kde/kf6-kbookmarks"
|
|
"local/recipes/kde/kf6-kcmutils"
|
|
"local/recipes/kde/kf6-kcodecs"
|
|
"local/recipes/kde/kf6-kcompletion"
|
|
"local/recipes/kde/kf6-kconfig"
|
|
"local/recipes/kde/kf6-kcoreaddons"
|
|
"local/recipes/kde/kf6-kdbusaddons"
|
|
"local/recipes/kde/kf6-kdeclarative"
|
|
"local/recipes/kde/kf6-kded6"
|
|
"local/recipes/kde/kf6-kglobalaccel"
|
|
"local/recipes/kde/kf6-kitemviews"
|
|
"local/recipes/kde/kf6-kjobwidgets"
|
|
"local/recipes/kde/kf6-knotifications"
|
|
"local/recipes/kde/kf6-kwayland"
|
|
"local/recipes/kde/kf6-kwidgetsaddons"
|
|
"local/recipes/kde/kf6-kwindowsystem"
|
|
"local/recipes/kde/kf6-notifyconfig"
|
|
"local/recipes/kde/kf6-solid"
|
|
"local/recipes/kde/kf6-sonnet"
|
|
"local/recipes/kde/kf6-syntaxhighlighting"
|
|
"local/recipes/kde/kglobalacceld"
|
|
"local/recipes/kde/kirigami"
|
|
"local/recipes/kde/konsole"
|
|
"local/recipes/kde/sddm"
|
|
"local/recipes/kde/kwin"
|
|
"local/recipes/kde/plasma-desktop"
|
|
"local/recipes/kde/plasma-workspace"
|
|
)
|
|
|
|
cleaned=0
|
|
skipped=0
|
|
failed=0
|
|
|
|
for recipe_dir in "${recipe_dirs[@]}"; do
|
|
name=$(basename "$recipe_dir")
|
|
recipe="$recipe_dir/recipe.toml"
|
|
patch_file="local/patches/$name/01-initial-migration.patch"
|
|
|
|
if [ ! -e "$recipe" ]; then
|
|
echo "SKIP: $name (no recipe.toml)"
|
|
skipped=$((skipped+1))
|
|
continue
|
|
fi
|
|
|
|
if [ ! -e "$patch_file" ]; then
|
|
echo "SKIP: $name (no migration patch — not migrated yet)"
|
|
skipped=$((skipped+1))
|
|
continue
|
|
fi
|
|
|
|
# Check if the recipe already calls cookbook_apply_patches.
|
|
if grep -q "cookbook_apply_patches" "$recipe"; then
|
|
echo "SKIP: $name (already migrated)"
|
|
skipped=$((skipped+1))
|
|
continue
|
|
fi
|
|
|
|
if ! grep -q "sed -i" "$recipe"; then
|
|
echo "SKIP: $name (no sed chains — likely NO-OP or already cleaned)"
|
|
skipped=$((skipped+1))
|
|
continue
|
|
fi
|
|
|
|
cp "$recipe" "$recipe.bak.$(date +%s)"
|
|
|
|
python3 - "$recipe" "$name" <<'PY'
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
recipe_path = Path(sys.argv[1])
|
|
name = sys.argv[2]
|
|
text = recipe_path.read_text()
|
|
lines = text.splitlines(keepends=True)
|
|
|
|
BS = chr(92)
|
|
|
|
# Pass 1: identify the indexes of every `sed -i` line
|
|
# and its continuations.
|
|
to_remove = set()
|
|
i = 0
|
|
while i < len(lines):
|
|
line = lines[i]
|
|
if "sed -i" in line:
|
|
to_remove.add(i)
|
|
i += 1
|
|
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))
|
|
nxt_is_continuation = (
|
|
ends_with_bs
|
|
or is_indented
|
|
or (nxt_strip.startswith("&&") and (" cd " in nxt_strip or nxt_strip.startswith("&&" + BS)))
|
|
)
|
|
if nxt_is_continuation:
|
|
to_remove.add(i)
|
|
i += 1
|
|
continue
|
|
break
|
|
continue
|
|
i += 1
|
|
|
|
# Pass 2: build the output. Insert the cookbook_apply_patches
|
|
# call in place of the FIRST removed sed, and skip all
|
|
# other removed lines.
|
|
out = []
|
|
inserted = False
|
|
for idx, line in enumerate(lines):
|
|
if idx in to_remove:
|
|
if not inserted:
|
|
out.append(
|
|
f'REDBEAR_PATCHES_DIR="${{COOKBOOK_RECIPE}}/../../../../local/patches/{name}"\n'
|
|
)
|
|
out.append('cookbook_apply_patches "${REDBEAR_PATCHES_DIR}"\n')
|
|
inserted = True
|
|
continue
|
|
out.append(line)
|
|
|
|
recipe_path.write_text("".join(out))
|
|
PY
|
|
|
|
if ! grep -q "cookbook_apply_patches" "$recipe"; then
|
|
echo "FAIL: $name (cookbook_apply_patches not inserted)"
|
|
failed=$((failed+1))
|
|
continue
|
|
fi
|
|
if grep -q "sed -i" "$recipe"; then
|
|
echo "FAIL: $name (still has sed chains)"
|
|
failed=$((failed+1))
|
|
continue
|
|
fi
|
|
|
|
echo "EDITED: $name"
|
|
cleaned=$((cleaned+1))
|
|
done
|
|
|
|
echo
|
|
echo "=== Summary ==="
|
|
echo "Edited: $cleaned"
|
|
echo "Skipped: $skipped"
|
|
echo "Failed: $failed"
|