|
|
|
@ -40,6 +40,7 @@ from .common import getTupleVersion
|
|
|
|
|
from contextlib import closing
|
|
|
|
|
from functools import total_ordering
|
|
|
|
|
from itertools import ifilter, imap, chain, groupby
|
|
|
|
|
import hashlib
|
|
|
|
|
|
|
|
|
|
Colors = TextState.Colors
|
|
|
|
|
import glob
|
|
|
|
@ -1789,3 +1790,38 @@ def clear_binhost_garbage(dn):
|
|
|
|
|
fullpath=True):
|
|
|
|
|
if fn.endswith(".portage.lockfile") or fn.endswith(".partial"):
|
|
|
|
|
os.unlink(fn)
|
|
|
|
|
|
|
|
|
|
class PortageState(object):
|
|
|
|
|
"""
|
|
|
|
|
Подсчёт контрольной суммы для определения изменений /etc/portage
|
|
|
|
|
"""
|
|
|
|
|
paths = ["/etc/portage", "/var/log/emerge.log"]
|
|
|
|
|
|
|
|
|
|
def __init__(self, prefix='/'):
|
|
|
|
|
self.prefix = prefix
|
|
|
|
|
|
|
|
|
|
def readFileContent(self, fn):
|
|
|
|
|
if fn.endswith("/var/log/emerge.log"):
|
|
|
|
|
return readFile(fn)[:-200]
|
|
|
|
|
return readFile(fn)
|
|
|
|
|
|
|
|
|
|
def getpathdata(self, fn):
|
|
|
|
|
yield "%s"%fn
|
|
|
|
|
if path.lexists(fn):
|
|
|
|
|
if path.islink(fn):
|
|
|
|
|
yield os.readlink(fn)
|
|
|
|
|
elif path.isdir(fn):
|
|
|
|
|
for x in os.listdir(fn):
|
|
|
|
|
dfn = pathJoin(fn, x)
|
|
|
|
|
for dirdata in self.getpathdata(dfn):
|
|
|
|
|
yield dirdata
|
|
|
|
|
else:
|
|
|
|
|
yield readFile(fn)
|
|
|
|
|
|
|
|
|
|
def get_state(self):
|
|
|
|
|
m = hashlib.md5()
|
|
|
|
|
for dn in self.paths:
|
|
|
|
|
fdn = pathJoin(self.prefix, dn)
|
|
|
|
|
for data in self.getpathdata(fdn):
|
|
|
|
|
m.update(data)
|
|
|
|
|
return m.hexdigest()
|
|
|
|
|