From 53e89d3eb84bd9c7396bc8aa8553919711de329c Mon Sep 17 00:00:00 2001 From: Sahil Jaiswal Date: Sat, 21 Mar 2026 04:25:21 +0530 Subject: [PATCH 1/2] setup: improve macOS handling in setup and dependency installer Signed-off-by: Sahil Jaiswal --- etc/DependencyInstaller.sh | 6 +++++- setup.sh | 27 +++++++++++++++++++++++---- 2 files changed, 28 insertions(+), 5 deletions(-) diff --git a/etc/DependencyInstaller.sh b/etc/DependencyInstaller.sh index 3a80d3764f..f2459dfe60 100755 --- a/etc/DependencyInstaller.sh +++ b/etc/DependencyInstaller.sh @@ -11,7 +11,11 @@ fi # package versions klayoutVersion=0.30.3 -numThreads=$(nproc) +if [[ "$OSTYPE" == "darwin"* ]]; then + numThreads=$(sysctl -n hw.ncpu) +else + numThreads=$(nproc) +fi _versionCompare() { local a b IFS=. ; set -f diff --git a/setup.sh b/setup.sh index 22a84cfea8..d2a65ce69d 100755 --- a/setup.sh +++ b/setup.sh @@ -5,8 +5,19 @@ set -euo pipefail # allow this script to be invoked from any folder DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -if [ $EUID -ne 0 ]; then - echo "This script must be run with sudo" +# macOS detection +IS_DARWIN=false +if [[ "$(uname)" == "Darwin" ]]; then + IS_DARWIN=true +fi + +if $IS_DARWIN && [[ $EUID -eq 0 ]]; then + echo "Do NOT run this script with sudo on macOS" + exit 1 +fi + +if ! $IS_DARWIN && [[ $EUID -ne 0 ]]; then + echo "This script must be run with sudo on Linux" exit 1 fi @@ -17,7 +28,11 @@ tmpfile=$(mktemp) git submodule status --recursive > "$tmpfile" if grep -q "^-" "$tmpfile"; then - sudo -u $SUDO_USER git submodule update --init --recursive + if $IS_DARWIN; then + git submodule update --init --recursive + else + sudo -u $SUDO_USER git submodule update --init --recursive + fi elif grep -q "^+" "$tmpfile"; then # Make it easy for users who are not hacking ORFS to do the right thing, # run with current submodules, at the cost of having ORFS @@ -27,4 +42,8 @@ elif grep -q "^+" "$tmpfile"; then fi "$DIR/etc/DependencyInstaller.sh" -base -sudo -u $SUDO_USER "$DIR/etc/DependencyInstaller.sh" -common -prefix="$DIR/dependencies" +if $IS_DARWIN; then + "$DIR/etc/DependencyInstaller.sh" -common -prefix="$DIR/dependencies" +else + sudo -u $SUDO_USER "$DIR/etc/DependencyInstaller.sh" -common -prefix="$DIR/dependencies" +fi From 98baadd21882748cf3be3d3cab28499e57156dc1 Mon Sep 17 00:00:00 2001 From: Sahil Jaiswal Date: Sun, 22 Mar 2026 00:39:32 +0530 Subject: [PATCH 2/2] Follow existing coding style Signed-off-by: Sahil Jaiswal --- setup.sh | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/setup.sh b/setup.sh index d2a65ce69d..b9f2853e1e 100755 --- a/setup.sh +++ b/setup.sh @@ -5,18 +5,12 @@ set -euo pipefail # allow this script to be invoked from any folder DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -# macOS detection -IS_DARWIN=false -if [[ "$(uname)" == "Darwin" ]]; then - IS_DARWIN=true -fi - -if $IS_DARWIN && [[ $EUID -eq 0 ]]; then +if [[ "$OSTYPE" == "darwin"* ]] && [[ $EUID -eq 0 ]]; then echo "Do NOT run this script with sudo on macOS" exit 1 fi -if ! $IS_DARWIN && [[ $EUID -ne 0 ]]; then +if [[ "$OSTYPE" != "darwin"* ]] && [[ $EUID -ne 0 ]]; then echo "This script must be run with sudo on Linux" exit 1 fi @@ -28,7 +22,7 @@ tmpfile=$(mktemp) git submodule status --recursive > "$tmpfile" if grep -q "^-" "$tmpfile"; then - if $IS_DARWIN; then + if [[ "$OSTYPE" == "darwin"* ]]; then git submodule update --init --recursive else sudo -u $SUDO_USER git submodule update --init --recursive @@ -42,7 +36,7 @@ elif grep -q "^+" "$tmpfile"; then fi "$DIR/etc/DependencyInstaller.sh" -base -if $IS_DARWIN; then +if [[ "$OSTYPE" == "darwin"* ]]; then "$DIR/etc/DependencyInstaller.sh" -common -prefix="$DIR/dependencies" else sudo -u $SUDO_USER "$DIR/etc/DependencyInstaller.sh" -common -prefix="$DIR/dependencies"