summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuca Longinotti <chtekk@gentoo.org>2005-12-28 13:49:36 +0000
committerLuca Longinotti <chtekk@gentoo.org>2005-12-28 13:49:36 +0000
commit3f0aad6a1bad1e89be9b127ef20dbc35f95b1aa0 (patch)
treeeffb07ae63dbe56737cf7b43cc12f2305b361f53 /app-admin/php-toolkit
parentmaking x86 & amd64 stable following testing. (diff)
downloadhistorical-3f0aad6a1bad1e89be9b127ef20dbc35f95b1aa0.tar.gz
historical-3f0aad6a1bad1e89be9b127ef20dbc35f95b1aa0.tar.bz2
historical-3f0aad6a1bad1e89be9b127ef20dbc35f95b1aa0.zip
Initial ebuild for php-toolkit.
Package-Manager: portage-2.0.53
Diffstat (limited to 'app-admin/php-toolkit')
-rw-r--r--app-admin/php-toolkit/ChangeLog16
-rw-r--r--app-admin/php-toolkit/Manifest12
-rw-r--r--app-admin/php-toolkit/files/digest-php-toolkit-1.00
-rw-r--r--app-admin/php-toolkit/files/php-select381
-rw-r--r--app-admin/php-toolkit/files/php-select-modules/apache1.sh20
-rw-r--r--app-admin/php-toolkit/files/php-select-modules/apache2.sh20
-rw-r--r--app-admin/php-toolkit/files/php-select-modules/libapache.sh233
-rw-r--r--app-admin/php-toolkit/files/php-select-modules/libsymlink.sh243
-rw-r--r--app-admin/php-toolkit/files/php-select-modules/php-cgi.sh18
-rw-r--r--app-admin/php-toolkit/files/php-select-modules/php-devel.sh21
-rw-r--r--app-admin/php-toolkit/files/php-select-modules/php.sh18
-rw-r--r--app-admin/php-toolkit/metadata.xml5
-rw-r--r--app-admin/php-toolkit/php-toolkit-1.0.ebuild30
13 files changed, 1017 insertions, 0 deletions
diff --git a/app-admin/php-toolkit/ChangeLog b/app-admin/php-toolkit/ChangeLog
new file mode 100644
index 000000000000..ede6caf806b2
--- /dev/null
+++ b/app-admin/php-toolkit/ChangeLog
@@ -0,0 +1,16 @@
+# ChangeLog for app-admin/php-toolkit
+# Copyright 1999-2005 Gentoo Foundation; Distributed under the GPL v2
+# $Header: /var/cvsroot/gentoo-x86/app-admin/php-toolkit/ChangeLog,v 1.1 2005/12/28 13:49:36 chtekk Exp $
+
+*php-toolkit-1.0 (28 Dec 2005)
+
+ 28 Dec 2005; Luca Longinotti <chtekk@gentoo.org> +files/php-select,
+ +files/php-select-modules/apache1.sh,
+ +files/php-select-modules/apache2.sh,
+ +files/php-select-modules/libapache.sh,
+ +files/php-select-modules/libsymlink.sh, +files/php-select-modules/php.sh,
+ +files/php-select-modules/php-cgi.sh,
+ +files/php-select-modules/php-devel.sh, +metadata.xml,
+ +php-toolkit-1.0.ebuild:
+ Initial ebuild for php-toolkit. Includes php-select.
+
diff --git a/app-admin/php-toolkit/Manifest b/app-admin/php-toolkit/Manifest
new file mode 100644
index 000000000000..b8d8be71fd51
--- /dev/null
+++ b/app-admin/php-toolkit/Manifest
@@ -0,0 +1,12 @@
+MD5 f53545a138f83cd59a147b3e314851b1 ChangeLog 696
+MD5 d41d8cd98f00b204e9800998ecf8427e files/digest-php-toolkit-1.0 0
+MD5 4a45245e9b5d4fd45b744f093190a08b files/php-select 8283
+MD5 dfd0ee80895ad0838d0d14d7bfb3cd5d files/php-select-modules/apache1.sh 508
+MD5 996b58c1298deb31512e75f0a4af1a61 files/php-select-modules/apache2.sh 512
+MD5 54965be7111a69cdabe1a7af4925eedb files/php-select-modules/libapache.sh 6160
+MD5 c60d3342a7482d3d7ff8f2314c8c3c66 files/php-select-modules/libsymlink.sh 6395
+MD5 4ecf2a69badd7ba1b12fc497544726f3 files/php-select-modules/php-cgi.sh 452
+MD5 e4c69f3c38351cce893f12122cf3262c files/php-select-modules/php-devel.sh 532
+MD5 13c38bfdc416d740518637fe1425f467 files/php-select-modules/php.sh 436
+MD5 c58d07ca1c1235bbad9bccaec96fc062 metadata.xml 157
+MD5 501706c57c870d3fd24f2cc8ba20dc70 php-toolkit-1.0.ebuild 969
diff --git a/app-admin/php-toolkit/files/digest-php-toolkit-1.0 b/app-admin/php-toolkit/files/digest-php-toolkit-1.0
new file mode 100644
index 000000000000..e69de29bb2d1
--- /dev/null
+++ b/app-admin/php-toolkit/files/digest-php-toolkit-1.0
diff --git a/app-admin/php-toolkit/files/php-select b/app-admin/php-toolkit/files/php-select
new file mode 100644
index 000000000000..3d589663ab29
--- /dev/null
+++ b/app-admin/php-toolkit/files/php-select
@@ -0,0 +1,381 @@
+#!/bin/bash
+#
+# /usr/sbin/php-select
+# Tool for managing PHP symlinks on Gentoo Linux
+#
+# Author Stuart Herbert
+# (stuart@gentoo.org)
+#
+# Copyright (c) 2005 Gentoo Foundation, Inc.
+# Released under v2 of the GNU General Public License
+#
+# ========================================================================
+#
+# USAGE
+# -----
+#
+# php-select <component> [<php-version>]
+#
+# where
+# <component> is one of
+# php|php-cgi|php-devel|apache|apache2
+#
+# <php-version> is the directory under /usr/lib where PHP is installed
+#
+# php-select with no arguments will list all components for each installed
+# php-version
+#
+# php-select <component> will list the current php-version in use for that
+# component
+#
+# php-select <component> <php-version> will reconfigure Gentoo to use
+# <php-version> of <component>. This normally involves replacing symlinks
+# on the system
+
+# ========================================================================
+
+G_ACTION=
+G_COMPONENT=
+G_COPYRIGHT[0]="Copyright (c) 2005 Gentoo Foundation, Inc."
+G_COPYRIGHT[1]="Released under v2 of the GNU General Public License"
+G_EXITSTATUS=0
+G_LIBDIR[0]="/usr/lib64"
+G_LIBDIR[1]="/usr/lib32"
+G_LIBDIR[2]="/usr/lib"
+G_MODULE_PATH="/usr/share/php-select"
+G_NEED_COMPONENT=0
+G_NEED_PHPVERSION=0
+G_PN="$0"
+G_PN_BASE="`basename $G_PN`"
+G_PVR="1.0.1"
+G_PHPVERSION=
+
+G_STATUS_OK=0
+G_STATUS_USAGE=1
+G_STATUS_NOTINSTALLED=2
+G_STATUS_NOTCOMPATIBLE=3
+G_STATUS_USINGOTHER=4
+G_STATUS_USINGNONE=5
+
+# ========================================================================
+# The Main Actions
+# ========================================================================
+
+# ------------------------------------------------------------------------
+# doCopyright() - output the copyright info
+#
+# No arguments
+
+doCopyright ()
+{
+ local i
+
+ for (( i = 0 ; i < ${#G_COPYRIGHT[@]} ; i = i + 1 )) ; do
+ echo ${G_COPYRIGHT[$i]}
+ done
+}
+
+# ------------------------------------------------------------------------
+# doHelp() - show full help
+#
+# No arguments
+
+doHelp ()
+{
+ doVerboseVersion
+ echo
+
+ doUsageShort
+ echo
+ echo " $G_PN_BASE <component>"
+ echo " Show which version of PHP is used for <component>"
+ echo
+ echo " $G_PN_BASE -t <component> <php-version>"
+ echo " Test if <component> uses <php-version> or not"
+ echo
+ echo " $G_PN_BASE <component> <php-version>"
+ echo " Set which version of PHP is used for <component>"
+ echo
+ echo " $G_PN_BASE -v"
+ echo " Show version number"
+ echo
+ echo " $G_PN_BASE -h"
+ echo " Show this help"
+ echo
+ echo "where <component> is one of:"
+ echo
+ echo " apache1 - Apache webserver v1.x"
+ echo " apache2 - Apache webserver v2.x"
+ echo " php - /usr/bin/php (the CLI SAPI)"
+ echo " php-cgi - /usr/bin/php-cgi (the CGI SAPI)"
+ echo " php-devel - the scripts used to build PECL extensions"
+ echo
+ echo "and where <php-version> is one of:"
+ echo
+ echo " php4 - php 4.x"
+ echo " php5 - php 5.x"
+ echo
+ echo "NOTE: none of these settings affect how Portage installs PHP or PEAR"
+ echo " packages or PECL extensions."
+ echo
+ echo "Exit status is one of:"
+ echo
+ echo " 0 == ok"
+ echo " 1 == usage error"
+ echo " 2 == no compatible PHP version found"
+ echo " 3 == incompatible PHP version specified"
+ echo " 4 == component uses a different PHP version"
+ echo " 5 == component not configured to use PHP"
+
+ echo
+ # doManPageDetails
+}
+
+# ------------------------------------------------------------------------
+# doManPageDetails() - show man page details
+#
+# No arguments
+
+doManPageDetails ()
+{
+ echo "See 'man $G_PN_BASE' for full details"
+}
+
+# ------------------------------------------------------------------------
+# doSetComponent() - set a component to use a particular php version
+#
+# $1: component to set
+# $2: php version to set the component to
+
+doSetComponent ()
+{
+ loadComponent $1 || exit 1
+ actionSet $2
+}
+
+# ------------------------------------------------------------------------
+# doShowComponent() - show which version of php a particular component is
+# currently using
+#
+# $1: component to show
+
+doShowComponent ()
+{
+ loadComponent $1 || exit 1
+ actionShow
+}
+
+# ------------------------------------------------------------------------
+# doTest() - check to see if a particular component is using a specified
+# version or not
+#
+# $1: component to test
+
+doTest ()
+{
+ loadComponent $1 || exit 1
+ actionTest
+}
+
+# ------------------------------------------------------------------------
+# doUsage() - tell the user to stop being a muppet :)
+#
+# No arguments
+
+doUsage ()
+{
+ doUsageShort
+ echo "use $G_PN_BASE --help for full details"
+ G_EXITSTATUS=1
+}
+
+# ------------------------------------------------------------------------
+# doUsageShort() - print out just the line to tell the user what to do
+#
+# No arguments
+
+doUsageShort ()
+{
+ echo "usage: $G_PN_BASE [-htv] [<component> [<php-version>] ]"
+}
+
+# ------------------------------------------------------------------------
+# doVerboseVersion() - show more version info
+#
+# No arguments
+
+doVerboseVersion ()
+{
+ doVersion
+ doCopyright
+}
+
+# ------------------------------------------------------------------------
+# doVersion() - show version info
+#
+# No arguments
+
+doVersion ()
+{
+ echo "$G_PN_BASE v$G_PVR"
+}
+
+# ========================================================================
+# Helping Functions
+# ========================================================================
+
+# ------------------------------------------------------------------------
+# loadComponent() - load a component's code into the script
+#
+# $1: component to load
+
+loadComponent ()
+{
+ # only load one component, and only do it once
+
+ if [[ -n $G_COMPONENT_LOADED ]] ; then
+ return
+ fi
+
+ local l_module="$G_MODULE_PATH/$1.sh"
+
+ if [[ ! -f $l_module ]] ; then
+ echo "Error: module $l_module not found"
+ return 1
+ fi
+
+ if [[ ! -r $l_module ]] ; then
+ echo "Error: module $l_module not readable"
+ return 1
+ fi
+
+ . "$l_module" && G_COMPONENT_LOADED=1
+ [[ $? != 0 ]] && echo "Error: component $l_module not loadable"
+
+ return 0
+}
+
+# ------------------------------------------------------------------------
+# missingComponent() - check to see if the user did not specify which
+# component to work on
+#
+# No arguments
+
+missingComponent ()
+{
+ if [[ -z $G_COMPONENT && $G_NEED_COMPONENT == 1 ]] ; then
+ echo "*** error: missing <component> argument"
+ return 0
+ fi
+
+ return 1
+}
+
+# ------------------------------------------------------------------------
+# missingPhpVersion() - check to see if the user did not specify which
+# PHP version to use
+#
+# No arguments
+
+missingPhpVersion ()
+{
+ if [[ -z $G_PHPVERSION && $G_NEED_PHPVERSION == 1 ]] ; then
+ echo "*** error: missing <php-version> argument"
+ return 0
+ fi
+
+ return 1
+}
+
+# ------------------------------------------------------------------------
+# parseArgs() - work out what the user has asked us to do
+#
+# $1: a php component (optional)
+# $2: a php version (optional)
+
+parseArgs ()
+{
+ # do we have any parameters at all?
+
+ if [[ -z $1 ]]; then
+ G_ACTION=doUsage
+ return
+ fi
+
+ # handle switches
+
+ while [[ -n $1 && ${1:0:1} == '-' ]]; do
+ case "$1" in
+ -v|--version)
+ G_ACTION=doVersion
+ return
+ ;;
+ -V)
+ G_ACTION=doVerboseVersion
+ return
+ ;;
+ -h|-\?|--help)
+ G_ACTION=doHelp
+ return
+ ;;
+ -t|--test)
+ G_ACTION=doTest
+ G_NEED_COMPONENT=1
+ G_NEED_PHPVERSION=1
+ ;;
+ *)
+ G_ACTION=doUsage
+ return
+ ;;
+ esac
+
+ shift
+ done
+
+ # if we get here, we have a non-switch to examine, or we
+ # don't have anything at all to look at
+
+ if [[ -z $1 ]]; then
+ if missingComponent || missingPhpVersion ; then
+ G_ACTION=doUsage
+ fi
+ return
+ fi
+
+ # we have a component - make a note of it
+
+ G_COMPONENT="$1"
+ shift
+
+ # do we have a php version too?
+
+ if [[ -z $1 ]]; then
+ if missingComponent || missingPhpVersion ; then
+ G_ACTION=doUsage
+ fi
+
+ [[ -z $G_ACTION ]] && G_ACTION=doShowComponent
+ return
+ fi
+
+ # yes we do - make a note of it too
+
+ G_PHPVERSION="$1"
+ [[ -z $G_ACTION ]] && G_ACTION=doSetComponent
+ shift
+
+ # we're done for now
+}
+
+# ------------------------------------------------------------------------
+# main() - it all happens here
+
+main ()
+{
+ parseArgs "$@"
+ $G_ACTION $G_COMPONENT $G_PHPVERSION
+
+ exit $G_EXITSTATUS
+}
+
+main "$@"
diff --git a/app-admin/php-toolkit/files/php-select-modules/apache1.sh b/app-admin/php-toolkit/files/php-select-modules/apache1.sh
new file mode 100644
index 000000000000..903819ca5b7b
--- /dev/null
+++ b/app-admin/php-toolkit/files/php-select-modules/apache1.sh
@@ -0,0 +1,20 @@
+#
+# /usr/share/php-select/apache1.sh
+# Module to manage mod_php for Apache2
+#
+# Written for Gentoo Linux
+#
+# Author Stuart Herbert
+# (stuart@gentoo.org)
+#
+# Copyright (c) 2005 Gentoo Foundation, Inc.
+# Released under version 2 of the GNU General Public License
+#
+# ========================================================================
+
+G_APACHE_CONF=/etc/conf.d/apache
+G_APACHE_INIT=/etc/init.d/apache
+G_OPTS_VAR="APACHE_OPTS"
+G_APACHE_MOD_DIR="/usr/lib/apache/modules"
+
+. $G_MODULE_PATH/libapache.sh
diff --git a/app-admin/php-toolkit/files/php-select-modules/apache2.sh b/app-admin/php-toolkit/files/php-select-modules/apache2.sh
new file mode 100644
index 000000000000..2add19ddfe30
--- /dev/null
+++ b/app-admin/php-toolkit/files/php-select-modules/apache2.sh
@@ -0,0 +1,20 @@
+#
+# /usr/share/php-select/apache2.sh
+# Module to manage mod_php for Apache2
+#
+# Written for Gentoo Linux
+#
+# Author Stuart Herbert
+# (stuart@gentoo.org)
+#
+# Copyright (c) 2005 Gentoo Foundation, Inc.
+# Released under version 2 of the GNU General Public License
+#
+# ========================================================================
+
+G_APACHE_CONF=/etc/conf.d/apache2
+G_APACHE_INIT=/etc/init.d/apache2
+G_OPTS_VAR="APACHE2_OPTS"
+G_APACHE_MOD_DIR="/usr/lib/apache2/modules"
+
+. $G_MODULE_PATH/libapache.sh
diff --git a/app-admin/php-toolkit/files/php-select-modules/libapache.sh b/app-admin/php-toolkit/files/php-select-modules/libapache.sh
new file mode 100644
index 000000000000..6aa6c8d25a40
--- /dev/null
+++ b/app-admin/php-toolkit/files/php-select-modules/libapache.sh
@@ -0,0 +1,233 @@
+#
+# /usr/share/php-select/libapache.sh
+# Tool for managing Apache options on Gentoo Linux
+#
+# Author Stuart Herbert
+# (stuart@gentoo.org)
+#
+# Copyright (c) 2005 Gentoo Foundation, Inc.
+# Released under v2 of the GNU General Public License
+#
+# ========================================================================
+
+actionSet ()
+{
+ setApacheConf
+}
+
+actionShow ()
+{
+ showApacheConf
+}
+
+actionTest ()
+{
+ testApacheConf
+}
+
+# ------------------------------------------------------------------------
+# chooseApacheVersion () - select which version of Apache[2] will use
+#
+# $1 - PHP version to set
+# $G_APACHE_CONF - apache config file to edit
+# $G_OPTS_VAR - config variable to edit
+# $G_APACHE_MOD_DIR - directory to look in for mod_php
+
+chooseApacheVersion ()
+{
+ # convert the PHP version to upper-case
+ chosen=$( echo $1 | tr [a-z] [A-Z] )
+
+ # make a list of the mod_php versions available
+ choices=( $(learnApacheMods $G_APACHE_MOD_DIR) )
+
+ for (( i = 0 ; i < ${#choices[@]} ; i = i + 1 )) ; do
+ if [[ ${choices[$i]} == $1 ]] ; then
+ echo $chosen
+ fi
+ done
+}
+
+# ------------------------------------------------------------------------
+# isInstalledForApache() - do we have any mod_php's installed for this
+# version of Apache or not?
+
+isInstalledForApache ()
+{
+ # find out which mod_php's are installed (if any!)
+ choices=( $(learnApacheMods ${G_APACHE_MOD_DIR}) )
+
+ # if there are no installed mod_php's, we tell the user
+ if [[ -z $choices ]] ; then
+ echo "*** error: mod_php is not installed for this version of Apache"
+ G_EXITSTATUS=$G_STATUS_NOTINSTALLED
+ return 1
+ fi
+
+ return 0
+}
+
+# ------------------------------------------------------------------------
+# isUsingModPhp() - determine if Apache is configured to use mod_php or not
+
+isUsingModPhp ()
+{
+ chosen=$(learnApacheConf ${G_APACHE_CONF})
+ if [[ -z $chosen ]] ; then
+ echo "No mod_php configured in $G_APACHE_CONF"
+ G_EXITSTATUS=$G_STATUS_USINGNONE
+ return 1
+ fi
+
+ return 0
+}
+
+# ------------------------------------------------------------------------
+# learnApacheConf() - determine which PHP mod is set
+#
+# $1 - apache config file to examine
+
+learnApacheConf ()
+{
+ . $1
+ echo "${!G_OPTS_VAR}" | sed -e 's|^.*\(PHP[0-9]\).*|\1|;'
+}
+
+# ------------------------------------------------------------------------
+# learnApacheMods() - learn which versions of mod_php are available for
+# a chosen Apache version
+#
+# $1 - directory to search
+
+learnApacheMods ()
+{
+ ls -1 $1/libphp*.so 2>/dev/null | sed -e 's|^.*lib\(php[0-9]\).*|\1|;'
+}
+
+# ------------------------------------------------------------------------
+# setApacheConf () - set which version of Apache[2] will use
+#
+# $1 - PHP version to set
+# $G_APACHE_CONF - apache config file to edit
+# $G_OPTS_VAR - config variable to edit
+# $G_APACHE_MOD_DIR - directory to look in for mod_php
+
+setApacheConf ()
+{
+ isInstalledForApache || return 1
+
+ # find out which option to set for Apache[2]
+ #
+ # if we can't find a matching mod_php to use, tell the user what
+ # versions are available
+
+ apacheChoice=$(chooseApacheVersion $1)
+ if [[ -z $apacheChoice ]] ; then
+ echo "*** error: compatible PHP version not found"
+ echo "Compatible versions are:"
+ echo
+ for (( i = 0 ; i < ${#choices[@]} ; i = i + 1 )) ; do
+ echo "* ${choices[$i]}"
+ done
+
+ G_EXITSTATUS=$G_STATUS_NOTCOMPATIBLE
+ return
+ fi
+
+ # we know which version of mod_php we want to use
+ #
+ # create a new APACHE_OPTS variable
+
+ . $G_APACHE_CONF
+ newVar="$( echo ${!G_OPTS_VAR} | sed -e 's|-D PHP[0-9]||;' )"
+ newVar="$( echo $newVar -D $apacheChoice | sed -e 's| | |g;' )"
+
+ # replace the old variable in the config file with the new one
+
+ sed -e "s|$G_OPTS_VAR=.*|$G_OPTS_VAR=\"$newVar\"|;" -i $G_APACHE_CONF
+
+ # remember to tell the user to restart apache!
+
+ echo "Apache conf.d file updated. For this change to take effect, you"
+ echo "must restart the Apache webserver using this command:"
+ echo
+ echo "$G_APACHE_INIT restart"
+}
+
+# ------------------------------------------------------------------------
+# showApacheConf() - show which version of PHP that Apache[2] is configured
+# to use
+#
+# $G_APACHE_CONF - the Gentoo config file for Apache
+# $G_OPTS_VAR - the variable in the config file to check
+
+showApacheConf ()
+{
+ isInstalledForApache || return 1
+
+ # if we get here, then we have 1 or more mod_php's installed
+ #
+ # find out which mod_php Apache is configured for (if any)
+
+ isUsingModPhp || return 1
+
+ # if we get here, then apache is configured for a mod_php ...
+ # is it one that is installed?
+
+ chosen="$( echo $chosen | tr [A-Z] [a-z] )"
+ for (( i = 0 ; i < ${#choices[@]} ; i = i + 1 )) ; do
+ if [[ ${choices[$i]} == $chosen ]] ; then
+ echo $chosen
+ return
+ fi
+ done
+
+ # no, it is not installed
+ # tell the user that they have a problem
+
+ echo "*** warning: Apache is configured to use $chosen, but there is no"
+ echo " matching mod_php installed on this machine"
+}
+
+# ------------------------------------------------------------------------
+# testApacheConf() - test which version of PHP that Apache[2] is configured
+# to use
+#
+# $G_APACHE_CONF - the Gentoo config file for Apache
+# $G_OPTS_VAR - the variable in the config file to check
+
+testApacheConf ()
+{
+ isInstalledForApache || return 1
+
+ # if we get here, then we have 1 or more mod_php's installed
+ #
+ # find out which mod_php Apache is configured for (if any)
+
+ isUsingModPhp || return 1
+
+ # if we get here, then apache is configured for a mod_php ...
+ # is it one that is installed?
+
+ chosen="$( echo $chosen | tr [A-Z] [a-z] )"
+ for (( i = 0 ; i < ${#choices[@]} ; i = i + 1 )) ; do
+ if [[ ${choices[$i]} == $chosen ]] ; then
+ # we have one installed; but is it what we want?
+ if [[ $chosen == $G_PHPVERSION ]]; then
+ echo "Okay"
+ return
+ fi
+ echo "*** warning: Apache is configured to use a different version of PHP"
+ G_EXITSTATUS=$G_STATUS_USINGOTHER
+ return 1
+ fi
+ done
+
+ # no, it is not installed
+ # tell the user that they have a problem
+
+ echo "*** warning: Apache is configured to use $chosen, but there is no"
+ echo " matching mod_php installed on this machine"
+
+ G_EXITSTATUS=$G_STATUS_NOTINSTALLED
+}
diff --git a/app-admin/php-toolkit/files/php-select-modules/libsymlink.sh b/app-admin/php-toolkit/files/php-select-modules/libsymlink.sh
new file mode 100644
index 000000000000..fb25507c4620
--- /dev/null
+++ b/app-admin/php-toolkit/files/php-select-modules/libsymlink.sh
@@ -0,0 +1,243 @@
+#
+# /usr/share/php-select/libsymlink.sh
+# Library for managing PHP symlinks on Gentoo Linux
+#
+# Author Stuart Herbert
+# (stuart@gentoo.org)
+#
+# Copyright (c) 2005 Gentoo Foundation, Inc.
+# Released under v2 of the GNU General Public License
+#
+# ========================================================================
+
+actionSet ()
+{
+ setSymlinks
+}
+
+actionShow ()
+{
+ showSymlinks
+}
+
+actionTest ()
+{
+ testSymlinks
+}
+
+# ------------------------------------------------------------------------
+# buildTargets() - map source files to target files
+#
+# $1 - php topdir to map from
+# $G_SYMLINK_SOURCE - array of files to map from
+#
+# echo's a list of files to map to - capture and turn into an array
+
+buildTargets ()
+{
+ for (( i = 0 ; i < ${#G_SYMLINK_SOURCE[@]} ; i + i + 1 )) ; do
+ echo "$1/${G_SYMLINK_SOURCE[$i]}"
+ done
+}
+
+# ------------------------------------------------------------------------
+# choosePhpVersion() - select which version of PHP to use for our files
+#
+# $1 - php version required
+# $G_SYMLINK_SOURCE - array of files to look for
+#
+# returns 0 on success, 1 on failure
+# echos the path to the PHP libdir containing the files on success
+
+choosePhpVersion ()
+{
+ # which PHP versions supply our files?
+ local choices
+ choices=( $(learnPhpVersions) )
+
+ # do we have the PHP version we want in our list of choices?
+ for (( i = 0 ; i < ${#choices[@]} ; i = i + 1 )) ; do
+ if [[ `basename ${choices[$i]}` == $1 ]] ; then
+ echo "${choices[$i]}"
+ fi
+ done
+}
+
+# ------------------------------------------------------------------------
+# hasCompatiblePhpVersions() - do we have compatible PHP versions installed
+# or not?
+
+hasCompatiblePhpVersions ()
+{
+ # find out which compatible PHP versions are installed (if any!)
+ choices=$(learnPhpVersions)
+
+ # if there are no installed php versions, we tell the user
+ if [[ -z $choices ]] ; then
+ echo "*** error: no compatible PHP version installed"
+ G_EXITSTATUS=$G_STATUS_NOTINSTALLED
+ return 1
+ fi
+
+ return 0
+}
+
+# ------------------------------------------------------------------------
+# learnPhpVersions() - generate a list of valid PHP versions for this
+# particular machine and component
+#
+# $G_SYMLINK_SOURCE - array of files to look for
+
+learnPhpVersions ()
+{
+ local i
+ local musthave
+ local x
+ local n
+
+ # how many files are we looking for?
+ musthave=${#G_SYMLINK_SOURCE[@]}
+
+ for (( i = 0 ; i < ${#G_LIBDIR[@]} ; i = i + 1 )) ; do
+ for x in `echo ${G_LIBDIR[$i]}/php*` ; do
+ (( dohave = 0 ))
+
+ for (( n = 0 ; n < musthave ; n = n + 1 )) ; do
+ if [[ -f $x/${G_SYMLINK_SOURCE[$n]} ]] ; then
+ (( dohave = dohave + 1 ))
+ fi
+ done
+
+ if (( dohave == musthave )) ; then
+ echo "$x"
+ fi
+ done
+ done
+}
+
+# ------------------------------------------------------------------------
+# learnSymlinks() - generate a list of where the files are symlinked to
+#
+# $G_SYMLINK_TARGET - array of files to look at
+
+learnSymlinks ()
+{
+ for (( i = 0 ; i < ${#G_SYMLINK_TARGET[$i]} ; i = i + 1 )) ; do
+ if [[ ! -e ${G_SYMLINK_TARGET[$i]} ]] ; then
+ echo "Not_found"
+ elif [[ ! -L ${G_SYMLINK_TARGET[$i]} ]] ; then
+ echo "Not_link"
+ else
+ echo "$(readlink ${G_SYMLINK_TARGET[$i]})"
+ fi
+ done
+}
+
+# ------------------------------------------------------------------------
+# setSymlinks () - set our target files to link to our source files
+#
+# $1 - PHP version to link to
+# $G_SYMLINK_SOURCE - array of files to symlink to
+# $G_SYMLINK_TARGET - array of symlink targets to create
+
+setSymlinks ()
+{
+ # find out which compatible PHP versions are installed (if any!)
+ hasCompatiblePhpVersions || return 1
+
+ # find the directory holding the requested PHP version
+ #
+ # if we can't find the directory, tell the user which PHP
+ # versions they can use with this module
+
+ libdir=$(choosePhpVersion $G_PHPVERSION)
+ if [[ -z $libdir ]] ; then
+ echo "*** error: compatible php version not found"
+ echo "Compatible versions are:"
+ echo
+
+ for (( i = 0 ; i < ${#choices[@]} ; i = i + 1 )) ; do
+ echo "* `basename ${choices[$i]}`"
+ done
+
+ G_EXITSTATUS=$G_STATUS_NOTCOMPATIBLE
+ return 1
+ fi
+
+ # we know where the file(s) are - create the symlinks
+
+ for (( i = 0 ; i < ${#G_SYMLINK_SOURCE[@]} ; i = i + 1 )) ; do
+ ln -sf ${libdir}/${G_SYMLINK_SOURCE[$i]} ${G_SYMLINK_TARGET[$i]}
+ done
+}
+
+# ------------------------------------------------------------------------
+# showSymlinks () - show the files that we link to
+#
+# $G_SYMLINK_TARGET - array of files that may be linked
+
+showSymlinks ()
+{
+ # find out which compatible PHP versions are installed (if any!)
+ hasCompatiblePhpVersions || return 1
+
+ # find out where each symlink points
+ files=( $(learnSymlinks) )
+
+ for (( i = 0 ; i < ${#files[@]} ; i = i + 1 )) ; do
+ if [[ ${files[$i]} == "Not_found" ]]; then
+ echo "${G_SYMLINK_TARGET[$i]} is not set"
+ if (( G_EXITSTATUS < $G_STATUS_USINGNONE )) ; then
+ G_EXITSTATUS=$G_STATUS_USINGNONE
+ fi
+ elif [[ ${files[$i]} == "Not_link" ]] ; then
+ echo "${G_SYMLINK_TARGET[$i]} is not a symlink"
+ if (( G_EXITSTATUS < $G_STATUS_USINGOTHER )) ; then
+ G_EXITSTATUS=$G_STATUS_USINGOTHER
+ fi
+ else
+ echo "${G_SYMLINK_TARGET[$i]} is set to ${files[$i]}"
+ fi
+ done
+}
+
+# ------------------------------------------------------------------------
+# testSymlinks () - test symlinks for a specified PHP version
+#
+# $G_SYMLINK_TARGET - array of files that may be linked
+# $G_PHPVERSION - PHP version to check against
+
+testSymlinks ()
+{
+ # find out which compatible PHP versions are installed (if any!)
+ hasCompatiblePhpVersions || return 1
+
+ # find out where each symlink points
+ files=( $(learnSymlinks) )
+
+ for (( i = 0 ; i < ${#files[@]} ; i = i + 1 )) ; do
+ if [[ ${files[$i]} == "Not_found" ]]; then
+ echo "*** warning: ${G_SYMLINK_TARGET[$i]} does not exist"
+ if (( G_EXITSTATUS < $G_STATUS_USINGNONE )) ; then
+ G_EXITSTATUS=$G_STATUS_USINGNONE
+ fi
+ elif [[ ${files[$i]} == "Not_link" ]] ; then
+ echo "*** warning: ${G_SYMLINK_TARGET[$i]} is not a symlink"
+ if (( G_EXITSTATUS < $G_STATUS_USINGNONE )) ; then
+ G_EXITSTATUS=$G_STATUS_USINGNONE
+ fi
+ else
+ echo ${files[$i]} | grep $G_PHPVERSION > /dev/null 2>&1
+ if [[ $? != 0 ]] ; then
+ echo "*** warning: ${G_SYMLINK_TARGET[$i]} does not use $G_PHPVERSION"
+ if (( G_EXITSTATUS < $G_STATUS_USINGOTHER )) ; then
+ G_EXITSTATUS=$G_STATUS_USINGOTHER
+ fi
+ fi
+ fi
+ done
+
+ if [[ $G_EXITSTATUS == 0 ]] ; then
+ echo "Okay"
+ fi
+}
diff --git a/app-admin/php-toolkit/files/php-select-modules/php-cgi.sh b/app-admin/php-toolkit/files/php-select-modules/php-cgi.sh
new file mode 100644
index 000000000000..2fe84c1a79ed
--- /dev/null
+++ b/app-admin/php-toolkit/files/php-select-modules/php-cgi.sh
@@ -0,0 +1,18 @@
+#
+# /usr/share/php-select/php-cgi.sh
+# Module to manage /usr/bin/php-cgi binary
+#
+# Written for Gentoo Linux
+#
+# Author Stuart Herbert
+# (stuart@gentoo.org)
+#
+# Copyright (c) 2005 Gentoo Foundation, Inc.
+# Released under version 2 of the GNU General Public License
+#
+# ========================================================================
+
+G_SYMLINK_SOURCE[0]="bin/php-cgi"
+G_SYMLINK_TARGET[0]="/usr/bin/php-cgi"
+
+. $G_MODULE_PATH/libsymlink.sh
diff --git a/app-admin/php-toolkit/files/php-select-modules/php-devel.sh b/app-admin/php-toolkit/files/php-select-modules/php-devel.sh
new file mode 100644
index 000000000000..f016fc7623ce
--- /dev/null
+++ b/app-admin/php-toolkit/files/php-select-modules/php-devel.sh
@@ -0,0 +1,21 @@
+#
+# /usr/share/php-select/php-devel.sh
+# Module to manage PHP development scripts
+#
+# Written for Gentoo Linux
+#
+# Author Stuart Herbert
+# (stuart@gentoo.org)
+#
+# Copyright (c) 2005 Gentoo Foundation, Inc.
+# Released under version 2 of the GNU General Public License
+#
+# ========================================================================
+
+G_SYMLINK_SOURCE[0]="bin/php-config"
+G_SYMLINK_TARGET[0]="/usr/bin/php-config"
+
+G_SYMLINK_SOURCE[1]="bin/phpize"
+G_SYMLINK_TARGET[1]="/usr/bin/phpize"
+
+. $G_MODULE_PATH/libsymlink.sh
diff --git a/app-admin/php-toolkit/files/php-select-modules/php.sh b/app-admin/php-toolkit/files/php-select-modules/php.sh
new file mode 100644
index 000000000000..21430f3ecb82
--- /dev/null
+++ b/app-admin/php-toolkit/files/php-select-modules/php.sh
@@ -0,0 +1,18 @@
+#
+# /usr/share/php-select/php.sh
+# Module to manage /usr/bin/php binary
+#
+# Written for Gentoo Linux
+#
+# Author Stuart Herbert
+# (stuart@gentoo.org)
+#
+# Copyright (c) 2005 Gentoo Foundation, Inc.
+# Released under version 2 of the GNU General Public License
+#
+# ========================================================================
+
+G_SYMLINK_SOURCE[0]="bin/php"
+G_SYMLINK_TARGET[0]="/usr/bin/php"
+
+. $G_MODULE_PATH/libsymlink.sh
diff --git a/app-admin/php-toolkit/metadata.xml b/app-admin/php-toolkit/metadata.xml
new file mode 100644
index 000000000000..fd3dbe39fa64
--- /dev/null
+++ b/app-admin/php-toolkit/metadata.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
+<pkgmetadata>
+ <herd>php</herd>
+</pkgmetadata>
diff --git a/app-admin/php-toolkit/php-toolkit-1.0.ebuild b/app-admin/php-toolkit/php-toolkit-1.0.ebuild
new file mode 100644
index 000000000000..dab1aa21da0a
--- /dev/null
+++ b/app-admin/php-toolkit/php-toolkit-1.0.ebuild
@@ -0,0 +1,30 @@
+# Copyright 1999-2005 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/app-admin/php-toolkit/php-toolkit-1.0.ebuild,v 1.1 2005/12/28 13:49:36 chtekk Exp $
+
+inherit eutils
+
+KEYWORDS="~x86"
+DESCRIPTION="Utilities for managing installed copies of PHP ."
+HOMEPAGE="http://svn.gnqs.org/projects/gentoo-php-overlay/wiki/PhpToolkit"
+SRC_URI=""
+LICENSE="GPL-2"
+SLOT="0"
+IUSE=""
+
+DEPEND="!app-admin/eselect-php"
+
+src_install() {
+ # install php-select
+ dosbin "${FILESDIR}/php-select"
+
+ dodir /usr/share/php-select
+ insinto /usr/share/php-select
+ doins "${FILESDIR}/php-select-modules/libapache.sh"
+ doins "${FILESDIR}/php-select-modules/libsymlink.sh"
+ doins "${FILESDIR}/php-select-modules/apache1.sh"
+ doins "${FILESDIR}/php-select-modules/apache2.sh"
+ doins "${FILESDIR}/php-select-modules/php.sh"
+ doins "${FILESDIR}/php-select-modules/php-cgi.sh"
+ doins "${FILESDIR}/php-select-modules/php-devel.sh"
+}