[Dbconfig-common-changes] [dbconfig-common] r237 - in
branches/sqlite: dpkg internal
Matt Brown
mattb-guest at costa.debian.org
Tue May 30 14:35:39 CEST 2006
Author: mattb-guest
Date: 2006-05-30 12:35:37 +0000 (Tue, 30 May 2006)
New Revision: 237
Modified:
branches/sqlite/dpkg/config
branches/sqlite/dpkg/prerm
branches/sqlite/internal/sqlite
Log:
* More conditionalising of authentication template handling in the prerm script
* Change how/where the sqlite database is created and named
- Don't prompt the user for name / location
- Place into /var/lib/dbconfig-common/$dbc_package.sqlite
This seems to be in keeping with how mysql/pgsql handle things
Basic SQLite functionality is complete and working with this commit. Have not
tested upgrades or error cases yet but install/remove/purge works ok.
Modified: branches/sqlite/dpkg/config
===================================================================
--- branches/sqlite/dpkg/config 2006-05-30 10:24:49 UTC (rev 236)
+++ branches/sqlite/dpkg/config 2006-05-30 12:35:37 UTC (rev 237)
@@ -150,8 +150,8 @@
dbc_config $@
fi
- # there's a bit more to do with client/server rdbms
- if [ "$dbc_dbtype" = "mysql" -o "$dbc_dbtype" = "pgsql" ]; then
+ # there's a bit more to do with rdbms that support authentication
+ if echo "$dbc_authenticated_dbtypes" | grep -q "$dbc_dbtype"; then
# if these haven't been specified, use defaults
if [ ! "$dbc_dbadmin" ]; then
dbc_dbadmin="$dbc_default_admin";
@@ -159,17 +159,14 @@
if [ ! "$dbc_dbuser" ]; then
dbc_dbuser="$dbc_default_dbuser"
fi
- if [ ! "$dbc_dbname" ]; then
- dbc_dbname=`echo $dbc_package | tr -d +-.`;
- fi
- db_set $dbc_package/db/dbname "$dbc_dbname"
- elif [ "$dbc_dbtype" = "sqlite" ]; then
- # Set the db name to a sensible default
- db_set $dbc_package/db/dbname "/var/lib/$dbc_package.sqlite"
- db_input high $dbc_package/db/dbname || true
fi
+ if [ ! "$dbc_dbname" ]; then
+ dbc_dbname=`echo $dbc_package | tr -d +-.`;
+ fi
+
# pre-seed any already defined values into debconf as defaults
+ db_set $dbc_package/db/dbname "$dbc_dbname"
if [ "$dbc_upgrade" ]; then
db_set $dbc_package/dbconfig-upgrade "$dbc_upgrade"
fi
Modified: branches/sqlite/dpkg/prerm
===================================================================
--- branches/sqlite/dpkg/prerm 2006-05-30 10:24:49 UTC (rev 236)
+++ branches/sqlite/dpkg/prerm 2006-05-30 12:35:37 UTC (rev 237)
@@ -14,7 +14,11 @@
###
dbc_read_package_config
- need_admin_pw="yup"
+ if echo "$dbc_authenticated_dbtypes" | grep -q "$dbc_dbtype"; then
+ need_admin_pw="yup"
+ else
+ need_admin_pw=""
+ fi
if [ "$dbc_command" = "remove" ]; then
###
Modified: branches/sqlite/internal/sqlite
===================================================================
--- branches/sqlite/internal/sqlite 2006-05-30 10:24:49 UTC (rev 236)
+++ branches/sqlite/internal/sqlite 2006-05-30 12:35:37 UTC (rev 237)
@@ -10,6 +10,8 @@
# get some common functions
. /usr/share/dbconfig-common/internal/common
+SQLITE_BASE_DIRECTORY="/var/lib/dbconfig-common"
+
##
## execute a file with sqlite commands
##
@@ -23,8 +25,8 @@
dbc_log="no file supplied to execute"
return 1
fi
-
- sqlite $dbc_dbname < "$l_sqlfile"
+ dbfile="$SQLITE_BASE_DIRECTORY/${dbc_dbname}.sqlite"
+ sqlite "$dbfile" < "$l_sqlfile"
retval=$?
return $retval
}
@@ -55,7 +57,8 @@
_dbc_sqlite_check_database(){
local dbc_dbname
dbc_dbname=$1
- if test -f "$dbc_dbname"; then
+ dbfile="$SQLITE_BASE_DIRECTORY/${dbc_dbname}.sqlite"
+ if test -f "$dbfile"; then
return 0
else
return 1
@@ -88,6 +91,7 @@
dbc_logline "already exists"
dbc_status=nothing
else
+ mkdir -p "$SQLITE_BASE_DIRECTORY"
_dbc_nodb="yes" dbc_sqlite_exec_command ".schema"
ret=$?
_dbc_nodb=""
@@ -110,7 +114,7 @@
## drops the sqlite database file by removing it from the disk
##
##
-dbc_mysql_dropdb(){
+dbc_sqlite_dropdb(){
dbc_status=error
_dbc_sanity_check dbname || return 1
@@ -118,7 +122,7 @@
dbc_logpart "dropping database $dbc_dbname:"
if _dbc_sqlite_check_database "$dbc_dbname"; then
- if rm -f "$dbc_dbname"; then
+ if rm -f "$SQLITE_BASE_DIRECTORY/${dbc_dbname}.sqlite"; then
dbc_logline "success"
dbc_logpart "verifying database $dbc_dbname was dropped:"
if _dbc_sqlite_check_database "$dbc_dbname"; then
More information about the Dbconfig-common-changes
mailing list