58 lines
1.4 KiB
Bash
Executable File
58 lines
1.4 KiB
Bash
Executable File
#!/usr/bin/env sh
|
|
set -o errexit
|
|
|
|
build_exclude_arg() {
|
|
x="$1"
|
|
if [ -n "$x" ]; then
|
|
set -- -path "$x" -prune -o
|
|
exclude_arg="$*"
|
|
else
|
|
set -- exclude_arg
|
|
fi
|
|
}
|
|
|
|
build_pkgs() {
|
|
pkg_root="$1"
|
|
build_exclude_arg "$2"
|
|
|
|
# shellcheck disable=2086
|
|
find "$pkg_root" $exclude_arg -name "PKGBUILD" \
|
|
-exec sh -c 'p="$1"; echo "building and signing $(basename "$p")..."; cd $(dirname "$p") && makepkg -src --sign' shell {} \;
|
|
}
|
|
|
|
build_repo() {
|
|
pkg_root="$1"
|
|
repo="$2"
|
|
repo_name="$3"
|
|
build_exclude_arg "$repo"
|
|
|
|
if [ ! -d "$repo" ]; then
|
|
mkdir -p "$repo"
|
|
fi
|
|
|
|
# shellcheck disable=2086
|
|
find "$pkg_root" $exclude_arg -type f \
|
|
\( -name "*.pkg.tar.zst" -o -name "*.pkg.tar.zst.sig" \) -exec cp "{}" "$repo" \;
|
|
# shellcheck disable=2035
|
|
cd "$repo" && repo-add --new --prevent-downgrade --sign "$repo_name.db.tar.gz" *.pkg.tar.zst
|
|
}
|
|
|
|
if [ -z "$1" ] || { [ "$1" != "pkgs" ] && [ "$1" != "repo" ]; }; then
|
|
echo "usage: $0 pkgs|repo"
|
|
echo
|
|
echo "pkgs takes two additional arguments:"
|
|
echo " - root directory of the package tree"
|
|
echo " - repo directory (use if it is in the same directory tree, optional)"
|
|
echo
|
|
echo "repo takes two additional arguments:"
|
|
echo " - root directory of the package tree"
|
|
echo " - repo directory"
|
|
echo " - repo name"
|
|
else
|
|
if [ "$1" = "pkgs" ]; then
|
|
build_pkgs "$2" "$3"
|
|
else
|
|
build_repo "$2" "$3" "$4"
|
|
fi
|
|
fi
|