From 48cfea3f3eae74739cce31a70839f3ffbf8820a1 Mon Sep 17 00:00:00 2001 From: Shivam Mathur Date: Sun, 2 Feb 2020 04:30:01 +0530 Subject: [PATCH] Add script to help cache extensions --- src/scripts/ext/extensions.sh | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 src/scripts/ext/extensions.sh diff --git a/src/scripts/ext/extensions.sh b/src/scripts/ext/extensions.sh new file mode 100644 index 00000000..af88bcae --- /dev/null +++ b/src/scripts/ext/extensions.sh @@ -0,0 +1,15 @@ +php_h="https://raw.githubusercontent.com/php/php-src/PHP-$2/main/php.h" +os=$(uname -s) +if [ "$os" = "Linux" ]; then + apiv=$(curl -sSL --retry 5 "$php_h" | grep "PHP_API_VERSION" | cut -d' ' -f 3) + dir="/usr/lib/php/$apiv" + sudo mkdir -p "$dir" && sudo chown -R "$USER":"$(id -g -n)" /usr/lib/php +elif [ "$os" = "Darwin" ]; then + apiv=$(curl -sSL --retry 5 "$php_h" | grep "PHP_API_VERSION" | cut -d' ' -f 3) + dir="/usr/local/lib/php/pecl/$apiv" +else + dir='C:\\tools\\php\\ext' +fi +hash=$(echo -n "$1" | openssl dgst -sha256 | cut -d ' ' -f 2) +echo "::set-output name=ext_dir::$dir" +echo "::set-output name=ext_hash::$hash" \ No newline at end of file