Lines 5018-5059
Link Here
|
5018 |
myc.close() |
5018 |
myc.close() |
5019 |
pos=1 |
5019 |
pos=1 |
5020 |
for line in mylines: |
5020 |
for line in mylines: |
5021 |
mydat = string.split(line) |
|
|
5022 |
# we do this so we can remove from non-root filesystems |
5023 |
# (use the ROOT var to allow maintenance on other partitions) |
5024 |
try: |
5021 |
try: |
5025 |
mydat[1]=os.path.normpath(root+mydat[1][1:]) |
5022 |
fixroot = lambda x:os.path.normpath(root+x[1:]) |
5026 |
if mydat[0]=="obj": |
5023 |
if line[:3] == 'obj': |
5027 |
#format: type, mtime, md5sum |
5024 |
m = re.match(r"obj (.*) ([0-9a-f]+) ([0-9]+)\n$", line) |
5028 |
pkgfiles[string.join(mydat[1:-2]," ")]=[mydat[0], mydat[-1], mydat[-2]] |
5025 |
assert m # make sure we matched, otherwise, trapped below |
5029 |
elif mydat[0]=="dir": |
5026 |
fname = fixroot(m.group(1)) |
5030 |
#format: type |
5027 |
# format: type, mtime, md5sum |
5031 |
pkgfiles[string.join(mydat[1:])]=[mydat[0] ] |
5028 |
pkgfiles[fname] = [line[:3], m.group(3), m.group(2)] |
5032 |
elif mydat[0]=="sym": |
5029 |
elif line[:3] in ['dir','dev','fif']: |
5033 |
#format: type, mtime, dest |
5030 |
# format: type |
5034 |
x=len(mydat)-1 |
5031 |
fname = fixroot(line[4:-1]) # strip newline |
5035 |
if (x >= 13) and (mydat[-1][-1]==')'): # Old/Broken symlink entry |
5032 |
pkgfiles[fname] = [line[:3]] |
5036 |
mydat = mydat[:-10]+[mydat[-10:][ST_MTIME][:-1]] |
5033 |
elif line[:3] == 'sym': |
5037 |
writemsg("FIXED SYMLINK LINE: %s\n" % mydat, 1) |
5034 |
# format: type, mtime, dest |
5038 |
x=len(mydat)-1 |
5035 |
m = re.match(r"sym (.*) -> (.*) ([0-9]+)\n$", line) |
5039 |
splitter=-1 |
5036 |
assert m # make sure we matched, otherwise, trapped below |
5040 |
while(x>=0): |
5037 |
fname = fixroot(m.group(1)) |
5041 |
if mydat[x]=="->": |
5038 |
pkgfiles[fname] = [line[:3], m.group(3), m.group(2)] |
5042 |
splitter=x |
|
|
5043 |
break |
5044 |
x=x-1 |
5045 |
if splitter==-1: |
5046 |
return None |
5047 |
pkgfiles[string.join(mydat[1:splitter]," ")]=[mydat[0], mydat[-1], string.join(mydat[(splitter+1):-1]," ")] |
5048 |
elif mydat[0]=="dev": |
5049 |
#format: type |
5050 |
pkgfiles[string.join(mydat[1:]," ")]=[mydat[0] ] |
5051 |
elif mydat[0]=="fif": |
5052 |
#format: type |
5053 |
pkgfiles[string.join(mydat[1:]," ")]=[mydat[0]] |
5054 |
else: |
5039 |
else: |
5055 |
return None |
5040 |
assert None # throw an AssertionError, this line is unrecognised |
5056 |
except (KeyError,IndexError): |
5041 |
except (AssertionError,KeyError,IndexError): |
5057 |
print "portage: CONTENTS line",pos,"corrupt!" |
5042 |
print "portage: CONTENTS line",pos,"corrupt!" |
5058 |
pos += 1 |
5043 |
pos += 1 |
5059 |
return pkgfiles |
5044 |
return pkgfiles |