Skip to content

Commit a9c25c8

Browse files
committed
Shell files code format
1 parent 9cec493 commit a9c25c8

File tree

2 files changed

+83
-94
lines changed

2 files changed

+83
-94
lines changed

script/bootstrap

+77-88
Original file line numberDiff line numberDiff line change
@@ -6,114 +6,103 @@ 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+
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
6675
fi
6776

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
8880

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
9284

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..."
9687

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)
9889

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
10695

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
111100

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
117106
}
118107

119108
main

script/update_libgit2

+6-6
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@ set -e
55
cd "External/libgit2"
66

77
if [ -d "build" ]; then
8-
rm -rf "build"
8+
rm -rf "build"
99
fi
1010

1111
mkdir build
1212
cd build
1313

1414
# OpenSSL is keg-only, so add its pkgconfig location manually
15-
if [[ `uname -m` == 'arm64' ]]; then
15+
if [[ $(uname -m) == 'arm64' ]]; then
1616
echo "Running on a Apple Silicon M1"
1717
export ARCH_PREFIX=/opt/homebrew
1818
else
@@ -27,10 +27,10 @@ export PKG_CONFIG_PATH=$ARCH_PREFIX/opt/openssl/lib/pkgconfig
2727
PATH="$ARCH_PREFIX/bin:$PATH"
2828

2929
cmake -DBUILD_SHARED_LIBS:BOOL=OFF \
30-
-DLIBSSH2_INCLUDE_DIRS:PATH=$ARCH_PREFIX/include/ \
31-
-DBUILD_CLAR:BOOL=OFF \
32-
-DTHREADSAFE:BOOL=ON \
33-
..
30+
-DLIBSSH2_INCLUDE_DIRS:PATH=$ARCH_PREFIX/include/ \
31+
-DBUILD_CLAR:BOOL=OFF \
32+
-DTHREADSAFE:BOOL=ON \
33+
..
3434
cmake --build .
3535

3636
product="libgit2.a"

0 commit comments

Comments
 (0)