[Dbconfig-common-changes] [dbconfig-common] r208 - in trunk: debian
dpkg examples/db-test-mysql-2.0/debian
examples/db-test-mysql-2.1/debian internal
Sean Finney
seanius at costa.debian.org
Mon Apr 24 01:25:26 CEST 2006
Author: seanius
Date: 2006-04-23 23:25:24 +0000 (Sun, 23 Apr 2006)
New Revision: 208
Modified:
trunk/debian/changelog
trunk/debian/dbconfig-common.templates
trunk/debian/rules
trunk/dpkg/common
trunk/dpkg/config
trunk/dpkg/postinst
trunk/dpkg/postrm
trunk/dpkg/prerm
trunk/examples/db-test-mysql-2.0/debian/postrm
trunk/examples/db-test-mysql-2.1/debian/postrm
trunk/internal/common
Log:
i think this is it for .12
Modified: trunk/debian/changelog
===================================================================
--- trunk/debian/changelog 2006-04-23 21:18:40 UTC (rev 207)
+++ trunk/debian/changelog 2006-04-23 23:25:24 UTC (rev 208)
@@ -1,4 +1,4 @@
-dbconfig-common (1.8.12) UNRELEASED; urgency=low
+dbconfig-common (1.8.12) unstable; urgency=low
[sean finney]
* dbconfig-common is now migrated to svn.debian.org.
@@ -22,8 +22,16 @@
to each other. this *should* be fixed now, but i'm sure i'll
hear if it isn't.
* added missing build-depend on gs.
+ * added a debugging and logging function, and started using it
+ in various places as i add more code. to get a little more
+ info on what goes on, export dbc_debug=1 before installing
+ a dbc-using package.
+ * logic fix for install/upgrades in postinst that would otherwise
+ result in installation code being run when it shouldn't, which
+ can be really annoying. now everything *should* work the way
+ it ought to...
- -- sean finney <seanius at debian.org> Mon, 10 Apr 2006 09:01:02 +0200
+ -- sean finney <seanius at debian.org> Mon, 24 Apr 2006 01:26:02 +0200
dbconfig-common (1.8.11) unstable; urgency=low
Modified: trunk/debian/dbconfig-common.templates
===================================================================
--- trunk/debian/dbconfig-common.templates 2006-04-23 21:18:40 UTC (rev 207)
+++ trunk/debian/dbconfig-common.templates 2006-04-23 23:25:24 UTC (rev 208)
@@ -382,3 +382,7 @@
${pkg}. Later, these settings will be validated, and if there is
any problem with loading or using them you will be given the option to
enter them again later.
+
+Template: dbconfig-common/internal/reconfiguring
+Type: boolean
+Default: false
Modified: trunk/debian/rules
===================================================================
--- trunk/debian/rules 2006-04-23 21:18:40 UTC (rev 207)
+++ trunk/debian/rules 2006-04-23 23:25:24 UTC (rev 208)
@@ -47,7 +47,6 @@
cp -Pr internal debian/dbconfig-common/usr/share/dbconfig-common/
cp -P dbconfig-generate-include debian/dbconfig-common/usr/sbin/
cp -P dbconfig-load-include debian/dbconfig-common/usr/sbin/
- find debian/dbconfig-common -type d -name CVS -exec rm -rf "{}" \; -prune
# Build architecture-independent files here.
binary-indep: build install
Modified: trunk/dpkg/common
===================================================================
--- trunk/dpkg/common 2006-04-23 21:18:40 UTC (rev 207)
+++ trunk/dpkg/common 2006-04-23 23:25:24 UTC (rev 208)
@@ -10,6 +10,7 @@
. /usr/share/dbconfig-common/internal/common
dbc_config(){
+ dbc_debug "dbc_config() $@"
###
### some global variables
###
@@ -18,6 +19,7 @@
dbc_command="$2"
dbc_oldversion="$3"
+
if ! _dbc_sanity_check package command; then
dbc_install_error "determining package or command";
fi
@@ -30,7 +32,7 @@
### some internal variables
###
# templates common to all database types
- dbc_standard_templates="database-type dbconfig-install dbconfig-upgrade dbconfig-remove password-confirm app-password-confirm purge upgrade-backup passwords-do-not-match install-error upgrade-error remove-error import-oldsettings performing_upgrade"
+ dbc_standard_templates="database-type dbconfig-install dbconfig-upgrade dbconfig-remove password-confirm app-password-confirm purge upgrade-backup passwords-do-not-match install-error upgrade-error remove-error import-oldsettings performing_upgrade internal/reconfiguring"
# templates common to mysql database types
dbc_mysql_templates="mysql/method remote/host remote/newhost mysql/app-pass mysql/admin-user mysql/admin-pass remote/port db/dbname db/app-user"
@@ -110,6 +112,7 @@
### dump global configuration to a config file
###
dbc_write_global_config(){
+ dbc_debug "dbc_write_global_config() $@"
cat << EOF > $dbc_globalconfig
# automatically generated by the maintainer scripts of dbconfig-common
# any changes you make to configuration options in this file will be
@@ -123,6 +126,7 @@
}
dbc_read_package_config(){
+ dbc_debug "dbc_read_package_config() $@"
_dbc_sanity_check package packageconfig || dbc_install_error
if [ -f $dbc_packageconfig ]; then
. $dbc_packageconfig
@@ -135,6 +139,7 @@
### the "Debconf is Not a Registry" dilemma.
###
dbc_preseed_package_debconf(){
+ dbc_debug "dbc_preseed_package_config() $@"
_dbc_sanity_check package packageconfig || dbc_install_error
# if the package configuration does not exist then there is
@@ -198,6 +203,7 @@
### with respect to the package's configuration and dbconfig-common.
###
dbc_read_package_debconf(){
+ dbc_debug "dbc_read_package_debconf() $@"
_dbc_sanity_check package || dbc_install_error
# gracefully fetch this to support multi-dbtype packages
@@ -253,6 +259,7 @@
###
dbc_write_package_config(){
local iformat ofile warn tfile
+ dbc_debug "dbc_write_package_config() $@"
_dbc_sanity_check packageconfig || dbc_install_error
echo "dbconfig-common: writing config to $dbc_packageconfig" >&2
@@ -524,6 +531,7 @@
## exactly what you'd think
##
dbc_forget_dbadmin_password(){
+ dbc_debug "dbc_forget_dbadmin_password() $@"
echo dbconfig-common: flushing administrative password >&2
db_reset $dbc_package/$dbc_dbtype/admin-pass
db_fset $dbc_package/$dbc_dbtype/admin-pass seen false
@@ -535,6 +543,7 @@
## exactly what you'd think
##
dbc_forget_app_password(){
+ dbc_debug "dbc_forget_app_password() $@"
db_reset $dbc_package/$dbc_dbtype/app-pass || true
db_fset $dbc_package/$dbc_dbtype/app-pass seen false || true
db_reset $dbc_package/app-password-confirm || true
@@ -548,6 +557,7 @@
##
dbc_get_admin_pass(){
local have_admin_pass pass1
+ dbc_debug "dbc_get_admin_pass() $@"
db_fget $dbc_package/$dbc_dbtype/admin-pass seen
if [ "$RET" = "true" ]; then
@@ -583,6 +593,7 @@
##
dbc_get_app_pass(){
local have_app_pass pass1 pass2
+ dbc_debug "dbc_get_app_pass() $@"
db_fget $dbc_package/$dbc_dbtype/app-pass seen
if [ "$RET" = "true" ]; then
@@ -635,6 +646,7 @@
## perform any necessary cleanup before exiting the postinst
##
dbc_postinst_cleanup(){
+ dbc_debug "dbc_postinst_cleanup() $@"
if [ "$dbc_remember_admin_pass" != "true" ]; then
dbc_forget_dbadmin_password
fi
@@ -648,6 +660,7 @@
##
dbc_detect_dbtype(){
local query_dbtype
+ dbc_debug "dbc_detect_dbtype() $@"
query_dbtype=$1
dbc_dbtype_supported="no"
dbc_dbtype_installed="no"
@@ -680,6 +693,7 @@
###
dbc_register_debconf(){
local f
+ dbc_debug "dbc_register_debconf() $@"
for f in $dbc_register_templates; do
# perform some basic customizing substitutions
db_register dbconfig-common/$f $dbc_package/$f
Modified: trunk/dpkg/config
===================================================================
--- trunk/dpkg/config 2006-04-23 21:18:40 UTC (rev 207)
+++ trunk/dpkg/config 2006-04-23 23:25:24 UTC (rev 208)
@@ -5,6 +5,8 @@
dbc_go(){
local db happy default_dbtype host newhost port oldhosts authmethod_user authmethod_admin do_config need_adminpw need_userpw f _preconf_list _s _t STATEiformat ifile
. /usr/share/dbconfig-common/dpkg/common
+ dbc_debug "(config) dbc_go() $@"
+
dbc_config $@
db_capb backup
@@ -323,4 +325,11 @@
exit 10
fi
done
+
+ # finally, if we are reconfiguring (via dpkg-reconfigure), leave a hint
+ # for our future postinst selves so we know we *should* run the code
+ # that would otherwise think we were upgrading
+ if [ "$dbc_command" = "reconfigure" ]; then
+ db_set $dbc_package/internal/reconfiguring true
+ fi
}
Modified: trunk/dpkg/postinst
===================================================================
--- trunk/dpkg/postinst 2006-04-23 21:18:40 UTC (rev 207)
+++ trunk/dpkg/postinst 2006-04-23 23:25:24 UTC (rev 208)
@@ -2,8 +2,11 @@
### load up common variables and functions
###
dbc_go(){
- local prev_dbc_upgrade importing_from_non_dbc f
+ local prev_dbc_upgrade importing_from_non_dbc upgrading f
+
. /usr/share/dbconfig-common/dpkg/common
+ dbc_debug "(postinst) dbc_go() $@"
+
dbc_config $@
# read in debconf responses (which are seeded from the config)
dbc_read_package_debconf $@
@@ -41,16 +44,29 @@
export dbc_config_include
fi
+ # find out if we're upgrading/reinstalling
+ if [ "$dbc_oldversion" ]; then
+ # read that little crumb left in config if we're reconfiguring
+ db_get $dbc_package/internal/reconfiguring
+ # if not, we're definitely upgrading
+ if [ "$RET" = "false" ]; then
+ upgrading="yes"
+ fi
+ # and set it back to false
+ db_reset $dbc_package/internal/reconfiguring
+ fi
+
# now, determine if we're upgrading from a non-dbc version. if so,
# there's a bunch of stuff that we do NOT want to do
- if [ "$dbc_first_version" ] && [ "$dbc_oldversion" ]; then
+ if [ "$upgrading" ] && [ "$dbc_first_version" ]; then
if dpkg --compare-versions "$dbc_first_version" gt "$dbc_oldversion"; then
+ dbc_logline "detected upgrade from previous non-dbconfig version"
importing_from_non_dbc="true"
fi
fi
# don't perform the following block of code during upgrades
- if [ ! "${importing_from_non_dbc}" ]; then
+ if [ ! "$upgrading" ]; then
###
### now, create the app user account
###
@@ -66,28 +82,34 @@
###
### populate the database
###
- # sqlfile is the file to use for installing the database, this is
+ # sqlfile is the file to use for installing the database
dbc_sqlfile=$dbc_share/data/$dbc_package/install/$dbc_dbtype
dbc_sqlfile_adm=$dbc_share/data/$dbc_package/install-dbadmin/$dbc_dbtype
dbc_scriptfile=$dbc_share/scripts/$dbc_package/install/$dbc_dbtype
if [ -f "$dbc_scriptfile" ]; then
+ dbc_logpart "populating database via scriptfile... "
if ! sh -c "$dbc_scriptfile $*"; then
dbc_error="$dbc_scriptfile exited with non-zero status"
dbc_install_error "populating database"
[ "$dbc_tried_again" ] && return 0
fi
+ dbc_logline "done"
fi
if [ -f "$dbc_sqlfile_adm" ]; then
+ dbc_logpart "populating database via administrative sql... "
$dbc_sqlfile_cmd $dbc_sqlfile_adm || dbc_install_error "populating database with administrative sql"
[ "$dbc_tried_again" ] && return 0
+ dbc_logline "done"
fi
if [ -f "$dbc_sqlfile" ]; then
+ dbc_logpart "populating database via administrative sql... "
_dbc_asuser="yes"
$dbc_sqlfile_cmd $dbc_sqlfile || dbc_install_error "populating database"
_dbc_asuser=""
[ "$dbc_tried_again" ] && return 0
+ dbc_logline "done"
fi
fi
@@ -102,7 +124,7 @@
# begin upgrade section
- if [ "$dbc_oldversion" ]; then
+ if [ "$upgrading" ]; then
_dbc_upgrades_pending=`_dbc_find_upgrades`
@@ -130,7 +152,7 @@
# this is the file into which upgrade backups go
_dbc_dbfile=/var/cache/dbconfig-common/backups/${dbc_package}_${dbc_oldversion}.$dbc_dbtype
- echo dbconfig-common: creating database backup in $_dbc_dbfile >&2
+ dbc_logline "creating database backup in $_dbc_dbfile"
# backup before we upgrade
_dbc_asuser=""
$dbc_dump_cmd > $_dbc_dbfile
@@ -190,6 +212,7 @@
##
_dbc_apply_upgrades(){
local f vers sqlfile admsqlfile scriptfile
+ dbc_debug "_dbc_apply_upgrades() $@"
# check for new upgrades in these three locations
vers="$1"
sqlfile="$dbc_share/data/$dbc_package/upgrade/$dbc_dbtype/$vers"
@@ -199,9 +222,9 @@
# now go through script updates
if [ -f "$scriptfile" ]; then
- echo "dbconfig-common: applying upgrade script for $dbc_oldvers -> $vers" >&2
+ dbc_logline "applying upgrade script for $dbc_oldversion -> $vers"
# XXX $*
- if ! sh -c "$scriptfile $*"; then
+ if ! sh -c "$scriptfile $*"; then
dbc_error="$scriptfile exited with non-zero status"
dbc_upgrade_error "processing $scriptfile"
[ "$dbc_tried_again" ] && return 0
@@ -210,14 +233,14 @@
_dbc_asuser=""
if [ -f "$admsqlfile" ]; then
- echo "dbconfig-common: applying upgrade admin sql for $dbc_oldvers -> $vers" >&2
+ dbc_logline "applying upgrade admin sql for $dbc_oldversion -> $vers"
$dbc_sqlfile_cmd $admsqlfile || dbc_upgrade_error "processing $admsqlfile"
[ "$dbc_tried_again" ] && return 0
fi
if [ -f "$sqlfile" ]; then
_dbc_asuser="yes"
- echo "dbconfig-common: applying upgrade sql for $dbc_oldvers -> $vers" >&2
+ dbc_logline "applying upgrade sql for $dbc_oldversion -> $vers"
$dbc_sqlfile_cmd $sqlfile || dbc_upgrade_error "processing $sqlfile"
[ "$dbc_tried_again" ] && return 0
_dbc_asuser=""
Modified: trunk/dpkg/postrm
===================================================================
--- trunk/dpkg/postrm 2006-04-23 21:18:40 UTC (rev 207)
+++ trunk/dpkg/postrm 2006-04-23 23:25:24 UTC (rev 208)
@@ -3,6 +3,7 @@
###
dbc_go(){
. /usr/share/dbconfig-common/dpkg/common
+ dbc_debug "(postrm) dbc_go() $@"
dbc_config $@
if [ "$dbc_command" = "purge" ]; then
Modified: trunk/dpkg/prerm
===================================================================
--- trunk/dpkg/prerm 2006-04-23 21:18:40 UTC (rev 207)
+++ trunk/dpkg/prerm 2006-04-23 23:25:24 UTC (rev 208)
@@ -5,6 +5,8 @@
local need_admin_pw
. /usr/share/dbconfig-common/dpkg/common
+ dbc_debug "(prerm) dbc_go() $@"
+
dbc_config $@
need_admin_pw="yup"
Modified: trunk/examples/db-test-mysql-2.0/debian/postrm
===================================================================
--- trunk/examples/db-test-mysql-2.0/debian/postrm 2006-04-23 21:18:40 UTC (rev 207)
+++ trunk/examples/db-test-mysql-2.0/debian/postrm 2006-04-23 23:25:24 UTC (rev 208)
@@ -9,6 +9,7 @@
if [ "$1" = "purge" ]; then
rm -f /etc/db-test-mysql/debian-db.php
+ ucf --purge /etc/db-test-mysql/debian-db.php
fi
#DEBHELPER#
Modified: trunk/examples/db-test-mysql-2.1/debian/postrm
===================================================================
--- trunk/examples/db-test-mysql-2.1/debian/postrm 2006-04-23 21:18:40 UTC (rev 207)
+++ trunk/examples/db-test-mysql-2.1/debian/postrm 2006-04-23 23:25:24 UTC (rev 208)
@@ -9,6 +9,7 @@
if [ "$1" = "purge" ]; then
rm -f /etc/db-test-mysql/debian-db.php
+ ucf --purge /etc/db-test-mysql/debian-db.php
fi
#DEBHELPER#
Modified: trunk/internal/common
===================================================================
--- trunk/internal/common 2006-04-23 21:18:40 UTC (rev 207)
+++ trunk/internal/common 2006-04-23 23:25:24 UTC (rev 208)
@@ -35,6 +35,15 @@
fi
}
+###
+### simple debugging function
+###
+dbc_debug(){
+ if [ "$dbc_debug" ]; then
+ dbc_logline $@
+ fi
+}
+
##
## internal sanity check for certain important variables
##
More information about the Dbconfig-common-changes
mailing list