Lines 4712-4717
Link Here
|
4712 |
|
4728 |
|
4713 |
self.myroot=myroot |
4729 |
self.myroot=myroot |
4714 |
self.updateprotect() |
4730 |
self.updateprotect() |
|
|
4731 |
self.contentscache=[] |
4715 |
|
4732 |
|
4716 |
def getpath(self): |
4733 |
def getpath(self): |
4717 |
"return path to location of db information (for >>> informational display)" |
4734 |
"return path to location of db information (for >>> informational display)" |
Lines 4752-4757
Link Here
|
4752 |
def getcontents(self): |
4769 |
def getcontents(self): |
4753 |
if not os.path.exists(self.dbdir+"/CONTENTS"): |
4770 |
if not os.path.exists(self.dbdir+"/CONTENTS"): |
4754 |
return None |
4771 |
return None |
|
|
4772 |
if self.contentscache != []: |
4773 |
return self.contentscache |
4755 |
pkgfiles={} |
4774 |
pkgfiles={} |
4756 |
myc=open(self.dbdir+"/CONTENTS","r") |
4775 |
myc=open(self.dbdir+"/CONTENTS","r") |
4757 |
mylines=myc.readlines() |
4776 |
mylines=myc.readlines() |
Lines 4792-4797
Link Here
|
4792 |
except (KeyError,IndexError): |
4811 |
except (KeyError,IndexError): |
4793 |
print "portage: CONTENTS line",pos,"corrupt!" |
4812 |
print "portage: CONTENTS line",pos,"corrupt!" |
4794 |
pos += 1 |
4813 |
pos += 1 |
|
|
4814 |
self.contentscache=pkgfiles |
4795 |
return pkgfiles |
4815 |
return pkgfiles |
4796 |
|
4816 |
|
4797 |
def updateprotect(self): |
4817 |
def updateprotect(self): |
Lines 5069-5074
Link Here
|
5069 |
|
5089 |
|
5070 |
unlockdir(mydbdir_lock) |
5090 |
unlockdir(mydbdir_lock) |
5071 |
|
5091 |
|
|
|
5092 |
def isowner(self,filename,destroot): |
5093 |
""" check if filename is a new file or belongs to this package |
5094 |
(for this or a previous version)""" |
5095 |
destfile = os.path.normpath(destroot+"/"+filename) |
5096 |
if not os.path.exists(destfile): |
5097 |
return True |
5098 |
if self.getcontents() and filename in self.getcontents().keys(): |
5099 |
return True |
5100 |
|
5101 |
return False |
5102 |
|
5072 |
def treewalk(self,srcroot,destroot,inforoot,myebuild): |
5103 |
def treewalk(self,srcroot,destroot,inforoot,myebuild): |
5073 |
global db |
5104 |
global db |
5074 |
# srcroot = ${D}; |
5105 |
# srcroot = ${D}; |
Lines 5077-5082
Link Here
|
5077 |
# secondhand = list of symlinks that have been skipped due to |
5108 |
# secondhand = list of symlinks that have been skipped due to |
5078 |
# their target not existing (will merge later), |
5109 |
# their target not existing (will merge later), |
5079 |
|
5110 |
|
|
|
5111 |
# check for package collisions |
5112 |
if "collision-protect" in features: |
5113 |
myfilelist = listdir(srcroot, recursive=1, filesonly=1) |
5114 |
stopmerge=False |
5115 |
starttime=time.time() |
5116 |
i=0 |
5117 |
|
5118 |
otherpkg=[] |
5119 |
otherversions=[] |
5120 |
mypkglist=[] |
5121 |
|
5122 |
# this is a ugly hack to get the other versions of the same package, |
5123 |
# feel free to improve |
5124 |
if os.path.exists(self.myroot+"var/db/pkg/"+self.cat): |
5125 |
for mydir in os.listdir(self.myroot+"var/db/pkg/"+self.cat): |
5126 |
otherpkg.append(self.cat+"/"+mydir.split("/")[-1]) |
5127 |
for p in otherpkg: |
5128 |
# the new package doesn't have a category, this can create problems |
5129 |
# if there are packages with the same name in different categories |
5130 |
if catpkgsplit(p)[0] == self.cat and catpkgsplit(p)[1] == pkgsplit(self.pkg)[0]: |
5131 |
otherversions.append(p.split("/")[1]) |
5132 |
|
5133 |
if self.pkg in otherversions: |
5134 |
otherversions.remove(self.pkg) # we already checked this package |
5135 |
|
5136 |
for v in otherversions: |
5137 |
# should we check for same SLOT here ? |
5138 |
mypkglist.append(dblink(self.cat,v,destroot,self.settings)) |
5139 |
|
5140 |
print green("*")+" checking "+str(len(myfilelist))+" files for package collisions" |
5141 |
for f in myfilelist: |
5142 |
i=i+1 |
5143 |
if i % 1000 == 0: |
5144 |
print str(i)+" files checked ..." |
5145 |
if f[0] != "/": |
5146 |
f="/"+f |
5147 |
isowned = False |
5148 |
for ver in [self]+mypkglist: |
5149 |
if (ver.isowner(f, destroot) or ver.isprotected(f)): |
5150 |
isowned = True |
5151 |
break |
5152 |
if not isowned: |
5153 |
print "existing file "+f+" is not owned by this package" |
5154 |
stopmerge=True |
5155 |
print green("*")+" spend "+str(time.time()-starttime)+" seconds checking for file collisions" |
5156 |
if stopmerge: |
5157 |
print red("*")+" This package is blocked because it wants to overwrite" |
5158 |
print red("*")+" files belonging to other packages (see messages above)." |
5159 |
print red("*")+" If you have no clue what this is all about report it " |
5160 |
print red("*")+" as a bug for this package on http://bugs.gentoo.org" |
5161 |
print |
5162 |
print red("package "+self.cat+"/"+self.pkg+" NOT merged") |
5163 |
print |
5164 |
# Why is the package already merged here db-wise? Shouldn't be the case |
5165 |
# only unmerge if it ia new package and has no contents |
5166 |
if not self.getcontents(): |
5167 |
self.unmerge() |
5168 |
self.delete() |
5169 |
sys.exit(1) |
5170 |
|
5171 |
|
5080 |
# get old contents info for later unmerging |
5172 |
# get old contents info for later unmerging |
5081 |
oldcontents=self.getcontents() |
5173 |
oldcontents=self.getcontents() |
5082 |
|
5174 |
|