From: Samir Benmendil Date: Thu, 4 May 2023 08:43:42 +0000 (+0100) Subject: bin: ocp aur-sync-devel to bin X-Git-Url: https://git.rmz.io/dotfiles.git/commitdiff_plain/9df61146b8c60774a5fa84de601e86f35782fd29 bin: ocp aur-sync-devel to bin --- diff --git a/bin/aur-sync-devel b/bin/aur-sync-devel new file mode 100755 index 0000000..f699fed --- /dev/null +++ b/bin/aur-sync-devel @@ -0,0 +1,66 @@ +#!/bin/bash +# Example taken from /usr/share/doc/aurutils/examples/sync-devel + +set -e +argv0=sync-devel +XDG_CACHE_HOME=${XDG_CACHE_HOME:-$HOME/.cache} + +# For the purposes of this example, we assume AURDEST contains both AUR and +# non-AUR git repositories (e.g. from github or archweb), with corresponding +# packages in the local repository. +AURDEST=${AURDEST:-$XDG_CACHE_HOME/aurutils/sync} +AURVCS=".*-(cvs|svn|git|hg|bzr|darcs)$" + +# Pattern the defines VCS packages. The AUR has no formal definition of a VCS +# package - here we include the most common version control systems. +filter_vcs() { + awk -v "mask=$AURVCS" '$1 ~ mask {print $1}' "$@" +} + +# Scratch space for intermediary results. +mkdir -pm 0700 "${TMPDIR:-/tmp}/aurutils-$UID" +tmp=$(mktemp -d --tmpdir "aurutils-$UID/$argv0.XXXXXXXX") +trap 'rm -rf "$tmp"' EXIT + +# Retrieve a list of the local repository contents. The repository +# can be specified with the usual aur-repo arguments. +aur repo --list "$@" | tee "$tmp"/db | filter_vcs - >"$tmp"/vcs + +# Only AUR repositories can be cloned anew, as the source of non-AUR packages +# is unknown beforehand. Their existence is checked with `git-ls-remote` (`-e`) +# Running makepkg locally on a PKGBUILD with pkgver() results in local changes, +# so these are removed with `--discard`. New upstream commits are then merged +# with `git-merge` or `git-rebase` (`--sync=auto`). The final PKGBUILD is shown +# in `aur-view` later on. +cd "$AURDEST" +aur fetch -e --discard --sync=auto --results="$tmp"/fetch_results - <"$tmp"/vcs + +# Make sure empty repositories are not considered for inspection. +targets=() +while IFS=: read -r mode rev_old rev path; do + path=${path#file://} name=${path##*/} + + case $mode in + clone|merge|fetch|rebase|reset) + [[ $rev != "0" ]] && targets+=("$name") ;; + esac +done <"$tmp"/fetch_results + +# Inspect new AUR (downstream) commits with aur-view(1). This is done +# before running aur-srcver, which runs makepkg and sources the +# PKGBUILD. +aur view "${targets[@]}" + +# Update `epoch:pkgver-pkgrel` for each target with `aur-srcver`. +# This runs `makepkg`, cloning upstream to the latest revision. The +# output is then compared with the contents of the local repository. +cat "$tmp"/db | aur vercmp -p <(aur srcver "${targets[@]}") | \ + awk '{print $1}' >"$tmp"/ood + +# Build the packages. Arguments are shared between aur-repo and +# aur-build to specify the local repository. +if [[ -s $tmp/ood ]]; then + aur build "$@" -a "$tmp"/ood --syncdeps --rmdeps --noconfirm +else + printf >&2 '%s: all packages up-to-date\n' "$argv0" +fi