SHA256
1
0
forked from pool/rpmlint
rpmlint/suse-sysv-init-checks.diff
Ludwig Nussel bda5d592a2 - new versioin 1.6
- add script update_git.sh based on qemu's to simplify importing
  a patch series from git after rebasing.
* Patches dropped:
  0001-Python-3-compatibility-tweaks.patch (upstream)
  0001-Set-Python-3.4-magic-number-to-3310.patch (upstream)
  add-scoring-support.diff (different upstream solution)
  check-buildroot-during-install.diff (need to fix no-cleaning-of-buildroot check upstream)
  fix-versioned-prereq.diff (was disabled, not sure what it's useful for)
  ignore-non-readable-in-etc.diff (filtered anyways)
  locale-support.diff (drop)
  locale-update.diff (different upstream solution now)
  more-verbose-lsb-check.diff (drop)
  perl-versioned-rpath-deps.diff (upstream)
  rpmlint-1.5-disallow-var-run-and-var-lock.diff (upstream)
  rpmlint-1.5-Fix-setgroups-error-name.diff (upstream)
  rpmlint-decode-fix.diff (different upstream solution)
  rpmlint-fix-unexpanded-macros-for-array-values.patch (different upstream solution)
  stricter-tags-check.diff (merged in weak deps and check-for-self-provides.diff)
  suppress-for-perl-python.diff (use filter instead)
  suse-binary-info-compile-opts.diff (drop)
  suse-changelog.patch (change config instead)
  suse-mono-deps-checks.diff (useful?)
  suse-required-lsb-tags.diff (different upstream solution)
  verify-buildrequires.diff (very build system specific, drop)
  xdg-check-exception.diff (upstream)
* renamed patches:
  script-interpreter-only-for-exec-scripts.diff
  -> script-interpreter-only-for-exec-sc.diff
  confusing-invalid-spec-name.patch

OBS-URL: https://build.opensuse.org/package/show/devel:openSUSE:Factory:rpmlint/rpmlint?expand=0&rev=317
2015-04-10 14:35:46 +00:00

80 lines
3.6 KiB
Diff

From 738e37c34c66a665012bcf6b123b81717c16d3f3 Mon Sep 17 00:00:00 2001
From: Ludwig Nussel <ludwig.nussel@suse.de>
Date: Fri, 10 Apr 2015 14:38:22 +0200
Subject: [PATCH] suse sysv init checks
we don't use chkconfig but have different macros
---
InitScriptCheck.py | 44 ++++++++++++++++++++++++++++++--------------
1 file changed, 30 insertions(+), 14 deletions(-)
diff --git a/InitScriptCheck.py b/InitScriptCheck.py
index fb53d93..1a58562 100644
--- a/InitScriptCheck.py
+++ b/InitScriptCheck.py
@@ -36,6 +36,10 @@ LSB_KEYWORDS = ('Provides', 'Required-Start', 'Required-Stop', 'Should-Start',
RECOMMENDED_LSB_KEYWORDS = ('Provides', 'Required-Start', 'Required-Stop',
'Default-Stop', 'Short-Description')
+suse = True
+stop_on_removal_regex=re.compile('bin/systemctl stop \$service >/dev/null')
+restart_on_update_regex=re.compile('bin/systemctl try-restart \$service >/dev/null')
+insserv_cleanup_regex=re.compile('^\s*/sbin/insserv /etc/init.d$', re.MULTILINE)
class InitScriptCheck(AbstractCheck.AbstractCheck):
@@ -44,6 +48,12 @@ class InitScriptCheck(AbstractCheck.AbstractCheck):
def check_binary(self, pkg):
initscript_list = []
+
+ # check chkconfig call in %post and %preun
+ postin = Pkg.b2s(pkg[rpm.RPMTAG_POSTIN]) or pkg.scriptprog(rpm.RPMTAG_POSTINPROG)
+ preun = Pkg.b2s(pkg[rpm.RPMTAG_PREUN]) or pkg.scriptprog(rpm.RPMTAG_PREUNPROG)
+ postun = Pkg.b2s(pkg[rpm.RPMTAG_POSTUN]) or pkg.scriptprog(rpm.RPMTAG_POSTUNPROG)
+
for fname, pkgfile in pkg.files().items():
if not fname.startswith('/etc/init.d/') and \
@@ -61,20 +71,26 @@ class InitScriptCheck(AbstractCheck.AbstractCheck):
if "." in basename:
printError(pkg, 'init-script-name-with-dot', fname)
- # check chkconfig call in %post and %preun
- postin = Pkg.b2s(pkg[rpm.RPMTAG_POSTIN]) or \
- pkg.scriptprog(rpm.RPMTAG_POSTINPROG)
- if not postin:
- printError(pkg, 'init-script-without-chkconfig-postin', fname)
- elif not chkconfig_regex.search(postin):
- printError(pkg, 'postin-without-chkconfig', fname)
-
- preun = Pkg.b2s(pkg[rpm.RPMTAG_PREUN]) or \
- pkg.scriptprog(rpm.RPMTAG_PREUNPROG)
- if not preun:
- printError(pkg, 'init-script-without-chkconfig-preun', fname)
- elif not chkconfig_regex.search(preun):
- printError(pkg, 'preun-without-chkconfig', fname)
+ if not suse:
+ if not postin:
+ printError(pkg, 'init-script-without-chkconfig-postin', fname)
+ elif not chkconfig_regex.search(postin):
+ printError(pkg, 'postin-without-chkconfig', fname)
+
+ if not preun:
+ printError(pkg, 'init-script-without-chkconfig-preun', fname)
+ elif not chkconfig_regex.search(preun):
+ printError(pkg, 'preun-without-chkconfig', fname)
+
+ else:
+ if not preun or not stop_on_removal_regex.search(preun):
+ printError(pkg, 'init-script-without-%stop_on_removal-preun', fname)
+
+ if not postun or not restart_on_update_regex.search(postun):
+ printError(pkg, 'init-script-without-%restart_on_update-postun', fname)
+
+ if not postun or not insserv_cleanup_regex.search(postun):
+ printError(pkg, 'init-script-without-%insserv_cleanup-postun', fname)
status_found = False
reload_found = False