From 2f9fd42a91a25c90fb4d7f0a46071e0a5fccbab5 Mon Sep 17 00:00:00 2001 From: ZGaetano Date: Wed, 6 May 2026 16:16:57 -0400 Subject: [PATCH] chore: add build scaffolding, overlay structure, CI workflow: apply-overlay.sh --- apply-overlay.sh | 67 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 apply-overlay.sh diff --git a/apply-overlay.sh b/apply-overlay.sh new file mode 100644 index 0000000..4be039e --- /dev/null +++ b/apply-overlay.sh @@ -0,0 +1,67 @@ +#!/bin/sh +# apply-overlay.sh — Wild Dragon reskin applied to a freshly cloned +# datarhei/restreamer-ui tree. Two phases: +# +# 1. File overlay: cp the contents of $OVERLAY/{public,src} on top of +# the upstream working tree. Whole-file replacements only — simple +# and idempotent. Modified views (Edit/index.js, Main/index.js) and +# all new components (WHEP.js, WHEPStatus.js, Logo/) live here. +# +# 2. Targeted awk patches for one-line UI strings that aren't worth a +# whole-file overlay (the header title, welcome strings). Each +# pattern is anchored to unique surrounding context so a future +# upstream rename fails loudly rather than silently no-op'ing. +# +# Caller: the Dockerfile ui-builder stage. Expects: +# $OVERLAY = /overlay (repo overlay/ COPYd into the build) +# $UI = /ui (cloned upstream source root) +# +# Idempotent on a single source tree (re-running is a no-op). + +set -eu + +OVERLAY="${OVERLAY:-/overlay}" +UI="${UI:-/ui}" + +echo "wilddragon-overlay: layering $OVERLAY -> $UI" + +# Phase 1 — file copies. -L follows symlinks, -p preserves perms, +# -R recursive. --delete is intentionally omitted: the upstream tree +# stays intact except for the files we override. +for sub in public src; do + if [ -d "$OVERLAY/$sub" ]; then + cp -RLp "$OVERLAY/$sub/." "$UI/$src/" + fi +done + +# Phase 2 — targeted awk patches. Fails loudly if the needle is missing +# (upstream changed the patched line). +patch_line() { + file="$1"; needle="$2"; replacement="$3" + if ! grep -qF "$needle" "$file"; then + echo "wilddragon-overlay: ERROR — pattern not found in $file:" + echo " $needle" + exit 1 + fi + tmp="$(mktemp)" + awk -v n="$needle" -v r="$replacement" ' + index($0, n) { sub(n, r); } + { print } + ' "$file" > "$tmp" + mv "$tmp" "$file" + echo "wilddragon-overlay: patched $(basename "$file") — $needle -> $replacement" +} + +patch_line "$UI/src/Header.js" \ + 'Restreamer' \ + 'Wild Dragon' + +patch_line "$UI/src/views/Welcome.js" \ + 'title="Welcome to Restreamer v2"' \ + 'title="Welcome to Wild Dragon"' + +patch_line "$UI/src/views/Settings.js" \ + 'title="Welcome to Restreamer v2"' \ + 'title="Welcome to Wild Dragon"' + +echo "wilddragon-overlay: done."