From f9ebd51193903e1a8c723fb727cda3e7ff655394 Mon Sep 17 00:00:00 2001 From: fbt Date: Fri, 15 May 2020 01:23:03 +0300 Subject: [PATCH] pkgbuilder Signed-off-by: fbt --- pkgbuilder | 106 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 106 insertions(+) create mode 100755 pkgbuilder diff --git a/pkgbuilder b/pkgbuilder new file mode 100755 index 0000000..1e4a3f7 --- /dev/null +++ b/pkgbuilder @@ -0,0 +1,106 @@ +#!/usr/bin/env bash + +err() { printf '%s\n' "$*" >&2; } + +build_remote() { sudo makepkg-overlay "$@"; } +cleanup() { rm -f "$lockfile"; } + +lock() { + [[ -f "$lockfile" ]] && { + printf 'Lockfile found: %s\n' "$lockfile" >&2 + return 1 + } + + echo $$ > "$lockfile" + lock_pid=$(<"$lockfile") + [[ $$ == "$lock_pid" ]] || return 1 +} + +# Ensure one instance +lockfile="$HOME/.cache/pkgbuilder/.lock" +lock || exit 1 +trap cleanup EXIT + +spark_repos="$HOME/public" + +declare -A pkg_dests +pkg_dests=( + [spark]="$spark_repos/spark/import" + [spark-extra]="$spark_repos/spark-extra/import" + [spark-testing]="$spark_repos/spark-testing/import" + [spark-updates]="$spark_repos/spark-updates/spark/import" +) + +repos=( + spark "https://code.fleshless.org/pkgbuilds/sinit-spark" + spark "https://code.fleshless.org/pkgbuilds/sinit-sysvcompat" + spark "https://code.fleshless.org/pkgbuilds/smdev" + spark "https://code.fleshless.org/pkgbuilds/spark-etc" + spark "https://code.fleshless.org/pkgbuilds/spark-rc" + spark "https://code.fleshless.org/pkgbuilds/ssm" + spark "https://code.fleshless.org/pkgbuilds/ssm-services-git" + spark "https://code.fleshless.org/pkgbuilds/systemd-dummy" + spark "https://code.fleshless.org/pkgbuilds/ubase-extras" + spark "https://code.fleshless.org/pkgbuilds/udev-dummy" + spark "https://code.fleshless.org/pkgbuilds/xorg-noudev-conf" + spark-extra "https://code.fleshless.org/pkgbuilds/anope-services" + spark-extra "https://code.fleshless.org/pkgbuilds/chef-client" + spark-extra "https://code.fleshless.org/pkgbuilds/dmenu-q-xywh-xft-git" + spark-extra "https://code.fleshless.org/pkgbuilds/dxvk-bin" + spark-extra "https://code.fleshless.org/pkgbuilds/eudev" + spark-extra "https://code.fleshless.org/pkgbuilds/fake" + spark-extra "https://code.fleshless.org/pkgbuilds/graphicsmagick-webp" + spark-extra "https://code.fleshless.org/pkgbuilds/ircd-ratbox" + spark-extra "https://code.fleshless.org/pkgbuilds/lemonbar" + spark-extra "https://code.fleshless.org/pkgbuilds/libsystemd-standalone" + spark-extra "https://code.fleshless.org/pkgbuilds/loksh" + spark-extra "https://code.fleshless.org/pkgbuilds/mlmmj" + spark-extra "https://code.fleshless.org/pkgbuilds/nginx-mod-rtmp" + spark-extra "https://code.fleshless.org/pkgbuilds/posh" + spark-extra "https://code.fleshless.org/pkgbuilds/prm" + spark-extra "https://code.fleshless.org/pkgbuilds/qstat" + spark-extra "https://code.fleshless.org/pkgbuilds/scron" + spark-extra "https://code.fleshless.org/pkgbuilds/sx-utils" + spark-extra "https://code.fleshless.org/pkgbuilds/systemd-libs-systemd" + spark-extra "https://code.fleshless.org/pkgbuilds/ufw-tools" + spark-extra "https://code.fleshless.org/pkgbuilds/xkb-layout-ducky-mini" + spark-extra "https://code.fleshless.org/pkgbuilds/xsct-git" + spark-testing "https://code.fleshless.org/pkgbuilds/compton-git" + spark-testing "https://code.fleshless.org/pkgbuilds/fskit-git" + spark-testing "https://code.fleshless.org/pkgbuilds/ssm-git" + spark-testing "https://code.fleshless.org/pkgbuilds/xtitle-git" +) + + + +wrkdir="$HOME/.cache/pkgbuilder/repositories" +mkdir -p "$wrkdir" + +set -- "${repos[@]}" +while (($#>1)); do + pkg_repo=$2 + pkg_dest="${pkg_dests[$1]}" + + repo_name="${pkg_repo##*/}" + repo_path="${pkg_repo##*://}" + repo_local="$wrkdir/${repo_path%.git}" + + err "repo: $repo_local" + err " - url: $pkg_repo" + + # Check if the repo already exists + if ! [[ -d "$repo_local" ]]; then + mkdir -p "$wrkdir/${repo_path%$repo_name}" + git clone "$pkg_repo" "$repo_local" + + build_remote "$pkg_repo" "$pkg_dest" + else + git -C "$repo_local" remote update + if git -C "$repo_local" status --porcelain -bu | grep -q behind; then + build_remote "$pkg_repo" "$pkg_dest" + git -C "$repo_local" pull + fi + fi + + shift 2 +done