Skip to content

Commit 8ad0af6

Browse files
authored
Merge pull request #358 from nai1ka/fix-installation-on-mac
Fix installation on mac
2 parents c429158 + 95e1df4 commit 8ad0af6

File tree

3 files changed

+22
-15
lines changed

3 files changed

+22
-15
lines changed

help/sudo.sh

+16-9
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,19 @@
2323
set -e
2424
set -o pipefail
2525

26-
if "${LOCAL}/help/is-linux.sh"; then
27-
if [ ! "$(id -u)" = 0 ]; then
28-
echo "You should run it as root: 'sudo make install'"
29-
exit 1
30-
fi
31-
"$@"
32-
else
33-
sudo "$@"
34-
fi
26+
if "${LOCAL}/help/is-linux.sh" || "${LOCAL}/help/is-macos.sh" ; then
27+
if [ ! "$(id -u)" = 0 ]; then
28+
echo "You should run it as root: 'sudo make install'"
29+
exit 1
30+
fi
31+
32+
if [ "$1" == "--as-user" ]; then
33+
shift
34+
sudo -u "$SUDO_USER" "$@"
35+
else
36+
# If no flag is provided, root is the default option
37+
"$@"
38+
fi
39+
else
40+
sudo "$@"
41+
fi

installs/install-pmd.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,5 +48,5 @@ wget --quiet "https://github.com/pmd/pmd/releases/download/pmd_releases%2F${pmd_
4848
unzip -qq "${name}.zip"
4949
rm "${name}.zip"
5050
mv "pmd-bin-${pmd_version}" pmd
51-
ln -s /usr/local/pmd/bin/run.sh /usr/local/bin/pmd
51+
ln -s /usr/local/pmd/bin/pmd /usr/local/bin/pmd
5252
echo "PMD installed into /usr/local/bin/pmd"

steps/install.sh

+5-5
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ function install_package() {
3838
"${LOCAL}/help/sudo.sh" apt-get install -y "$PACKAGE"
3939
elif "${LOCAL}/help/is-macos.sh"; then
4040
if brew -v; then
41-
brew install "$PACKAGE"
41+
"${LOCAL}/help/sudo.sh" --as-user brew install "$PACKAGE"
4242
else
4343
echo "If you install Homebrew, all necessary packages will be installed automatically by running 'make install'. Visit the Homebrew installation documentation at: https://docs.brew.sh/Installation"
4444
exit 1
@@ -59,15 +59,15 @@ install_package xmlstarlet
5959
install_package gawk
6060

6161
if "${LOCAL}/help/is-macos.sh"; then
62-
brew install coreutils
63-
brew install wget
62+
"${LOCAL}/help/sudo.sh" --as-user brew install coreutils
63+
"${LOCAL}/help/sudo.sh" --as-user brew install wget
6464
fi
6565

6666
if ! pdftotext -v >/dev/null 2>&1; then
6767
if "${LOCAL}/help/is-linux.sh"; then
6868
"${LOCAL}/help/sudo.sh" apt-get install -y xpdf
6969
elif "${LOCAL}/help/is-macos.sh"; then
70-
brew install poppler
70+
"${LOCAL}/help/sudo.sh" --as-user brew install poppler
7171
else
7272
"${LOCAL}/help/assert-tool.sh" pdftotext -v
7373
fi
@@ -79,7 +79,7 @@ if ! inkscape --version >/dev/null 2>&1; then
7979
"${LOCAL}/help/sudo.sh" apt-get update -y --fix-missing && \
8080
"${LOCAL}/help/sudo.sh" apt-get install -y inkscape
8181
elif "${LOCAL}/help/is-macos.sh"; then
82-
brew install --cask inkscape
82+
"${LOCAL}/help/sudo.sh" --as-user brew install --cask inkscape
8383
else
8484
"${LOCAL}/help/assert-tool.sh" inkscape --version
8585
fi

0 commit comments

Comments
 (0)