--- portage.py.orig 2004-02-08 12:54:40.000000000 +0200 +++ portage.py 2004-02-08 16:34:06.063654437 +0200 @@ -5018,42 +5018,27 @@ myc.close() pos=1 for line in mylines: - mydat = string.split(line) - # we do this so we can remove from non-root filesystems - # (use the ROOT var to allow maintenance on other partitions) try: - mydat[1]=os.path.normpath(root+mydat[1][1:]) - if mydat[0]=="obj": - #format: type, mtime, md5sum - pkgfiles[string.join(mydat[1:-2]," ")]=[mydat[0], mydat[-1], mydat[-2]] - elif mydat[0]=="dir": - #format: type - pkgfiles[string.join(mydat[1:])]=[mydat[0] ] - elif mydat[0]=="sym": - #format: type, mtime, dest - x=len(mydat)-1 - if (x >= 13) and (mydat[-1][-1]==')'): # Old/Broken symlink entry - mydat = mydat[:-10]+[mydat[-10:][ST_MTIME][:-1]] - writemsg("FIXED SYMLINK LINE: %s\n" % mydat, 1) - x=len(mydat)-1 - splitter=-1 - while(x>=0): - if mydat[x]=="->": - splitter=x - break - x=x-1 - if splitter==-1: - return None - pkgfiles[string.join(mydat[1:splitter]," ")]=[mydat[0], mydat[-1], string.join(mydat[(splitter+1):-1]," ")] - elif mydat[0]=="dev": - #format: type - pkgfiles[string.join(mydat[1:]," ")]=[mydat[0] ] - elif mydat[0]=="fif": - #format: type - pkgfiles[string.join(mydat[1:]," ")]=[mydat[0]] + fixroot = lambda x:os.path.normpath(root+x[1:]) + if line[:3] == 'obj': + m = re.match(r"obj (.*) ([0-9a-f]+) ([0-9]+)\n$", line) + assert m # make sure we matched, otherwise, trapped below + fname = fixroot(m.group(1)) + # format: type, mtime, md5sum + pkgfiles[fname] = [line[:3], m.group(3), m.group(2)] + elif line[:3] in ['dir','dev','fif']: + # format: type + fname = fixroot(line[4:-1]) # strip newline + pkgfiles[fname] = [line[:3]] + elif line[:3] == 'sym': + # format: type, mtime, dest + m = re.match(r"sym (.*) -> (.*) ([0-9]+)\n$", line) + assert m # make sure we matched, otherwise, trapped below + fname = fixroot(m.group(1)) + pkgfiles[fname] = [line[:3], m.group(3), m.group(2)] else: - return None - except (KeyError,IndexError): + assert None # throw an AssertionError, this line is unrecognised + except (AssertionError,KeyError,IndexError): print "portage: CONTENTS line",pos,"corrupt!" pos += 1 return pkgfiles