Merge pull request #1027 from AladW/build-asroot-example
[aurutils.git] / lib / aur-build--sync
blob67befd38da086a56919d04733349a7b04d641084
1 #!/bin/bash
2 # shellcheck disable=SC2086
3 # build--sync - helper for upgrading local repository
4 set -o errexit
5 [[ -v AUR_DEBUG ]] && set -o xtrace
6 AUR_PACMAN_AUTH=${AUR_PACMAN_AUTH:-sudo}
7 argv0=build--sync
8 PS4='+(${BASH_SOURCE}:${LINENO}): ${FUNCNAME[0]:+${FUNCNAME[0]}(): }'
10 if (( ! $# )); then
11 printf >&2 '%s: repository not specified\n' "$argv0"
12 exit 1
15 # propagate local repo contents
16 arg_repo=$1
17 $AUR_PACMAN_AUTH pacsync "$arg_repo"
18 $AUR_PACMAN_AUTH pacsync "$arg_repo" --dbext=.files
20 # retrieve upgrade targets
21 targets=()
22 while IFS='/' read -r repo name; do
23 if [[ $repo == "$arg_repo" ]]; then
24 targets+=("$repo/$name")
26 done < <(pacman -Sup --print-format '%r/%n')
27 wait "$!"
29 if (( ${#targets[@]} )); then
30 printf >&2 "%s: upgrading packages in repository '%s'\n" "$argv0" "$arg_repo"
31 printf '%s\n' "${targets[@]}" | $AUR_PACMAN_AUTH pacman -S --noconfirm -
34 # vim: set et sw=4 sts=4 ft=sh: