From 3248cee07fb888866c140788817baf651e2a7c66 Mon Sep 17 00:00:00 2001 From: George Rawlinson Date: Fri, 29 Oct 2021 06:46:08 +0000 Subject: [PATCH] build: cache Rust/Go downloads when required --- .repo/build | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/.repo/build b/.repo/build index 58a0b8d..0b68298 100755 --- a/.repo/build +++ b/.repo/build @@ -14,7 +14,8 @@ traperr() { trap traperr ERR -PACKAGES=( "$@" ) +PACKAGES=("$@") +EXTRA_ARGS=() if [ ${#PACKAGES[@]} -eq 0 ]; then echo "${BOLD}${RED}ERROR:${RESET}${BOLD} no packages specified${RESET}" @@ -24,7 +25,20 @@ fi for package in "${PACKAGES[@]}"; do ( # change to package directory - cd "$package" || exit 1; + cd "$package" || exit 1 + + # capture output for parsing dependencies + makepkg_output=$(makepkg --printsrcinfo) + + # cache downloaded crates + if grep -q "depends = rust\|cargo" <<<"$makepkg_output"; then + EXTRA_ARGS+=(--bind-rw /var/cache/cargo:/build/.cargo) + fi + + # cache downloaded modules + if grep -q "depends = go" <<<"$makepkg_output"; then + EXTRA_ARGS+=(--bind-rw /var/cache/golang:/build/go) + fi # build signed package in chroot & add to local repo aur build \ @@ -32,7 +46,8 @@ for package in "${PACKAGES[@]}"; do --gpg-sign \ --remove \ --force \ - --makepkg-conf=/etc/aurutils/makepkg-grawlinson.conf + --makepkg-conf=/etc/aurutils/makepkg-grawlinson.conf \ + "${EXTRA_ARGS[@]}" ) done