@@ -6,114 +6,103 @@ export SCRIPT_DIR=$(cd "$(dirname "$0")" && pwd)
6
6
# # Configuration Variables
7
7
# #
8
8
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" }
13
13
14
- export REQUIRED_TOOLS
14
+ export REQUIRED_TOOLS
15
15
}
16
16
17
17
# #
18
18
# # Bootstrap Process
19
19
# #
20
20
21
- main ()
22
- {
23
- config
21
+ main () {
22
+ config
24
23
25
- git submodule update --init --recursive
24
+ git submodule update --init --recursive
26
25
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
32
30
}
33
31
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) "
57
51
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
+ for tool in $REQUIRED_TOOLS ; do
67
+ # Skip packages that are already installed.
68
+ echo " $installed " | grep -q " $tool " && code=$? || code=$?
69
+
70
+ if [ " $code " -eq " 0" ]; then
71
+ echo " *** $tool is available 👍"
72
+ continue
73
+ elif [ " $code " -ne " 1" ]; then
74
+ exit $code
66
75
fi
67
76
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
77
+ echo " *** Installing $tool with Homebrew..."
78
+ brew install " $tool "
79
+ done
88
80
89
- install_path=" ./External"
90
- echo " *** copy " $brew_prefix " /lib/libssh2.a to $install_path "
91
- cp " $brew_prefix " /lib/libssh2.a $install_path
81
+ install_path=" ./External"
82
+ echo " *** copy " $brew_prefix " /lib/libssh2.a to $install_path "
83
+ cp " $brew_prefix " /lib/libssh2.a $install_path
92
84
93
- if [ " $brew_prefix " != " $expected_prefix " ]
94
- then
95
- echo " *** Adding soft links into $expected_prefix ..."
85
+ if [ " $brew_prefix " != " $expected_prefix " ]; then
86
+ echo " *** Adding soft links into $expected_prefix ..."
96
87
97
- products=(lib/libssh2.a include/libssh2.h include/libssh2_sftp.h include/libssh2_publickey.h)
88
+ products=(lib/libssh2.a include/libssh2.h include/libssh2_sftp.h include/libssh2_publickey.h)
98
89
99
- for product in " ${products[@]} "
100
- do
101
- destination=" $expected_prefix /$product "
102
- if [ -e " $destination " ]
103
- then
104
- continue
105
- fi
90
+ for product in " ${products[@]} " ; do
91
+ destination=" $expected_prefix /$product "
92
+ if [ -e " $destination " ]; then
93
+ continue
94
+ fi
106
95
107
- sudo mkdir -p " $( dirname " $destination " ) "
108
- sudo ln -s " $brew_prefix /$product " " $destination "
109
- done
110
- fi
96
+ sudo mkdir -p " $( dirname " $destination " ) "
97
+ sudo ln -s " $brew_prefix /$product " " $destination "
98
+ done
99
+ fi
111
100
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"
116
- ls -la $install_path
101
+ # openssl@1 is expected
102
+ sslSource=$( find $brew_prefix -name libcrypto.a | grep openssl | sort | head -1 | xargs dirname)
103
+ echo " Find libcrypto.a and take first $sslSource and copy to $install_path "
104
+ cp $sslSource /* $install_path 2> /dev/null | echo " Copy and ignore subdirectory. This makes build work on x86 and arm64"
105
+ ls -la $install_path
117
106
}
118
107
119
108
main
0 commit comments