From d3c294d20692c2e543135bfd650c05e81c76052e Mon Sep 17 00:00:00 2001 From: Sandon Van Ness Date: Thu, 13 Mar 2014 16:02:04 -0700 Subject: [PATCH] Make distro kernels work on Trusty. Some grub changes and package names caused them to fail on trusty. Signed-off-by: Sandon Van Ness --- teuthology/task/kernel.py | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/teuthology/task/kernel.py b/teuthology/task/kernel.py index 933b15c928b44..7d63190dcc04f 100644 --- a/teuthology/task/kernel.py +++ b/teuthology/task/kernel.py @@ -603,7 +603,13 @@ def install_distro_kernel(remote): menuentry = '' for line in grub2conf.split('\n'): if 'submenu' in line: - submenu = line.split('"')[1] + submenu = line.split('submenu ')[1] + # Ubuntu likes to be sneaky and change formatting of + # grub.cfg between quotes/doublequotes between versions + if submenu.startswith("'"): + submenu = submenu.split("'")[1] + if submenu.startswith('"'): + submenu = submenu.split('"')[1] if 'menuentry' in line: if newversion in line and 'recovery' not in line: menuentry = line.split('\'')[1] @@ -747,12 +753,18 @@ def get_version_from_pkg(remote, ostype): return newest #Ubuntu is a depend in a depend. if 'ubuntu' in ostype: - remote.run(args=['sudo', 'apt-get', '-y', 'install', 'linux-image-current-generic' ], stdout=output, stderr=err_mess ) - remote.run(args=['dpkg', '-s', 'linux-image-current-generic' ], stdout=output, stderr=err_mess ) - for line in output.getvalue().split('\n'): - if 'Depends:' in line: - depends = line.split('Depends: ')[1] - remote.run(args=['dpkg', '-s', depends ], stdout=output, stderr=err_mess ) + try: + remote.run(args=['sudo', 'apt-get', '-y', 'install', 'linux-image-current-generic' ], stdout=output, stderr=err_mess ) + remote.run(args=['dpkg', '-s', 'linux-image-current-generic' ], stdout=output, stderr=err_mess ) + for line in output.getvalue().split('\n'): + if 'Depends:' in line: + depends = line.split('Depends: ')[1] + remote.run(args=['dpkg', '-s', depends ], stdout=output, stderr=err_mess ) + except run.CommandFailedError: + # Non precise ubuntu machines (like trusty) don't have + # linux-image-current-generic so use linux-image-generic instead. + remote.run(args=['sudo', 'apt-get', '-y', 'install', 'linux-image-generic' ], stdout=output, stderr=err_mess ) + remote.run(args=['dpkg', '-s', 'linux-image-generic' ], stdout=output, stderr=err_mess ) for line in output.getvalue().split('\n'): if 'Depends:' in line: newest = line.split('linux-image-')[1] -- 2.39.5