From: Luis R. Rodriguez Date: Fri, 15 Mar 2013 02:05:47 +0000 (-0700) Subject: compat: fix ckmake to skip same base kernels X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=b118a9c59d399420005c97a8a1c9cec1514109f1;p=openwrt%2Fstaging%2Fblogic.git compat: fix ckmake to skip same base kernels The ckmake script was allowing testing of compilation of kernels even if the base kernels were the same. This fixes it to skip them, trimming down test kernel compilation down and not caring what old kernels you keep on your system. This also now prints the RC release correctly. The get_rel_spec() routine is based on the rel-html get_rel_spec() routine and rel-html is AGPL but since I wrote it I relicense a modified version of that routine here to GPLv2. Signed-off-by: Luis R. Rodriguez --- diff --git a/bin/ckmake b/bin/ckmake index 3d30bee84914..cd9741aed9a3 100755 --- a/bin/ckmake +++ b/bin/ckmake @@ -185,6 +185,62 @@ def sig_handler(signal, frame): clean() sys.exit(-2) +def get_rel_spec(rel): + if ("rc" in rel): + m = re.match(r"v*(?P\d+)\.+" \ + "(?P\d+)[.]+" \ + "(?P\d+)[-]+" \ + "\d+rc(?P\d+)\-*", + rel) + else: + m = re.match(r"v*(?P\d+)\.+" \ + "(?P\d+)[.]+" \ + "(?P\d+)[-]+" \ + "(?P\d+)\-*", + rel) + if (not m): + return m + rel_specs = m.groupdict() + return rel_specs + +def krel_same_base(new_rel, rel): + if (int(new_rel['ver']) != int(rel['ver'])): + return False + if (int(new_rel['pat']) != int(rel['pat'])): + return False + if (int(new_rel['ver']) == 3): + return True + if (int(new_rel['ver']) != 2): + return False + if (int(new_rel['sub']) == int(rel['sub'])): + return True + return False + +def krel_base_update(new_rel, rel): + if (not krel_same_base(new_rel, rel)): + return False + if (int(new_rel['sub']) > int(rel['sub'])): + return True + if (int(new_rel['sub']) < int(rel['sub'])): + return False + + # Too lazy to deal with 2.x kernels, + if (not new_rel['is_rc']): + return False + + if (int(new_rel['ext']) <= int(rel['ext'])): + return False + return True + +def krel_base_smaller(new_rel, rel): + if (not krel_same_base(new_rel, rel)): + return False + if (int(new_rel['sub']) > int(rel['sub'])): + return False + if (int(new_rel['sub']) < int(rel['sub'])): + return True + return False + class kernel_set(): def __init__(self, stdscr): self.queue = Queue() @@ -221,38 +277,47 @@ class kernel_set(): self.lock.acquire() self.stdscr.refresh() self.lock.release() + def evaluate_new_rel(self, new_rel): + for rel in self.releases: + if (krel_base_update(new_rel, rel)): + new_rel['idx'] = rel['idx'] + self.releases.remove(rel) + break + if (krel_base_smaller(new_rel, rel)): + return + self.releases.insert(new_rel['idx'], new_rel) def parse_releases(self): for dirname, dirnames, filenames in os.walk(modules): dirnames.sort() for subdirname in dirnames: - m = re.match(r"v*(?P\w+.)" \ - "(?P\w+.*)" \ - "(?P\w*)" \ - "(?P[.-]\w*)" \ - "(?P[-]\w*).*", \ - subdirname) - if not m: + specifics = get_rel_spec(subdirname) + if (not specifics): continue + rc = False - specifics = m.groupdict() - - ver = specifics['VERSION'] + \ - specifics['PATCHLEVEL'] + \ - specifics['SUBLEVEL'] + ver = specifics['VERSION'] + '.' + \ + specifics['PATCHLEVEL'] - for rel in self.releases: - if (rel['version'] == ver): - continue + if ("rc" in subdirname): + rc = True + ver = ver + '-rc' + specifics['EXTRAVERSION'] + else: + ver = ver + '.' + specifics['SUBLEVEL'] rel = dict(idx=len(self.releases), name=subdirname, full_path=dirname + '/' + - subdirname, + subdirname, version=ver, + is_rc = rc, + ver=specifics['VERSION'], + pat=specifics['PATCHLEVEL'], + sub=specifics['SUBLEVEL'], + ext=specifics['EXTRAVERSION'], processed=False, log='', status=1234) - self.releases.insert(rel['idx'], rel) + self.evaluate_new_rel(rel) self.refresh() def setup_screen(self): for i in range(0, len(self.releases)):