From c84ac6ba5eb892a54128e42649b9beb53fc1c20e Mon Sep 17 00:00:00 2001 From: Praveen K Pandey Date: Wed, 3 Oct 2018 11:52:08 +0530 Subject: [PATCH] Fixed issue address issue #2873 (kernel library) as when url not passed while kernel download avocado error out as TypeError: unsupported operand type(s) for +: 'NoneType' and 'str' when url not passed it uses default else try to use custome url as base url Reported-by: lolyu Signed-off-by: Praveen K Pandey --- avocado/utils/kernel.py | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/avocado/utils/kernel.py b/avocado/utils/kernel.py index 30332be7..23535397 100644 --- a/avocado/utils/kernel.py +++ b/avocado/utils/kernel.py @@ -71,9 +71,15 @@ class KernelBuild(object): source tarball :type url: str or None """ + kernel_file = self.SOURCE.format(version=self.version) - if url is not None: + # if there's no url to override, the default is the one + # specified in the class + if url is None: base_url = self.URL.format(major=self.version.split('.', 1)[0]) + + # however, if there's a url informed as a parameter, this one + # should be used as the base url. else: base_url = url full_url = base_url + kernel_file @@ -94,7 +100,8 @@ class KernelBuild(object): Configure/prepare kernel source to build. """ self.linux_dir = os.path.join(self.work_dir, 'linux-%s' % self.version) - build.make(self.linux_dir, extra_args='-C %s mrproper' % self.linux_dir) + build.make(self.linux_dir, extra_args='-C %s mrproper' % + self.linux_dir) if self.config_path is not None: dotconfig = os.path.join(self.linux_dir, '.config') shutil.copy(self.config_path, dotconfig) @@ -114,10 +121,13 @@ class KernelBuild(object): if self.distro.name == "Ubuntu": build_output_format = "deb-pkg" if self.config_path is None: - build.make(self.linux_dir, extra_args='-C %s defconfig' % self.linux_dir) + build.make(self.linux_dir, extra_args='-C %s defconfig' % + self.linux_dir) else: - build.make(self.linux_dir, extra_args='-C %s olddefconfig' % self.linux_dir) - build.make(self.linux_dir, extra_args='-C %s %s' % (self.linux_dir, build_output_format)) + build.make(self.linux_dir, extra_args='-C %s olddefconfig' % + self.linux_dir) + build.make(self.linux_dir, extra_args='-C %s %s' % + (self.linux_dir, build_output_format)) def install(self): """ @@ -125,7 +135,8 @@ class KernelBuild(object): """ log.info("Starting kernel install") if self.distro.name == "Ubuntu": - process.run('dpkg -i %s/*.deb' % self.work_dir, shell=True, sudo=True) + process.run('dpkg -i %s/*.deb' % + self.work_dir, shell=True, sudo=True) else: log.info("Skipping kernel install") -- GitLab