Skip to content

Commit

Permalink
Fix composer permissions on unix
Browse files Browse the repository at this point in the history
  • Loading branch information
shivammathur committed Jul 21, 2021
1 parent 9d1fe69 commit b57416e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 11 deletions.
16 changes: 11 additions & 5 deletions src/scripts/darwin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,14 @@ configure_composer() {
add_log "$cross" "composer" "Could not download composer"
exit 1;
fi
if ! [ -d "$composer_home" ]; then
sudo -u "$(id -un)" -g "$(id -gn)" mkdir -p -m=00755 "$composer_home"
else
sudo chown -R "$(id -un)":"$(id -gn)" "$composer_home"
fi
if ! [ -e "$composer_json" ]; then
echo '{}' | tee "$composer_json" >/dev/null 2>&1
sudo chmod 644 "$composer_json"
echo '{}' | tee "$composer_json" >/dev/null
chmod 644 "$composer_json"
fi
composer -q config -g process-timeout 0
echo "$composer_bin" >> "$GITHUB_PATH"
Expand Down Expand Up @@ -297,9 +302,10 @@ version=$1
dist=$2
tool_path_dir="/usr/local/bin"
curl_opts=(-sL)
composer_bin="$HOME/.composer/vendor/bin"
composer_json="$HOME/.composer/composer.json"
composer_lock="$HOME/.composer/composer.lock"
composer_home="$HOME/.composer"
composer_bin="$composer_home/vendor/bin"
composer_json="$composer_home/composer.json"
composer_lock="$composer_home/composer.lock"
brew_prefix="$(brew --prefix)"
brew_repo="$(brew --repository)"
tap_dir="$brew_repo"/Library/Taps
Expand Down
17 changes: 11 additions & 6 deletions src/scripts/linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -182,10 +182,14 @@ configure_composer() {
add_log "$cross" "composer" "Could not download composer"
exit 1;
fi
if ! [ -d "$composer_home" ]; then
sudo -u "$(id -un)" -g "$(id -gn)" mkdir -p -m=00755 "$composer_home"
else
sudo chown -R "$(id -un)":"$(id -gn)" "$composer_home"
fi
if ! [ -e "$composer_json" ]; then
sudo mkdir -p "$(dirname "$composer_json")"
echo '{}' | tee "$composer_json" >/dev/null 2>&1
sudo chmod 644 "$composer_json"
echo '{}' | tee "$composer_json" >/dev/null
chmod 644 "$composer_json"
fi
composer -q config -g process-timeout 0
echo "$composer_bin" >> "$GITHUB_PATH"
Expand Down Expand Up @@ -320,9 +324,10 @@ debconf_fix="DEBIAN_FRONTEND=noninteractive"
apt_install="sudo $debconf_fix apt-fast install -y"
tool_path_dir="/usr/local/bin"
curl_opts=(-sL)
composer_bin="$HOME/.composer/vendor/bin"
composer_json="$HOME/.composer/composer.json"
composer_lock="$HOME/.composer/composer.lock"
composer_home="$HOME/.composer"
composer_bin="$composer_home/vendor/bin"
composer_json="$composer_home/composer.json"
composer_lock="$composer_home/composer.lock"
existing_version=$(php-config --version 2>/dev/null | cut -c 1-3)

# Setup PHP
Expand Down

0 comments on commit b57416e

Please sign in to comment.