sync-rebuild: python rewrite
[aurutils.git] / examples / vercmp-devel
blobf1ee1ee0f37b3e4785b5f7ed08e9750b6d3a31e6
1 #!/bin/bash
2 set -e
3 argv0=vercmp-devel
4 XDG_CACHE_HOME=${XDG_CACHE_HOME:-$HOME/.cache}
5 AURVCS=".*-(cvs|svn|git|hg|bzr|darcs)$"
7 # Pattern the defines VCS packages. The AUR has no formal definition of a VCS
8 # package - here we include the most common version control systems.
9 filter_vcs() {
10 awk -v "mask=$AURVCS" '$1 ~ mask {print $1}' "$@"
13 # For the purposes of this example, we assume AURDEST contains both
14 # AUR and non-AUR git repositories (e.g. from github or archweb), with
15 # corresponding packages in the local repository.
16 AURDEST=${AURDEST:-$XDG_CACHE_HOME/aurutils/sync}
17 cd "$AURDEST"
19 # Scratch space for intermediary results.
20 mkdir -pm 0700 "${TMPDIR:-/tmp}/aurutils-$UID"
21 tmp=$(mktemp -d --tmpdir "aurutils-$UID/$argv0.XXXXXXXX")
22 trap 'rm -rf "$tmp"' EXIT
24 # Retrieve a list of the local repository contents. The repository
25 # can be specified with the usual aur-repo arguments.
26 aur repo --list "$@" | tee "$tmp"/db | filter_vcs - >"$tmp"/vcs
28 # Update `epoch:pkgver-pkgrel` for each target with `aur-srcver`.
29 # This runs `makepkg`, cloning upstream to the latest revision. The
30 # output is then compared with the contents of the local repository.
31 aur vercmp -p <(xargs -ra "$tmp"/vcs aur srcver) <"$tmp"/db