2 # run as: `sudo sync-asroot ...`
3 [[ -v AUR_DEBUG
]] && set -o xtrace
4 SUDO_HOME
=$
(eval echo "~$SUDO_USER")
5 XDG_CACHE_HOME
=${XDG_CACHE_HOME:-$SUDO_HOME/.cache}
6 AURDEST
=${AURDEST:-$XDG_CACHE_HOME/aurutils/sync}
10 build_args
=(-LR --chroot) sync_args
=() keep_going
=1
14 while getopts :U
:d
:k
:fSuN OPT
; do
16 d
) build_args
+=(-d "$OPTARG"); sync_args
+=(-d "$OPTARG") ;;
17 f
) build_args
+=(-f "$OPTARG") ;;
18 S
) build_args
+=(-S) ;;
19 U
) build_user
=$OPTARG ;;
20 k
) keep_going
=$OPTARG ;;
22 N
) sync_args
+=(--no-ver) ;;
27 ninja_dir
=$
(mktemp
-d) ||
exit
28 trap 'rm -rf "$ninja_dir"' EXIT
30 # 1. define unprivileged commands ------------------------------------------------->
31 build_user
=${build_user:-${SUDO_USER:-$USER}}
32 build_args
+=(-U "$build_user")
34 build_env
=(AUR_MAKEPKG
="runuser -u $build_user -- makepkg"
35 AUR_GPG
="runuser -u $build_user -- gpg"
36 AUR_REPO_ADD
="runuser -u $build_user -- repo-add")
38 # 2. retrieve sources ------------------------------------------------------------->
40 runuser
-u "$build_user" -- \
41 env AURDEST
="$AURDEST" aur sync
"${sync_args[@]}" "$@" --columns >graph ||
exit 1
43 # 3. build queue ------------------------------------------------------------------>
44 if [[ -s graph
]]; then
45 runuser
-u "$build_user" -- aur sync--ninja
"$AURDEST" <graph
>build.ninja
-- \
46 env AUR_ASROOT
=1 "${build_env[@]}" aur build
"${build_args[@]}"
48 env NINJA_STATUS
='[%s/%t] ' ninja
-C "$ninja_dir" -k "$keep_going"