After a successful sync, aurb runs git clean -fx in each clone under the aurutils sync folder, removing downloaded sources and build logs while keeping tracked files and VCS source folders.
44 lines
1.4 KiB
Bash
Executable File
44 lines
1.4 KiB
Bash
Executable File
#!/bin/bash
|
|
# aurb / aurs: aur build / aur sync with ccache and the ThinLTO cache mounted in the chroot (use with -c).
|
|
# Builds with clang by default (see aurutils-makepkg.conf); --gcc builds with gcc instead.
|
|
case "$(basename "$0")" in
|
|
aurb) cmd=build ;;
|
|
aurs) cmd=sync ;;
|
|
*) echo "Invoke as aurb or aurs" >&2; exit 1 ;;
|
|
esac
|
|
|
|
baseconf="$HOME/.config/aurutils-makepkg.conf"
|
|
args=()
|
|
clang=1
|
|
for arg in "$@"; do
|
|
if [[ $arg == --gcc ]]; then clang=0; else args+=("$arg"); fi
|
|
done
|
|
|
|
conf=$baseconf
|
|
if ((clang)); then
|
|
conf=$(mktemp "${XDG_RUNTIME_DIR:-/tmp}/aurb-clang.XXXXXX.conf") || exit 1
|
|
trap 'rm -f "$conf"' EXIT
|
|
{ echo 'AURB_CLANG=1'; cat "$baseconf"; } > "$conf"
|
|
fi
|
|
|
|
CCACHE_HOST_DIR="$HOME/.cache/ccache"
|
|
THINLTO_HOST_DIR="$HOME/.cache/thinlto"
|
|
mkdir -p "$CCACHE_HOST_DIR" "$THINLTO_HOST_DIR"
|
|
|
|
aur "$cmd" \
|
|
--makepkg-conf "$conf" \
|
|
--bind-rw "$CCACHE_HOST_DIR" \
|
|
--bind-rw "$THINLTO_HOST_DIR" \
|
|
--bind "$HOME/.config/aurb" \
|
|
"${args[@]}"
|
|
status=$?
|
|
|
|
# After a successful sync, drop downloaded sources and logs from the AUR clones. Without -d,
|
|
# git clean keeps untracked directories, so VCS sources (bare clones) survive.
|
|
if [[ $cmd == sync && $status -eq 0 ]]; then
|
|
for clone in "${AURDEST:-${XDG_CACHE_HOME:-$HOME/.cache}/aurutils/sync}"/*/; do
|
|
[[ -d $clone.git ]] && git -C "$clone" clean -fxq
|
|
done
|
|
fi
|
|
exit "$status"
|