SHA256
1
0
forked from pool/rpmlint
rpmlint/improve-postdep-check.diff

94 lines
3.9 KiB
Diff
Raw Normal View History

--- PostCheck.py
+++ PostCheck.py
@@ -33,7 +33,7 @@
# shells that grok the -n switch for debugging
syntaxcheck_shells = ('/bin/sh', '/bin/bash')
-percent_regex = re.compile('%{?\w{3,}', re.MULTILINE)
+percent_regex = re.compile('^[^#]*%{?\w{3,}', re.MULTILINE)
bracket_regex=re.compile('^[^#]*if.*[^ :\]]\]', re.MULTILINE)
home_regex=re.compile('[^a-zA-Z]+~/|\${?HOME(\W|$)', re.MULTILINE)
dangerous_command_regex=re.compile("(^|[;\|`]|&&|$\()\s*(?:\S*/s?bin/)?(cp|mv|ln|tar|rpm|chmod|chown|rm|cpio|install|perl|userdel|groupdel)\s", re.MULTILINE)
@@ -44,14 +44,48 @@
menu_regex=re.compile('^/usr/lib/menu/|^/etc/menu-methods/|^/usr/share/applications/')
bogus_var_regex=re.compile('(\${?RPM_BUILD_(ROOT|DIR)}?)')
+# [foo, (bar, baz)]:
+# if a script contains foo then the rpm must prerequire bar or contain baz
prereq_assoc = (
# ['chkconfig', ('chkconfig', '/sbin/chkconfig')],
['chkfontpath', ('chkfontpath', '/usr/sbin/chkfontpath')],
['rpm-helper', ('rpm-helper',)],
+ ['cp', ('coreutils', '/bin/cp')],
+ ['ln', ('coreutils', '/bin/ln')],
+ ['mv', ('coreutils', '/bin/mv')],
+ ['rm', ('coreutils', '/bin/rm')],
+ ['rmdir', ('coreutils', '/bin/rmdir')],
+ ['cat', ('coreutils', '/bin/cat')],
+ ['cut', ('coreutils', '/usr/bin/cut')],
+ ['uname', ('coreutils', '/bin/uname')],
+ ['md5sum', ('coreutils', '/usr/bin/md5sum')],
+ ['pear', ('php5-pear', '/usr/bin/pear')],
+ ['update-alternatives', ('update-alternatives', '/usr/sbin/update-alternatives')],
+ ['a2enmod', ('apache2', '/usr/sbin/a2enmod')],
+
+ ['sed', ('sed', '/bin/sed')],
+ ['awk', ('gawk', '/usr/bin/awk')],
+ ['gawk', ('gawk', '/usr/bin/gawk')],
+ ['grep', ('grep', '/usr/bin/grep')],
+ ['useradd', ('pwdutils', '/usr/sbin/useradd')],
+ ['groupadd', ('pwdutils', '/usr/sbin/groupadd')],
+ ['chkstat', ('permissions', '/usr/bin/chkstat')],
+ ['diff', ('diffutils', '/usr/bin/diff')],
+ ['cmp', ('diffutils', '/usr/bin/cmp')],
+ ['patch', ('patch', '/usr/bin/patch')],
+ ['fillup', ('fillup', '/bin/fillup')],
+ ['tar', ('tar', '/bin/tar')],
+ ['cpio', ('cpio', '/bin/cpio')],
+ ['odbcinst', ('unixODBC', '/usr/bin/odbcinst')],
+ ['install-info', ('info', '/sbin/install-info')],
+ ['gpg', ('gpg2', '/usr/bin/gpg')],
+ ['nm', ('binutils', '/usr/bin/nm')],
+ ['edit-xml-catalog', ('awk', '/usr/bin/awk')],
)
+# \b is word boundary
for p in prereq_assoc:
- p[0] = re.compile('^[^#]+' + p[0], re.MULTILINE)
+ p[0] = re.compile('^[^#]+\\b(' + p[0] + ')\\b', re.MULTILINE)
# pychecker fix
del p
@@ -163,15 +196,17 @@
printError(pkg, 'update-menus-without-menu-file-in-' + tag[2])
if tmp_regex.search(script):
printError(pkg, 'use-tmp-in-' + tag[2])
+
for c in prereq_assoc:
- if c[0].search(script):
+ res = c[0].search(script)
+ if res:
found=0
for p in c[1]:
if p in prereq or p in files:
found=1
break
if not found:
- printError(pkg, 'no-prereq-on', c[1][0])
+ printError(pkg, 'no-prereq-on', c[1][0], 'or', c[1][1], 'for', res.group(1))
if prog in syntaxcheck_shells:
if incorrect_shell_script(prog, script):
@@ -230,6 +265,11 @@
policy type was found in the scriptlet. These types are subject to change
on a policy version upgrade. Use the restorecon command which queries the
currently loaded policy for the correct type instead.''',
+
+'no-prereq-on',
+'''Your rpm post/postun scripts contain a call to a command that is missing
+from the rpm prereq list. This might cause the package to fail during
+installation due to the required program not being available yet.'''
)
# PostCheck.py ends here