From c2b5d134a4e9b8a58d283ef85b17303aeaf8880e Mon Sep 17 00:00:00 2001 From: Fleshless Builder Date: Mon, 20 Nov 2017 05:45:42 +0300 Subject: [PATCH] kek --- post-receive | 9 ++------- repo-clean | 3 ++- repo-maintenance | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ repo-sign | 1 - 4 files changed, 52 insertions(+), 9 deletions(-) create mode 100755 repo-maintenance diff --git a/post-receive b/post-receive index da1c1f9..0cded9a 100755 --- a/post-receive +++ b/post-receive @@ -8,10 +8,5 @@ self_url="https://pkg.fleshless.org/$self" spark_repo=$( "$HOME/log/repo-sign.$spark_repo.log" -"$HOME/scripts/repo-clean" &> "$HOME/log/repo-clean.$spark_repo.log" - -repo-add -n "$spark_repo.db.tar.gz" *.pkg.tar.xz &> "$HOME/log/repo-add.$spark_repo.log" +suex makepkg-overlay "$self_url" "$spark_repo_path/import" +repo-maintenance "$spark_repo" diff --git a/repo-clean b/repo-clean index 16db969..c195f3b 100755 --- a/repo-clean +++ b/repo-clean @@ -34,6 +34,7 @@ _pacsort() { while (( $# )); do case "$1" in -r) flag_rm=1;; + -d) flag_debug=1;; esac shift done @@ -59,7 +60,7 @@ done for f in ${package_files[@]}; do if is_latest "$f"; then - printf '%s is the latest version available\n' "$f" + (( flag_debug )) && printf '%s is the latest version available\n' "$f" else printf 'Removing: %s\n' "$f" diff --git a/repo-maintenance b/repo-maintenance new file mode 100755 index 0000000..7418a35 --- /dev/null +++ b/repo-maintenance @@ -0,0 +1,48 @@ +#!/usr/bin/env bash +shopt -s nullglob + +lockfile='.mainenance.lock' + +usage() { echo "$0 "; } + +spark_repo=$1 +[[ "$spark_repo" ]] || { + usage + exit 1 +} + +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 +} + +cd "$HOME/public/$spark_repo" || exit $? + +lock || exit 1 + +trap cleanup EXIT + +for f in import/*; do + f_name="${f##*/}" + if [[ -f "$f_name" ]]; then + printf 'Package already exists: %s, not overwriting\n' "$f_name" >&2 + else + mv -vf "$f" ./ + new_pkgs+=( "$f_name" ) + fi +done + +repo-sign +repo-clean + +for p in "${new_pkgs[@]}"; do + repo-add -n "$spark_repo.db.tar.gz" "$p" +done diff --git a/repo-sign b/repo-sign index f8b756a..288eb48 100755 --- a/repo-sign +++ b/repo-sign @@ -11,5 +11,4 @@ done for i in "${unsigned_pkgs[@]}"; do echo $i gpg --pinentry-mode loopback --passphrase-fd 0 --batch --no-tty --detach-sign --no-armor "$i" < ~/.gnupg/passphrase - #gpg --batch --no-tty --detach-sign --no-armor "$i" done