[Pkg-php-commits] r926 - php5/branches/rg-extension-manager/debian

Raphael Geissert atomo64-guest at alioth.debian.org
Mon Dec 3 02:16:55 UTC 2007


Author: atomo64-guest
Date: 2007-12-03 02:16:54 +0000 (Mon, 03 Dec 2007)
New Revision: 926

Added:
   php5/branches/rg-extension-manager/debian/extsmngr.db
   php5/branches/rg-extension-manager/debian/php5exts.sh
Modified:
   php5/branches/rg-extension-manager/debian/changelog
   php5/branches/rg-extension-manager/debian/copyright.header
   php5/branches/rg-extension-manager/debian/php5disext
   php5/branches/rg-extension-manager/debian/php5enext
   php5/branches/rg-extension-manager/debian/rules
Log:
Added conflicts handling support on the extensions manager (added the pgsql-curl to the default database)
Updated copyright.header acordingly

Modified: php5/branches/rg-extension-manager/debian/changelog
===================================================================
--- php5/branches/rg-extension-manager/debian/changelog	2007-12-02 15:51:28 UTC (rev 925)
+++ php5/branches/rg-extension-manager/debian/changelog	2007-12-03 02:16:54 UTC (rev 926)
@@ -5,8 +5,9 @@
   [ Raphael Geissert ]
   * Added new extensions manager (see http://wiki.debian.org/PHP)
   * Make use of dh_phpext (which is aware of the new extensions manager)
+  * Added a conflict between pgsql and curl on the new extensions manager database
 
- -- Raphael Geissert <atomo64 at gmail.com>  Tue, 23 Oct 2007 18:44:56 -0500
+ -- Raphael Geissert <atomo64 at gmail.com>  Sun, 02 Dec 2007 20:06:13 -0600
 
 php5 (5.2.4-1) unstable; urgency=low
 

Modified: php5/branches/rg-extension-manager/debian/copyright.header
===================================================================
--- php5/branches/rg-extension-manager/debian/copyright.header	2007-12-02 15:51:28 UTC (rev 925)
+++ php5/branches/rg-extension-manager/debian/copyright.header	2007-12-03 02:16:54 UTC (rev 926)
@@ -1,14 +1,22 @@
 This package was debianized by Gergely Madarasz <gorgo at sztaki.hu> on
 Tue, 16 Nov 1999 19:33:42 +0100.
 
-The last maintainer was Petr Cech <cech at debian.org>, who did a LOT of
+An older maintainer was Petr Cech <cech at debian.org>, who did a LOT of
 work on these packages.
 
-The current maintainer is Adam Conrad <adconrad at 0c3.net>, who gets a
+The previous maintainer was Adam Conrad <adconrad at 0c3.net>, who got a
 significant chunk of input and help from Steve Langasek <vorlon at debian.org>
 and Andres Salomon <dilinger at debian.org>.
 
-It was downloaded from www.php.net/version5/downloads
+The package is now maintained by the "Debian PHP Maintainers" Team,
+conformed by several people with changes from many of its members.
+
+The extensions manager is Copyright 2007 by Raphael Geissert <atomo64 at gmail.com>
+and licensed under the GNU General Public License version 3, or
+(at your option) any later version. These files are:
+debian/php5disext, debian/php5enext and debian/php5exts.sh
+
+The PHP source was downloaded from www.php.net/version5/downloads
 Changes: removed ext/dbase dir (non-free)
 
 Upstream Authors: The PHP group for PHP5, Andi Gutmans and Zeev Suraski

Added: php5/branches/rg-extension-manager/debian/extsmngr.db
===================================================================
--- php5/branches/rg-extension-manager/debian/extsmngr.db	                        (rev 0)
+++ php5/branches/rg-extension-manager/debian/extsmngr.db	2007-12-03 02:16:54 UTC (rev 926)
@@ -0,0 +1,3 @@
+VERSION|1
+# based on http://bugs.debian.org/cgi-bin/bugreport.cgi?msg=65;bug=411982 :
+CONFLICT|pgsql|curl
\ No newline at end of file

Modified: php5/branches/rg-extension-manager/debian/php5disext
===================================================================
--- php5/branches/rg-extension-manager/debian/php5disext	2007-12-02 15:51:28 UTC (rev 925)
+++ php5/branches/rg-extension-manager/debian/php5disext	2007-12-03 02:16:54 UTC (rev 926)
@@ -1,51 +1,53 @@
-#!/bin/sh
+#!/bin/bash
 
-# Simple script to disable php extensions in the per-SAPI conf.d directory
-# Copyright (C) 2007 by Raphael Geissert <atomo64 at gmail.com>
-# Licence: GNU GPLv3 (see /usr/share/common-licenses/GPL-3 for the full text)
+# (not so) Simple script to disable php extensions in the per-SAPI conf.d directory
+####################
+#    Copyright (C) 2007 by Raphael Geissert <atomo64 at gmail.com>
+#
+#    This file is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation, either version 3 of the License, or
+#    (at your option) any later version.
+#
+#    This file is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License
+#    along with this file.  If not, see <http://www.gnu.org/licenses/>.
+#
+#    On Debian systems, the complete text of the GNU General
+#    Public License version 3 can be found in `/usr/share/common-licenses/GPL-3'.
+#
+####################
 
-PHPDIR="/etc/php5"
 QUIET=0
 FATAL=1
 MISSING_SAPI_IS_ERROR=1
 ALREADY_DISABLED_EXT_IS_ERROR=1
 
+# source common functions
+. /var/lib/php5/php5exts.sh
+
 if [ -z "$1" ] || [ -z "$2" ]; then
 	echo "Usage: php5disext SAPIS EXTENSIONS [verbose|quiet] [fatal|nonfatal]"
-	echo -e "\t SAPIS: list of SAPIs or 'all'"
+	echo -e "\t SAPIS: one or a list of SAPIs, e.g. 'cli cgi', or 'all'"
 	echo -e "\t EXTENSIONS: a single extension name, a list or 'all' (use with CARE)"
-	echo -e "\t quiet: Don't display any messages (not default)"
+	echo -e "\t quiet: Don't display any message (not default)"
 	echo -e "\t fatal: exit with non-zero status if the extension is already disabled (default)"
 	exit 1
 fi
 
-readOption() {
-	
-	case $OPT in
-		quiet)
-			QUIET=1
-		;;
-		verbose)
-			QUIET=0
-		;;
-		fatal)
-			FATAL=1
-		;;
-		nonfatal)
-			FATAL=0
-		;;
-	esac
-}
+testDB
 
 # verbose|quiet and fatal|nonfatal can actually be in any order
 if [ ! -z "$3" ]; then
-	OPT="$3"
-	readOption
+	readOption "$3"
 fi
 
 if [ ! -z "$4" ]; then
-	OPT="$4"
-	readOption
+	readOption "$4"
 fi
 
 EXTS="$2"
@@ -57,7 +59,7 @@
 fi
 
 if [ "$EXTS" = "all" ]; then
-	EXTS="`/bin/ls -A $PHPDIR/conf.d | grep .ini`"
+	EXTS="`/bin/ls -A $PHPDIR/conf.d | egrep '.ini$'`"
 	ALREADY_DISABLED_EXT_IS_ERROR=0
 fi
 
@@ -65,9 +67,7 @@
 	for SAPI in $SAPIS; do
 		if [ ! -e "$PHPDIR/$SAPI" ]; then
 			if [ $MISSING_SAPI_IS_ERROR -eq 1 ]; then
-				if [ ! $QUIET -eq 1 ]; then
-					echo "The $SAPI SAPI doesn't seem to be installed!"
-				fi
+				Say "The $SAPI SAPI doesn't seem to be installed!"
 				exit 4
 			else
 				continue
@@ -78,9 +78,7 @@
 		#  this is helpful in situations where the SAPI hasn't been upgraded but a new ext is installed
 		#  preventing the removal of the _real_ .ini file
 		if [ -d "$PHPDIR/$SAPI/conf.d" ] && [ -s "$PHPDIR/$SAPI/conf.d" ]; then
-			if [ ! $QUIET -eq 1 ]; then
-				echo "$PHPDIR/$SAPI/conf.d is not a real directory!"
-			fi
+			Say "$PHPDIR/$SAPI/conf.d is not a real directory!"
 			# this option can prevent postrm scripts from stopping the removal
 			#  in case the sapi hasn't been upgraded yet
 			if [ $FATAL -eq 1 ]; then
@@ -90,20 +88,16 @@
 			fi
 		fi
 
-		if [ ! -L "$PHPDIR/$SAPI/conf.d/$EXT.ini" ]; then
-			if [ ! $QUIET -eq 1 ]; then
-				echo "The $EXT extension is not enabled on the $SAPI SAPI!"
-			fi
+		if isExtDisabled "$EXT" "$SAPI"; then
+			Say "The $EXT extension is not enabled on the $SAPI SAPI!"
 
 			if [ $FATAL -eq 1 ] && [ $ALREADY_DISABLED_EXT_IS_ERROR -eq 1 ]; then
 				exit 2
 			fi
 		else
 			unlink "$PHPDIR/$SAPI/conf.d/$EXT.ini"
-			if [ ! $QUIET -eq 1 ]; then
-				echo "The $EXT extension has been disabled on the $SAPI SAPI"
-				echo "In case $SAPI is a web server you might need to restart it"
-			fi
+			Say "The $EXT extension has been disabled on the $SAPI SAPI"
+			Say "In case $SAPI is a web server you might need to restart it for changes to take effect"
 		fi
 	done
 done

Modified: php5/branches/rg-extension-manager/debian/php5enext
===================================================================
--- php5/branches/rg-extension-manager/debian/php5enext	2007-12-02 15:51:28 UTC (rev 925)
+++ php5/branches/rg-extension-manager/debian/php5enext	2007-12-03 02:16:54 UTC (rev 926)
@@ -1,51 +1,54 @@
-#!/bin/sh
+#!/bin/bash
 
-# Simple script to enable php extensions in the per-SAPI conf.d directory
-# Copyright (C) 2007 by Raphael Geissert <atomo64 at gmail.com>
-# Licence: GNU GPLv3 (see /usr/share/common-licenses/GPL-3 for the full text)
+# (not so) Simple script to enable php extensions in the per-SAPI conf.d directory
+####################
+#    Copyright (C) 2007 by Raphael Geissert <atomo64 at gmail.com>
+#
+#    This file is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation, either version 3 of the License, or
+#    (at your option) any later version.
+#
+#    This file is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License
+#    along with this file.  If not, see <http://www.gnu.org/licenses/>.
+#
+#    On Debian systems, the complete text of the GNU General
+#    Public License version 3 can be found in `/usr/share/common-licenses/GPL-3'.
+#
+####################
 
-PHPDIR="/etc/php5"
 QUIET=0
 FATAL=1
 MISSING_SAPI_IS_ERROR=1
 ALREADY_ENABLED_EXT_IS_ERROR=1
+CONFLICTING_EXT_IS_ERROR=1
 
+# source common functions
+. /var/lib/php5/php5exts.sh
+
 if [ -z "$1" ] || [ -z "$2" ]; then
 	echo "Usage: php5enext SAPIS EXTENSIONS [verbose|quiet] [fatal|nonfatal]"
-	echo -e "\t SAPIS: list of SAPIs, e.g. 'cli cgi', or 'all'"
+	echo -e "\t SAPIS: one or a list of SAPIs, e.g. 'cli cgi', or 'all'"
 	echo -e "\t EXTENSIONS: a single extension name, a list or 'all' (use with CARE)"
-	echo -e "\t quiet: Don't display any messages (not default)"
+	echo -e "\t quiet: Don't display any message (not default)"
 	echo -e "\t fatal: exit with non-zero status if the extension is already enabled (default)"
 	exit 1
 fi
 
-readOption() {
-	
-	case $OPT in
-		quiet)
-			QUIET=1
-		;;
-		verbose)
-			QUIET=0
-		;;
-		fatal)
-			FATAL=1
-		;;
-		nonfatal)
-			FATAL=0
-		;;
-	esac
-}
+testDB
 
 # verbose|quiet and fatal|nonfatal can actually be in any order
 if [ ! -z "$3" ]; then
-	OPT="$3"
-	readOption
+	readOption "$3"
 fi
 
 if [ ! -z "$4" ]; then
-	OPT="$4"
-	readOption
+	readOption "$4"
 fi
 
 EXTS="$2"
@@ -57,17 +60,16 @@
 fi
 
 if [ "$EXTS" = "all" ]; then
-	EXTS="`/bin/ls -A $PHPDIR/conf.d | grep .ini`"
+	EXTS="`/bin/ls -A $PHPDIR/conf.d | egrep '.ini$'`"
 	ALREADY_ENABLED_EXT_IS_ERROR=0
+	CONFLICTING_EXT_IS_ERROR=0
 fi
 
 for EXT in $EXTS; do
 	for SAPI in $SAPIS; do
 		if [ ! -e "$PHPDIR/$SAPI" ]; then
 			if [ $MISSING_SAPI_IS_ERROR -eq 1 ]; then
-				if [ ! $QUIET -eq 1 ]; then
-	                        	echo "The $SAPI SAPI doesn't seem to be installed!"
-				fi
+				Say "The $SAPI SAPI doesn't seem to be installed!"
 				exit 4
 			else
 				continue
@@ -78,9 +80,7 @@
 		#  this is helpful in situations where the SAPI hasn't been upgraded but a new ext is installed
 		#  preventing the removal of the _real_ .ini file
 		if [ -d "$PHPDIR/$SAPI/conf.d" ] && [ -s "$PHPDIR/$SAPI/conf.d" ]; then
-			if [ ! $QUIET -eq 1 ]; then
-				echo "$PHPDIR/$SAPI/conf.d is not a real directory!"
-			fi
+			Say "$PHPDIR/$SAPI/conf.d is not a real directory!"
 			# this option can prevent postinst scripts from stopping the installation
 			#  in case the sapi hasn't been upgraded yet
 			if [ $FATAL -eq 1 ]; then
@@ -90,20 +90,22 @@
 			fi
 		fi
 
-		if [ -L "$PHPDIR/$SAPI/conf.d/$EXT.ini" ]; then
-			if [ ! $QUIET -eq 1 ]; then
-				echo "The $EXT extension is already enabled on the $SAPI SAPI"
-			fi
+		if isExtEnabled "$EXT" "$SAPI"; then
+			Say "The $EXT extension is already enabled on the $SAPI SAPI"
 
 			if [ $FATAL -eq 1 ] && [ $ALREADY_ENABLED_EXT_IS_ERROR -eq 1 ]; then
 				exit 2
 			fi
 		else
+			if ! mayEnable "$EXT" "$SAPI"; then
+				Say "Not enabling $EXT because a conflicting extension is already enabled"
+				if [ $CONFLICTING_EXT_IS_ERROR -eq 1 ]; then
+					exit 5
+				fi
+			fi
 			ln -s "$PHPDIR/conf.d/$EXT.ini" "$PHPDIR/$SAPI/conf.d/"
-			if [ ! $QUIET -eq 1 ]; then
-				echo "The $EXT extension has been enabled on the $SAPI SAPI"
-				echo "In case $SAPI is a web server you might need to restart it"
-			fi
+			Say "The $EXT extension has been enabled on the $SAPI SAPI"
+			Say "In case $SAPI is a web server you might need to restart it for changes to take effect"
 		fi
 	done
 done

Added: php5/branches/rg-extension-manager/debian/php5exts.sh
===================================================================
--- php5/branches/rg-extension-manager/debian/php5exts.sh	                        (rev 0)
+++ php5/branches/rg-extension-manager/debian/php5exts.sh	2007-12-03 02:16:54 UTC (rev 926)
@@ -0,0 +1,198 @@
+
+####################
+#    Copyright (C) 2007 by Raphael Geissert <atomo64 at gmail.com>
+#
+#    This file is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation, either version 3 of the License, or
+#    (at your option) any later version.
+#
+#    This file is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License
+#    along with this file.  If not, see <http://www.gnu.org/licenses/>.
+#
+#    On Debian systems, the complete text of the GNU General
+#    Public License version 3 can be found in `/usr/share/common-licenses/GPL-3'.
+#
+####################
+
+#set -e
+
+# Default config (override them at $CONFFILE or as ENV vars, but don't edit here):
+
+# Path to PHP's config base dir
+[ -z "$PHPDIR" ] && PHPDIR="/etc/php5"
+
+# Path to the extension manager's database
+[ -z "$EXTSDB" ] && EXTSDB="$PHPDIR/extsmngr.db"
+
+# Default policy on 'should-auto-enable' requests (0: yes, 1: no)
+[ -z "$AUTOPOLICY" ] && AUTOPOLICY=`true; echo $?`
+
+# Path to the config file (shell format)
+[ -z "$CONFFILE" ] && CONFFILE="$PHPDIR/extsmngr.conf"
+
+# source the config file if present
+[ ! -f "$CONFFILE" ] || . "$CONFFILE"
+
+# make sure the db exists and let's better add a version mark since the begining
+[ -f "$EXTSDB" ] || echo "VERSION|1" > "$EXTSDB"
+
+testDB() {
+	[ -f "$EXTSDB" ] || exit 20
+	local ver="`egrep -m1 "^VERSION\|.+$" "$EXTSDB" | cut '-d|' -f2`"
+	if [ "$ver" != "1" ]; then
+		echo "Unknown database version, I don't know how to deal with it, aborting"
+		echo 21
+	fi
+}
+
+getConflictsForExt() {
+	if [ -z "${1:-}" ]; then
+		echo "No extension specified, aborting"
+		exit 2
+	fi
+	
+	local primConflict secConflict conflicts
+	
+	primConflict="`egrep "^CONFLICT\|${1:-}\|.+$" "$EXTSDB" | cut '-d|' -f3 `" || true
+	secConflict="`egrep "^CONFLICT\|.+\|${1:-}$" "$EXTSDB" | cut '-d|' -f2 `" || true
+	conflicts="`echo "$primConflict" "$secConflict" | sort -u `"
+
+	echo $conflicts
+	true; return
+}
+
+addExtsConflict() {
+	if [ -z "${1:-}" ] || [ -z "${2:-}" ]; then
+		echo "No extensions specified, aborting"
+		exit 2
+	fi
+
+	echo "CONFLICT|${1:-}|${2:-}" >> "$EXTSDB"
+}
+
+remExtsConflict() {
+	if [ -z "${1:-}" ] || [ -z "${2:-}" ]; then
+		echo "No extensions specified, aborting"
+		exit 2
+	fi
+
+	sed -i "s/CONFLICT|${1:-}|${2:-}//g" "$EXTSDB"
+}
+
+shouldAutoEnable() {
+	if [ -z "${1:-}" ]; then
+		echo "No extension specified, aborting"
+		exit 2
+	fi
+
+	local auto="$AUTOPOLICY"
+
+	egrep "^ENABLE\|${1:-}$" "$EXTSDB" >/dev/null && auto=0
+	egrep "^DISABLE\|${1:-}$" "$EXTSDB" >/dev/null && auto=1
+
+	return $auto
+}
+
+addAutoEnableRule() {
+	if [ -z "${1:-}" ] || [ -z "${2:-}" ]; then
+		echo "No extension/action specified, aborting"
+		exit 2
+	fi
+
+	local ext="${1:-}" rule="${2:-}"
+
+	if [ "$rule" != "ENABLE" ] && [ "$rule" != "DISABLE" ]; then
+		echo "Unknown auto enable rule: $rule, aborting"
+		exit 3
+	fi
+
+	echo "$rule|$ext" >> "$EXTSDB"
+}
+
+remAutoEnableRule() {
+	if [ -z "${1:-}" ]; then
+		echo "No extension/action specified, aborting"
+		exit 2
+	fi
+
+	local ext="${1:-}" rules="${2:-}" rule=
+
+	if [ -z "$rules" ]; then
+		rules="ENABLE DISABLE"
+	fi
+
+	for rule in $rules; do
+		if [ "$rule" != "ENABLE" ] && [ "$rule" != "DISABLE" ]; then
+			echo "Unknown auto enable rule: $rule, aborting"
+			exit 3
+		fi
+		sed -i "s/$rule|$ext//g" "$EXTSDB"
+	done
+}
+
+readOption() {
+	if [ ! -z "${1:-}" ]; then
+		local OPT="${1:-}"
+	fi
+	case $OPT in
+		quiet)
+			QUIET=1
+		;;
+		verbose)
+			QUIET=0
+		;;
+		fatal)
+			FATAL=1
+		;;
+		nonfatal)
+			FATAL=0
+		;;
+	esac
+}
+
+mayEnable() {
+	if [ -z "${1:-}" ] || [ -z "${2:-}" ]; then
+		echo "No extension/sapi specified, aborting"
+		exit 2
+	fi
+
+	local ext="${1:-}" sapi="${2:-}" conflicts="`getConflictsForExt "$ext"`" c=
+
+	for c in $conflicts; do
+		if isExtEnabled "$c" "$sapi"; then
+			false; return
+		fi
+	done
+
+	true
+}
+
+isExtEnabled() {
+	if [ -z "${1:-}" ] || [ -z "${2:-}" ]; then
+		echo "No extension/SAPI specified, aborting"
+		exit 2
+	fi
+	local EXT="${1:-}" SAPI="${2:-}"
+	if [ -L "$PHPDIR/$SAPI/conf.d/$EXT.ini" ]; then return; else return; fi
+}
+
+isExtDisabled() {
+	if [ -z "${1:-}" ] || [ -z "${2:-}" ]; then
+		echo "No extension/SAPI specified, aborting"
+		exit 2
+	fi
+	local EXT="${1:-}" SAPI="${2:-}"
+	if [ ! -L "$PHPDIR/$SAPI/conf.d/$EXT.ini" ]; then return; else return; fi
+}
+
+Say() {
+	if [ ! $QUIET -eq 1 ]; then
+		echo "$@"
+	fi
+}

Modified: php5/branches/rg-extension-manager/debian/rules
===================================================================
--- php5/branches/rg-extension-manager/debian/rules	2007-12-02 15:51:28 UTC (rev 925)
+++ php5/branches/rg-extension-manager/debian/rules	2007-12-03 02:16:54 UTC (rev 926)
@@ -311,12 +311,16 @@
 	dh_clean -k
 	dh_installdirs
 	
-	# Install php5enext and php5disext
+	# Install the extensions manager components
 	mkdir -p debian/php5-common/usr/sbin
 	cp debian/php5enext \
 		debian/php5-common/usr/sbin/
 	cp debian/php5disext \
 		debian/php5-common/usr/sbin/
+	cp debian/php5exts.sh \
+		debian/php5-common/usr/lib/php5/
+	cp debian/extsmngr.db \
+		debian/php5-common/etc/php5/
 
 	chmod 01733 debian/php5-common/var/lib/php5
 




More information about the Pkg-php-commits mailing list