On tor, 2006-11-23 at 21:02 +0100, sean finney wrote:

> unfortunately, this won't work because some apps work only with mysql,
> others with mysql | pgsql, others sqlite only, thus it's possible that

To me that means they should have exactly those dependencies!
Right now applications like "phpgacl" have to depend on both
mysql-client AND postgresql-client because it's supports both, but only
needs one (depending on which you choose).

(And yes, phpgacl could do this detection itself... but that would mean
we will duplicate it in about every package that uses dbconfig-common.)

> unless it specified its own dependencies, the app would be installed
> without any supported db clients installed. (phpmysqladmin on
> a system with dbconfig+sqlite already installed, for example)

My idea is that an application like "phpgacl" depends on
"dbconfig-common, postgresql-client | mysql-client".
Sends in $dbc_dbtypes="pgsql, mysql" to hint supported db types to
dbconfig-common and then have dbconfig-common only present the options
that actually works!
If phpgacl is installed on a clean system during this scenario a popup
sign shows "mysql is supported but the client is missing so that option
won't be available at this moment..." and then continues on with pgsql
as the only option.
If the user on the other hand personally prefers using mysql he has to
manually request that at the time of installing phpgacl ("apt-get
install mysql-client phpgacl"), which would mean that postgresql-client
won't have to be installed.
(Or if both clients are pre-installed he'll actually get to choose
between them during configuration.)

If the application on the other hand supports any database type it will
not depend on anything but just "dbconfig-common" and not pass in any
$dbc_dbtypes. That will then pull in one of the supported database
clients because of dbconfig-commons dependency on one, which will be
used... (this you are actually already checking, so I didn't have to
make any modifications... I also reused your helper functions in the
changes for the first case).

See attached patch for "proof of concept"....
(It's probably broken, but so are my english. I hope the patch explains
it better then I do with words...)




TODO:
It would probably be even better to not remove choices but instead
detect if a not-installed option is choosen and then show a note on how
to install the missing client and offer to safely abort or go back and
chose another database (since there is atleast one available that will
work)... This way there's no annoying popups telling you what you can't
do when you don't care, while giving you helpful hints when you do care.


Regards,
Andreas Henriksson
diff -ur -x '*.po' -x '*.pot' dbconfig-common-1.8.29-orig/debian/changelog dbconfig-common-1.8.30~0.1/debian/changelog
--- dbconfig-common-1.8.29-orig/debian/changelog	2006-11-11 17:59:23.000000000 +0100
+++ dbconfig-common-1.8.30~0.1/debian/changelog	2006-11-24 00:09:28.000000000 +0100
@@ -1,3 +1,13 @@
+dbconfig-common (1.8.30~0.1) unstable; urgency=low
+
+  * NMU
+  * Add dependency on atleast one of the db clients.
+  * Show a note when there is supported clients missing.
+  * Make only options with installed db clients available when selecting
+    one in multidb setups.
+
+ -- Andreas Henriksson <[EMAIL PROTECTED]>  Thu, 23 Nov 2006 23:42:12 +0100
+
 dbconfig-common (1.8.29) unstable; urgency=medium
 
   * Fabio Tranchitella discovered that in some environments passwords
diff -ur -x '*.po' -x '*.pot' dbconfig-common-1.8.29-orig/debian/control dbconfig-common-1.8.30~0.1/debian/control
--- dbconfig-common-1.8.29-orig/debian/control	2006-10-30 11:52:40.000000000 +0100
+++ dbconfig-common-1.8.30~0.1/debian/control	2006-11-23 23:20:15.000000000 +0100
@@ -7,8 +7,7 @@
 
 Package: dbconfig-common
 Architecture: all
-Depends: ucf, ${misc:Depends}
-Suggests: virtual-mysql-client | mysql-client | postgresql-client
+Depends: ucf, ${misc:Depends}, mysql-client | postgresql-client | sqlite
 Description: common framework for packaging database applications
  dbconfig-common presents a policy and implementation for
  managing various databases used by applications included in
diff -ur -x '*.po' -x '*.pot' dbconfig-common-1.8.29-orig/debian/dbconfig-common.templates dbconfig-common-1.8.30~0.1/debian/dbconfig-common.templates
--- dbconfig-common-1.8.29-orig/debian/dbconfig-common.templates	2006-10-12 23:52:02.000000000 +0200
+++ dbconfig-common-1.8.30~0.1/debian/dbconfig-common.templates	2006-11-23 23:59:16.000000000 +0100
@@ -95,6 +95,14 @@
  ${pkg} can be configured to use one of many database types.
  Below, you will be presented with the available choices.
 
+Template: dbconfig-common/database-type-notinst
+Type: note
+_Description: Supported but unavailable options
+ The following database options are supported by this package
+ but can unfortunately not be configured since the database
+ client is not available at this time:
+ ${database_types_notinst}
+
 Template: dbconfig-common/purge
 Type: boolean
 Default: false
diff -ur -x '*.po' -x '*.pot' dbconfig-common-1.8.29-orig/dpkg/common dbconfig-common-1.8.30~0.1/dpkg/common
--- dbconfig-common-1.8.29-orig/dpkg/common	2006-11-06 20:59:16.000000000 +0100
+++ dbconfig-common-1.8.30~0.1/dpkg/common	2006-11-24 00:03:55.000000000 +0100
@@ -840,7 +840,7 @@
 ### register all the necessary debconf templates
 ###
 dbc_register_debconf(){
-	local f local
+	local f local db db_inst db_notinst
 	dbc_debug "dbc_register_debconf() $@"
 
 	for f in $dbc_register_templates; do
@@ -851,7 +851,30 @@
 			db_subst $dbc_package/$f dbvendor $dbc_dbvendor
 		fi
 	done
-	if [ "$dbc_dbtypes" ]; then
-		db_subst $dbc_package/database-type database_types $dbc_dbtypes
+
+	# sort out which of the requested types are available and not.
+	for db in $dbc_all_supported_dbtypes; do
+		if dbc_detect_supported_dbtype $db ; then
+			if dbc_detect_installed_dbtype $db ; then
+				if [ "$db_inst" ]; then
+					db_inst="${db_inst}, "
+				fi
+				db_inst="${db_inst}$db"
+			else
+				if [ "$db_notinst" ]; then
+					db_notinst="${db_notinst}, "
+				fi
+				db_notinst="${db_notinst}$db"
+			fi
+		fi
+	done
+
+	if [ -n "$db_notinst" ]; then
+		db_subst dbconfig-common/database-type-notinst database_types_notinst $db_notinst
+		db_input medium dbconfig-common/database-type-notinst
+	fi
+
+	if [ "$db_inst" ]; then
+		db_subst $dbc_package/database-type database_types $db_inst
 	fi
 }

Reply via email to