Bug#233116: lintian: check that templates are separated by an empty line
On Fri, Mar 05, 2004 at 07:29:52AM +0100, Denis Barbier wrote:
> On Fri, Mar 05, 2004 at 02:11:08AM +0100, Frank Lichtenheld wrote:
> [...]
> > I thought about adding your check. But I wonder if your assumption
> > that the Template field is always first in a stanza? The Debconf
> > specification does not enforce this. But perhaps this is true
> > none-the-less. As you have seen a lot more templates than me, what's
> > your opinion? ;)
>
> I never saw such a template, but you are right. I will propose later
> a fully different approach, by checking for duplicate fields.
Here it is.
Denis
Index: checks/debconf
===================================================================
--- checks/debconf (revision 92)
+++ checks/debconf (working copy)
@@ -73,6 +73,34 @@
print "E: $pkg $type: debconf-config-not-executable\n";
}
+# First check that templates look valid
+if ($seentemplates) {
+ open(TMPL, "control/templates") or fail("Can't open control/templates: $!");
+ local $/ = "\n\n";
+ while (<TMPL>) {
+ chomp;
+ my %fields = ();
+ my $name = 'unknown';
+ foreach my $line (split "\n", $_) {
+ if ($line =~ s/([-_.A-Za-z0-9]+):\s*//) {
+ my $field = $1;
+ if ($field eq 'Template') {
+ $name = $line;
+ }
+ if (exists $fields{$field}) {
+ print "E: $pkg $type: duplicate-fields-in-templates $name $field\n";
+ # Templates file is corrupted, no need to report
+ # further errors
+ $seentemplates = '';
+ last;
+ }
+ $fields{$field} = 1;
+ }
+ }
+ }
+ close TMPL;
+}
+
# Lots of template checks.
my @templates = $seentemplates ? read_dpkg_control("control/templates") : ();
Index: checks/debconf.desc
===================================================================
--- checks/debconf.desc (revision 92)
+++ checks/debconf.desc (working copy)
@@ -26,6 +26,12 @@
package if debconf is not present; please contact &maint; so that this
exception would be recognized in future versions of Lintian.
+Tag: duplicate-fields-in-templates
+Type: error
+Info: A template contains two identical fields (with identical values or
+ not). This is either an error in this template, or two templates are
+ not properly seperated by a lone newline.
+
Tag: unknown-field-in-templates
Type: error
Info: See the Debconf Programmer's Tutorial for a list of the possible
Reply to: