Lines 6093-6099
Link Here
|
6093 |
mysettings.get("CONFIG_PROTECT","").split(), |
6093 |
mysettings.get("CONFIG_PROTECT","").split(), |
6094 |
mysettings.get("CONFIG_PROTECT_MASK","").split()) |
6094 |
mysettings.get("CONFIG_PROTECT_MASK","").split()) |
6095 |
self.updateprotect = protect_obj.updateprotect |
6095 |
self.updateprotect = protect_obj.updateprotect |
6096 |
self.isprotected = protect_obj.isprotected |
6096 |
self._config_protect = protect_obj |
|
|
6097 |
self._installed_instance = None |
6097 |
self.contentscache=[] |
6098 |
self.contentscache=[] |
6098 |
self._contents_inodes = None |
6099 |
self._contents_inodes = None |
6099 |
|
6100 |
|
Lines 6293-6300
Link Here
|
6293 |
mykeys.sort() |
6294 |
mykeys.sort() |
6294 |
mykeys.reverse() |
6295 |
mykeys.reverse() |
6295 |
|
6296 |
|
6296 |
self.updateprotect() |
|
|
6297 |
|
6298 |
#process symlinks second-to-last, directories last. |
6297 |
#process symlinks second-to-last, directories last. |
6299 |
mydirs=[] |
6298 |
mydirs=[] |
6300 |
modprotect="/lib/modules/" |
6299 |
modprotect="/lib/modules/" |
Lines 6325-6331
Link Here
|
6325 |
# upgraded. We effectively only want one half of the config protection |
6324 |
# upgraded. We effectively only want one half of the config protection |
6326 |
# functionality for /lib/modules. For portage-ng both capabilities |
6325 |
# functionality for /lib/modules. For portage-ng both capabilities |
6327 |
# should be able to be independently specified. |
6326 |
# should be able to be independently specified. |
6328 |
if self.isprotected(obj) or ((len(obj) > len(modprotect)) and (obj[0:len(modprotect)]==modprotect)): |
6327 |
if obj.startswith(modprotect): |
6329 |
writemsg_stdout("--- cfgpro %s %s\n" % (pkgfiles[objkey][0], obj)) |
6328 |
writemsg_stdout("--- cfgpro %s %s\n" % (pkgfiles[objkey][0], obj)) |
6330 |
continue |
6329 |
continue |
6331 |
|
6330 |
|
Lines 6427-6432
Link Here
|
6427 |
|
6426 |
|
6428 |
return False |
6427 |
return False |
6429 |
|
6428 |
|
|
|
6429 |
def isprotected(self, filename): |
6430 |
"""Files are protected by CONFIG_PROTECT only if they are identical |
6431 |
to the file that was originally installed (otherwise, the unmerge phase |
6432 |
can remove them). This allows the merge phase to replace files that |
6433 |
will eventually be unmerged anyway.""" |
6434 |
if not self._config_protect.isprotected(filename): |
6435 |
return False |
6436 |
if self._installed_instance is None: |
6437 |
return True |
6438 |
mydata = self._installed_instance.getcontents().get(filename, None) |
6439 |
if mydata is None: |
6440 |
return True |
6441 |
# Duplicate unmerge logic. Protect the file if it's not identical |
6442 |
# to the one that was originally merged. |
6443 |
try: |
6444 |
lstatobj = os.lstat(filename) |
6445 |
except OSError, e: |
6446 |
if e.errno != errno.ENOENT: |
6447 |
raise |
6448 |
del e |
6449 |
# The file has disappeared, so it's not protected. |
6450 |
return False |
6451 |
try: |
6452 |
statobj = os.stat(filename) |
6453 |
except OSError, e: |
6454 |
if e.errno != errno.ENOENT: |
6455 |
raise |
6456 |
del e |
6457 |
statobj = None |
6458 |
lmtime = str(lstatobj[stat.ST_MTIME]) |
6459 |
mytype = mydata[0] |
6460 |
if mytype not in ("dir","fif","dev") and \ |
6461 |
lmtime != mydata[1]: |
6462 |
return True |
6463 |
if "dir" == mytype: |
6464 |
return statobj is None or not stat.S_ISDIR(statobj.st_mode) |
6465 |
elif "sym" == mytype: |
6466 |
return not stat.S_ISLNK(lstatobj.st_mode) |
6467 |
elif "obj" == mytype: |
6468 |
if statobj is None or not stat.S_ISREG(statobj.st_mode): |
6469 |
return True |
6470 |
try: |
6471 |
mymd5 = portage_checksum.perform_md5(filename, calc_prelink=1) |
6472 |
except portage_exception.FileNotFound: |
6473 |
# The file has disappeared, so it's not protected. |
6474 |
return False |
6475 |
return mymd5 != mydata[2].lower() |
6476 |
elif "fif" == mytype: |
6477 |
return not stat.S_ISFIFO(lstatobj[stat.ST_MODE]) |
6478 |
elif "dev" == mytype: |
6479 |
return True |
6480 |
# This should be unreachable. |
6481 |
raise AssertionError("Unrecognized type '%s' in file '%s'" % (mytype, |
6482 |
os.path.join(self._installed_instance.dbdir, "CONTENTS"))) |
6483 |
|
6430 |
def treewalk(self, srcroot, destroot, inforoot, myebuild, cleanup=0, |
6484 |
def treewalk(self, srcroot, destroot, inforoot, myebuild, cleanup=0, |
6431 |
mydbapi=None, prev_mtimes=None): |
6485 |
mydbapi=None, prev_mtimes=None): |
6432 |
# srcroot = ${D}; |
6486 |
# srcroot = ${D}; |
Lines 6447-6452
Link Here
|
6447 |
for v in self.vartree.dbapi.cp_list(self.mysplit[0]): |
6501 |
for v in self.vartree.dbapi.cp_list(self.mysplit[0]): |
6448 |
otherversions.append(v.split("/")[1]) |
6502 |
otherversions.append(v.split("/")[1]) |
6449 |
|
6503 |
|
|
|
6504 |
slot_matches = self.vartree.dbapi.match( |
6505 |
"%s:%s" % (self.mysplit[0], self.settings["SLOT"])) |
6506 |
if slot_matches: |
6507 |
# Used by self.isprotected(). |
6508 |
self._installed_instance = dblink(self.cat, |
6509 |
catsplit(slot_matches[0])[1], destroot, self.settings, |
6510 |
vartree=self.vartree) |
6511 |
|
6450 |
# check for package collisions |
6512 |
# check for package collisions |
6451 |
if "collision-protect" in self.settings.features: |
6513 |
if "collision-protect" in self.settings.features: |
6452 |
collision_ignore = set([normalize_path(myignore) for myignore in \ |
6514 |
collision_ignore = set([normalize_path(myignore) for myignore in \ |