SHA256
1
0
forked from pool/rpmlint
rpmlint/sysv5-init-checks.diff
OBS User autobuild 7383a6345e Accepting request 17759 from Base:System
Copy from Base:System/rpmlint based on submit request 17759 from user thomasbiege

OBS-URL: https://build.opensuse.org/request/show/17759
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/rpmlint?expand=0&rev=43
2009-08-21 16:19:06 +00:00

88 lines
3.5 KiB
Diff

--- InitScriptCheck.py
+++ InitScriptCheck.py
@@ -30,6 +30,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)
LSB_KEYWORDS = ('Provides', 'Required-Start', 'Required-Stop', 'Should-Start',
'Should-Stop', 'Default-Start', 'Default-Stop',
@@ -48,6 +50,13 @@
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 fname, pkgfile in pkg.files().items():
if rc_regex.search(fname):
basename = os.path.basename(fname)
@@ -57,13 +66,17 @@
if dot_in_name_regex.match(basename):
printError(pkg, 'init-script-name-with-dot', fname)
- # 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', fname)
+ printError(pkg, 'init-script-without-%stop_on_removal-postin', fname)
+ else:
+ 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 chkconfig_regex.search(postin):
- printError(pkg, 'postin-without-chkconfig', fname)
+ if not insserv_regex.search(postun):
+ printError(pkg, 'postun-without-%insserv_cleanup', f)
preun = pkg[rpm.RPMTAG_PREUN] or pkg[rpm.RPMTAG_PREUNPROG]
if not preun:
@@ -193,10 +206,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.''',
@@ -254,6 +275,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