Created
October 25, 2011 14:57
-
-
Save wssrstrm/1313029 to your computer and use it in GitHub Desktop.
pecl zip installer script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
set -e | |
# Version 1.0, 2007-10-18 | |
# | |
# - Initial Release (2007-10-18) | |
#### User Configuration Options | |
# Temporary source directory | |
SRCDIR=/usr/local/source | |
# Download temporary DIST files to which directory? | |
DISTDIR=/usr/local/source/dist | |
# Delete contents of DISTDIR after installation? (Default: Yes) | |
DISTDEL="No" | |
# Install Pecl-Zip to which directory? | |
# Note: This *MUST* be set to your PHP5 installation directory! | |
INSTALLDIR=/usr/local/php5 | |
# Nice Level for Processes. (Depreciated) | |
# Higher is nicer, lower is less nice and could get your install process killed! | |
NICE=19 | |
## Program Version Configuration | |
# Don't touch unless you know what you're doing! | |
AUTOCONF="autoconf-2.61" | |
AUTOMAKE="automake-1.10" | |
ZIP="zip-1.8.10" | |
# What features do you want enabled? | |
ZIPFEATURES="--prefix=${INSTALLDIR}" | |
#### END User Configuration Options | |
########## DO NOT MODIFY BELOW ########## | |
sleep 1s | |
# Push the install dir's bin directory into the path | |
export PATH=${INSTALLDIR}/bin:$PATH | |
# Clear and/or create the source directory. | |
if [ -d ${SRCDIR} ]; then | |
echo "Source directory already exists! Cleaning it..." | |
rm -rf $SRCDIR/* | |
else | |
echo "Creating source directory..." | |
mkdir -p ${SRCDIR} | |
fi | |
# Create the dist files directory if it doesn't exist | |
# optionally cleaning it if it does exist already. | |
if [ -d ${DISTDIR} ]; then | |
echo ""; echo "Distribution directory already exists!"; echo "Clean it?" | |
if [ ${DISTDEL} == "Yes" ] | |
then | |
echo ""; echo "Yes!"; echo "Cleaning now..."; echo "" | |
rm -rf $DISTDIR/* | |
else | |
echo ""; echo "No!"; echo "Leaving the distribution directory intact."; echo "" | |
fi | |
else | |
echo "Creating distribution directory..." | |
mkdir -p ${DISTDIR} | |
fi | |
# Make sure the extensions directory exists. | |
if [ -d ${INSTALLDIR}/lib/php/extensions ]; then | |
echo "lib/php/extensions folder already exists! Doing nothing..." | |
else | |
mkdir -p ${INSTALLDIR}/lib/php/extensions | |
fi | |
# Detect how many processors the system has (for more optimal compliation). | |
cores=2 # the number of cores/procs to use when building | |
if [ $cores -a $cores -gt 1 ]; then | |
j="-j$cores " | |
fi | |
OS=`uname -s` | |
if [ "Darwin" = $OS ]; then | |
sed=gnused | |
makefile=makefile.macosx | |
else | |
makefile=makefile.linux_x86_ppc_alpha | |
sed=sed | |
fi | |
for i in $sed wget; do | |
$i --version >/dev/null 2>&1 | |
done | |
## Check if packages already exist and get packages the ones that don't. | |
cd ${DISTDIR} | |
# Do not abort on errors. | |
set +e | |
# Wget options | |
WGETOPT="-t1 -T10 -w5 -q -c" | |
# Do some of our own error checking here too. | |
if [ -a ${DISTDIR}/${AUTOCONF}.tar.gz ]; then | |
echo "Skipping wget of ${AUTOCONF}.tar.gz" | |
else | |
wget $WGETOPT ftp://ftp.ucsb.edu/pub/mirrors/linux/gentoo/distfiles/${AUTOCONF}.tar.gz | |
# If primary mirror fails, use the alternative mirror. | |
if [ -a ${DISTDIR}/${AUTOCONF}.tar.gz ]; then | |
echo "Got ${AUTOCONF}.tar.gz" | |
else | |
wget $WGETOPT ftp://ftp.gnu.org/gnu/autoconf/${AUTOCONF}.tar.gz | |
# Check to make sure the alternative mirror worked. | |
if [ -a ${DISTDIR}/${AUTOCONF}.tar.gz ]; then | |
echo "Got ${AUTOCONF}.tar.gz" | |
else | |
echo "Failed to get ${AUTOCONF}.tar.gz. Aborting install!" | |
exit 0 | |
fi | |
fi | |
fi | |
if [ -a ${DISTDIR}/${AUTOMAKE}.tar.bz2 ]; then | |
echo Skipping wget of ${AUTOMAKE}.tar.bz2 | |
else | |
wget $WGETOPT ftp://ftp.ucsb.edu/pub/mirrors/linux/gentoo/distfiles/${AUTOMAKE}.tar.bz2 | |
# If primary mirror fails, use the alternative mirror. | |
if [ -a ${DISTDIR}/${AUTOMAKE}.tar.bz2 ]; then | |
echo "Got ${AUTOMAKE}.tar.bz2" | |
else | |
wget $WGETOPT ftp://ftp.gnu.org/gnu/automake/${AUTOMAKE}.tar.bz2 | |
# Check to make sure the alternative mirror worked. | |
if [ -a ${DISTDIR}/${AUTOMAKE}.tar.bz2 ]; then | |
echo "Got ${AUTOMAKE}.tar.bz2" | |
else | |
echo "Failed to get ${AUTOMAKE}.tar.bz2. Aborting install!" | |
exit 0 | |
fi | |
fi | |
fi | |
if [ -a ${DISTDIR}/${ZIP}.tgz ]; then | |
echo "Skipping wget of ${ZIP}.tgz" | |
else | |
wget $WGETOPT ftp://ftp.ucsb.edu/pub/mirrors/linux/gentoo/distfiles/${ZIP}.tgz | |
# If primary mirror fails, use the alternative mirror. | |
if [ -a ${DISTDIR}/${ZIP}.tgz ]; then | |
echo "Got ${ZIP}.tgz" | |
else | |
wget $WGETOPT http://pecl.php.net/get/${ZIP}.tgz | |
# Check to make sure the alternative mirror worked. | |
if [ -a ${DISTDIR}/${ZIP}.tgz ]; then | |
echo "Got ${ZIP}.tgz" | |
else | |
echo "Failed to get ${ZIP}.tgz. Aborting install!" | |
exit 0 | |
fi | |
fi | |
fi | |
set -e | |
# Extract the source files into the source directory. | |
cd ${SRCDIR} | |
echo "Extracting ${AUTOCONF}..." | |
tar xzf ${DISTDIR}/${AUTOCONF}.tar.gz > /dev/null | |
echo "Done." | |
echo "Extracting ${AUTOMAKE}..." | |
tar xjf ${DISTDIR}/${AUTOMAKE}.tar.bz2 > /dev/null | |
echo "Done." | |
echo "Extracting ${ZIP}..." | |
tar xzf ${DISTDIR}/${ZIP}.tgz > /dev/null | |
echo "Done." | |
# Required exports | |
export PATH=${SRCDIR}/bin:$PATH | |
export PHP_PREFIX=${INSTALLDIR}/bin | |
## Compile deps and install Pecl-Zip | |
#AUTOCONF | |
cd ${SRCDIR}/${AUTOCONF} | |
./configure --prefix=${SRCDIR} | |
# make clean | |
nice -n ${NICE} make | |
make install | |
#AUTOMAKE | |
cd ${SRCDIR}/${AUTOMAKE} | |
./configure --prefix=${SRCDIR} | |
# make clean | |
nice -n ${NICE} make | |
make install | |
#ZIP | |
cd ${SRCDIR}/${ZIP} | |
$PHP_PREFIX/phpize | |
./configure ${ZIPFEATURES} | |
# make clean | |
nice -n ${NICE} make | |
# Install Pecl-Zip now by copying the lib file over to the PHP extension dir. | |
cp modules/zip.so ${INSTALLDIR}/lib/php/extensions/zip.so | |
cp modules/zip.la ${INSTALLDIR}/lib/php/extensions/zip.la | |
# Post install clean-up. | |
sleep 2s | |
cd /usr/local/source && clear | |
#rm -rf $SRCDIR | |
if [ ${DISTDEL} == "Yes" ]; then | |
rm -rf $DISTDIR | |
elif [ ${DISTDEL} == "No" ]; then | |
echo "Your DISTDIR will not be cleaned." | |
else | |
echo "Unknown DISTDEL option! Cleaning your DISTDIR by default." | |
fi | |
## End of Install | |
echo "Installation completed!" `date +%r` | |
#EOF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is the script that (I think) worked.