Skip to content

Commit

Permalink
Add aur-vercmp-devel to lib
Browse files Browse the repository at this point in the history
Support aurutils v3
  • Loading branch information
alexheretic committed Oct 18, 2020
1 parent f66f250 commit afe06e3
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 10 deletions.
31 changes: 31 additions & 0 deletions lib/aurto/aur-vercmp-devel
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/usr/bin/env bash
## from: man aurvcs
# shellcheck disable=SC2035 disable=2094
set -eu

XDG_CACHE_HOME=${XDG_CACHE_HOME:-$HOME/.cache}
AURDEST=${AURDEST:-$XDG_CACHE_HOME/aurutils/sync}
AURVCS=${AURVCS:-.*-(cvs|svn|git|hg|bzr|darcs)$}

filter_vcs() {
awk -v "mask=$AURVCS" '$1 ~ mask {print $1}' "$@"
}

# Note that valid PKGBUILDs cannot contain \n in pkgname.
get_latest_revision() {
grep -Fxf - <(printf '%s\n' *) | xargs -r aur srcver
}

db_tmp=$(mktemp)
trap 'rm -rf "$db_tmp"' EXIT

# Retrieve a list of the local repository contents. The repository
# can be specified with the usual aur-repo arguments.
aur repo --list "$@" >"$db_tmp"

# Find VCS packages that are outdated according to aur-srcver.
# This checks out the latest revision for existing source directories,
# assuming the PKGBUILD has been viewed priorly.
if cd "$AURDEST"; then
aur vercmp -p <(filter_vcs "$db_tmp" | get_latest_revision) < "$db_tmp"
fi
11 changes: 7 additions & 4 deletions lib/aurto/update-aurto
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
## Should be in the same dir as `check-aurto-git`
set -eu

readonly AURVCS=${AURVCS:-.*-(bzr|git|hg|svn)$}
readonly AURVCS=${AURVCS:-.*-(cvs|svn|git|hg|bzr|darcs)$}

if [[ $EUID -ne 0 ]]; then
# retry as root
Expand Down Expand Up @@ -78,12 +78,15 @@ if rm "$lib_dir/check-vcs" 2>/dev/null; then
vcs_pkgs=$(aur repo --database=aurto --list | cut -f1 | grep -E "$AURVCS" || true)
if [ -n "$vcs_pkgs" ]; then
echo "Checking $(echo "$vcs_pkgs" | wc -l) VCS packages matching $(yellow "$AURVCS") for updates..." >&2
# init vcs sync cache
# init vcs sync cache (aurutils v3 args with ||-fallback to v2 args)
sudo -u "$user" \
aur sync "$vcs_pkgs" \
--no-ver-shallow --print >/dev/null 2>&1
--no-ver --no-build --no-view --database=aurto >/dev/null 2>&1 \
|| sudo -u "$user" \
aur sync "$vcs_pkgs" \
--no-ver-shallow --print --database=aurto >/dev/null 2>&1

mapfile -t git_outdated < <(sudo -u "$user" aur vercmp-devel --database=aurto | cut -d: -f1)
mapfile -t git_outdated < <(sudo -u "$user" "$lib_dir"/aur-vercmp-devel --database=aurto | cut -d: -f1)
if [ ${#git_outdated[@]} -gt 0 ]; then
sudo -u "$user" aurto remove "${git_outdated[@]}"
sudo -u "$user" aurto add "${git_outdated[@]}"
Expand Down
12 changes: 6 additions & 6 deletions trust-check/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit afe06e3

Please sign in to comment.