I'm looking into this as part of BSP in Dublin.

The problem with Niels's fix is that it requires code changes to the program
invoking autoscript, dh_installxmlcatalogs in this case.

I tried Tristan's idea - patch below - and although it works, MY PATCH
INTRODUCES A SUBTLE INCOMPATIBILITY. Here's why:

The fourth parameter to autoscript() is NOT actually a sed one-liner, as
autoscript() documentation claims. It is a string, that is first interpreted by
the shell, and then passed - by the shell - as an argument to "sed". This means
that autoscript() callers need to properly quote some characters, e.g. write:
 \"
rather than
 "
.

When those escaped strings are put into a sed script file (instead via shell)
the sed code is overquoted. While sed "helpfully" just seems to ignore
superfluous backslashes, so I think this would just work for simple use cases,
I'm afraid it might break other valid but more complicated use-cases. So it
does not seem like a good thing to do during the freeze, without a DH_COMPAT
change. And this also means code changes to dh_installxmlcatalogs

Does anyone know a way to strip the quoting in a way compable with the shell,
however without invoking the shell (because in this case it would just barf on
"argument too long")?


So there are a few problems:
 - debhelper misdocumenting the 4th argument to autoscript.

 If it properly mentioned the length of the string is limited due to being
 passed through a shell command-line, then callers might have reconsidered
 before using this functionality to substitute strings of unknown length.
 Ideally the next compatibility version should pass the snippet via a temporary
 file, similar to the patch below.

 - dh_installxmlcatalogs passing an overly long string to autoscript().
 
 I think whatever fix is implemented (unless someone knows an answer to my
 question above), it will mean a change to dh_installxmlcatalogs. So perhaps
 this bug should be cloned against xml-core and it should implement its own
 version of autoscript that is safe for long strings (perhaps just copy
 autoscript from Dh_Lib and apply the patch below, and remove the extra quoting
 done in dh_installxmlcatalogs).


--- /usr/share/perl5/Debian/Debhelper/Dh_Lib.pm 2012-08-30 15:16:25.000000000 
+0000
+++ Debian/Debhelper/Dh_Lib.pm  2012-09-08 16:42:26.536199119 +0000
@@ -540,7 +540,12 @@
        }
        else {
                complex_doit("echo \"# Automatically added by 
".basename($0)."\">> $outfile");
-               complex_doit("sed \"$sed\" $infile >> $outfile");
+               use File::Temp qw/tempfile/;
+               my ($fh, $filename) = tempfile();
+               print $fh "$sed";
+               close $fh or die "$filename: $!;
+               warn "filename is $filename";  # for debugging
+               complex_doit("sed -f $filename $infile >> $outfile");
                complex_doit("echo '# End automatically added section' >> 
$outfile");
        }
 }


-- 
Marcin Owsiany <porri...@debian.org>             http://marcin.owsiany.pl/
GnuPG: 2048R/02F946FC  35E9 1344 9F77 5F43 13DD  6423 DBF4 80C6 02F9 46FC


-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org

Reply via email to