From 7bb8288d93e6b5c0dd063e2c698b5fe648f9e70f Mon Sep 17 00:00:00 2001 From: George Rawlinson Date: Thu, 16 Jun 2022 20:36:37 +1200 Subject: [PATCH] feat(zsh): add wrapper around extra-x86_64-build for caching downloaded dependencies --- zsh/.config/zsh/source/archlinux-contrib.zsh | 45 ++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/zsh/.config/zsh/source/archlinux-contrib.zsh b/zsh/.config/zsh/source/archlinux-contrib.zsh index 1709a39..01b88ef 100644 --- a/zsh/.config/zsh/source/archlinux-contrib.zsh +++ b/zsh/.config/zsh/source/archlinux-contrib.zsh @@ -24,4 +24,49 @@ function tag2commit() { git ls-remote $repository $tag } + +# wrapper around extra-x86_64-build for caching downloaded dependencies +# TODO expand to use testing/staging +function ab-extra() { + local EXTRA_ARGS=() + + # capture output for parsing dependencies + makepkg_output=$(makepkg --printsrcinfo) + + # + # cache various downloads + # + # rust - crates + if grep -q "depends = rust\|cargo" <<<"$makepkg_output"; then + EXTRA_ARGS+=( + -d /var/cache/cargo/git:/build/.cargo/git + -d /var/cache/cargo/registry:/build/.cargo/registry + ) + fi + + # go - modules + if grep -q "depends = go" <<<"$makepkg_output"; then + EXTRA_ARGS+=( + -d /var/cache/golang/pkg:/build/go/pkg + -d /var/cache/golang/build:/build/.cache/go-build + ) + fi + + # dart - packages + if grep -q "depends = dart" <<<"$makepkg_output"; then + EXTRA_ARGS+=(-d /var/cache/dartlang:/build/.pub-cache) + fi + + # javascript - npm/yarn/pkg + if grep -q "depends = npm\|yarn\|nodejs" <<<"$makepkg_output"; then + EXTRA_ARGS+=( + -d /var/cache/javascript/npm:/build/.npm + -d /var/cache/javascript/pkg-cache:/build/.pkg-cache + -d /var/cache/javascript/yarn:/build/.cache/yarn + ) + fi + + extra-x86_64-build -- ${EXTRA_ARGS[@]} ${@} +} + # vim: ft=zsh expandtab tabstop=2 shiftwidth=2