forge: step 1 — bootstrap wrapper workflow

This commit is contained in:
cj-vana
2026-05-14 12:08:59 -06:00
parent b28469d1d9
commit 346ca7cb93
19 changed files with 2192 additions and 0 deletions

31
scripts/apply-patches.sh Executable file
View File

@@ -0,0 +1,31 @@
#!/usr/bin/env bash
set -euo pipefail
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/meshcore-env.sh"
if [ ! -d "${MESHCORE_DIR}/.git" ] && [ ! -f "${MESHCORE_DIR}/.git" ]; then
echo "MeshCore submodule is missing at ${MESHCORE_DIR}" >&2
echo "Run: git submodule update --init --recursive" >&2
exit 1
fi
if [ -n "$(git -C "${MESHCORE_DIR}" status --porcelain)" ]; then
echo "MeshCore submodule has uncommitted or untracked changes; commit, export, or reset them before applying patches." >&2
exit 1
fi
shopt -s nullglob
patches=("${PATCH_DIR}"/*.patch)
shopt -u nullglob
if [ "${#patches[@]}" -eq 0 ]; then
echo "No MeshCore patches to apply. MeshCore commit: $(meshcore_commit)"
exit 0
fi
for patch in "${patches[@]}"; do
echo "Applying ${patch#${MESHCORE_FW_ROOT}/}"
git -C "${MESHCORE_DIR}" apply --index "$patch"
done
echo "Applied ${#patches[@]} MeshCore patch(es) to $(meshcore_commit)"

34
scripts/export-patches.sh Executable file
View File

@@ -0,0 +1,34 @@
#!/usr/bin/env bash
set -euo pipefail
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/meshcore-env.sh"
base_ref="${1:-origin/main}"
if [ ! -d "${MESHCORE_DIR}/.git" ] && [ ! -f "${MESHCORE_DIR}/.git" ]; then
echo "MeshCore submodule is missing at ${MESHCORE_DIR}" >&2
echo "Run: git submodule update --init --recursive" >&2
exit 1
fi
if ! git -C "${MESHCORE_DIR}" rev-parse --verify "${base_ref}" >/dev/null 2>&1; then
echo "Base ref '${base_ref}' is not available in the MeshCore submodule." >&2
exit 1
fi
if [ -n "$(git -C "${MESHCORE_DIR}" status --porcelain)" ]; then
echo "MeshCore submodule has uncommitted or untracked changes; commit them in the submodule before exporting patches." >&2
exit 1
fi
commit_count="$(git -C "${MESHCORE_DIR}" rev-list --count "${base_ref}..HEAD")"
if [ "${commit_count}" -eq 0 ]; then
echo "No MeshCore commits to export after ${base_ref}."
exit 1
fi
mkdir -p "${PATCH_DIR}"
rm -f "${PATCH_DIR}"/*.patch
git -C "${MESHCORE_DIR}" format-patch --zero-commit --no-signature --output-directory "${PATCH_DIR}" "${base_ref}..HEAD" >/dev/null
echo "Exported ${commit_count} MeshCore patch(es) to ${PATCH_DIR#${MESHCORE_FW_ROOT}/}"

22
scripts/meshcore-env.sh Executable file
View File

@@ -0,0 +1,22 @@
#!/usr/bin/env bash
meshcore_fw_repo_root() {
local script_dir
script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
(cd "${script_dir}/.." && pwd)
}
MESHCORE_FW_ROOT="${MESHCORE_FW_ROOT:-$(meshcore_fw_repo_root)}"
MESHCORE_DIR="${MESHCORE_DIR:-${MESHCORE_FW_ROOT}/vendor/MeshCore}"
PATCH_DIR="${PATCH_DIR:-${MESHCORE_FW_ROOT}/patches/meshcore}"
REPRESENTATIVE_ENVS=(
Heltec_v3_companion_radio_usb
Heltec_v3_companion_radio_ble
RAK_4631_companion_radio_usb
RAK_4631_companion_radio_ble
)
meshcore_commit() {
git -C "${MESHCORE_DIR}" rev-parse HEAD
}