From 03274f16bef92efbb5a6679605574bef1d798d0d Mon Sep 17 00:00:00 2001 From: Jack Pappas Date: Tue, 14 Feb 2017 20:11:26 -0500 Subject: [PATCH] Fix word-splitting bug in before_install.sh. Also, the certificate check (via certmgr) needs to check both the user and machine stores to ensure it works on a variety of systems. Related to #2125. --- before_install.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/before_install.sh b/before_install.sh index be63fd9478..247abe9912 100755 --- a/before_install.sh +++ b/before_install.sh @@ -28,7 +28,11 @@ fi # Check if SSL certificates have been imported into Mono's certificate store. # If certs haven't been installed, some/all of the Nuget packages will fail to restore. -if [ $('certmgr -list -c Trust | grep -c -F "X.509"') -le 1 ]; then +# Note, the result of the certmgr and grep commands returns the number of installed X.509 certificates. +# We need to run the command twice -- on some systems (e.g. macOS) the certs are installed in the user store, +# and on other systems (e.g., Ubuntu) they're installed to the machine store. certmgr only shows what's in +# the selected store, which is why we need to check both. +if [ "$(certmgr -list -c Trust | grep -c -F "X.509")" -le 1 ] && [ "$(certmgr -list -c -m Trust | grep -c -F "X.509")" -le 1 ]; then echo "No SSL certificates installed so unable to restore NuGet packages." >&2; echo "Run 'mozroots --sync --import' to install certificates to Mono's certificate store." >&2; exit 1