Jakub Wilk wrote: > Lintian is already aware of existing dh_* commands (see > data/debhelper/dh_commands), so maybe we could use this list instead of > manually maintaining possible misspellings?
Not without changing this data structure as we want multiple misspellings to map to the correct spelling. A clever regex is also not suitable either as there are some dh_ commands that *do* have an underscore as a separator. > [..] Well, all those typos in my patch were ironically embarrassing given what its meant to solve. :) Updated patch attached. Regards, -- ,''`. : :' : Chris Lamb `. `'` la...@debian.org / chris-lamb.co.uk `-
From 213ec736850d0c706264d6a482dad14f8172be89 Mon Sep 17 00:00:00 2001 From: Chris Lamb <la...@debian.org> Date: Fri, 22 Jul 2016 12:43:30 +0100 Subject: [PATCH] c/rules: Check for common typos in debian/rules target names. Misspelling a target (eg. "override_dh_install_debconf") results in that rule silently not being called. See #831772 for an example in the wild. Signed-off-by: Chris Lamb <la...@debian.org> --- checks/rules.desc | 7 +++++++ checks/rules.pm | 4 ++++ data/rules/target-typos | 31 +++++++++++++++++++++++++++++++ t/tests/rules-general/debian/debian/rules | 2 ++ t/tests/rules-general/desc | 3 ++- t/tests/rules-general/tags | 1 + 6 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 data/rules/target-typos diff --git a/checks/rules.desc b/checks/rules.desc index 25c565b..3f4f738 100644 --- a/checks/rules.desc +++ b/checks/rules.desc @@ -248,3 +248,10 @@ Info: The source package does not have both a build-arch and a build-indep . Please consider adding both the build-arch and build-indep targets. +Tag: typo-in-debian-rules-target +Severity: normal +Certainty: certain +Info: The listed target in debian/rules command is a misspelling. + . + This can result in (for example) a <tt>dh_override_</tt>-style target + silently not being executed by <tt>make</tt>. diff --git a/checks/rules.pm b/checks/rules.pm index bd3a141..1100032 100644 --- a/checks/rules.pm +++ b/checks/rules.pm @@ -38,6 +38,7 @@ our $ANYPYTHON_DEPEND my $KNOWN_MAKEFILES = Lintian::Data->new('rules/known-makefiles', '\|\|'); my $DEPRECATED_MAKEFILES = Lintian::Data->new('rules/deprecated-makefiles'); my $POLICYRULES = Lintian::Data->new('rules/policy-rules', qr/\s++/); +my $TARGETTYPOS = Lintian::Data->new('rules/target-typos', qr/\s++/); # forbidden construct in rules my $BAD_CONSTRUCT_IN_RULES @@ -313,6 +314,9 @@ sub run { if (any { $target =~ /$_/ } @arch_rules) { push(@arch_rules, @depends); } + tag 'typo-in-debian-rules-target', $target, '->', + $TARGETTYPOS->value($target), "(line $.)" + if ($TARGETTYPOS->known($target)); } undef %debhelper_group; } elsif (/^define /) { diff --git a/data/rules/target-typos b/data/rules/target-typos new file mode 100644 index 0000000..e7da585 --- /dev/null +++ b/data/rules/target-typos @@ -0,0 +1,31 @@ +# a list of common incorrect targets in debian/rules +# format is +# <typo> <suggestion> +# +override_dh_autotest override_dh_auto_test +override_dh_install_catalogs override_dh_installcatalogs +override_dh_install_changelog override_dh_installchangelogs +override_dh_install_cron override_dh_installcron +override_dh_install_deb override_dh_installdeb +override_dh_install_debconf override_dh_installdebconf +override_dh_install_dirs override_dh_installdirs +override_dh_install_docs override_dh_installdocs +override_dh_install_emacsen override_dh_installemacsen +override_dh_install_example override_dh_installexamples +override_dh_install_examples override_dh_installexamples +override_dh_install_info override_dh_installinfo +override_dh_install_init override_dh_installinit +override_dh_install_logcheck override_dh_installlogcheck +override_dh_install_logrotate override_dh_installlogrotate +override_dh_install_man override_dh_installman +override_dh_install_manpage override_dh_installmanpages +override_dh_install_manpages override_dh_installmanpages +override_dh_install_mans override_dh_installman +override_dh_install_menu override_dh_installmenu +override_dh_install_mime override_dh_installmime +override_dh_install_modules override_dh_installmodules +override_dh_install_pam override_dh_installpam +override_dh_install_udev override_dh_installudev +override_dh_install_xmlcatalogs override_dh_installxmlcatalogs +override_dh_installmanpage override_dh_installman +override_dh_usr_local override_dh_usrlocal diff --git a/t/tests/rules-general/debian/debian/rules b/t/tests/rules-general/debian/debian/rules index cddbc03..2febda6 100755 --- a/t/tests/rules-general/debian/debian/rules +++ b/t/tests/rules-general/debian/debian/rules @@ -9,3 +9,5 @@ clean: dh_clean echo $(DEB_BUILD_OPTS) $(PWD) @echo $(_) + +override_dh_install_examples: diff --git a/t/tests/rules-general/desc b/t/tests/rules-general/desc index 1f41c20..5ca2b82 100644 --- a/t/tests/rules-general/desc +++ b/t/tests/rules-general/desc @@ -7,4 +7,5 @@ Test-For: debian-rules-should-not-automatically-update-control debian-rules-should-not-use-DEB_BUILD_OPTS debian-rules-should-not-use-pwd - debian-rules-should-not-use-underscore-variable \ No newline at end of file + debian-rules-should-not-use-underscore-variable + typo-in-debian-rules-target diff --git a/t/tests/rules-general/tags b/t/tests/rules-general/tags index 3e7351b..4dc0775 100644 --- a/t/tests/rules-general/tags +++ b/t/tests/rules-general/tags @@ -3,3 +3,4 @@ E: rules-general source: debian-rules-should-not-automatically-update-control li W: rules-general source: debian-rules-should-not-use-DEB_BUILD_OPTS line 10 W: rules-general source: debian-rules-should-not-use-pwd line 10 W: rules-general source: debian-rules-should-not-use-underscore-variable line 11 +W: rules-general source: typo-in-debian-rules-target override_dh_install_examples -> override_dh_installexamples (line 13) -- 2.8.1