Bug#537535: other missing utilities for debconf replacement

2009-07-25 Thread Colin Watson
On Sun, Jul 19, 2009 at 11:31:55AM +0200, Joey Hess wrote:
 * debconf-escape (the perl script could be copied into cdebconf
   and would work ok, but cdebconf is also missing the escape CAPB)

I found the attached patch lying around my working tree, which purports
to implement debconf-escape and makes a start at the escape capability.
It's dated 2007-12-31, so at this point I don't remember what state it
was in. It'll be at least as useful in the BTS as in my working tree
though!

-- 
Colin Watson   [cjwat...@debian.org]

Property changes on: src
___
Name: svn:ignore
   - commands-list.h
config.h
libdebconf.so*
libdebconfclient.so*
*.a
debconf
debconf-communicate
debconf-copydb
debconf-dumpdb
debconf-loadtemplate
dpkg-reconfigure
debconf.conf
cdebconf.conf-dist
*.opic
Makefile
*.o

   + commands-list.h
config.h
libdebconf.so*
libdebconfclient.so*
*.a
debconf
debconf-communicate
debconf-copydb
debconf-dumpdb
debconf-escape
debconf-loadtemplate
dpkg-reconfigure
debconf.conf
cdebconf.conf-dist
*.opic
Makefile
*.o


Index: src/Makefile.in
===
--- src/Makefile.in	(revision 50731)
+++ src/Makefile.in	(working copy)
@@ -13,7 +13,7 @@
 CLISONAME=$(CLILIB).$(MAJOR)
 DEBCONF=debconf
 TOOLS=debconf-loadtemplate debconf-copydb debconf-communicate \
-	debconf-dumpdb \
+	debconf-dumpdb debconf-escape \
 	dpkg-reconfigure #dpkg-preconfigure
 BIN=$(DEBCONF) $(TOOLS)
 
@@ -63,6 +63,7 @@
 	install -d -m 755 $(DESTDIR)${moddir}
 	install -m 755 debconf debconf-loadtemplate $(DESTDIR)${moddir}
 	install -m 755 debconf-copydb debconf-dumpdb $(DESTDIR)${moddir}
+	install -m 755 debconf-escape $(DESTDIR)${moddir}
 ifneq ($(TARGET),udeb)
 	install -m 755 debconf-communicate $(DESTDIR)${moddir}
 	install -m 755 dpkg-reconfigure $(DESTDIR)${moddir}
@@ -78,7 +79,7 @@
 	install -d -m 755 $(DESTDIR)${sbindir}
 	install -d -m 755 $(DESTDIR)${sharedir}
 	set -e; for p in debconf debconf-loadtemplate \
-			debconf-copydb debconf-dumpdb; do \
+			debconf-copydb debconf-dumpdb debconf-escape; do \
 		ln -sf ../lib/cdebconf/$$p $(DESTDIR)${bindir}; \
 	done
 	install -m 644 client/confmodule $(DESTDIR)${sharedir}
Index: src/commands.c
===
--- src/commands.c	(revision 50731)
+++ src/commands.c	(working copy)
@@ -127,9 +127,11 @@
 mod-frontend-capability |= DCF_CAPB_BACKUP;
 else if (strcmp(argv[i], progresscancel) == 0)
 mod-frontend-capability |= DCF_CAPB_PROGRESSCANCEL;
+else if (strcmp(argv[i], escape) == 0)
+mod-frontend-capability |= DCF_CAPB_ESCAPE;
 }
 
-if (asprintf(out, %u multiselect backup progresscancel, CMDSTATUS_SUCCESS) == -1)
+if (asprintf(out, %u multiselect backup progresscancel escape, CMDSTATUS_SUCCESS) == -1)
 DIE(Out of memory);
 
 plugin_state = NULL;
Index: src/frontend.h
===
--- src/frontend.h	(revision 50731)
+++ src/frontend.h	(working copy)
@@ -20,6 +20,7 @@
 
 #define DCF_CAPB_BACKUP		(1UL  0)
 #define DCF_CAPB_PROGRESSCANCEL	(1UL  1)
+#define DCF_CAPB_ESCAPE		(1UL  2)
 
 struct frontend_module {
 int (*initialize)(struct frontend *, struct configuration *);
Index: src/strutl.c
===
--- src/strutl.c	(revision 50731)
+++ src/strutl.c	(working copy)
@@ -327,15 +327,15 @@
 	int i = 0;
 	while (*p != 0  i  maxlen-1)
 	{
-		/*  Debconf only escapes \n  */
+		/* Debconf only escapes \ and \n */
 		if (*p == '\\')
 		{
-			if (*(p+1) == 'n')
+			if (*(p+1) == '\\' || *(p+1) == 'n')
 			{
-outbuf[i++] = '\n';
+outbuf[i++] = (*(p+1) == '\\') ? '\\' : '\n';
 p += 2;
 			}
-			else if (quote != 0  (*(p+1) == '' || *(p+1) == '\\'))
+			else if (quote != 0  *(p+1) == '')
 			{
 outbuf[i++] = *(p+1);
 p += 2;
@@ -355,15 +355,15 @@
 	int i = 0;
 	while (*p != 0  i  maxlen-1)
 	{
-		/*  Debconf only escapes \n  */
-		if (*p == '\n')
+		/* Debconf only escapes \ and \n */
+		if (*p == '\\' || *p == '\n')
 		{
 			if (i + 2 = maxlen) break;
 			outbuf[i++] = '\\';
-			outbuf[i++] = 'n';
+			outbuf[i++] = (*p == '\\') ? '\\' : 'n';
 			p++;
 		}
-		else if (quote != 0  (*p == '' || *p == '\\'))
+		else if (quote != 0  *p == '')
 		{
 			if (i + 2 = maxlen) break;
 			outbuf[i++] = '\\';
Index: src/debconf-escape.c
===
--- src/debconf-escape.c	(revision 0)
+++ src/debconf-escape.c	(revision 0)
@@ -0,0 +1,130 @@
+/**
+ * @file debconf-escape.c
+ * @brief helper when working with debconf's escape capability
+ */
+
+#include stdlib.h
+#include stdio.h
+#include string.h
+#include getopt.h
+
+static int escape = 0;
+static int unescape = 0;
+
+static struct option options[] = {
+{ help, 0, 0, 'h' },
+{ escape, 0, 

Bug#537535: other missing utilities for debconf replacement

2009-07-19 Thread Joey Hess
Package: cdebconf
Version: 0.146
Severity: normal

In order to replace perl debconf, the following utilities
are also probably needed in cdebconf:

* debconf-set-selections (preseed has a shell version of this,
  just needs some minor breaking out and the ability to read
  stdin if no file is specified)
* debconf-get-selections
* debconf-show
* debconf-escape (the perl script could be copied into cdebconf
  and would work ok, but cdebconf is also missing the escape CAPB)

-- System Information:
Debian Release: squeeze/sid
  APT prefers unstable
  APT policy: (500, 'unstable'), (500, 'testing'), (500, 'stable')
Architecture: i386 (i686)

Kernel: Linux 2.6.30-1-686 (SMP w/2 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash

Versions of packages cdebconf depends on:
ii  debconf   1.5.27 Debian configuration management sy
ii  libc6 2.9-19 GNU C Library: Shared libraries
ii  libdebian-installer4  0.63   Library of common debian-installer
ii  libnewt0.52   0.52.10-4  Not Erik's Windowing Toolkit - tex
ii  libslang2 2.1.4-3The S-Lang programming library - r
ii  libtextwrap1  0.1-8  text-wrapping library with i18n - 

cdebconf recommends no packages.

Versions of packages cdebconf suggests:
pn  cdebconf-gtk  none (no description available)

-- no debconf information

-- 
see shy jo


signature.asc
Description: Digital signature