aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGalen Guyer <galen@galenguyer.com>2022-08-02 23:23:53 -0400
committerGalen Guyer <galen@galenguyer.com>2022-08-02 23:23:53 -0400
commit11ecaa5a588eee30646e6a02b08d71120a60cb62 (patch)
tree37fe285a236881b4de55bb029d4ccaea68418b72
parentfff935979ef9e7921d9d7a0fe63e5668890fee53 (diff)
update scripts to latest versionsHEADmain
-rwxr-xr-xadd-package.sh26
-rwxr-xr-x[-rw-r--r--]build.sh45
-rw-r--r--packages1
-rw-r--r--setup.sh11
-rwxr-xr-xupdate-local.sh21
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"
diff --git a/build.sh b/build.sh
index 5c850c2..b0a7ffa 100644..100755
--- a/build.sh
+++ b/build.sh
@@ -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
diff --git a/setup.sh b/setup.sh
index 5ee70bf..1e9e64e 100644
--- a/setup.sh
+++ b/setup.sh
@@ -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"