SHA256
1
0
forked from pool/rpmlint
rpmlint/sysv5-init-checks.diff

94 lines
3.7 KiB
Diff
Raw Normal View History

--- InitScriptCheck.py
+++ InitScriptCheck.py
@@ -27,6 +27,8 @@
use_deflevels=Config.getOption('UseDefaultRunlevels', 1)
lsb_tags_regex = re.compile('^# ([\w-]+):\s*(.*?)\s*$')
lsb_cont_regex = re.compile('^#(?:\t| )(.*?)\s*$')
+insserv_regex=re.compile('^\s*sbin/insserv', re.MULTILINE)
+preun_regex=re.compile('^\s*/etc/init.d/\S+ stop', re.MULTILINE)
class InitScriptCheck(AbstractCheck.AbstractCheck):
@@ -39,6 +41,12 @@
return
initscript_list = []
+
+ # check chkconfig call in %post and %preun
+ postin=pkg[rpm.RPMTAG_POSTIN] or pkg[rpm.RPMTAG_POSTINPROG]
+ preun=pkg[rpm.RPMTAG_PREUN] or pkg[rpm.RPMTAG_PREUNPROG]
+ postun=pkg[rpm.RPMTAG_POSTUN] or pkg[rpm.RPMTAG_POSTUNPROG]
+
for f in pkg.files().keys():
if rc_regex.search(f):
basename=basename_regex.search(f).group(1)
@@ -48,20 +56,23 @@
if dot_in_name_regex.match(basename):
printError(pkg, 'init-script-name-with-dot', f)
- # check chkconfig call in %post and %preun
- postin=pkg[rpm.RPMTAG_POSTIN] or pkg[rpm.RPMTAG_POSTINPROG]
if not postin:
printError(pkg, 'init-script-without-chkconfig-postin', f)
else:
if not chkconfig_regex.search(postin):
printError(pkg, 'postin-without-chkconfig', f)
- preun=pkg[rpm.RPMTAG_PREUN] or pkg[rpm.RPMTAG_PREUNPROG]
if not preun:
- printError(pkg, 'init-script-without-chkconfig-preun', f)
+ printError(pkg, 'init-script-without-%stop_on_removal-preun', f)
else:
- if not chkconfig_regex.search(preun):
- printError(pkg, 'preun-without-chkconfig', f)
+ if not preun_regex.search(preun):
+ printError(pkg, 'preun-without-%stop_on_removal-preun', f)
+
+ if not postun:
+ printError(pkg, 'init-script-without-%insserv_cleanup-postun', f)
+ else:
+ if not insserv_regex.search(postun):
+ printError(pkg, 'postun-without-%insserv_cleanup', f)
status_found = 0
reload_found = 0
@@ -183,10 +194,18 @@
'postin-without-chkconfig',
'''The package contains an init script but doesn't call chkconfig in its %post.''',
-'init-script-without-chkconfig-preun',
+'init-script-without-%stop_on_removal-preun',
'''The package contains an init script but doesn't contain a %preun with
a call to chkconfig.''',
+'init-script-without-%insserv_cleanup-postun',
+'''The package contains an init script but doesn't contain a %postun
+with a call to %insserv_cleanup-postun''',
+
+'postun-without-%insserv_cleanup',
+'''The package contains an init script but doesn't contain a %postun
+with a call to %insserv_cleanup-postun''',
+
'preun-without-chkconfig',
'''The package contains an init script but doesn't call chkconfig in its %preun.''',
@@ -241,6 +260,18 @@
'init-script-non-executable',
'''The init script should have at least the execution bit set for root
in order for it to run at boot time.''',
+
+'init-script-without-%stop_on_removal-preun',
+'''The init script should have a %preun script that calls %stop_on_removal.''',
+
+'preun-without-%stop_on_removal-preun',
+'''The init script is not listed in %stop_on_removal in %preun.''',
+
+'init-script-without-%insserv_cleanup-postun',
+'''The package doesn't have a %insserv_cleanup call in %postun''',
+
+'postun-without-%insserv_cleanup',
+'''The package doesn't have a %insserv_cleanup call in %postun''',
)
# InitScriptCheck.py ends here