--- portage.py.orig 2004-01-18 05:41:58.000000000 -0500 +++ portage.py 2004-01-30 12:28:13.996729528 -0500 @@ -922,30 +922,41 @@ # version is None and error is a string # def ExtractKernelVersion(base_dir): - pathname = os.path.join(base_dir, 'include/linux/version.h') + lines = [] + pathname = os.path.join(base_dir, 'Makefile') try: - lines = open(pathname, 'r').readlines() + f = open(pathname, 'r') except OSError, details: return (None, str(details)) except IOError, details: return (None, str(details)) + try: + for i in range(4): + lines.append(f.readline()) + except OSError, details: + return (None, str(details)) + except IOError, details: + return (None, str(details)) + lines = map(string.strip, lines) version = '' for line in lines: - items = string.split(line, ' ', 2) - if items[0] == '#define' and \ - items[1] == 'UTS_RELEASE': - version = items[2] # - may be wrapped in quotes - break - - if version == '': - return (None, "Unable to locate UTS_RELEASE in %s" % (pathname)) + # split on the '=' then remove annoying whitespace + items = string.split(line, '=') + items = map(string.strip, items) + if items[0] == 'VERSION' or \ + items[0] == 'PATCHLEVEL': + version += items[1] + version += "." + elif items[0] == 'SUBLEVEL': + version += items[1] + elif items[0] == 'EXTRAVERSION' and \ + items[-1] != items[0]: + version += items[1] - if version[0] == '"' and version[-1] == '"': - version = version[1:-1] return (version,None) aumtime=0