Merge pull request #970 from AladW/build-fixups
[aurutils.git] / examples / vercmp-devel
blobeadd2f0990797fb6eba056362d08f31a5bb04979
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 tmp=$(mktemp -d --tmpdir "aurutils-$UID/$argv0.XXXXXXXX")
21 trap 'rm -rf "$tmp"' EXIT
23 # Retrieve a list of the local repository contents. The repository
24 # can be specified with the usual aur-repo arguments.
25 aur repo --list "$@" | tee "$tmp"/db | filter_vcs - >"$tmp"/vcs
27 # Update `epoch:pkgver-pkgrel` for each target with `aur-srcver`.
28 # This runs `makepkg`, cloning upstream to the latest revision. The
29 # output is then compared with the contents of the local repository.
30 aur vercmp -p <(xargs -ra "$tmp"/vcs aur srcver) <"$tmp"/db