On Thu, Jan 17, 2008 at 10:15:16PM -0800, Steve Langasek wrote:

> Taking into consideration the concerns you expressed on IRC about the tight
> coupling between the debconf templates and the code, here is a preliminary
> patch which tries to add support for a new --debconf-template option which
> will use the named template, but which will pull the names of the debconf
> choices from the original ucf templates at runtime and substitute them into
> the provided template.

> This still leaves open the possibility that a future version of ucf will
> change or reorder the available choices, resulting in the debconf UI being
> out of sync with the backend.  If you want to be free to make changes to the
> list of ucf debconf choices in the future, another option would be to query
> the Choices-C content for both the original and alternate templates, and
> only use the alternate template if the Choices-C lists match exactly.  I'm
> happy to rework the patch with that goal if you think that's a better idea.

Thinking this over, I've concluded that the latter option is the more
sensible, so here is a patch to implement that as well.  It also adds the
new option to the --help output.

Cheers,
-- 
Steve Langasek                   Give me a lever long enough and a Free OS
Debian Developer                   to set it on, and I can move the world.
Ubuntu Developer                                    http://www.debian.org/
[EMAIL PROTECTED]                                     [EMAIL PROTECTED]
diff -Nru ucf-3.004/debian/changelog ucf-3.004/debian/changelog
--- ucf-3.004/debian/changelog	2007-11-30 01:34:53.000000000 -0800
+++ ucf-3.004/debian/changelog	2008-01-17 22:05:32.000000000 -0800
@@ -1,3 +1,12 @@
+ucf (3.004-0.1) unstable; urgency=low
+
+  * Non-maintainer upload.
+  * Based on the preceding enhancement from Frans, add a new
+    --debconf-template option to specify an alternate caller-provided
+    debconf template for the user prompt.  Closes: #456241.
+
+ -- Steve Langasek <[EMAIL PROTECTED]>  Thu, 17 Jan 2008 18:34:56 -0800
+
 ucf (3.004) unstable; urgency=high
 
   * For "keep current" and "threeway merge", ucf expects answers from
diff -Nru /tmp/2zAP84MgIe/ucf-3.004/ucf /tmp/8MT2pCCsNN/ucf-3.004/ucf
--- ucf-3.004/ucf	2007-11-30 01:34:52.000000000 -0800
+++ ucf-3.004/ucf	2008-01-22 08:16:27.000000000 -0800
@@ -107,6 +107,9 @@
                              default '/var/lib/ucf'. Used mostly for testing.
              --debconf-ok    Indicate that it is ok for uct to use an already
                              running debconf instance for prompting.
+             --debconf-template bar
+                             Specify an alternate, caller-provided debconf
+                             template to use for prompting.
 Usage: $progname  -p  destination
      -p,     --purge         Remove any reference to destination from records
 
@@ -358,6 +361,8 @@
 	    opt_old_mdsum_file="$2";		  shift 2 ;;
 	--state-dir)
 	    opt_state_dir="$2";                        shift 2 ;;
+	--debconf-template)
+	    override_template="$2";                    shift 2 ;;
 	-D|-d|--debug|--DEBUG)
             # d has an optional argument. As we are in quoted mode,
             # an empty parameter will be generated if its optional
@@ -822,6 +827,13 @@
 		else
 			templ=ucf/changeprompt
 		fi
+		if [ "X$override_template" != "X" ]; then
+			choices="$(db_metaget $templ Choices-C)"
+			choices2="$(db_metaget $override_template Choices-C)"
+			if [ "$choices" = "$choices2" ]; then
+				templ=$override_template
+			fi
+		fi
 		db_fset $templ seen false
 		db_reset $templ
 		db_subst $templ FILE "$dest_file"
diff -Nru /tmp/2zAP84MgIe/ucf-3.004/ucf.1 /tmp/8MT2pCCsNN/ucf-3.004/ucf.1
--- ucf-3.004/ucf.1	2007-11-30 01:34:52.000000000 -0800
+++ ucf-3.004/ucf.1	2008-01-17 22:04:12.000000000 -0800
@@ -203,6 +203,17 @@
 with this option should take care to depend on version 0.28 or higher
 of ucf (the first to support use this option).
 .TP
+.B "\-\-debconf\-template  foo"
+Instruct ucf to use the named multiselect debconf template instead of
+the normal ucf-provided debconf template.  The caller is responsible for
+ensuring that the named template exists and has a list of choices
+matching those for the default ucf template, and should set
+Choices\-C: ${CHOICES} to ensure the returned values match those from
+the default template.  Note that the choices must be different according
+to whether the
+.B \-\-three\-way
+option is also set.
+.TP
 .B "\-\-state\-dir /path/to/dir"
 Set the state directory to /path/to/dir instead of the default
 .I /var/lib/ucf. 

Reply via email to