Skip to content

Commit 51ad123

Browse files
authored
Merge pull request #4023 from Sahil7741/fix/macos-setup-installer
Improve macOS handling in setup and dependency installer scripts
2 parents 8ad0ff7 + 98baadd commit 51ad123

2 files changed

Lines changed: 22 additions & 5 deletions

File tree

etc/DependencyInstaller.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,11 @@ fi
1111

1212
# package versions
1313
klayoutVersion=0.30.3
14-
numThreads=$(nproc)
14+
if [[ "$OSTYPE" == "darwin"* ]]; then
15+
numThreads=$(sysctl -n hw.ncpu)
16+
else
17+
numThreads=$(nproc)
18+
fi
1519

1620
_versionCompare() {
1721
local a b IFS=. ; set -f

setup.sh

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,13 @@ set -euo pipefail
55
# allow this script to be invoked from any folder
66
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
77

8-
if [ $EUID -ne 0 ]; then
9-
echo "This script must be run with sudo"
8+
if [[ "$OSTYPE" == "darwin"* ]] && [[ $EUID -eq 0 ]]; then
9+
echo "Do NOT run this script with sudo on macOS"
10+
exit 1
11+
fi
12+
13+
if [[ "$OSTYPE" != "darwin"* ]] && [[ $EUID -ne 0 ]]; then
14+
echo "This script must be run with sudo on Linux"
1015
exit 1
1116
fi
1217

@@ -17,7 +22,11 @@ tmpfile=$(mktemp)
1722
git submodule status --recursive > "$tmpfile"
1823

1924
if grep -q "^-" "$tmpfile"; then
20-
sudo -u $SUDO_USER git submodule update --init --recursive
25+
if [[ "$OSTYPE" == "darwin"* ]]; then
26+
git submodule update --init --recursive
27+
else
28+
sudo -u $SUDO_USER git submodule update --init --recursive
29+
fi
2130
elif grep -q "^+" "$tmpfile"; then
2231
# Make it easy for users who are not hacking ORFS to do the right thing,
2332
# run with current submodules, at the cost of having ORFS
@@ -27,4 +36,8 @@ elif grep -q "^+" "$tmpfile"; then
2736
fi
2837

2938
"$DIR/etc/DependencyInstaller.sh" -base
30-
sudo -u $SUDO_USER "$DIR/etc/DependencyInstaller.sh" -common -prefix="$DIR/dependencies"
39+
if [[ "$OSTYPE" == "darwin"* ]]; then
40+
"$DIR/etc/DependencyInstaller.sh" -common -prefix="$DIR/dependencies"
41+
else
42+
sudo -u $SUDO_USER "$DIR/etc/DependencyInstaller.sh" -common -prefix="$DIR/dependencies"
43+
fi

0 commit comments

Comments
 (0)