initial commit

This commit is contained in:
Sebastian Hugentobler 2023-06-22 09:49:39 +02:00
commit a98c64521d
Signed by: shu
GPG Key ID: BB32CF3CA052C2F0
3 changed files with 81 additions and 0 deletions

4
.gitignore vendored Normal file
View File

@ -0,0 +1,4 @@
*~
.DS_Store
*.pkg.tar.zst
*.pkg.tar.zst.sig

20
PKGBUILD Normal file
View File

@ -0,0 +1,20 @@
# Maintainer: Sebastian Hugentobler <shu@vanwa.ch>
pkgname=repo-tool
pkgver=0.1.0
pkgrel=1
pkgdesc="Build a tree of pacman packages and build a repo of them."
arch=("any")
url="https://code.vanwa.ch"
license=('MIT')
depends=("pacman" "gnupg" "findutils")
source=(
"repo-tool"
)
sha256sums=("9eae4888a23637580d2323678ba0218bdce2d924e381ddbe2b0114b4a8dbe408")
package() {
cd "$srcdir/"
install -Dm 755 repo-tool "$pkgdir/usr/bin/repo-tool"
}

57
repo-tool Executable file
View File

@ -0,0 +1,57 @@
#!/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