[Dbconfig-common-devel] dbconfig-common dbconfig-generate-include, 1.8, 1.9 dbconfig-generate-include.1, 1.3, 1.4

seanius at haydn.debian.org seanius at haydn.debian.org
Mon Aug 8 02:20:15 UTC 2005


Update of /cvsroot/dbconfig-common/dbconfig-common
In directory haydn:/org/alioth.debian.org/chroot/home/users/seanius/tmp/cvs-serv22285

Modified Files:
	dbconfig-generate-include dbconfig-generate-include.1 
Log Message:
added support for template-based output from dbc-g-i


Index: dbconfig-generate-include
===================================================================
RCS file: /cvsroot/dbconfig-common/dbconfig-common/dbconfig-generate-include,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- dbconfig-generate-include	28 Apr 2005 03:11:27 -0000	1.8
+++ dbconfig-generate-include	8 Aug 2005 02:20:06 -0000	1.9
@@ -30,6 +30,7 @@
 	infile            use the given dbconfig-common config file as input
 	outfile           use the given file as input (default: stdout)
 	-f|--format       use the given output format (default: sh)
+	-o|--options		provide output-format-specific options
 	-a|--all          include all information in output (default)
 	-d|--dbname       include the dbname in the output
 	-p|--dbpass       include the dbpass in the output
@@ -48,12 +49,13 @@
 		sh - /bin/sh style include file
 		perl - perl parseable include file
 		php - php parseable include file
+		template - perform pattern substitution on a pre-existing template
 		cpp - c-style header file, using #define'd constants
 
 EOF
 }
 
-TEMP=`getopt -o af:hd::m:p::u::s::t::O:P::Uv --long help,dbuser::,dbpass::,dbport::,dbserver::,dbtype::,output:,format:,owner:,mode:,ucf,version -n $0 -- "$@"`
+TEMP=`getopt -o af:hd::m:o:p::u::s::t::O:P::Uv --long help,dbuser::,dbpass::,dbport::,dbserver::,dbtype::,output:,format:,options:,owner:,mode:,ucf,version -n $0 -- "$@"`
 
 if [ $? != 0 ] ; then usage >&2 ; exit 1 ; fi
 
@@ -131,6 +133,13 @@
 		do_ucf=1
 		exit
 	;;
+	-o|--options)
+	set -x
+		eval $2
+		echo template_infile is $template_infile
+	set +x
+		shift 2
+	;;
 	--)
 		shift
 		break
@@ -282,6 +291,30 @@
 #endif /* _DBCONFIG_COMMON_CONFIG_ */
 EOF
 ;;
+template)
+	if [ ! "$template_infile" ]; then
+		cat << EOF >&2
+error: you must specify a template file. for example: '-o template_infile=foo'
+EOF
+		exit 1
+	elif [ ! -f "$template_infile" ]; then
+		echo "error: template infile $template_infile does not exist" >&2
+		exit 1
+	fi
+	sedtmp=`mktemp -t dbconfig-generate-include.sed.XXXXXX`
+	if [ ! -f "$sedtmp" ]; then
+		echo "unable to create temporary file $sedtmp" >&2
+		exit 1
+	fi
+	cat << EOF > "$sedtmp"
+s/_DBC_DBUSER_/$dbc_dbuser/g
+s/_DBC_DBPASS_/$dbc_dbpass/g
+s/_DBC_DBNAME_/$dbc_dbname/g
+s/_DBC_DBNAME_/$dbc_dbname/g
+s/_DBC_DBTYPE_/$dbc_dbtype/g
+EOF
+	sed -f "$sedtmp" < "$template_infile" 
+;;
 esac
 
 if [ "$outputfile" ]; then

Index: dbconfig-generate-include.1
===================================================================
RCS file: /cvsroot/dbconfig-common/dbconfig-common/dbconfig-generate-include.1,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- dbconfig-generate-include.1	28 Apr 2005 03:11:28 -0000	1.3
+++ dbconfig-generate-include.1	8 Aug 2005 02:20:06 -0000	1.4
@@ -3,7 +3,7 @@
 dbconfig-generate-include \- generate custom format db include files
 
 .SH SYNOPSIS
-.B dbconfig\-generate\-include [-hv] [-f format] [\-a] [\-d [varname]] [\-u [varname]] [\-p [varname]] [\-s [varname]] [\-P [varname]] [\-t [varname]] [\-O owner[:group]] [\-m mode] [\-U] infile [outfile]
+.B dbconfig\-generate\-include [\-hv] [\-f format] [\-o options] [\-a] [\-d [varname]] [\-u [varname]] [\-p [varname]] [\-s [varname]] [\-P [varname]] [\-t [varname]] [\-O owner[:group]] [\-m mode] [\-U] infile [outfile]
 .br
 .Xc
 
@@ -23,6 +23,10 @@
 \fB\-f\fR|\-\-format
 use the given output format (default: sh)
 .TP
+\fB\-o\fR|\-\-options
+pass options specific to an output format in a semicolon seperated list. see
+OUTPUT FORMATS/OPTIONS for more information.
+.TP
 \fB\-a\fR|\-\-all
 include all information in output (default)
 .TP
@@ -59,19 +63,25 @@
 \fB\-v\fR|\-\-version
 output the version and exit
 
-.PP
+.SH OUTPUT FORMATS/OPTIONS
 format is one of a list of include\-file style formats for various
 programming languages.  the current list includes:
 .TP
 sh 
-/bin/sh style include file
+/bin/sh style include file.
 .TP
 perl
-perl parseable include file
+perl parseable include file.
 .TP
 php
-php parseable include file
+php parseable include file.
+.TP
+template
+a file which contains a series of fields to be replaced with actual
+values.  all substitutable fields consist of the underlying dbc_ variable
+name capitalized and surrounded with underscores.  for example: _DBC_DBUSER_.
+\fB options: \fR template_infile (path to input file containing template)
 .TP
 cpp
-c\-style header file, using #define'd constants
+c\-style header file, using #define'd constants.
 




More information about the Dbconfig-common-devel mailing list