diff options
-rwxr-xr-x | add-package.sh | 26 | ||||
-rwxr-xr-x[-rw-r--r--] | build.sh | 45 | ||||
-rw-r--r-- | packages | 1 | ||||
-rw-r--r-- | setup.sh | 11 | ||||
-rwxr-xr-x | update-local.sh | 21 |
5 files changed, 94 insertions, 10 deletions
diff --git a/add-package.sh b/add-package.sh new file mode 100755 index 0000000..f0fdf5d --- /dev/null +++ b/add-package.sh @@ -0,0 +1,26 @@ +#!/usr/bin/env bash +set -euo pipefail + +_script="$0" +_package="$1" + +function log() { + echo "[$(basename $_script)] $@" +} + +if grep -qP '^'"$_package"'$' packages; then + log "package list already contains $_package" + exit 0 +fi +if grep -qP '^#'"$_package"'$' packages; then + log "package list already contains $_package but it is disabled" + exit 0 +fi + +echo "$_package" >> packages + +_tmpfile="$(mktemp)" +cat "packages" | sort > "$_tmpfile" +cp "$_tmpfile" "packages" + +log "added $_package to package list" @@ -1,7 +1,44 @@ -#!/bin/bash +#!/usr/bin/env bash source ./constants.sh -export PACKAGE_LIST="yay" +readonly PS4='+(${BASH_SOURCE}:${LINENO}): ${FUNCNAME[0]:+${FUNCNAME[0]}(): }' +readonly XDG_CACHE_HOME=${XDG_CACHE_HOME:-$HOME/.cache} +readonly AURDEST=${AURDEST:-$XDG_CACHE_HOME/aurutils/sync} +readonly AURVCS=${AURVCS:-".*-(cvs|svn|git|hg|bzr|darcs)"} -sudo pacman -Syu --noconfirm -aur sync --sign -A --noconfirm --noview --database "$REPO_NAME" --root "$REPO_ROOT" "$PACKAGE_LIST" +export PACKAGE_LIST="$(cat packages | grep -Pv '^#')" + +TMPDIR="$(mktemp -d)" +function cleanup { + rm -rf "$TMPDIR" +} +trap cleanup EXIT + +sudo pacman --noconfirm -Syu +aur sync \ + --sign \ + --ignore-arch \ + --remove \ + --noconfirm \ + --noview \ + --database "$REPO_NAME" \ + --root "$REPO_ROOT" \ + $PACKAGE_LIST + +cd "$AURDEST" + +aur repo --list | grep -E $AURVCS > "$TMPDIR/local" +aur repo --list | grep -E $AURVCS | cut -f1 | xargs -r aur srcver > "$TMPDIR/vcs" +aur vercmp -p "$TMPDIR/vcs" < "$TMPDIR/local" | cut -d\ -f1 > "$TMPDIR/updates" + +if [[ "$(cat $TMPDIR/updates | wc -l)" -gt 0 ]]; then + xargs -a "$TMPDIR/updates" aur sync \ + --sign \ + --ignore-arch \ + --remove \ + --noconfirm \ + --noview \ + --no-ver-argv \ + --database "$REPO_NAME" \ + --root "$REPO_ROOT" +fi diff --git a/packages b/packages new file mode 100644 index 0000000..8435ed0 --- /dev/null +++ b/packages @@ -0,0 +1 @@ +yay @@ -1,16 +1,15 @@ -#!/bin/bash +#!/usr/bin/env bash source ./constants.sh echo "updating packages..." -sudo pacman -Syyu --noconfirm -sudo pacman -S base base-devel git --noconfirm +sudo pacman -Syu --needed --noconfirm +sudo pacman -S base base-devel git --needed --noconfirm echo "building aurutils..." cd /tmp -curl --output aurutils.tar.gz https://aur.archlinux.org/cgit/aur.git/snapshot/aurutils.tar.gz -tar xf aurutils.tar.gz +git clone https://aur.archlinux.org/aurutils.git cd aurutils makepkg --syncdeps --noconfirm mkdir -p "$REPO_ROOT" sudo pacman -U --noconfirm aurutils-*.pkg.tar.zst -repo-add "$REPO_ROOT/$REPO_NAME.db.tar.zst" +repo-add -s "$REPO_ROOT/$REPO_NAME.db.tar.zst" diff --git a/update-local.sh b/update-local.sh new file mode 100755 index 0000000..78f0629 --- /dev/null +++ b/update-local.sh @@ -0,0 +1,21 @@ +#!/usr/bin/env bash +_scriptname="$(basename $0)" + +function log() { + echo "[$_scriptname] $@" +} + +if [[ -z $1 ]]; then + log "no package given" + exit 1 +fi + +_pkg="$1" +_basename="$(basename $_pkg)" + +log "signing $_basename" +gpg --detach-sign --no-armor --batch --output "$_pkg.sig" "$_pkg" + +log "adding $_basename to repo" +cp -v "$_pkg"* $HOME/pub/ +repo-add -s pub/aur-builds.db.tar.zst pub/"$_basename" |