setting up
This commit is contained in:
84
scripts/bundle.sh
Executable file
84
scripts/bundle.sh
Executable file
@@ -0,0 +1,84 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
EXT_DIR="$ROOT/extensions"
|
||||
TMP="$(mktemp -d)"
|
||||
trap 'rm -rf "$TMP"' EXIT
|
||||
|
||||
mkdir -p "$EXT_DIR"
|
||||
|
||||
# Format: name|repo_url|branch|dest_subdir_under_extensions
|
||||
REPOS=(
|
||||
"boxbot3000|https://github.com/jondale/boxbot3000.git|main|boxbot3000"
|
||||
"km-living-hinge|https://github.com/KnoxMakers/km-living-hinge.git|main|km-living-hinge"
|
||||
"km-plot|https://git.knoxmakers.org/KnoxMakers/km-plot.git|main|km-plot"
|
||||
)
|
||||
|
||||
sync_one() {
|
||||
local name="$1" url="$2" branch="$3" dest="$4"
|
||||
local work="$TMP/$name"
|
||||
local target="$EXT_DIR/$dest"
|
||||
|
||||
echo "==> Sync $name from $url ($branch) -> extensions/$dest"
|
||||
|
||||
git clone --depth 1 --branch "$branch" "$url" "$work"
|
||||
|
||||
rm -rf "$target"
|
||||
mkdir -p "$target"
|
||||
cp -a "$work/." "$target/"
|
||||
rm -rf "$target/.git"
|
||||
|
||||
# Provenance
|
||||
(cd "$work" && git rev-parse HEAD) > "$target/.upstream_commit"
|
||||
echo "$url" > "$target/.upstream_url"
|
||||
echo "$branch" > "$target/.upstream_branch"
|
||||
}
|
||||
|
||||
post_process() {
|
||||
echo "==> Post-processing bundled extensions"
|
||||
|
||||
local inx="$EXT_DIR/boxbot3000/botbox.inx"
|
||||
if [[ ! -f "$inx" ]]; then
|
||||
echo "ERROR: expected file not found: $inx"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Patching $inx"
|
||||
|
||||
# 1) Set the <id>...</id>
|
||||
sed -i 's|<id>[^<]*</id>|<id>org.knoxmakers.botbox</id>|' "$inx"
|
||||
|
||||
# 2) Replace the <effectsmenu>...</effectsmenu> block
|
||||
sed -i '/<effectsmenu>/,/<\/effectsmenu>/c\
|
||||
<effectsmenu>\
|
||||
<submenu _name="Knox Makers">\
|
||||
<submenu _name="Laser"/>\
|
||||
</submenu>\
|
||||
</effectsmenu>' "$inx"
|
||||
}
|
||||
|
||||
main() {
|
||||
# Sync phase
|
||||
for entry in "${REPOS[@]}"; do
|
||||
IFS='|' read -r name url branch dest <<<"$entry"
|
||||
sync_one "$name" "$url" "$branch" "$dest"
|
||||
done
|
||||
|
||||
# Post-processing phase
|
||||
post_process
|
||||
|
||||
# Commit phase
|
||||
cd "$ROOT"
|
||||
git add extensions
|
||||
|
||||
if git diff --cached --quiet; then
|
||||
echo "No bundle changes."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
git commit -m "bundle: update ($(date -u +%Y-%m-%d))"
|
||||
}
|
||||
|
||||
main "$@"
|
||||
|
||||
Reference in New Issue
Block a user