Skip to content

Instantly share code, notes, and snippets.

@tgabi333
Last active February 3, 2016 15:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tgabi333/f6841d9517225f231a33 to your computer and use it in GitHub Desktop.
Save tgabi333/f6841d9517225f231a33 to your computer and use it in GitHub Desktop.
travis php pecl package cacher
#!/bin/bash
MODULE_CACHE_DIR=${TRAVIS_BUILD_DIR}/travis_cache/`php-config --vernum`
INI_DIR=${TRAVIS_BUILD_DIR}/travis_cache/ini
PHP_TARGET_DIR=`php-config --extension-dir`
PHP_INI_FILE=`php -r "echo php_ini_loaded_file();"`
if [ -d ${MODULE_CACHE_DIR} ]
then
cp ${MODULE_CACHE_DIR}/* ${PHP_TARGET_DIR}
fi
mkdir -p ${INI_DIR}
mkdir -p ${MODULE_CACHE_DIR}
for module in $MODULES
do
FILENAME=`echo $module|cut -d : -f 1`
PRIORITY=`echo $module|cut -d : -f 2`
PACKAGE=`echo $module|cut -d : -f 3`
if [ ! -f ${PHP_TARGET_DIR}/${FILENAME} ]
then
echo "$FILENAME not found in extension dir, compiling"
printf "yes\n" | pecl install ${PACKAGE}
sed -i '1d' ${PHP_INI_FILE}
fi
echo "Adding $FILENAME to php config"
echo "extension = $FILENAME" > ${INI_DIR}/${PRIORITY}-${FILENAME}.ini
phpenv config-add ${INI_DIR}/${PRIORITY}-${FILENAME}.ini
cp ${PHP_TARGET_DIR}/${FILENAME} ${MODULE_CACHE_DIR}
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment