]> git.apps.os.sepia.ceph.com Git - teuthology.git/commitdiff
kernel: fix commit hash matching in need_to_install(), take 2
authorIlya Dryomov <idryomov@redhat.com>
Fri, 5 Dec 2014 17:26:30 +0000 (20:26 +0300)
committerIlya Dryomov <idryomov@redhat.com>
Thu, 11 Dec 2014 14:30:31 +0000 (17:30 +0300)
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 <idryomov@redhat.com>
teuthology/task/kernel.py

index cb2216a0071efa43df9f73a0a394c8952548d081..3329ac539c61745bcdfe5fc84e4dd1440f822827 100644 (file)
@@ -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: