[Dbconfig-common-changes] [dbconfig-common] r435 - in trunk: debian internal

Sean Finney seanius at alioth.debian.org
Sun Mar 30 18:43:29 UTC 2008


Author: seanius
Date: 2008-03-30 18:43:28 +0000 (Sun, 30 Mar 2008)
New Revision: 435

Modified:
   trunk/debian/changelog
   trunk/internal/common
   trunk/internal/mysql
Log:
fixes from first unit tests

Modified: trunk/debian/changelog
===================================================================
--- trunk/debian/changelog	2008-03-30 18:40:09 UTC (rev 434)
+++ trunk/debian/changelog	2008-03-30 18:43:28 UTC (rev 435)
@@ -7,9 +7,7 @@
   * centralize definition of dbc.log location
   * a test suite! now using shunit2 for unit tests, implemented some
     basic tests for logging as a proof-of-concept.
-  * first fix from unit tests, use ${param:-} for possibly unset params
-    in dbc_mktemp (others will follow as they're found).  fixes like this
-    will allow dbconfig-common to run "set -u" eventually.
+  * various fixes found from new unit tests
 
  -- Sean Finney <seanius at debian.org>  Thu, 27 Mar 2008 22:58:26 +0100
 

Modified: trunk/internal/common
===================================================================
--- trunk/internal/common	2008-03-30 18:40:09 UTC (rev 434)
+++ trunk/internal/common	2008-03-30 18:43:28 UTC (rev 435)
@@ -189,8 +189,8 @@
 		ttemplate="dbconfig-common.XXXXXX"; 
 	fi
 
-	tfile=`mktemp -t $ttemplate`
-	if [ ! -f $tfile ]; then
+	tfile=`mktemp -t "$ttemplate"`
+	if [ ! -f "$tfile" ]; then
 		dbc_error="error creating temporary file"
 		dbc_logline "error creating temporary file"
 		return 1

Modified: trunk/internal/mysql
===================================================================
--- trunk/internal/mysql	2008-03-30 18:40:09 UTC (rev 434)
+++ trunk/internal/mysql	2008-03-30 18:43:28 UTC (rev 435)
@@ -13,10 +13,9 @@
 ##
 _dbc_generate_mycnf(){
 	local mycnf l_date
-	mycnf=`mktemp -t dbconfig-common_my.cnf.XXXXXX`
-	[ ! "$mycnf" ] && return 1
+	mycnf=`dbc_mktemp dbconfig-common_my.cnf.XXXXXX` || return 1
 	l_date=`date`
-	cat << EOF > $mycnf
+	cat << EOF > "$mycnf"
 # temporary my.cnf generated for usage by dbconfig-common 
 # generated on $l_date
 # if you're reading this, it probably means something went wrong and
@@ -44,12 +43,13 @@
 ##
 ## check that we can actually connect to the specified mysql server
 ##
+## TODO: don't smash stdout/stderr together
 _dbc_mysql_check_connect(){
 	local constat mycnf
 	constat="bad"
 	mycnf=`_dbc_generate_mycnf`
 	dbc_error=`mysql --defaults-extra-file="$mycnf" </dev/null 2>&1` && constat=good
-	rm -f $mycnf
+	rm -f "$mycnf"
 	if [ "$constat" = "bad" ]; then
 		dbc_logline "$dbc_error"
 		dbc_logline "unable to connect to mysql server"
@@ -65,7 +65,8 @@
 dbc_mysql_exec_file(){
 	local l_sqlfile l_retval l_error l_dbname l_errfile
 	l_sqlfile=$1
-	l_errfile=`mktemp -t dbconfig-common_sql_exec_error.XXXXXX`
+	l_errfile="`mktemp -t dbconfig-common_sql_exec_error.XXXXXX`"
+	l_retval=0
 
 	if [ ! "$l_sqlfile" ]; then
 		dbc_error="no file supplied to execute"
@@ -74,14 +75,14 @@
 	fi
 
 	l_dbname=
-	if [ ! "$_dbc_nodb" ]; then
+	if [ ! "${_dbc_nodb:-}" ]; then
 		l_dbname="$dbc_dbname"
 	fi
 
 	mycnf=`_dbc_generate_mycnf`
-	if ! mysql --defaults-extra-file="$mycnf" $l_dbname 2>"$l_errfile" <$l_sqlfile; then
+	if ! mysql --defaults-extra-file="$mycnf" $l_dbname 2>"$l_errfile" <"$l_sqlfile"; then
 		l_retval=1
-		dbc_error="mysql said: `cat $l_errfile`"
+		dbc_error="mysql said: `cat \"$l_errfile\"`"
 	fi
 	rm -f "$mycnf" "$l_errfile"
 	return $l_retval
@@ -113,7 +114,8 @@
 _dbc_mysql_check_database(){
 	local dbc_dbname local _dbc_nodb
 	dbc_dbname=$1
-	_dbc_nodb="yes" dbc_mysql_exec_command "SHOW DATABASES" 2>/dev/null | grep -q "^$dbc_dbname\$"
+	_dbc_nodb="yes" 
+	dbc_mysql_exec_command "SHOW DATABASES" 2>/dev/null | grep -q "^$dbc_dbname\$"
 	return $?
 }
 




More information about the Dbconfig-common-changes mailing list