42 lines
1.5 KiB
Bash
Executable File
42 lines
1.5 KiB
Bash
Executable File
#!/bin/sh
|
|
#
|
|
# ext-sync.sh -- put the recipes of ext/ into the pkgsrc tree
|
|
#
|
|
# usage: tools/ext-sync.sh [PKGSRCDIR]
|
|
#
|
|
# A fork under ext/src/<name>/ (ext/AGENTS.md) keeps its pkgsrc recipe in
|
|
# ext/src/<name>/pkgsrc/. pkgsrc builds a recipe only from inside its tree
|
|
# (the recipe includes ../../mk/bsd.pkg.mk), so this copies it to
|
|
# PKGSRCDIR/<category>/<name>, the category being the first word of the
|
|
# recipe's CATEGORIES -- the way an owned copy is kept in this tree.
|
|
# PKGSRCDIR defaults to pkgsrc/ of this tree; tools/userland.sh gives the build
|
|
# VM's copy.
|
|
#
|
|
# A copy, not a link: the source set (msrc) and the VM need real files. The
|
|
# target is only ever replaced when upstream pkgsrc does not own that path
|
|
# (`git ls-files' of the pkgsrc import is empty for it): an upstream package
|
|
# of the same name is never overwritten.
|
|
|
|
set -eu
|
|
|
|
TOP=$(cd "$(dirname "$0")/.." && pwd)
|
|
PKGSRCDIR=${1:-$TOP/pkgsrc}
|
|
|
|
for recipe in "$TOP"/ext/src/*/pkgsrc; do
|
|
[ -f "$recipe/Makefile" ] || continue
|
|
name=$(basename "$(dirname "$recipe")")
|
|
cat=$(sed -n 's/^CATEGORIES=[[:space:]]*\([^[:space:]]*\).*/\1/p' \
|
|
"$recipe/Makefile")
|
|
[ -n "$cat" ] || { echo "ext-sync: no CATEGORIES in $recipe/Makefile" >&2; exit 1; }
|
|
dst=$PKGSRCDIR/$cat/$name
|
|
if [ -d "$PKGSRCDIR/.git" ] &&
|
|
[ -n "$(git -C "$PKGSRCDIR" ls-files -- "$cat/$name" | head -1)" ]; then
|
|
echo "ext-sync: $cat/$name belongs to upstream pkgsrc, not replaced" >&2
|
|
exit 1
|
|
fi
|
|
rm -rf "$dst"
|
|
mkdir -p "$dst"
|
|
(cd "$recipe" && tar -cf - .) | (cd "$dst" && tar -xf -)
|
|
echo "ext-sync: $cat/$name"
|
|
done
|