@@ -6,113 +6,105 @@ export SCRIPT_DIR=$(cd "$(dirname "$0")" && pwd)
66# # Configuration Variables
77# #
88
9- config () {
10- # A whitespace-separated list of executables that must be present and locatable.
11- # These will each be installed through Homebrew if not found.
12- : ${REQUIRED_TOOLS=" cmake libssh2 libtool autoconf automake pkg-config openssl" }
9+ config () {
10+ # A whitespace-separated list of executables that must be present and locatable.
11+ # These will each be installed through Homebrew if not found.
12+ : ${REQUIRED_TOOLS=" cmake libssh2 libtool autoconf automake pkg-config openssl" }
1313
14- export REQUIRED_TOOLS
14+ export REQUIRED_TOOLS
1515}
1616
1717# #
1818# # Bootstrap Process
1919# #
2020
21- main ()
22- {
23- config
21+ main () {
22+ config
2423
25- git submodule update --init --recursive
24+ git submodule update --init --recursive
2625
27- if [ -n " $REQUIRED_TOOLS " ]
28- then
29- echo " ** Checking dependencies in Homebrew ..."
30- check_deps
31- fi
26+ if [ -n " $REQUIRED_TOOLS " ]; then
27+ echo " ** Checking dependencies in Homebrew ..."
28+ check_deps
29+ fi
3230}
3331
34- check_deps ()
35- {
36- # Check if Homebrew is installed
37- which -s brew
38- local result=$?
39-
40- if [ " $result " -ne " 0" ]
41- then
42- echo
43- echo " Homebrew is not installed (http://brew.sh). You will need to manually ensure the following tools are installed:"
44- echo " $REQUIRED_TOOLS "
45- echo
46- echo " Additionally, the following libssh2 files must be symlinked under /usr/local or /opt/homebrew :"
47- echo " lib/libssh2.a include/libssh2.h include/libssh2_sftp.h include/libssh2_publickey.h"
48-
49- if [ ! -z " $CI " ]
50- then
51- echo
52- echo " I will try to install it now on github CI"
53- /bin/bash -c " $( curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh) "
54- echo ' eval "$(/opt/homebrew/bin/brew shellenv)"' >> /Users/hannes/.zprofile
55- eval " $( /opt/homebrew/bin/brew shellenv) "
56- fi
32+ check_deps () {
33+ # Check if Homebrew is installed
34+ which -s brew
35+ local result=$?
36+
37+ if [ " $result " -ne " 0" ]; then
38+ echo
39+ echo " Homebrew is not installed (http://brew.sh). You will need to manually ensure the following tools are installed:"
40+ echo " $REQUIRED_TOOLS "
41+ echo
42+ echo " Additionally, the following libssh2 files must be symlinked under /usr/local or /opt/homebrew :"
43+ echo " lib/libssh2.a include/libssh2.h include/libssh2_sftp.h include/libssh2_publickey.h"
44+
45+ if [ ! -z " $CI " ]; then
46+ echo
47+ echo " I will try to install it now on github CI"
48+ /bin/bash -c " $( curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh) "
49+ echo ' eval "$(/opt/homebrew/bin/brew shellenv)"' >> /Users/hannes/.zprofile
50+ eval " $( /opt/homebrew/bin/brew shellenv) "
5751 fi
58-
59- brew_prefix=` brew --prefix`
60- if [[ ` uname -m` == ' arm64' ]]; then
61- echo " ** Running on a Apple Silicon M1"
62- export expected_prefix=/opt/homebrew
63- else
64- echo " ** Running on a Apple x86"
65- export expected_prefix=/usr/local
52+ fi
53+
54+ brew_prefix=$( brew --prefix)
55+ if [[ $( uname -m) == ' arm64' ]]; then
56+ echo " ** Running on a Apple Silicon M1"
57+ export expected_prefix=/opt/homebrew
58+ else
59+ echo " ** Running on a Apple x86"
60+ export expected_prefix=/usr/local
61+ fi
62+
63+ # Ensure that we have libgit2's dependencies installed.
64+ installed=$( brew list)
65+
66+ echo " Brew comes with following installed ssl programs"
67+ brew list | grep ssl
68+
69+ for tool in $REQUIRED_TOOLS ; do
70+ # Skip packages that are already installed.
71+ echo " $installed " | grep -q " $tool " && code=$? || code=$?
72+
73+ if [ " $code " -eq " 0" ]; then
74+ echo " *** $tool is available 👍"
75+ continue
76+ elif [ " $code " -ne " 1" ]; then
77+ exit $code
6678 fi
6779
68- # Ensure that we have libgit2's dependencies installed.
69- installed=` brew list`
70-
71- for tool in $REQUIRED_TOOLS
72- do
73- # Skip packages that are already installed.
74- echo " $installed " | grep -q " $tool " && code=$? || code=$?
75-
76- if [ " $code " -eq " 0" ]
77- then
78- echo " *** $tool is available 👍"
79- continue
80- elif [ " $code " -ne " 1" ]
81- then
82- exit $code
83- fi
84-
85- echo " *** Installing $tool with Homebrew..."
86- brew install " $tool "
87- done
80+ echo " *** Installing $tool with Homebrew..."
81+ brew install " $tool "
82+ done
8883
89- install_path=" ./External"
90- echo " *** copy " $brew_prefix " /lib/libssh2.a to $install_path "
91- cp " $brew_prefix " /lib/libssh2.a $install_path
84+ install_path=" ./External"
85+ echo " *** copy " $brew_prefix " /lib/libssh2.a to $install_path "
86+ cp " $brew_prefix " /lib/libssh2.a $install_path
9287
93- if [ " $brew_prefix " != " $expected_prefix " ]
94- then
95- echo " *** Adding soft links into $expected_prefix ..."
88+ if [ " $brew_prefix " != " $expected_prefix " ]; then
89+ echo " *** Adding soft links into $expected_prefix ..."
9690
97- products=(lib/libssh2.a include/libssh2.h include/libssh2_sftp.h include/libssh2_publickey.h)
91+ products=(lib/libssh2.a include/libssh2.h include/libssh2_sftp.h include/libssh2_publickey.h)
9892
99- for product in " ${products[@]} "
100- do
101- destination=" $expected_prefix /$product "
102- if [ -e " $destination " ]
103- then
104- continue
105- fi
93+ for product in " ${products[@]} " ; do
94+ destination=" $expected_prefix /$product "
95+ if [ -e " $destination " ]; then
96+ continue
97+ fi
10698
107- sudo mkdir -p " $( dirname " $destination " ) "
108- sudo ln -s " $brew_prefix /$product " " $destination "
109- done
110- fi
99+ sudo mkdir -p " $( dirname " $destination " ) "
100+ sudo ln -s " $brew_prefix /$product " " $destination "
101+ done
102+ fi
111103
112- # openssl@1 is expected
113- sslSource=$( find $brew_prefix -name libcrypto.a | grep openssl | sort | head -1 | xargs dirname)
114- echo " Find libcrypto.a and take first $sslSource and copy to $install_path "
115- cp $sslSource /* $install_path 2> /dev/null | echo " Copy and ignore subdirectory. This makes build work on x86 and arm64"
104+ # openssl@1 is expected
105+ sslSource=$( find $brew_prefix -name libcrypto.a | grep openssl | sort | head -1 | xargs dirname)
106+ echo " Find libcrypto.a and take first $sslSource and copy to $install_path "
107+ cp $sslSource /* $install_path 2> /dev/null | echo " Copy and ignore subdirectory. This makes build work on x86 and arm64"
116108}
117109
118110main
0 commit comments