Speedup pass on macOS and brew
pass-maillinglist at artursterz.de
pass-maillinglist at artursterz.de
Mon Oct 22 18:50:31 CEST 2018
Hi,
currently (and as I can tell also in the past, see [1],[2],[3],[4],[5]), brew —prefix <FORMULA> is really slow (see the example output below), which makes it somewhat annoying using pass on macOS. I hunted this down and found that the problem is the following: brew runs git rev-parse --short=4 --verify -q HEAD every time to find the currently installed version of the formula (which seems somewhat unreasonable). Depending on your git and network connectivity, this may take longer. Using brew —prefix without a formula is reasonably fast. As far as I can tell, there is currently no way to change the prefix path in brew, thus using $(brew —prefix)/opt/gnu-getopt should be a save way for determining the path to gnu-getopt.
I patched this and attached the patch to this mail. Since my implementation is somewhat longer, I think it should not be implemented in one line anymore, but split it up as I did (see the patch). If you come up with something better let me know (or, of course, patch it yourself). Additionally, since I am not using Macports, I can not test if this also works with ports. Before considering pushing my patch upstream, someone needs to test this! For brew, it works fine.
Thank you for reading this and best regards,
Artur
Appendix:
Brew time measurement:
$ time brew --prefix gnu-getopt
/usr/local/opt/gnu-getopt
1.31 real 0.80 user 0.41 sys
References:
[1]: https://github.com/Homebrew/brew/issues/4947 <https://github.com/Homebrew/brew/issues/4947>[2]: https://github.com/Homebrew/brew/issues/3327 <https://github.com/Homebrew/brew/issues/3327>
[3]: https://github.com/Homebrew/brew/issues/3097 <https://github.com/Homebrew/brew/issues/3097>[4]: https://github.com/Homebrew/brew/issues/2938 <https://github.com/Homebrew/brew/issues/2938>
[5]: https://github.com/Homebrew/brew/issues/4153 <https://github.com/Homebrew/brew/issues/4153>
Patch:
diff --git a/src/platform/darwin.sh b/src/platform/darwin.sh
index 342ecce..04d8ef3 100644
--- a/src/platform/darwin.sh
+++ b/src/platform/darwin.sh
@@ -43,6 +43,14 @@ qrcode() {
fi
}
-GETOPT="$(brew --prefix gnu-getopt 2>/dev/null || { which port &>/dev/null && echo /opt/local; } || echo /usr/local)/bin/getopt"
+if [[ $(command -v brew) ]]; then
+ GETOPT="$(brew --prefix)/opt/gnu-getopt"
+elif [[ $(command -v port) ]]; then
+ GETOPT="{ which port &>/dev/null && echo /opt/local; }"
+else
+ GETOPT="echo /usr/local"
+fi
+GETOPT="$GETOPT/bin/getopt"
+
SHRED="srm -f -z"
BASE64="openssl base64"
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.zx2c4.com/pipermail/password-store/attachments/20181022/35edec20/attachment.html>
More information about the Password-Store
mailing list