[yum-commits] 2 commits - needs-restarting.py
skvidal at osuosl.org
skvidal at osuosl.org
Fri Aug 26 21:34:37 UTC 2011
needs-restarting.py | 42 +++++++++++++++++++++++++++++++++++++-----
1 file changed, 37 insertions(+), 5 deletions(-)
New commits:
commit 0bed41d099579a045ddd1f61402d6bb7130179f9
Merge: c53740c d0c4d3a
Author: Seth Vidal <skvidal at fedoraproject.org>
Date: Fri Aug 26 17:34:22 2011 -0400
Merge branch 'master' of ssh://yum.baseurl.org/srv/projects/yum/git/yum-utils
* 'master' of ssh://yum.baseurl.org/srv/projects/yum/git/yum-utils: (5 commits)
Detailed usage for --arch option. BZ 732593.
...
commit c53740ce33d39e5bade9b0f0af8385c1d654010b
Author: Seth Vidal <skvidal at fedoraproject.org>
Date: Fri Aug 26 17:17:48 2011 -0400
add better tests to determine if a process needs to be restarted:
- adds if a file is deleted and is from *bin/*
- adds if a file is deleted and is from an older pkg
it won't solve every case (especially on fedora) but it will solve them for rhel.
diff --git a/needs-restarting.py b/needs-restarting.py
index 6bc883f..20415e6 100755
--- a/needs-restarting.py
+++ b/needs-restarting.py
@@ -40,6 +40,7 @@
import sys
import os
import yum
+import yum.misc
import glob
import stat
from optparse import OptionParser
@@ -87,7 +88,7 @@ def get_open_files(pid):
line = line.replace('\n', '')
slash = line.find('/')
filename = line[slash:]
- filename = filename.replace('(deleted)', '') #only mildly retarded
+ #filename = filename.replace('(deleted)', '') #only mildly retarded
filename = filename.strip()
if filename not in files:
files.append(filename)
@@ -106,7 +107,7 @@ def main(args):
if opts.useronly:
myuid = os.getuid()
- needing_restart = []
+ needing_restart = set()
for pid in return_running_pids(uid=myuid):
try:
@@ -117,12 +118,43 @@ def main(args):
for fn in get_open_files(pid):
if found_match:
break
-
- for pkg in my.rpmdb.searchFiles(fn):
+ just_fn = fn.replace('(deleted)', '')
+ just_fn = just_fn.strip()
+ bogon = False
+ # if the file is in a pkg which has been updated since we started the pid - then it needs to be restarted
+ for pkg in my.rpmdb.searchFiles(just_fn):
if float(pkg.installtime) > float(pid_start):
- needing_restart.append(pid)
+ needing_restart.add(pid)
found_match = True
+ continue
+ if just_fn in pkg.ghostlist:
+ bogon = True
+ break
+
+ if bogon:
+ continue
+ # if the file is deleted
+ if fn.find('(deleted)') != -1:
+ # and it is from /*bin/* then it needs to be restarted
+ if yum.misc.re_primary_filename(just_fn):
+ needing_restart.add(pid)
+ found_match = True
+ continue
+
+ # if the file is from an old ver of an installed pkg - then assume it was just updated but the
+ # new pkg doesn't have the same file names. Fabulous huh?!
+ my.conf.cache = False
+ for oldpkg in my.pkgSack.searchFiles(just_fn): # ghostfiles are always bogons
+ if just_fn in oldpkg.ghostlist:
+ continue
+ if my.rpmdb.installed(oldpkg.name):
+ needing_restart.add(pid)
+ found_match = True
+ break
+
+
+
for pid in needing_restart:
try:
cmdline = open('/proc/' +pid+ '/cmdline', 'r').read()
More information about the Yum-commits
mailing list