61 | 61 |
sys.stderr.write('usage: checkrestart [-vhpa]\n')
|
62 | 62 |
|
63 | 63 |
def main():
|
|
64 |
global lc_all_c_env
|
64 | 65 |
process = None
|
65 | 66 |
toRestart = {}
|
|
67 |
|
|
68 |
lc_all_c_env = os.environ
|
|
69 |
lc_all_c_env['LC_ALL'] = 'C'
|
|
70 |
|
66 | 71 |
|
67 | 72 |
# Process options
|
68 | 73 |
try:
|
|
130 | 135 |
for process in toRestart:
|
131 | 136 |
print "Process %s (PID: %d) " % (process.program, process.pid)
|
132 | 137 |
process.listDeleted()
|
133 | |
|
134 | |
lc_all_c_env = os.environ
|
135 | |
lc_all_c_env['LC_ALL'] = 'C'
|
136 | 138 |
|
137 | 139 |
packages = {}
|
138 | 140 |
diverted = None
|
|
173 | 175 |
if package == 'util-linux':
|
174 | 176 |
continue
|
175 | 177 |
dpkgQuery = ["dpkg-query", "--listfiles", package.name]
|
176 | |
dpkgProc = subprocess.Popen(dpkgQuery, stdout=subprocess.PIPE, stderr=None)
|
|
178 |
dpkgProc = subprocess.Popen(dpkgQuery, stdout=subprocess.PIPE, stderr=None,
|
|
179 |
env = lc_all_c_env)
|
177 | 180 |
for line in dpkgProc.stdout.readlines():
|
178 | 181 |
path = line[:-1]
|
179 | 182 |
if path.startswith('/etc/init.d/'):
|
|
259 | 262 |
# - 0 (NO) for known locations of files which might be deleted
|
260 | 263 |
# - 1 (YES) for valid deleted files we are interested in
|
261 | 264 |
def isdeletedFile (f):
|
|
265 |
|
|
266 |
global lc_all_c_env
|
|
267 |
|
262 | 268 |
if allFiles:
|
263 | 269 |
return 1
|
264 | 270 |
# We don't care about log files
|
|
306 | 312 |
return 0
|
307 | 313 |
# Skip, if asked to, files that do not belong to any package
|
308 | 314 |
if onlyPackageFiles:
|
309 | |
dpkgQuery = ["dpkg-query", "--search", f]
|
310 | |
dpkgProc = subprocess.Popen(dpkgQuery, stdout=subprocess.PIPE, stderr=None)
|
|
315 |
file_in_package = False
|
|
316 |
# Remove some lsof information from the file to ensure that it is
|
|
317 |
# a proper filename
|
|
318 |
file_name = re.sub(r'\(.*\)','', f)
|
|
319 |
file_name = re.sub(r'\s+$','', file_name)
|
|
320 |
dpkgQuery = ["dpkg-query", "--search", file_name]
|
|
321 |
dpkgProc = subprocess.Popen(dpkgQuery, stdout=subprocess.PIPE, stderr=None,
|
|
322 |
env = lc_all_c_env)
|
311 | 323 |
for line in dpkgProc.stdout.readlines():
|
312 | 324 |
if line.endswith(f):
|
313 | 325 |
file_in_package = True
|