Package: lintian Version: 2.2.17 Severity: wishlist I noticed that some of my packages ship files in /etc/cron.{d,hourly,daily,weekly,monthly} but don't depend on cron. That never bit me in person, but I suppose a lintian check wouldn't do any harm.
I knocked up a quick implementation, see attached patch against a recent debcheckout. It makes a difference between files in /etc/cron.{d,hourly}, which require a cron-like daemon, and those in /etc/cron.{daily,weekly,monthly}, which can work with anacron. Feel free to rewrite or discard entirely.
diff --git a/checks/cron b/checks/cron new file mode 100644 index 0000000..291a868 --- /dev/null +++ b/checks/cron @@ -0,0 +1,89 @@ +# cron -- lintian check script -*- perl -*- + +# Copyright (C) 2009 Roland Mas +# based on work Copyright (C) 2001 Colin Watson +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, you can find it on the World Wide +# Web at http://www.gnu.org/copyleft/gpl.html, or write to the Free +# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, +# MA 02110-1301, USA. + +package Lintian::cron; +use strict; +use Tags; + +use Lintian::Relation; +use Util; + +# All the packages that provide debconf functionality. Anything using debconf +# needs to have dependencies that satisfy one of these. +my @fullcronds = qw(cron fcron); +my @cronds = @fullcronds; +push @cronds, qw(anacron); + +sub run { + +my $pkg = shift; +my $type = shift; +my $info = shift; + + +my $version; +if (defined $info->field('version')) { + $_ = $info->field('version'); + $version = "$pkg (= $_)"; +} + +# parse depends info for later checks + +my (%dependencies, @alldeps); + +for my $field (qw(depends pre-depends)) { + if (defined $info->field($field)) { + $_ = $info->field($field); + $_ .= ", $version" if defined $version; + push @alldeps, $_; + $dependencies{$field} = Lintian::Relation->new($_); + } else { + push @alldeps, $version; + $dependencies{$field} = Lintian::Relation->new($version); + } +} + +my $alldependencies = Lintian::Relation->new(join ', ', @alldeps); + +# Check that the right dependencies are in the control file. Accept any +# package that might provide cron functionality. +my $usesfullcrond = $alldependencies->implies(join (' | ', @fullcronds)); +my $usescrond = $alldependencies->implies(join (' | ', @cronds)); + +foreach my $file (sort keys %{$info->index}) { + next if $file eq ""; + if ($file =~ m,etc/cron.(d|hourly)/., and !$usesfullcrond) { + tag "missing-cron-dependency", $file; + } + if ($file =~ m,etc/cron.(daily|weekly|monthly)/., and !$usescrond) { + tag "missing-restricted-cron-dependency", $file; + } +} + +} + +1; + +# Local Variables: +# indent-tabs-mode: t +# cperl-indent-level: 4 +# End: +# vim: syntax=perl ts=8 diff --git a/checks/cron.desc b/checks/cron.desc new file mode 100644 index 0000000..25f986a --- /dev/null +++ b/checks/cron.desc @@ -0,0 +1,20 @@ +Check-Script: cron +Author: Roland Mas <lola...@debian.org> +Abbrev: cr +Type: binary +Unpack-Level: 2 +Info: This looks for common mistakes in packages using cron. + +Tag: missing-cron-dependency +Severity: normal +Certainty: possible +Info: Packages shipping crontabs should depend on a cron-like + scheduler, since cron is not an essential package. + +Tag: missing-restricted-cron-dependency +Severity: normal +Certainty: possible +Info: Packages shipping scripts in + /etc/cron.(hourly|daily|weekly|monthly) should depend on a cron-like + scheduler or possibly a restricted variant such as anacron, since + cron is not an essential package. diff --git a/debian/changelog b/debian/changelog index 9201736..0083576 100755 --- a/debian/changelog +++ b/debian/changelog @@ -38,6 +38,8 @@ lintian (2.2.18) UNRELEASED; urgency=low + [FL] Add /usr/lib/python*/dist-packages to exception list for incorrect-libdir-in-la-file. Thanks, Mathieu Trudel. (Closes: #551134) + * checks/cron: + + Added file. * data/changelog-file/ubuntu-dists: + [CW] Add lucid as an allowable distribution for Ubuntu, and remove @@ -45,7 +47,7 @@ lintian (2.2.18) UNRELEASED; urgency=low * data/doc-base/sections: + [FL] Update from doc-base 0.9.5. Adds Typesetting section. Thanks Julian Gilbey. (Closes: #552526) - + -- Frank Lichtenheld <dj...@debian.org> Sat, 31 Oct 2009 23:17:02 +0100 lintian (2.2.17) unstable; urgency=medium
(By the way, thanks for Lintian, it's a great tool.) Roland. -- System Information: Debian Release: squeeze/sid APT prefers unstable APT policy: (500, 'unstable'), (1, 'experimental') Architecture: i386 (i686) Kernel: Linux 2.6.30-2-686 (SMP w/1 CPU core) Locale: LANG=fr_FR.UTF-8, LC_CTYPE=fr_FR.UTF-8 (charmap=UTF-8) Shell: /bin/sh linked to /bin/bash Versions of packages lintian depends on: ii binutils 2.20-2 The GNU assembler, linker and bina ii diffstat 1.47-1 produces graph of changes introduc ii dpkg-dev 1.15.4.1 Debian package development tools ii file 5.03-2 Determines file type using "magic" ii gettext 0.17-8 GNU Internationalization utilities ii intltool-debian 0.35.0+20060710.1 Help i18n of RFC822 compliant conf ii libapt-pkg-perl 0.1.24 Perl interface to libapt-pkg ii libclass-accessor-perl 0.34-1 Perl module that automatically gen ii libipc-run-perl 0.84-1 Perl module for running processes ii libparse-debianchangel 1.1.1-2 parse Debian changelogs and output ii libtimedate-perl 1.1900-1 Time and date functions for Perl ii liburi-perl 1.37+dfsg-1 Manipulates and accesses URI strin ii man-db 2.5.6-3 on-line manual pager ii perl [libdigest-sha-pe 5.10.1-6 Larry Wall's Practical Extraction lintian recommends no packages. Versions of packages lintian suggests: pn binutils-multiarch <none> (no description available) ii libtext-template-perl 1.45-1 Text::Template perl module ii man-db 2.5.6-3 on-line manual pager -- no debconf information -- Roland Mas Neko-no me-to, onna-gokoro-to, aki-no-sora. -- Proverbe japonais (« Souvent femme varie, bien fol est qui s'y fie. »)