mirror of
https://github.com/shivammathur/setup-php.git
synced 2024-11-22 11:51:07 +07:00
Cleanup dependency code on macOS and add retry to git fetch
This commit is contained in:
parent
48e0de2ea6
commit
21eeae309a
@ -113,17 +113,6 @@ add_pecl() {
|
|||||||
add_log "${tick:?}" "PECL" "Found PECL $pear_version"
|
add_log "${tick:?}" "PECL" "Found PECL $pear_version"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to link all libraries of a formula.
|
|
||||||
link_libraries() {
|
|
||||||
formula=$1
|
|
||||||
formula_prefix="$(brew --prefix "$formula")"
|
|
||||||
sudo mkdir -p "$formula_prefix"/lib
|
|
||||||
for lib in "$formula_prefix"/lib/*.dylib; do
|
|
||||||
lib_name=$(basename "$lib")
|
|
||||||
sudo cp -a "$lib" "$brew_prefix/lib/$lib_name" 2>/dev/null || true
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
# Link opcache extension to extensions directory.
|
# Link opcache extension to extensions directory.
|
||||||
link_opcache() {
|
link_opcache() {
|
||||||
opcache_ini="$brew_prefix"/etc/php/"$version"/conf.d/ext-opcache.ini
|
opcache_ini="$brew_prefix"/etc/php/"$version"/conf.d/ext-opcache.ini
|
||||||
@ -142,19 +131,11 @@ patch_brew() {
|
|||||||
trap "sudo sed -Ei '' 's/$code.*/$code, overwrite: overwrite?\)/' $formula_installer" exit
|
trap "sudo sed -Ei '' 's/$code.*/$code, overwrite: overwrite?\)/' $formula_installer" exit
|
||||||
}
|
}
|
||||||
|
|
||||||
# Helper function to update the dependencies.
|
|
||||||
update_dependencies_helper() {
|
|
||||||
dependency=$1
|
|
||||||
[[ "${dependency:0:3}" = "lib" ]] && prefix=lib || prefix="${dependency:0:1}"
|
|
||||||
get -q -n "$core_repo/Formula/$prefix/$dependency.rb" "https://raw.githubusercontent.com/Homebrew/homebrew-core/master/Formula/$prefix/$dependency.rb"
|
|
||||||
link_libraries "$dependency"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Function to update dependencies.
|
# Function to update dependencies.
|
||||||
update_dependencies() {
|
update_dependencies() {
|
||||||
patch_brew
|
patch_brew
|
||||||
if ! [ -e /tmp/update_dependencies ]; then
|
if ! [ -e /tmp/update_dependencies ]; then
|
||||||
git -C "$core_repo" fetch origin master && git -C "$core_repo" reset --hard origin/master
|
git_retry -C "$core_repo" fetch origin master && git -C "$core_repo" reset --hard origin/master
|
||||||
echo '' | sudo tee /tmp/update_dependencies >/dev/null 2>&1
|
echo '' | sudo tee /tmp/update_dependencies >/dev/null 2>&1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
@ -294,6 +275,7 @@ export HOMEBREW_NO_INSTALL_FROM_API=1
|
|||||||
# shellcheck source=.
|
# shellcheck source=.
|
||||||
. "${scripts:?}"/unix.sh
|
. "${scripts:?}"/unix.sh
|
||||||
. "${scripts:?}"/tools/brew.sh
|
. "${scripts:?}"/tools/brew.sh
|
||||||
|
. "${scripts:?}"/tools/retry.sh
|
||||||
. "${scripts:?}"/tools/add_tools.sh
|
. "${scripts:?}"/tools/add_tools.sh
|
||||||
. "${scripts:?}"/extensions/source.sh
|
. "${scripts:?}"/extensions/source.sh
|
||||||
. "${scripts:?}"/extensions/add_extensions.sh
|
. "${scripts:?}"/extensions/add_extensions.sh
|
||||||
|
20
src/scripts/tools/retry.sh
Normal file
20
src/scripts/tools/retry.sh
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
function retry {
|
||||||
|
local try=0
|
||||||
|
|
||||||
|
until "$@"; do
|
||||||
|
exit_code="$?"
|
||||||
|
try=$((try + 1))
|
||||||
|
|
||||||
|
if [ $try -lt 10 ]; then
|
||||||
|
sleep "$((2 ** try))"
|
||||||
|
else
|
||||||
|
return $exit_code
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
function git_retry {
|
||||||
|
retry git "$@"
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user