Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build vcs with sync-devel script #102

Merged
merged 3 commits into from
Sep 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 0 additions & 31 deletions lib/aurto/aur-vercmp-devel

This file was deleted.

58 changes: 58 additions & 0 deletions lib/aurto/sync-devel
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#!/usr/bin/env bash
## From https://github.com/aurutils/aurutils/blob/master/examples/sync-devel
set -euo pipefail

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)$}

build_args=(--syncdeps --rmdeps --noconfirm --database=aurto)
if [ "${1:---chroot}" = "--chroot" ]; then
build_args+=(--chroot
--makepkg-conf=/etc/aurto/makepkg-chroot.conf
--pacman-conf=/etc/aurto/pacman-chroot.conf)
fi

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

tmp=$(mktemp -d "/tmp/aurto-sync-devel.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 --database=aurto | 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.
mkdir -p "$AURDEST"
cd "$AURDEST"
aur fetch -e --discard --sync=auto --results="$tmp"/fetch_results - <"$tmp"/vcs

# Make sure empty repositories are not considered for inspection.
targets=()
# shellcheck disable=SC2034
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

# 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.
aur vercmp -p <(aur srcver "${targets[@]}") <"$tmp"/db | awk '{print $1}' >"$tmp"/ood

if [[ -s $tmp/ood ]]; then
aur build -a "$tmp"/ood "${build_args[@]}"
else
echo 'VCS packages up to date ✓' >&2
fi
17 changes: 1 addition & 16 deletions lib/aurto/update-aurto
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ clean_aurutils_cache() {
}
trap clean_aurutils_cache ERR


pacsync aurto >/dev/null || true

## Check trust
Expand Down Expand Up @@ -79,21 +78,7 @@ 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 (aurutils v3 args with ||-fallback to v2 args)
sudo -u "$user" \
aur sync "$vcs_pkgs" \
--no-ver-argv --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" "$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[@]}"
else
echo " VCS packages up to date $(green ✓)" >&2
fi
sudo -u "$user" AURVCS="$AURVCS" "$lib_dir"/sync-devel "$chroot_arg"
fi
fi

Expand Down
Loading