From c72be3e523aacb47fd5a5e0164485d6273e918ce Mon Sep 17 00:00:00 2001 From: Ilya Dryomov Date: Fri, 5 Dec 2014 20:26:30 +0300 Subject: [PATCH] kernel: fix commit hash matching in need_to_install(), take 2 Commit 10d7f9095fbb ("kernel: fix commit hash matching in need_to_install()") switched startswith() around to accommodate a shorter "want" version. That however broke the opposite case: when installing from gitbuilders "want" is actually a full 40-char hash. Do away with starswith() and just compare substrings. Signed-off-by: Ilya Dryomov --- teuthology/task/kernel.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/teuthology/task/kernel.py b/teuthology/task/kernel.py index cb2216a007..3329ac539c 100644 --- a/teuthology/task/kernel.py +++ b/teuthology/task/kernel.py @@ -151,7 +151,11 @@ def need_to_install(ctx, role, version): cur_sha1 = cur_sha1[0:dloc] log.debug('extracting sha1, {ver} -> {sha1}'.format( ver=cur_version, sha1=cur_sha1)) - if cur_sha1.startswith(version): + # FIXME: The above will match things like ...-generic on Ubuntu + # distro kernels resulting in 'eneric' cur_sha1. + m = min(len(cur_sha1), len(version)) + assert m >= 6, "cur_sha1 and/or version is too short, m = %d" % m + if cur_sha1[0:m] == version[0:m]: log.debug('extracted sha1 matches, do not need to install') ret = False else: -- 2.39.5