1 # -*- coding: utf-8 -*-
2 # Copyright (C) 2005 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; version 2 of the License.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the Free Software
15 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 from Filter import addDetails, printWarning
23 class DocFilesCheck(AbstractCheck.AbstractCheck):
25 AbstractCheck.AbstractCheck.__init__(self, 'DocFilesCheck')
27 def __checkRequirements(self, pkg):
29 doc_files = pkg.docFiles()
33 for fname, pkgfile in files.items():
34 reqs[fname] = [x[0] for x in pkgfile.requires]
36 core_reqs = {} # dependencies of non-doc files
37 doc_reqs = {} # dependencies of doc files
39 for dep in pkg.header.dsFromHeader():
40 # skip deps which were found by find-requires
41 if dep.Flags() & rpm.RPMSENSE_FIND_REQUIRES != 0:
43 core_reqs[dep.N()] = []
45 # register things which are provided by the package
46 for i in pkg.header[rpm.RPMTAG_PROVIDES] + files.keys():
51 continue # skip empty dependencies
62 # go through the calculated requirements of the %doc files
63 for (dep, req_files) in doc_reqs.items():
64 if dep not in core_reqs:
66 printWarning(pkg, "doc-file-dependency", f, dep)
68 def __checkUnwantedFiles(self, pkg):
70 for docfile in pkg.docFiles():
71 if docfile.endswith("/INSTALL"):
72 printWarning(pkg, "install-file-in-docs", docfile)
76 if pkg.isSource() or not pkg.docFiles():
79 self.__checkRequirements(pkg)
80 self.__checkUnwantedFiles(pkg)
83 check = DocFilesCheck()
86 'doc-file-dependency',
87 '''An included file marked as %doc creates a possible additional dependency in
88 the package. Usually, this is not wanted and may be caused by eg. example
89 scripts with executable bits set included in the package's documentation.''',
91 'install-file-in-docs',
92 '''A file whose name suggests that it contains installation instructions is
93 included in the package. Such instructions are often not relevant for already
94 installed packages; if this is the case for this file and it does not contain
95 any information that is of interest after the package has been built and
96 installed, do not include the file in the binary package.''',
99 # DocFilesCheck.py ends here
102 # indent-tabs-mode: nil
103 # py-indent-offset: 4