2008-04-17 04:52:37 +02:00
|
|
|
--- InitScriptCheck.py
|
|
|
|
+++ InitScriptCheck.py
|
2009-08-21 18:19:06 +02:00
|
|
|
@@ -30,6 +30,8 @@
|
|
|
|
use_deflevels = Config.getOption('UseDefaultRunlevels', 1)
|
2008-04-17 04:52:37 +02:00
|
|
|
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)
|
|
|
|
|
2009-08-21 18:19:06 +02:00
|
|
|
LSB_KEYWORDS = ('Provides', 'Required-Start', 'Required-Stop', 'Should-Start',
|
|
|
|
'Should-Stop', 'Default-Start', 'Default-Stop',
|
|
|
|
@@ -48,6 +50,13 @@
|
2008-04-17 04:52:37 +02:00
|
|
|
return
|
|
|
|
|
|
|
|
initscript_list = []
|
|
|
|
+
|
2009-08-21 18:19:06 +02:00
|
|
|
+
|
2008-04-17 04:52:37 +02:00
|
|
|
+ # check chkconfig call in %post and %preun
|
2009-08-21 18:19:06 +02:00
|
|
|
+ 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]
|
2008-04-17 04:52:37 +02:00
|
|
|
+
|
2009-08-21 18:19:06 +02:00
|
|
|
for fname, pkgfile in pkg.files().items():
|
|
|
|
if rc_regex.search(fname):
|
|
|
|
basename = os.path.basename(fname)
|
|
|
|
@@ -57,13 +66,17 @@
|
2008-04-17 04:52:37 +02:00
|
|
|
|
|
|
|
if dot_in_name_regex.match(basename):
|
2009-08-21 18:19:06 +02:00
|
|
|
printError(pkg, 'init-script-name-with-dot', fname)
|
2008-04-17 04:52:37 +02:00
|
|
|
- # check chkconfig call in %post and %preun
|
2009-08-21 18:19:06 +02:00
|
|
|
- postin = pkg[rpm.RPMTAG_POSTIN] or pkg[rpm.RPMTAG_POSTINPROG]
|
2008-04-17 04:52:37 +02:00
|
|
|
if not postin:
|
2009-08-21 18:19:06 +02:00
|
|
|
- printError(pkg, 'init-script-without-chkconfig-postin', fname)
|
|
|
|
+ printError(pkg, 'init-script-without-%stop_on_removal-postin', fname)
|
|
|
|
+ else:
|
2008-04-17 04:52:37 +02:00
|
|
|
+ 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)
|
2009-08-21 18:19:06 +02:00
|
|
|
else:
|
|
|
|
- if not chkconfig_regex.search(postin):
|
|
|
|
- printError(pkg, 'postin-without-chkconfig', fname)
|
2008-04-17 04:52:37 +02:00
|
|
|
+ if not insserv_regex.search(postun):
|
|
|
|
+ printError(pkg, 'postun-without-%insserv_cleanup', f)
|
|
|
|
|
2009-08-21 18:19:06 +02:00
|
|
|
preun = pkg[rpm.RPMTAG_PREUN] or pkg[rpm.RPMTAG_PREUNPROG]
|
|
|
|
if not preun:
|
|
|
|
@@ -193,10 +206,18 @@
|
2008-04-17 04:52:37 +02:00
|
|
|
'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.''',
|
|
|
|
|
2009-08-21 18:19:06 +02:00
|
|
|
@@ -254,6 +275,18 @@
|
2008-04-17 04:52:37 +02:00
|
|
|
'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
|