[Dbconfig-common-changes] [dbconfig-common] r413 - in trunk: debian doc dpkg

Sean Finney seanius at alioth.debian.org
Mon Jul 23 09:26:13 UTC 2007


tags 429722 pending
thanks

Author: seanius
Date: 2007-07-23 09:26:13 +0000 (Mon, 23 Jul 2007)
New Revision: 413

Modified:
   trunk/debian/changelog
   trunk/doc/dbconfig-common.sgml
   trunk/dpkg/common
   trunk/dpkg/prerm
Log:
wc change and removal hooks for zack

Modified: trunk/debian/changelog
===================================================================
--- trunk/debian/changelog	2007-06-23 16:25:56 UTC (rev 412)
+++ trunk/debian/changelog	2007-07-23 09:26:13 UTC (rev 413)
@@ -1,8 +1,13 @@
 dbconfig-common (1.8.36) UNRELEASED; urgency=low
 
   * NOT RELEASED YET
+  * added documentation and support for removal logic, to allow the
+    packager to have arbitrary sql/scripts run when the package is
+    being removed.  thanks to Stefano Zacchiroli for the suggestion.
+    (closes: #429722).
+  * another internal change or two needed for webapps-common.
 
- -- sean finney <sean at rangda.stickybit.se>  Sat, 23 Jun 2007 17:06:47 +0100
+ -- sean finney <seanius at debian.org>  Mon, 23 Jul 2007 11:25:56 +0200
 
 dbconfig-common (1.8.35) unstable; urgency=low
 

Modified: trunk/doc/dbconfig-common.sgml
===================================================================
--- trunk/doc/dbconfig-common.sgml	2007-06-23 16:25:56 UTC (rev 412)
+++ trunk/doc/dbconfig-common.sgml	2007-07-23 09:26:13 UTC (rev 413)
@@ -395,6 +395,36 @@
 			to not take any actions apart from prompting the local
             administrator for the pertinent information.
 
+		<sect1 id="removal">Packages that require extra logic during removal
+			<p>
+			sometimes, it may be that your install sql/scripts
+			perform operations that aren't automatically
+			undone by package removal.  for example, if your
+			package gives extra grants to a user (such as
+			stored procedures) it's possible that grants
+			will not automatically be revoked, which could
+			cause problems for later installations as well
+			as potential security concerns.  for this and
+			any other use you may need it for, you can place
+			files in the following locations for "removal"
+			maintainer code:
+
+			<list>
+			<item><file>/usr/share/dbconfig-common/data/PACKAGE/remove/DBTYPE/VERSION</file>
+			<item><file>/usr/share/dbconfig-common/scripts/PACKAGE/remove/DBTYPE/VERSION</file>
+			</list>
+
+			<p>
+			this works just like the install/upgrade code,
+			only it always runs a¿ the dbadmin.  this code
+			is run when the local admin does not opt out of
+			deconfiguration assistance (the default is to
+			have this assistance, though database purging is
+			a seperate question with a default of false).
+			Note that if you need to perform template
+			substitution, you should set dbc_sql_substitutions
+			to "yes" in your prerm maintainer script as well.
+
 		<sect1 id="defaults">Hinting defaults and advanced control of configuration/installation
 			<p>
 			<package>dbconfig-common</package> has a set of pre-defined default
@@ -470,7 +500,8 @@
 				<item>specifies encoding for created
 				postgres databases (defaults to:
 				empty/system default)
-			<tag>dbc_sql_substitutions (used in: <var>postinst</var>)
+			<tag>dbc_sql_substitutions (used in: <var>postinst</var>, 
+			                            sometimes <var>postrm</var>)
 				<item>if nonempty, specifies that
 				sql files should be piped through
 				a template substitution filter

Modified: trunk/dpkg/common
===================================================================
--- trunk/dpkg/common	2007-06-23 16:25:56 UTC (rev 412)
+++ trunk/dpkg/common	2007-07-23 09:26:13 UTC (rev 413)
@@ -888,7 +888,11 @@
 			return 1
 		fi
 		# perform some basic customizing substitutions
-		db_subst $dbc_package/$f pkg $dbc_package
+		if [ "$dbc_packagetitle" ]; then
+			db_subst $dbc_package/$f pkg $dbc_packagetitle
+		else
+			db_subst $dbc_package/$f pkg $dbc_package
+		fi
 		if [ "$dbc_dbvendor" ]; then
 			db_subst $dbc_package/$f dbvendor $dbc_dbvendor
 		fi

Modified: trunk/dpkg/prerm
===================================================================
--- trunk/dpkg/prerm	2007-06-23 16:25:56 UTC (rev 412)
+++ trunk/dpkg/prerm	2007-07-23 09:26:13 UTC (rev 413)
@@ -2,7 +2,7 @@
 ### some global variables etc
 ###
 dbc_go(){
-	local need_admin_pw dumpfile nowtime
+	local need_admin_pw dumpfile nowtime rmscript rmsql purgescript purgesql tsubstfile
 
 	. /usr/share/dbconfig-common/dpkg/common
 	_dbc_debug "(prerm) dbc_go() $@"
@@ -45,6 +45,34 @@
 		fi
 
 		###
+		###	package removal hooks
+		###
+		rmscript=/usr/share/dbconfig-common/scripts/$dbc_package/remove/$dbc_dbtype
+		rmsql=/usr/share/dbconfig-common/data/$dbc_package/remove/$dbc_dbtype
+		# run the script if it exists
+		if [ -f "$rmscript" ]; then
+			dbc_logpart "running maintainer removal script hook... "
+			if ! sh -c "$rmscript \"$@\""; then
+				dbc_error="$rmscript existed with non-zero status"
+				dbc_remove_error "running maintainer removal hook"
+			fi
+			dbc_logline "done"
+		fi
+		# run the sql if it exists
+		if [ -f "$rmsql" ]; then
+			dbc_logpart "running maintainer removal sql hook... "
+			if [ ! "$dbc_sql_substitutions" ]; then
+				$dbc_sqlfile_cmd $rmsql || dbc_remove_error "running maintainer removal sql hook"
+			else
+				tsubstfile=`dbc_mktemp`
+				/usr/sbin/dbconfig-generate-include -f template -o template_infile=$dbc_sqlfile_adm $dbc_packageconfig > $tsubstfile
+				$dbc_sqlfile_cmd $tsubstfile || dbc_remove_error "running maintainer removal sql hook"
+				rm -f $tsubstfile
+			fi
+			dbc_logline "done"
+		fi
+
+		###
 		### ask the admin if the database should be purged
 		###
 		db_input high $dbc_package/purge || true




More information about the Dbconfig-common-changes mailing list