Code cleanups.
git-svn-id: svn+ssh://rpmlint.zarb.org/home/projects/rpmlint/svn/trunk@1578 9bc8b190-ac0f-0410-8968-dc7d1f502856
This commit is contained in:
parent
7e9523a7dc
commit
7bbfd9bff6
|
@ -374,7 +374,7 @@ class BinariesCheck(AbstractCheck.AbstractCheck):
|
||||||
for f in files:
|
for f in files:
|
||||||
res = numeric_dir_regex.search(f)
|
res = numeric_dir_regex.search(f)
|
||||||
fn = res and res.group(1) or f
|
fn = res and res.group(1) or f
|
||||||
if not f in exec_files and not so_regex.search(f) and not versioned_dir_regex.search(fn):
|
if f not in exec_files and not so_regex.search(f) and not versioned_dir_regex.search(fn):
|
||||||
printError(pkg, 'non-versioned-file-in-library-package', f)
|
printError(pkg, 'non-versioned-file-in-library-package', f)
|
||||||
if version and version != -1 and pkg.name.find(version) == -1:
|
if version and version != -1 and pkg.name.find(version) == -1:
|
||||||
printError(pkg, 'incoherent-version-in-name', version)
|
printError(pkg, 'incoherent-version-in-name', version)
|
||||||
|
|
|
@ -56,7 +56,7 @@ def addCheck(check):
|
||||||
global _checks
|
global _checks
|
||||||
|
|
||||||
check = re.sub('\.py[co]?$', '', check)
|
check = re.sub('\.py[co]?$', '', check)
|
||||||
if not check in _checks:
|
if check not in _checks:
|
||||||
_checks.append(check)
|
_checks.append(check)
|
||||||
|
|
||||||
def allChecks():
|
def allChecks():
|
||||||
|
@ -84,7 +84,7 @@ def addCheckDir(dir):
|
||||||
|
|
||||||
d = os.path.expanduser(dir)
|
d = os.path.expanduser(dir)
|
||||||
|
|
||||||
if not d in _dirs:
|
if d not in _dirs:
|
||||||
_dirs.insert(0, d)
|
_dirs.insert(0, d)
|
||||||
|
|
||||||
def checkDirs():
|
def checkDirs():
|
||||||
|
|
|
@ -41,7 +41,7 @@ class ConfigCheck(AbstractCheck.AbstractCheck):
|
||||||
elif not ConfigCheck.etc_var_regex.search(c):
|
elif not ConfigCheck.etc_var_regex.search(c):
|
||||||
printWarning(pkg, "non-etc-or-var-file-marked-as-conffile", c)
|
printWarning(pkg, "non-etc-or-var-file-marked-as-conffile", c)
|
||||||
|
|
||||||
if not c in noreplace_files:
|
if c not in noreplace_files:
|
||||||
printWarning(pkg, "conffile-without-noreplace-flag", c)
|
printWarning(pkg, "conffile-without-noreplace-flag", c)
|
||||||
|
|
||||||
# Create an object to enable the auto registration of the test
|
# Create an object to enable the auto registration of the test
|
||||||
|
|
|
@ -38,20 +38,19 @@ class FHSCheck(AbstractCheck.AbstractCheck):
|
||||||
s = FHSCheck.usr_regex.search(fname)
|
s = FHSCheck.usr_regex.search(fname)
|
||||||
if s:
|
if s:
|
||||||
d = s.group(1)
|
d = s.group(1)
|
||||||
if not d in FHSCheck.usr_subdir:
|
if d not in FHSCheck.usr_subdir and d not in usr_list:
|
||||||
if not d in usr_list:
|
|
||||||
printWarning(pkg, "non-standard-dir-in-usr", d)
|
printWarning(pkg, "non-standard-dir-in-usr", d)
|
||||||
usr_list.append(d)
|
usr_list.append(d)
|
||||||
else:
|
else:
|
||||||
s = FHSCheck.var_regex.search(fname)
|
s = FHSCheck.var_regex.search(fname)
|
||||||
if s:
|
if s:
|
||||||
d = s.group(1)
|
d = s.group(1)
|
||||||
|
if d in var_list:
|
||||||
|
continue
|
||||||
if d in FHSCheck.var_fsstnd:
|
if d in FHSCheck.var_fsstnd:
|
||||||
if not d in var_list:
|
|
||||||
printWarning(pkg, "FSSTND-dir-in-var", fname)
|
printWarning(pkg, "FSSTND-dir-in-var", fname)
|
||||||
var_list.append(d)
|
var_list.append(d)
|
||||||
elif not d in FHSCheck.var_subdir:
|
elif d not in FHSCheck.var_subdir:
|
||||||
if not d in var_list:
|
|
||||||
printWarning(pkg, "non-standard-dir-in-var", d)
|
printWarning(pkg, "non-standard-dir-in-var", d)
|
||||||
var_list.append(d)
|
var_list.append(d)
|
||||||
|
|
||||||
|
|
|
@ -325,9 +325,9 @@ class FilesCheck(AbstractCheck.AbstractCheck):
|
||||||
|
|
||||||
if mispelled_macro_regex.search(f):
|
if mispelled_macro_regex.search(f):
|
||||||
printWarning(pkg, 'mispelled-macro', f)
|
printWarning(pkg, 'mispelled-macro', f)
|
||||||
if standard_users and not user in standard_users:
|
if standard_users and user not in standard_users:
|
||||||
printWarning(pkg, 'non-standard-uid', f, user)
|
printWarning(pkg, 'non-standard-uid', f, user)
|
||||||
if standard_groups and not group in standard_groups:
|
if standard_groups and group not in standard_groups:
|
||||||
printWarning(pkg, 'non-standard-gid', f, group)
|
printWarning(pkg, 'non-standard-gid', f, group)
|
||||||
|
|
||||||
if not module_rpms_ok and kernel_modules_regex.search(f) and not is_kernel_package:
|
if not module_rpms_ok and kernel_modules_regex.search(f) and not is_kernel_package:
|
||||||
|
@ -430,7 +430,7 @@ class FilesCheck(AbstractCheck.AbstractCheck):
|
||||||
printError(pkg, 'non-root-user-log-file', f, user)
|
printError(pkg, 'non-root-user-log-file', f, user)
|
||||||
if group != 'root':
|
if group != 'root':
|
||||||
printError(pkg, 'non-root-group-log-file', f, group)
|
printError(pkg, 'non-root-group-log-file', f, group)
|
||||||
if not f in ghost_files:
|
if f not in ghost_files:
|
||||||
printError(pkg, 'non-ghost-file', f)
|
printError(pkg, 'non-ghost-file', f)
|
||||||
|
|
||||||
if doc_regex.search(f):
|
if doc_regex.search(f):
|
||||||
|
@ -554,7 +554,7 @@ class FilesCheck(AbstractCheck.AbstractCheck):
|
||||||
if nonexec_file:
|
if nonexec_file:
|
||||||
printWarning(pkg, 'spurious-executable-perm', f)
|
printWarning(pkg, 'spurious-executable-perm', f)
|
||||||
elif f.startswith('/etc/'):
|
elif f.startswith('/etc/'):
|
||||||
if not f in config_files and not f in ghost_files:
|
if f not in config_files and f not in ghost_files:
|
||||||
printWarning(pkg, 'non-conffile-in-etc', f)
|
printWarning(pkg, 'non-conffile-in-etc', f)
|
||||||
|
|
||||||
if pkg.arch == 'noarch' and f.startswith('/usr/lib64/python'):
|
if pkg.arch == 'noarch' and f.startswith('/usr/lib64/python'):
|
||||||
|
@ -581,7 +581,7 @@ class FilesCheck(AbstractCheck.AbstractCheck):
|
||||||
# absolute link
|
# absolute link
|
||||||
r = absolute_regex.search(link)
|
r = absolute_regex.search(link)
|
||||||
if r:
|
if r:
|
||||||
if (not is_so) and link not in files and link not in req_names:
|
if not is_so and link not in files and link not in req_names:
|
||||||
is_exception = 0
|
is_exception = 0
|
||||||
for e in dangling_exceptions:
|
for e in dangling_exceptions:
|
||||||
if e[0].search(link):
|
if e[0].search(link):
|
||||||
|
@ -610,7 +610,7 @@ class FilesCheck(AbstractCheck.AbstractCheck):
|
||||||
is_exception = e[1]
|
is_exception = e[1]
|
||||||
break
|
break
|
||||||
if is_exception:
|
if is_exception:
|
||||||
if not is_exception in req_names:
|
if is_exception not in req_names:
|
||||||
printWarning(pkg, 'no-dependency-on', is_exception)
|
printWarning(pkg, 'no-dependency-on', is_exception)
|
||||||
else:
|
else:
|
||||||
printWarning(pkg, 'dangling-relative-symlink', f, link)
|
printWarning(pkg, 'dangling-relative-symlink', f, link)
|
||||||
|
|
|
@ -119,11 +119,11 @@ class I18NCheck(AbstractCheck.AbstractCheck):
|
||||||
if res:
|
if res:
|
||||||
locale = res.group(2)
|
locale = res.group(2)
|
||||||
# checks the same locale only once
|
# checks the same locale only once
|
||||||
if not locale in locales:
|
if locale not in locales:
|
||||||
locales.append(locale)
|
locales.append(locale)
|
||||||
res2 = correct_subdir_regex.search(locale)
|
res2 = correct_subdir_regex.search(locale)
|
||||||
if not res2:
|
if not res2:
|
||||||
if not locale in EXCEPTION_DIRS:
|
if locale not in EXCEPTION_DIRS:
|
||||||
printError(pkg, 'incorrect-locale-subdir', f)
|
printError(pkg, 'incorrect-locale-subdir', f)
|
||||||
else:
|
else:
|
||||||
locale_name = res2.group(2)
|
locale_name = res2.group(2)
|
||||||
|
@ -136,13 +136,13 @@ class I18NCheck(AbstractCheck.AbstractCheck):
|
||||||
subdir = None
|
subdir = None
|
||||||
if res:
|
if res:
|
||||||
subdir = res.group(1)
|
subdir = res.group(1)
|
||||||
if not subdir in CORRECT_SUBDIRS:
|
if subdir not in CORRECT_SUBDIRS:
|
||||||
printError(pkg, 'invalid-lc-messages-dir', f)
|
printError(pkg, 'invalid-lc-messages-dir', f)
|
||||||
else:
|
else:
|
||||||
res = man_regex.search(f)
|
res = man_regex.search(f)
|
||||||
if res:
|
if res:
|
||||||
subdir = res.group(1)
|
subdir = res.group(1)
|
||||||
if subdir != 'man' and not subdir in CORRECT_SUBDIRS:
|
if subdir != 'man' and subdir not in CORRECT_SUBDIRS:
|
||||||
printError(pkg, 'invalid-locale-man-dir', f)
|
printError(pkg, 'invalid-locale-man-dir', f)
|
||||||
else:
|
else:
|
||||||
subdir = None
|
subdir = None
|
||||||
|
|
|
@ -254,7 +254,7 @@ class MenuCheck(AbstractCheck.AbstractCheck):
|
||||||
command = command_line[1]
|
command = command_line[1]
|
||||||
break
|
break
|
||||||
if command[0] == '/':
|
if command[0] == '/':
|
||||||
if not command in files:
|
if command not in files:
|
||||||
printWarning(pkg, 'menu-command-not-in-package', command)
|
printWarning(pkg, 'menu-command-not-in-package', command)
|
||||||
else:
|
else:
|
||||||
if not ('/bin/' + command in files or
|
if not ('/bin/' + command in files or
|
||||||
|
@ -322,7 +322,7 @@ class MenuCheck(AbstractCheck.AbstractCheck):
|
||||||
printWarning(pkg, 'hardcoded-path-in-menu-icon', icon)
|
printWarning(pkg, 'hardcoded-path-in-menu-icon', icon)
|
||||||
else:
|
else:
|
||||||
for path in icon_paths:
|
for path in icon_paths:
|
||||||
if not (path[0] + icon) in files:
|
if (path[0] + icon) not in files:
|
||||||
printError(pkg, path[1] + '-icon-not-in-package', icon, f)
|
printError(pkg, path[1] + '-icon-not-in-package', icon, f)
|
||||||
else:
|
else:
|
||||||
printWarning(pkg, 'no-icon-in-menu', title)
|
printWarning(pkg, 'no-icon-in-menu', title)
|
||||||
|
|
2
Pkg.py
2
Pkg.py
|
@ -161,7 +161,7 @@ def get_default_valid_rpmgroups(filename = ""):
|
||||||
groups = fobj.read().strip().splitlines()
|
groups = fobj.read().strip().splitlines()
|
||||||
finally:
|
finally:
|
||||||
fobj.close()
|
fobj.close()
|
||||||
if not 'Development/Debug' in groups:
|
if 'Development/Debug' not in groups:
|
||||||
groups.append('Development/Debug')
|
groups.append('Development/Debug')
|
||||||
groups.sort()
|
groups.sort()
|
||||||
return groups
|
return groups
|
||||||
|
|
|
@ -132,13 +132,13 @@ class PostCheck(AbstractCheck.AbstractCheck):
|
||||||
for f in ghost_files:
|
for f in ghost_files:
|
||||||
if (not postin or postin.find(f) == -1) and \
|
if (not postin or postin.find(f) == -1) and \
|
||||||
(not prein or prein.find(f) == -1) and \
|
(not prein or prein.find(f) == -1) and \
|
||||||
not f in pkg.missingOkFiles():
|
f not in pkg.missingOkFiles():
|
||||||
printWarning(pkg, 'postin-without-ghost-file-creation', f)
|
printWarning(pkg, 'postin-without-ghost-file-creation', f)
|
||||||
|
|
||||||
def check_aux(self, pkg, files, prog, script, tag, prereq):
|
def check_aux(self, pkg, files, prog, script, tag, prereq):
|
||||||
if script:
|
if script:
|
||||||
if prog:
|
if prog:
|
||||||
if not prog in valid_shells:
|
if prog not in valid_shells:
|
||||||
printError(pkg, 'invalid-shell-in-' + tag[2], prog)
|
printError(pkg, 'invalid-shell-in-' + tag[2], prog)
|
||||||
if prog in empty_shells:
|
if prog in empty_shells:
|
||||||
printError(pkg, 'non-empty-' + tag[2], prog)
|
printError(pkg, 'non-empty-' + tag[2], prog)
|
||||||
|
|
|
@ -674,7 +674,7 @@ class TagsCheck(AbstractCheck.AbstractCheck):
|
||||||
if pkg.name in obs_names:
|
if pkg.name in obs_names:
|
||||||
printError(pkg, 'obsolete-on-name')
|
printError(pkg, 'obsolete-on-name')
|
||||||
for o in obs_names:
|
for o in obs_names:
|
||||||
if not o in prov_names:
|
if o not in prov_names:
|
||||||
printWarning(pkg, 'obsolete-not-provided', o)
|
printWarning(pkg, 'obsolete-not-provided', o)
|
||||||
for o in pkg.obsoletes():
|
for o in pkg.obsoletes():
|
||||||
if o[1].find('%') != -1:
|
if o[1].find('%') != -1:
|
||||||
|
|
4
rpmdiff
4
rpmdiff
|
@ -86,10 +86,10 @@ def sense2str(sense):
|
||||||
# compares 2 lists
|
# compares 2 lists
|
||||||
def cmp_list(o, n, name):
|
def cmp_list(o, n, name):
|
||||||
for old in o:
|
for old in o:
|
||||||
if not old in n:
|
if old not in n:
|
||||||
print DEPFORMAT % (REMOVED, name, old[0], sense2str(old[2]), old[1])
|
print DEPFORMAT % (REMOVED, name, old[0], sense2str(old[2]), old[1])
|
||||||
for new in n:
|
for new in n:
|
||||||
if not new in o:
|
if new not in o:
|
||||||
print DEPFORMAT % (ADDED, name, new[0], sense2str(new[2]), new[1])
|
print DEPFORMAT % (ADDED, name, new[0], sense2str(new[2]), new[1])
|
||||||
|
|
||||||
# filter the own name of the package
|
# filter the own name of the package
|
||||||
|
|
Loading…
Reference in New Issue