[SCM] Debian package checker branch, master, updated. 38002a14d5e0b494449410efb1d8555ead1cef30
The following commit has been merged in the master branch:
commit 38002a14d5e0b494449410efb1d8555ead1cef30
Author: Adam D. Barratt <adam@adam-barratt.org.uk>
Date: Sun Jul 6 13:23:01 2008 +0100
Detect unused templates and check all maintainer scripts for issues
Merge postrm-purge check back in to the main check loop
* checks/debconf{,.desc}:
+ [ADB] Check all maintainer scripts for issues, rather than just config
and postinst.
+ [ADB] Detect debconf templates which appear to be unused.
diff --git a/checks/debconf b/checks/debconf
index e20c73a..6eca3ce 100644
--- a/checks/debconf
+++ b/checks/debconf
@@ -205,6 +205,7 @@ if ($seentemplates) {
my @templates = $seentemplates ? read_dpkg_control("control/templates", "templates file") : ();
my %potential_db_abuse;
+my @templates_seen;
foreach my $template (@templates) {
my $isselect='';
@@ -212,8 +213,11 @@ foreach my $template (@templates) {
if (not exists $template->{template}) {
tag "no-template-name", "";
$template->{template} = 'no-template-name';
- } elsif ($template->{template}!~m|[A-Za-z0-9.+-](?:/[A-Za-z0-9.+-])|) {
- tag "malformed-template-name", "$template->{template}";
+ } else {
+ push @templates_seen, $template->{template};
+ if ($template->{template}!~m|[A-Za-z0-9.+-](?:/[A-Za-z0-9.+-])|) {
+ tag "malformed-template-name", "$template->{template}";
+ }
}
if (not exists $template->{type}) {
@@ -365,7 +369,10 @@ foreach my $template (@templates) {
# Check the maintainer scripts.
my $config_calls_db_input;
-for my $file (qw(config postinst)) {
+my $db_purge;
+my %templates_used;
+my %template_aliases;
+for my $file (qw(config prerm postrm preinst postinst)) {
my $potential_makedev = {};
if (open(IN, '<', "control/$file")) {
my $usesconfmodule='';
@@ -393,7 +400,8 @@ for my $file (qw(config postinst)) {
m/(use|require)\s+Debconf::Client::ConfModule/) {
$usesconfmodule=1;
}
- if (not $obsoleteconfmodule and
+ if (($file eq 'postinst' or $file eq 'config') and
+ not $obsoleteconfmodule and
m,(/usr/share/debconf/confmodule\.sh|
Debian::DebConf::Client::ConfModule),x) {
tag "$file-loads-obsolete-confmodule", "$1";
@@ -415,6 +423,7 @@ for my $file (qw(config postinst)) {
}
if (m/^\s*(?:db_input|db_text)\s+[\"\']?(\S+?)[\"\']?\s+(\S+)\s/) {
my ($priority, $template) = ($1, $2);
+ $templates_used{$template} = 1;
if ($priority !~ /^\$\S+$/) {
tag "unknown-debconf-priority", "$file:$. $1"
unless ($valid_priorities{$priority});
@@ -424,41 +433,61 @@ for my $file (qw(config postinst)) {
and ($priority =~ /^(low|medium)$/));
}
}
+ if (m/^\s*(?:db_get|db_set(?:title)?)\s+[\"\']?(\S+?)[\"\']?(\s|\Z)/) {
+ $templates_used{$1} = 1;
+ }
+ if (m/^\s*db_register\s+[\"\']?(\S+?)[\"\']?\s+(\S+)\s/) {
+ my ($template, $question) = ($1, $2);
+ push @{$template_aliases{$template}}, $question;
+ }
if (not $isdefault and m/db_fset.*isdefault/) {
# TODO: Perl?
tag "isdefault-flag-is-deprecated", "$file";
$isdefault=1;
}
+ if (not $db_purge and m/db_purge/) { # TODO: Perl?
+ $db_purge=1;
+ }
}
- unless ($usesconfmodule) {
- tag "$file-does-not-load-confmodule", ""
- unless ($type eq 'udeb' || ($file eq 'postinst' && !$seenconfig));
+ if ($file eq 'postinst' or $file eq 'config') {
+ unless ($usesconfmodule) {
+ tag "$file-does-not-load-confmodule", ""
+ unless ($type eq 'udeb' || ($file eq 'postinst' && !$seenconfig));
+ }
+ }
+
+ if ($file eq 'postrm') {
+ unless ($db_purge) {
+ tag "postrm-does-not-purge-debconf", "";
+ }
}
close IN;
} elsif ($file eq 'postinst') {
tag "$file-does-not-load-confmodule", ""
unless ($type eq 'udeb' || !$seenconfig);
+ } elsif ($file eq 'postrm') {
+ tag "postrm-does-not-purge-debconf", ""
+ unless ($type eq 'udeb');
}
}
-if (open(POSTRM, '<', "control/postrm")) {
- my $db_purge='';
+foreach my $template (@templates_seen) {
+ my $used = 0;
- while (<POSTRM>) {
- s/#.*//; # Not perfect for Perl, but should be OK
- if (not $db_purge and m/db_purge/) { # TODO: Perl?
- $db_purge=1;
- last;
+ if ($templates_used{$template}) {
+ $used = 1;
+ } else {
+ foreach my $alias (@{$template_aliases{$template}}) {
+ if ($templates_used{$alias}) {
+ $used = 1;
+ last;
+ }
}
}
-
- unless ($db_purge) {
- tag "postrm-does-not-purge-debconf", "";
- }
-} elsif ($type ne 'udeb') {
- tag "postrm-does-not-purge-debconf", "";
+ tag "unused-debconf-template", $template
+ unless $used and $pkg ne "debconf";
}
# Check that the right dependencies are in the control file. Accept any
diff --git a/checks/debconf.desc b/checks/debconf.desc
index 1f7e13b..9cdbae0 100644
--- a/checks/debconf.desc
+++ b/checks/debconf.desc
@@ -306,3 +306,24 @@ Info: The use of _Choices in templates is deprecated.
.
If in doubt, please ask for help on the debian-i18n mailing list.
Ref: po-debconf(7)
+
+Tag: unused-debconf-template
+Type: info
+Info: Templates which are not used by the package should be removed from
+ the templates file.
+ .
+ This will reduce the size of the templates database and prevent
+ translators from unnecessarily translating the template's text.
+ .
+ In some cases, the template is used but lintian is unable to determine
+ this. Common causes are:
+ .
+ - the maintainer scripts embed a variable in to the template name in
+ order to allow a template to be selected from a range of similar
+ templates (e.g. 'db_input low start_$service_at_boot')
+ - the template is not used by the maintainer scripts but is used by
+ a program in the package
+ - the maintainer scripts are written in perl. lintian currently only
+ understands the shell script debconf functions.
+ .
+ If any of the above applies, please install an override.
diff --git a/debian/changelog b/debian/changelog
index 0060171..19cd522 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -10,6 +10,9 @@ lintian (1.24.2) unstable; urgency=low
* checks/debconf{,.desc}:
+ [ADB] Warn about the use of "_Choices" in templates file and suggest
using "__Choices" instead (Closes: #481152)
+ + [ADB] Check all maintainer scripts for issues, rather than just config
+ and postinst.
+ + [ADB] Detect debconf templates which appear to be unused.
* checks/description{,.desc}:
+ [RA] Warn about duplicated words in the description. Patch from
Raphael Geissert. (Closes: #424746)
diff --git a/testset/debconf/debian/debconf-test.config b/testset/debconf/debian/debconf-test.config
index b0b32db..9e32d06 100644
--- a/testset/debconf/debian/debconf-test.config
+++ b/testset/debconf/debian/debconf-test.config
@@ -17,3 +17,8 @@ foo=medium
db_input $foo debconf/test
db_input "$foo" debconf/test
db_input 'medium' debconf/test
+
+# debconf/transtring should not be flagged as unused
+# (it's aliased to debconf/alias, which is used)
+db_register debconf/transtring debconf/alias
+db_input medium debconf/alias
diff --git a/testset/tags.debconf b/testset/tags.debconf
index da4eb5d..d033d0b 100644
--- a/testset/tags.debconf
+++ b/testset/tags.debconf
@@ -8,7 +8,22 @@ E: debconf-test: unknown-debconf-priority config:10 LOW
E: debconf-test: unknown-debconf-priority config:11 normal
E: debconf-udeb udeb: udeb-postinst-must-not-call-ldconfig
I: debconf source: package-needs-python-policy-debhelper
+I: debconf-test-noscripts: unused-debconf-template debconf/test
I: debconf-test: debconf-error-requires-versioned-depends debconf/error
+I: debconf-test: unused-debconf-template debconf/1st-person
+I: debconf-test: unused-debconf-template debconf/error
+I: debconf-test: unused-debconf-template debconf/internal
+I: debconf-test: unused-debconf-template debconf/language
+I: debconf-test: unused-debconf-template debconf/no-description
+I: debconf-test: unused-debconf-template debconf/should-be-boolean
+I: debconf-test: unused-debconf-template debconf/should-be-no-longer-a-problem
+I: debconf-test: unused-debconf-template debconf/testboolean
+I: debconf-test: unused-debconf-template debconf/testmulti
+I: debconf-test: unused-debconf-template debconf/testmulti-escape
+I: debconf-test: unused-debconf-template debconf/testnote
+I: debconf-test: unused-debconf-template debconf/teststring
+I: debconf-test: unused-debconf-template debconf/translate
+I: debconf-udeb udeb: unused-debconf-template debian-installer/debconf-udeb/title
W: debconf source: ancient-standards-version 3.7.2 (current is 3.8.0)
W: debconf source: debian-rules-calls-debhelper-in-odd-order dh_makeshlibs (line 49)
W: debconf source: debian-rules-calls-debhelper-in-odd-order dh_makeshlibs (line 53)
@@ -36,6 +51,7 @@ W: debconf-test-postinst: postinst-uses-db-input
W: debconf-test-preinst: copyright-contains-dh_make-todo-boilerplate
W: debconf-test-preinst: missing-debconf-dependency-for-preinst
W: debconf-test-preinst: old-fsf-address-in-copyright-file
+W: debconf-test-preinst: possible-debconf-note-abuse preinst:6 debconf/test
W: debconf-test: copyright-contains-dh_make-todo-boilerplate
W: debconf-test: making-assumptions-about-interfaces-in-templates debconf/testboolean
W: debconf-test: malformed-prompt-in-templates debconf/teststring
--
Debian package checker
Reply to: