[Dbconfig-common-changes] [dbconfig-common] r302 - in trunk: .
debian doc dpkg examples internal
Matt Brown
mattb-guest at costa.debian.org
Tue Aug 15 10:50:10 CEST 2006
Author: mattb-guest
Date: 2006-08-15 08:50:09 +0000 (Tue, 15 Aug 2006)
New Revision: 302
Added:
trunk/dpkg/config.sqlite
trunk/dpkg/postinst.sqlite
trunk/dpkg/postrm.sqlite
trunk/dpkg/preinst.sqlite
trunk/dpkg/prerm.sqlite
trunk/examples/db-test-sqlite-2.0/
trunk/internal/sqlite
Modified:
trunk/dbconfig-generate-include
trunk/dbconfig-load-include
trunk/debian/changelog
trunk/debian/dbconfig-common.postrm
trunk/debian/dbconfig-common.templates
trunk/doc/dbconfig-common.sgml
trunk/dpkg/common
trunk/dpkg/config
trunk/examples/buildpackages.sh
trunk/internal/common
Log:
Merged SQLite branch down into trunk. DONE!
Modified: trunk/dbconfig-generate-include
===================================================================
--- trunk/dbconfig-generate-include 2006-08-15 08:41:15 UTC (rev 301)
+++ trunk/dbconfig-generate-include 2006-08-15 08:50:09 UTC (rev 302)
@@ -8,6 +8,7 @@
dbserver_varname="dbserver"
dbport_varname="dbport"
dbtype_varname="dbtype"
+basepath_varname="basepath"
# the version will always be < the package version
VERSION="$Revision$"
@@ -32,6 +33,7 @@
-f|--format use the given output format (default: sh)
-o|--options provide output-format-specific options
-a|--all include all information in output (default)
+ -b|--basepath include the basepath in the output
-d|--dbname include the dbname in the output
-p|--dbpass include the dbpass in the output
-s|--dbserver include the dbserver in the output
@@ -65,7 +67,7 @@
fi
}
-TEMP=`getopt -o af:hd::m:o:p::u::s::t::C::O:P::Uv --long help,dbuser::,dbname::,dbpass::,dbport::,dbserver::,dbtype::,output:,format:,options:,comment::,owner:,mode:,ucf,version -n $0 -- "$@"`
+TEMP=`getopt -o af:hb::d::m:o:p::u::s::t::C::O:P::Uv --long help,dbuser::,dbname::,dbpass::,dbport::,dbserver::,dbtype::,basepath::,output:,format:,options:,comment::,owner:,mode:,ucf,version -n $0 -- "$@"`
if [ $? != 0 ] ; then usage >&2 ; exit 1 ; fi
@@ -77,6 +79,13 @@
use_all="yes"
shift
;;
+ -b|--basepath)
+ use_basepath="yes"
+ if [ ! -z "$2" ]; then
+ basepath_varname="$2"
+ fi
+ shift 2
+ ;;
-d|--dbname)
use_dbname="yes"
if [ ! -z "$2" ]; then
@@ -166,9 +175,10 @@
done
# if they asked for all vars, or didn't ask for anything (which defaults to all)
-if [ "$use_all" ] || [ ! "${use_dbuser}${use_dbpass}${use_dbname}${use_dbserver}${use_dbtype}${use_dbport}" ]; then
+if [ "$use_all" ] || [ ! "${use_dbuser}${use_dbpass}${use_basepath}${use_dbname}${use_dbserver}${use_dbtype}${use_dbport}" ]; then
use_dbuser="yes"
use_dbpass="yes"
+ use_basepath="yes"
use_dbname="yes"
use_dbserver="yes"
use_dbport="yes"
@@ -223,6 +233,7 @@
# now determine which things should be commented out if any
[ ! "$dbc_dbuser" ] && comment_dbuser="${comment_string}"
[ ! "$dbc_dbpass" ] && comment_dbpass="${comment_string}"
+ [ ! "$dbc_basepath" ] && comment_basepath="${comment_string}"
[ ! "$dbc_dbname" ] && comment_dbname="${comment_string}"
[ ! "$dbc_dbserver" ] && comment_dbserver="${comment_string}"
[ ! "$dbc_dbport" ] && comment_dbport="${comment_string}"
@@ -246,6 +257,7 @@
EOF
[ "$use_dbuser" ] && echo "${comment_dbuser}$dbuser_varname='$dbc_dbuser'"
[ "$use_dbpass" ] && echo "${comment_dbpass}$dbpass_varname='$dbc_dbpass'"
+ [ "$use_basepath" ] && echo "${comment_basepath}$basepath_varname='$dbc_basepath'"
[ "$use_dbname" ] && echo "${comment_dbname}$dbname_varname='$dbc_dbname'"
[ "$use_dbserver" ] && echo "${comment_dbserver}$dbserver_varname='$dbc_dbserver'"
[ "$use_dbport" ] && echo "${comment_dbport}$dbport_varname='$dbc_dbport'"
@@ -269,6 +281,7 @@
EOF
[ "$use_dbuser" ] && echo "${comment_dbuser}\$$dbuser_varname='$dbc_dbuser';"
[ "$use_dbpass" ] && echo "${comment_dbpass}\$$dbpass_varname='$dbc_dbpass';"
+ [ "$use_basepath" ] && echo "${comment_basepath}\$$basepath_varname='$dbc_basepath';"
[ "$use_dbname" ] && echo "${comment_dbname}\$$dbname_varname='$dbc_dbname';"
[ "$use_dbserver" ] && echo "${comment_dbserver}\$$dbserver_varname='$dbc_dbserver';"
[ "$use_dbport" ] && echo "${comment_dbport}\$$dbport_varname='$dbc_dbport';"
@@ -293,6 +306,7 @@
EOF
[ "$use_dbuser" ] && echo "${comment_dbuser}our \$$dbuser_varname='$dbc_dbuser';"
[ "$use_dbpass" ] && echo "${comment_dbpass}our \$$dbpass_varname='$dbc_dbpass';"
+ [ "$use_basepath" ] && echo "${comment_basepath}our \$$basepath_varname='$dbc_basepath';"
[ "$use_dbname" ] && echo "${comment_dbname}our \$$dbname_varname='$dbc_dbname';"
[ "$use_dbserver" ] && echo "${comment_dbserver}our \$$dbserver_varname='$dbc_dbserver';"
[ "$use_dbport" ] && echo "${comment_dbport}our \$$dbport_varname='$dbc_dbport';"
@@ -321,6 +335,7 @@
EOF
[ "$use_dbuser" ] && echo " ${comment_dbuser}#define $dbuser_varname \"$dbc_dbuser\";"
[ "$use_dbpass" ] && echo " ${comment_dbpass}#define $dbpass_varname \"$dbc_dbpass\";"
+ [ "$use_basepath" ] && echo "${comment_basepath}#define $basepath_varname \"$dbc_basepath\";"
[ "$use_dbname" ] && echo " ${comment_dbname}#define $dbname_varname \"$dbc_dbname\";"
[ "$use_dbserver" ] && echo " ${comment_dbserver}#define $dbserver_varname \"$dbc_dbserver\";"
[ "$use_dbport" ] && echo " ${comment_dbport}#define $dbport_varname \"$dbc_dbport\";"
@@ -347,6 +362,7 @@
cat << EOF > "$sedtmp"
s/^\(.*\)_DBC_DBUSER_/${comment_dbuser}\1$dbc_dbuser/g
s/^\(.*\)_DBC_DBPASS_/${comment_dbpass}\1$dbc_dbpass/g
+s/^\(.*\)_DBC_BASEPATH_/${comment_basepath}\1$dbc_basepath/g
s/^\(.*\)_DBC_DBNAME_/${comment_dbname}\1$dbc_dbname/g
s/^\(.*\)_DBC_DBSERVER_/${comment_dbserver}\1$dbc_dbserver/g
s/^\(.*\)_DBC_DBPORT_/${comment_dbport}\1$dbc_dbport/g
Modified: trunk/dbconfig-load-include
===================================================================
--- trunk/dbconfig-load-include 2006-08-15 08:41:15 UTC (rev 301)
+++ trunk/dbconfig-load-include 2006-08-15 08:50:09 UTC (rev 302)
@@ -7,6 +7,7 @@
dbserver_varname="dbserver"
dbport_varname="dbport"
dbtype_varname="dbtype"
+basepath_varname="basepath"
# the version will always be < the package version
VERSION="$Revision$"
@@ -29,6 +30,7 @@
infile use the given dbconfig-common config file as input
-f|--format use the given output format (must be specified)
-a|--all include all information in output (default)
+ -b|--basepath include the basepath in the output
-d|--dbname include the dbname in the output
-p|--dbpass include the dbpass in the output
-s|--dbserver include the dbserver in the output
@@ -47,7 +49,7 @@
EOF
}
-TEMP=`getopt -o af:hd::p::u::s::t::P::v -l help,dbuser::,dbname::,dbpass::,dbport::,dbserver::,dbtype::,format:,version -n $0 -- "$@"`
+TEMP=`getopt -o af:hb::d::p::u::s::t::P::v -l help,dbuser::,dbname::,dbpass::,dbport::,dbserver::,dbtype::,basepath::,format:,version -n $0 -- "$@"`
if [ $? != 0 ] ; then usage >&2 ; exit 1 ; fi
@@ -59,6 +61,13 @@
use_all="yes"
shift
;;
+ -b|--basepath)
+ use_basepath="yes"
+ if [ ! -z "$2" ]; then
+ basepath_varname="$2"
+ fi
+ shift 2
+ ;;
-d|--dbname)
use_dbname="yes"
if [ ! -z "$2" ]; then
@@ -125,9 +134,10 @@
done
# if they asked for all vars, or didn't ask for anything (which defaults to all)
-if [ "$use_all" ] || [ ! "${use_dbuser}${use_dbpass}${use_dbname}${use_dbserver}${use_dbtype}${use_dbport}" ]; then
+if [ "$use_all" ] || [ ! "${use_dbuser}${use_dbpass}${use_basepath}${use_dbname}${use_dbserver}${use_dbtype}${use_dbport}" ]; then
use_dbuser="yes"
use_dbpass="yes"
+ use_basepath="yes"
use_dbname="yes"
use_dbserver="yes"
use_dbport="yes"
@@ -159,6 +169,7 @@
. $inputfile
use_dbuser="$use_dbuser";
use_dbpass="$use_dbpass";
+use_basepath="$use_basepath";
use_dbname="$use_dbname";
use_dbserver="$use_dbserver";
use_dbport="$use_dbport";
@@ -170,6 +181,7 @@
[ "$use_dbpass" ] && cat << FOO
dbc_dbpass='\$$dbpass_varname'
FOO
+ [ "$use_basepath" ] && echo "dbc_basepath='\$$basepath_varname'"
[ "$use_dbname" ] && echo "dbc_dbname='\$$dbname_varname'"
[ "$use_dbserver" ] && echo "dbc_dbserver='\$$dbserver_varname'"
[ "$use_dbport" ] && echo "dbc_dbport='\$$dbport_varname'"
@@ -188,6 +200,7 @@
\$use_dbuser="$use_dbuser";
\$use_dbpass="$use_dbpass";
+ \$use_basepath="$use_basepath";
\$use_dbname="$use_dbname";
\$use_dbserver="$use_dbserver";
\$use_dbport="$use_dbport";
@@ -197,6 +210,8 @@
echo "dbc_dbuser='\$$dbuser_varname';\n";
if(!empty(\$use_dbpass) && isset(\$$dbpass_varname))
echo "dbc_dbpass='\$$dbpass_varname';\n";
+ if(!empty(\$use_basepath) && isset(\$$basepath_varname))
+ echo "dbc_basepath='\$$basepath_varname';\n";
if(!empty(\$use_dbname) && isset(\$$dbname_varname))
echo "dbc_dbname='\$$dbname_varname';\n";
if(!empty(\$use_dbserver) && isset(\$$dbserver_varname))
@@ -212,6 +227,7 @@
( cat $inputfile; cat << EOF ) | perl
print "dbc_dbuser='\$$dbuser_varname'\n" if("$use_dbuser");
print "dbc_dbpass='\$$dbpass_varname'\n" if("$use_dbpass");
+print "dbc_basepath='\$$basepath_varname'\n" if("$use_basepath");
print "dbc_dbname='\$$dbname_varname'\n" if("$use_dbname");
print "dbc_dbserver='\$$dbserver_varname'\n" if("$use_dbserver");
print "dbc_dbport='\$$dbport_varname'\n" if("$use_dbport");
Modified: trunk/debian/changelog
===================================================================
--- trunk/debian/changelog 2006-08-15 08:41:15 UTC (rev 301)
+++ trunk/debian/changelog 2006-08-15 08:50:09 UTC (rev 302)
@@ -1,7 +1,11 @@
dbconfig-common (1.8.20) UNRELEASED; urgency=low
+ [ sean finney ]
* NOT RELEASED YET
+ [ Matt Brown ]
+ * Added support for SQLite databases. closes: #379796.
+
-- sean finney <sean at localhost> Tue, 15 Aug 2006 08:57:34 +0200
dbconfig-common (1.8.19) unstable; urgency=high
Modified: trunk/debian/dbconfig-common.postrm
===================================================================
--- trunk/debian/dbconfig-common.postrm 2006-08-15 08:41:15 UTC (rev 301)
+++ trunk/debian/dbconfig-common.postrm 2006-08-15 08:50:09 UTC (rev 302)
@@ -5,6 +5,8 @@
if [ $1 = "purge" ]; then
rm -f /etc/dbconfig-common/config || true
rmdir /etc/dbconfig-common || true
+ # This might fail if a user has chosen not to purge a database
+ rmdir --ignore-fail-on-non-empty /var/lib/dbconfig-common || true
fi
#DEBHELPER#
Modified: trunk/debian/dbconfig-common.templates
===================================================================
--- trunk/debian/dbconfig-common.templates 2006-08-15 08:41:15 UTC (rev 301)
+++ trunk/debian/dbconfig-common.templates 2006-08-15 08:50:09 UTC (rev 302)
@@ -233,6 +233,12 @@
objects to be created by this installation. This user will have
complete freedom to insert, change or delete data in the database.
+Template: dbconfig-common/db/basepath
+Type: string
+_Description: ${dbvendor} storage directory for ${pkg}:
+ Please provide a path where the ${dbvendor} database file for ${pkg}
+ should be installed into.
+
Template: dbconfig-common/mysql/method
Type: select
__Choices: unix socket, tcp/ip
Modified: trunk/doc/dbconfig-common.sgml
===================================================================
--- trunk/doc/dbconfig-common.sgml 2006-08-15 08:41:15 UTC (rev 301)
+++ trunk/doc/dbconfig-common.sgml 2006-08-15 08:50:09 UTC (rev 302)
@@ -22,7 +22,7 @@
<p>
<package>dbconfig-common</package> can:
<list>
- <item>support mysql and postgresql based applications
+ <item>support mysql, postgresql and sqlite based applications
<item>create databases and database users
<item>access local or remote databases
<item>upgrade/modify databases when upstream changes
@@ -416,12 +416,26 @@
<tag>dbc_dbuser (used in: <var>config</var>)
<item>name to use when connecting to
database (defaults to: package name)
+ <tag>dbc_basepath (used in: <var>config</var>)
+ <item>database storage directory for local (filesystem)
+ based database types. Not applicable for RDBMs like mysql
+ and postgres. (defaults to: /var/lib/dbconfig-common)
<tag>dbc_dbname (used in: <var>config</var>)
<item>name of database resource to which
to connect (defaults to: package name)
<tag>dbc_dbtypes (used in: <var>config</var>)
<item>database types supported by the
package (defaults to: empty)
+ <tag>dbc_dbfile_owner (used in: <var>postinst</var>)
+ <item>set the owner:group for the generated database file. This
+ option is only valid for databases like SQLite that use a
+ single file for storage and is not prompted via debconf.
+ (defaults to: root:root)
+ <tag>dbc_dbfile_perms (used in: <var>postinst</var>)
+ <item>set the permissions for the generated database file. This
+ option is only valid for databases like SQLite that use a
+ single file for storage and is not prompted via debconf.
+ (defaults to: 0640)
<tag>dbc_generate_include (used in: <var>postinst</var>)
<item>format:outputfile pair for
an extra config to be generated by
Modified: trunk/dpkg/common
===================================================================
--- trunk/dpkg/common 2006-08-15 08:41:15 UTC (rev 301)
+++ trunk/dpkg/common 2006-08-15 08:50:09 UTC (rev 302)
@@ -39,8 +39,11 @@
# templates common to postgresql database types
dbc_pgsql_templates="pgsql/method remote/host remote/newhost pgsql/app-pass pgsql/admin-user pgsql/admin-pass remote/port pgsql/authmethod-admin pgsql/authmethod-user pgsql/changeconf pgsql/manualconf db/dbname db/app-user pgsql/no-empty-passwords"
+ # templates common to sqlite database types
+ dbc_sqlite_templates="db/dbname db/basepath"
+
# all dbtypes supported by dbconfig-common
- dbc_all_supported_dbtypes="mysql pgsql"
+ dbc_all_supported_dbtypes="mysql pgsql sqlite"
# database types supporting authenticated access
dbc_authenticated_dbtypes="mysql pgsql"
@@ -48,6 +51,9 @@
# database types supporting remote access
dbc_remote_dbtypes="mysql pgsql"
+ # database types storing files on the filesystem
+ dbc_fs_dbtypes="sqlite"
+
###
### source the pre-existing config, if it exists
###
@@ -76,6 +82,7 @@
###
### dbtype-specific variable section
###
+ dbc_default_basepath=""
# now set some variables based on the dbtype
case $dbc_dbtype in
@@ -110,8 +117,25 @@
dbc_use_dbuser="false"
dbc_dbvendor="PostgreSQL"
;;
+ sqlite)
+ . /usr/share/dbconfig-common/internal/sqlite
+ dbc_createuser_cmd=true
+ dbc_checkuser_cmd=true
+ dbc_createdb_cmd='dbc_sqlite_createdb'
+ dbc_dropdb_cmd='dbc_sqlite_dropdb'
+ dbc_dropuser_cmd=true
+ dbc_sqlexec_cmd='dbc_sqlite_exec_command'
+ dbc_sqlfile_cmd='dbc_sqlite_exec_file'
+ dbc_dump_cmd='dbc_sqlite_dump'
+ dbc_register_templates="$dbc_standard_templates $dbc_sqlite_templates"
+ dbc_default_admin=""
+ dbc_default_dbuser="";
+ dbc_default_basepath="/var/lib/dbconfig-common"
+ dbc_use_dbuser="false"
+ dbc_dbvendor="SQLite"
+ ;;
*)
- dbc_register_templates="$dbc_standard_templates $dbc_mysql_templates $dbc_pgsql_templates"
+ dbc_register_templates="$dbc_standard_templates $dbc_mysql_templates $dbc_pgsql_templates $dbc_sqlite_templates"
;;
esac
@@ -215,6 +239,11 @@
db_set $dbc_package/remote/port "$dbc_dbport"
fi
+ if echo "$dbc_fs_dbtypes" | grep -qa "$dbc_dbtype"; then
+ # set the directory that the database file is found in
+ db_set $dbc_package/db/basepath "$dbc_basepath"
+ fi
+
# set the name of the database to be created
db_set $dbc_package/db/dbname "$dbc_dbname"
@@ -287,6 +316,11 @@
db_get $dbc_package/remote/port && dbc_dbport="$RET"
fi
+ if echo "$dbc_fs_dbtypes" | grep -qa "$dbc_dbtype"; then
+ # get the directory that the database file is found in
+ db_get $dbc_package/db/basepath && dbc_basepath="$RET"
+ fi
+
# get the name of the database to be created
db_get $dbc_package/db/dbname && dbc_dbname="$RET"
@@ -396,6 +430,11 @@
# this is the administrative user that is used to create all of the above
dbc_dbadmin="$dbc_dbadmin"
+# dbc_basepath: base directory to hold database files
+# leave unset to use the default. only applicable if you are
+# using a local (filesystem based) database.
+dbc_basepath="$dbc_basepath"
+
##
## postgresql specific settings. if you don't use postgresql,
## you can safely ignore all of these
@@ -748,6 +787,8 @@
;;
"pgsql") testfile='/usr/bin/psql'
;;
+ "sqlite") testfile='/usr/bin/sqlite'
+ ;;
"")
;;
esac
Modified: trunk/dpkg/config
===================================================================
--- trunk/dpkg/config 2006-08-15 08:41:15 UTC (rev 301)
+++ trunk/dpkg/config 2006-08-15 08:50:09 UTC (rev 302)
@@ -203,6 +203,13 @@
fi
fi
+ if echo "$dbc_fs_dbtypes" | grep -q "$dbc_dbtype"; then
+ # if these haven't been specified, use defaults
+ if [ ! "$dbc_basepath" ]; then
+ dbc_basepath="$dbc_default_basepath";
+ fi
+ fi
+
if [ ! "$dbc_dbname" ]; then
dbc_dbname=`echo $dbc_package | tr -d +-.`;
fi
@@ -241,6 +248,13 @@
fi
db_input $dbc_remote_questions_priority $dbc_package/$dbc_dbtype/method || true
fi
+ if echo "$dbc_fs_dbtypes" | grep -q "$dbc_dbtype"; then
+ # if these haven't been specified, use defaults
+ if [ "$dbc_basepath" ]; then
+ db_set $dbc_package/db/basepath "$dbc_basepath"
+ fi
+ fi
+
;;
# state 4 - do stuff based on the connection method
4)
@@ -358,6 +372,11 @@
fi
+ if echo "$dbc_fs_dbtypes" | grep -q "$dbc_dbtype"; then
+ # check the path / permissions to install to
+ db_input low $dbc_package/db/basepath || true
+ fi
+
# get the name of the database to use
db_input $userdb_prio $dbc_package/db/dbname || true
;;
Copied: trunk/dpkg/config.sqlite (from rev 301, branches/sqlite/dpkg/config.sqlite)
Copied: trunk/dpkg/postinst.sqlite (from rev 301, branches/sqlite/dpkg/postinst.sqlite)
Copied: trunk/dpkg/postrm.sqlite (from rev 301, branches/sqlite/dpkg/postrm.sqlite)
Copied: trunk/dpkg/preinst.sqlite (from rev 301, branches/sqlite/dpkg/preinst.sqlite)
Copied: trunk/dpkg/prerm.sqlite (from rev 301, branches/sqlite/dpkg/prerm.sqlite)
Modified: trunk/examples/buildpackages.sh
===================================================================
--- trunk/examples/buildpackages.sh 2006-08-15 08:41:15 UTC (rev 301)
+++ trunk/examples/buildpackages.sh 2006-08-15 08:50:09 UTC (rev 302)
@@ -3,7 +3,7 @@
packages="db-test-mysql-2.0 db-test-mysql-2.1 db-test-mysql-frontend-2.0 \
db-test-mysql-perl-2.0 db-test-pgsql-2.0 \
db-test-pgsql-migration-1.9 db-test-pgsql-migration-2.0 \
- db-test-multidbtype-2.0"
+ db-test-multidbtype-2.0 db-test-sqlite-2.0 "
echo -n "building packages:"
for f in $packages; do
Copied: trunk/examples/db-test-sqlite-2.0 (from rev 301, branches/sqlite/examples/db-test-sqlite-2.0)
Modified: trunk/internal/common
===================================================================
--- trunk/internal/common 2006-08-15 08:41:15 UTC (rev 301)
+++ trunk/internal/common 2006-08-15 08:50:09 UTC (rev 302)
@@ -127,6 +127,14 @@
return 1
fi
;;
+ "sqlite")
+ if ! which sqlite >/dev/null; then
+ dbc_error="No sqlite client to execute. (have
+ you installed the sqlite package?"
+ dbc_logline "sanity check failed for sqlite"
+ return 1
+ fi
+ ;;
"createdb")
if ! which createdb >/dev/null; then
dbc_error="No pgsql createdb to execute. (have
Copied: trunk/internal/sqlite (from rev 301, branches/sqlite/internal/sqlite)
More information about the Dbconfig-common-changes
mailing list