1 # -*- coding: utf-8 -*-
2 #############################################################################
3 # File : SourceCheck.py
5 # Author : Frederic Lepied
6 # Created on : Wed Oct 27 21:17:03 1999
7 # Version : $Id: SourceCheck.py 1754 2010-03-30 20:34:48Z scop $
8 # Purpose : verify source package correctness.
9 #############################################################################
13 from Filter import addDetails, printError, printWarning
18 DEFAULT_VALID_SRC_PERMS = (0644, 0755)
20 source_regex = re.compile('\\.(tar|patch|tgz|diff)$')
21 compress_ext = Config.getOption("CompressExtension", "bz2")
22 valid_src_perms = Config.getOption("ValidSrcPerms", DEFAULT_VALID_SRC_PERMS)
24 class SourceCheck(AbstractCheck.AbstractCheck):
28 AbstractCheck.AbstractCheck.__init__(self, 'SourceCheck')
31 # Check only source package
32 if not pkg.isSource():
37 for fname, pkgfile in pkg.files().items():
38 if fname.endswith('.spec'):
40 printError(pkg, 'multiple-specfiles', spec_file, fname)
43 elif source_regex.search(fname) and compress_ext and \
44 not fname.endswith(compress_ext):
45 printWarning(pkg, 'source-or-patch-not-compressed',
47 perm = pkgfile.mode & 07777
48 if perm not in valid_src_perms:
49 printWarning(pkg, 'strange-permission', fname, oct(perm))
55 '''Your package contains multiple spec files. To build a
56 correct package, you need to have only one spec file containing
57 all your RPM information.''',
59 'source-or-patch-not-compressed',
60 '''A source archive or file in your package is not compressed using the %s
61 compression method (doesn't have the %s extension).''' %
62 (compress_ext, compress_ext),
65 '''A file that you listed to include in your package has strange
66 permissions. Usually, a file should have 0644 permissions.''',
70 # SourceCheck.py ends here
73 # indent-tabs-mode: nil