build system: engine preserves ALL RedBear-added files across a rebase
Data-loss bug: rsync --delete during a rebase dropped RedBear-added files that carry no __redox__ token (a Redox Wayland-crash wrapper .sh, a utmp compat header, a generated D-Bus interface) because the capture was grep-on-marker only. The engine now, for EVERY vendored rebase, fetches pristine(Vold) and carries forward every committed file absent from Vold (content-agnostic, matched by path) — so RedBear additions survive. If Vold cannot be fetched it rejects (manual) rather than produce a lossy tree. New tests E20 (non-marker added file preserved) + Vold fixtures for the rebase cases. 41 tests green.
This commit is contained in:
@@ -171,47 +171,57 @@ for dir in "${RECIPES[@]}"; do
|
||||
lv=$(apply_patch "$base/source" "$pf"); [ "$lv" = FAIL ] && preject=1
|
||||
done
|
||||
|
||||
# --- capture + reapply baked delta (changes beyond patches) ---
|
||||
# --- preserve RedBear additions + reapply baked Redox deltas ---
|
||||
# This runs for EVERY vendored rebase (not only marker-bearing ones): a
|
||||
# RedBear-added file (e.g. a Redox Wayland-crash wrapper .sh, a utmp compat
|
||||
# header) has no __redox__ token, so a grep-only capture misses it and
|
||||
# rsync --delete drops it. We compare against pristine(Vold) by PATH to keep
|
||||
# every RedBear addition, content-agnostic.
|
||||
breject=0
|
||||
if [ "$baked" -gt 0 ] && [ "$vold" != unknown ]; then
|
||||
# Derive the old-version URL: replace the full version, then the
|
||||
# major.minor directory component (KDE mirrors nest tarballs under a
|
||||
# major.minor dir, e.g. .../frameworks/6.28/foo-6.28.0.tar.xz -> 6.10/foo-6.10.0).
|
||||
if [ "$vold" != unknown ]; then
|
||||
# Old-version URL: replace the full version, then the major.minor dir
|
||||
# component (KDE mirrors nest under .../6.28/foo-6.28.0 -> 6.10/foo-6.10.0).
|
||||
oldurl="${url//$vnew/$vold}"
|
||||
vnm="${vnew%.*}"; vom="${vold%.*}"
|
||||
[ "$vnm" != "$vnew" ] && [ "$vnm" != "$vom" ] && oldurl="${oldurl//$vnm/$vom}"
|
||||
if download "$oldurl" "$WORK/$name-old.tar"; then
|
||||
op="$WORK/$name-old"; rm -rf "$op"; mkdir -p "$op"; tar xf "$WORK/$name-old.tar" -C "$op" 2>/dev/null
|
||||
otop="$(tar tf "$WORK/$name-old.tar" 2>/dev/null | head -1 | cut -d/ -f1)"; mv "$op/$otop" "$op/source" 2>/dev/null
|
||||
# For each Redox-marker file uncovered by patches, port its delta onto base.
|
||||
# A shim must NEVER be silently dropped: any failure -> breject (manual).
|
||||
relroot="${dir#$ROOT/}" # repo-relative recipe dir (git show needs this)
|
||||
while IFS= read -r line; do
|
||||
rel="${line#*/source/}"
|
||||
gitf="$WORK/gitf"
|
||||
if ! git -C "$ROOT" show "HEAD:$relroot/source/$rel" > "$gitf" 2>/dev/null || [ ! -s "$gitf" ]; then
|
||||
breject=1; continue # cannot read the Redox-modified file from HEAD
|
||||
fi
|
||||
relroot="${dir#$ROOT/}" # repo-relative recipe dir (git needs this)
|
||||
gitf="$WORK/gitf"
|
||||
|
||||
# (A) Carry forward every committed file absent from pristine(Vold): these
|
||||
# are RedBear additions upstream never had. Skip the stamp and files
|
||||
# the new pristine/patches already provide.
|
||||
while IFS= read -r rel; do
|
||||
[ "$rel" = ".redbear-src-version" ] && continue
|
||||
[ -e "$op/source/$rel" ] && continue # exists upstream -> not a RedBear addition
|
||||
[ -e "$base/source/$rel" ] && continue # already provided by pristine(Vnew) or a patch
|
||||
if ! git -C "$ROOT" show "HEAD:$relroot/source/$rel" > "$gitf" 2>/dev/null; then breject=1; continue; fi
|
||||
decorrupt "$gitf" > "$gitf.clean"
|
||||
if [ ! -f "$op/source/$rel" ]; then
|
||||
# Redox-ADDED file (absent from old upstream): carry it into the new tree verbatim.
|
||||
mkdir -p "$base/source/$(dirname "$rel")"; cp "$gitf.clean" "$base/source/$rel"; continue
|
||||
fi
|
||||
if [ ! -f "$base/source/$rel" ]; then
|
||||
breject=1; continue # file existed in old upstream+HEAD but gone in new -> manual
|
||||
fi
|
||||
if diff -q "$op/source/$rel" "$gitf.clean" >/dev/null 2>&1; then
|
||||
continue # marker is upstream's own (no Redox delta) -> nothing to port
|
||||
fi
|
||||
# Capture the delta to a file — do NOT pipe diff|patch. `diff` exits 1
|
||||
# whenever the files differ (always, here), and under `set -o pipefail`
|
||||
# that makes the pipeline look failed even when patch succeeded, which
|
||||
# would false-reject EVERY shim. Check patch's own exit status instead.
|
||||
diff -u "$op/source/$rel" "$gitf.clean" > "$WORK/delta.patch" 2>/dev/null
|
||||
if ! patch --fuzz=0 -s "$base/source/$rel" < "$WORK/delta.patch" >/dev/null 2>&1; then
|
||||
breject=1 # Redox delta will not apply cleanly at new upstream -> manual
|
||||
fi
|
||||
done < <(git -C "$ROOT" grep -lI "__redox__\|Q_OS_REDOX\|defined(__redox" HEAD -- "$dir/source" 2>/dev/null)
|
||||
mkdir -p "$base/source/$(dirname "$rel")"; cp "$gitf.clean" "$base/source/$rel"
|
||||
done < <(git -C "$ROOT" ls-tree -r --name-only HEAD -- "$relroot/source" | while IFS= read -r p; do printf '%s\n' "${p#"$relroot"/source/}"; done)
|
||||
|
||||
# (B) For marker-bearing files that ALSO exist in Vold (modified upstream
|
||||
# files), port the Redox delta. Added marker files were handled by (A).
|
||||
if [ "$baked" -gt 0 ]; then
|
||||
while IFS= read -r line; do
|
||||
rel="${line#*/source/}"
|
||||
[ -f "$op/source/$rel" ] || continue # added file -> already carried by (A)
|
||||
if ! git -C "$ROOT" show "HEAD:$relroot/source/$rel" > "$gitf" 2>/dev/null || [ ! -s "$gitf" ]; then
|
||||
breject=1; continue
|
||||
fi
|
||||
decorrupt "$gitf" > "$gitf.clean"
|
||||
if [ ! -f "$base/source/$rel" ]; then breject=1; continue; fi # gone in new upstream -> manual
|
||||
diff -q "$op/source/$rel" "$gitf.clean" >/dev/null 2>&1 && continue # marker is upstream's own
|
||||
# Capture delta to a file (never pipe diff|patch: diff exits 1 on any
|
||||
# difference and pipefail would false-reject every shim).
|
||||
diff -u "$op/source/$rel" "$gitf.clean" > "$WORK/delta.patch" 2>/dev/null
|
||||
if ! patch --fuzz=0 -s "$base/source/$rel" < "$WORK/delta.patch" >/dev/null 2>&1; then
|
||||
breject=1
|
||||
fi
|
||||
done < <(git -C "$ROOT" grep -lI "__redox__\|Q_OS_REDOX\|defined(__redox" HEAD -- "$dir/source" 2>/dev/null)
|
||||
fi
|
||||
else breject=1; fi
|
||||
fi
|
||||
|
||||
|
||||
Reference in New Issue
Block a user