wic: code cleanup

Fixed indentation, unused imports, trailing lines etc.

[YOCTO #10619]

(From OE-Core rev: 5fa7768bfb4b6d464c6a812822b0665f52e7bea4)

Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Ed Bartosh
2017-01-31 19:31:55 +02:00
committed by Richard Purdie
parent 1f7ce90af6
commit 653aaea3cc
15 changed files with 36 additions and 43 deletions

View File

@@ -29,7 +29,6 @@ import uuid
import tempfile
from time import strftime
from os.path import basename, splitext
from wic import msger
from wic.ksparser import KickStart, KickStartError
@@ -65,7 +64,7 @@ class DirectPlugin(ImagerPlugin):
except KickStartError as err:
msger.error(str(err))
name = "%s-%s" % (splitext(basename(ksconf))[0],
name = "%s-%s" % (os.path.splitext(os.path.basename(ksconf))[0],
strftime("%Y%m%d%H%M"))
# parse possible 'rootfs=name' items

View File

@@ -42,7 +42,7 @@ class BootimgEFIPlugin(SourcePlugin):
name = 'bootimg-efi'
@classmethod
def do_configure_grubefi(cls, hdddir, creator, cr_workdir, source_params):
def do_configure_grubefi(cls, creator, cr_workdir):
"""
Create loader-specific (grub-efi) config
"""
@@ -54,10 +54,10 @@ class BootimgEFIPlugin(SourcePlugin):
# Use a custom configuration for grub
grubefi_conf = custom_cfg
msger.debug("Using custom configuration file "
"%s for grub.cfg" % configfile)
"%s for grub.cfg" % configfile)
else:
msger.error("configfile is specified but failed to "
"get it from %s." % configfile)
"get it from %s." % configfile)
if not custom_cfg:
# Create grub configuration using parameters from wks file
@@ -125,10 +125,10 @@ class BootimgEFIPlugin(SourcePlugin):
# Use a custom configuration for systemd-boot
boot_conf = custom_cfg
msger.debug("Using custom configuration file "
"%s for systemd-boots's boot.conf" % configfile)
"%s for systemd-boots's boot.conf" % configfile)
else:
msger.error("configfile is specified but failed to "
"get it from %s." % configfile)
"get it from %s." % configfile)
if not custom_cfg:
# Create systemd-boot configuration using parameters from wks file
@@ -164,7 +164,7 @@ class BootimgEFIPlugin(SourcePlugin):
try:
if source_params['loader'] == 'grub-efi':
cls.do_configure_grubefi(hdddir, creator, cr_workdir, source_params)
cls.do_configure_grubefi(creator, cr_workdir)
elif source_params['loader'] == 'systemd-boot':
cls.do_configure_systemdboot(hdddir, creator, cr_workdir, source_params)
else:
@@ -185,7 +185,7 @@ class BootimgEFIPlugin(SourcePlugin):
if not bootimg_dir:
bootimg_dir = get_bitbake_var("DEPLOY_DIR_IMAGE")
if not bootimg_dir:
msger.error("Couldn't find DEPLOY_DIR_IMAGE, exiting\n")
msger.error("Couldn't find DEPLOY_DIR_IMAGE, exiting\n")
# just so the result notes display it
creator.set_bootimg_dir(bootimg_dir)

View File

@@ -26,10 +26,11 @@
import os
import re
from glob import glob
from wic import msger
from wic.pluginbase import SourcePlugin
from wic.utils.misc import exec_cmd, get_bitbake_var
from glob import glob
class BootimgPartitionPlugin(SourcePlugin):
"""
@@ -137,4 +138,3 @@ class BootimgPartitionPlugin(SourcePlugin):
msger.debug('Prepare boot partition using rootfs in %s' % (hdddir))
part.prepare_rootfs(cr_workdir, oe_builddir, hdddir,
native_sysroot)

View File

@@ -198,7 +198,5 @@ class BootimgPcbiosPlugin(SourcePlugin):
out = exec_cmd(du_cmd)
bootimg_size = out.split()[0]
part.size = int(out.split()[0])
part.size = int(bootimg_size)
part.source_file = bootimg

View File

@@ -100,10 +100,10 @@ class IsoImagePlugin(SourcePlugin):
grubefi_conf = get_custom_config(configfile)
if grubefi_conf:
msger.debug("Using custom configuration file "
"%s for grub.cfg" % configfile)
"%s for grub.cfg" % configfile)
else:
msger.error("configfile is specified but failed to "
"get it from %s." % configfile)
"get it from %s." % configfile)
else:
splash = os.path.join(cr_workdir, "EFI/boot/splash.jpg")
if os.path.exists(splash):
@@ -285,6 +285,7 @@ class IsoImagePlugin(SourcePlugin):
if not deploy_dir:
msger.error("Couldn't find DEPLOY_DIR_IMAGE, exiting\n")
cp_cmd = "cp %s/%s %s" % (deploy_dir, initrd, cr_workdir)
exec_cmd(cp_cmd)
else:
# Prepare initial ramdisk
initrd = "%s/initrd" % deploy_dir
@@ -293,8 +294,7 @@ class IsoImagePlugin(SourcePlugin):
if not os.path.isfile(initrd):
initrd = cls._build_initramfs_path(rootfs_dir, cr_workdir)
install_cmd = "install -m 0644 %s %s/initrd" \
% (initrd, isodir)
install_cmd = "install -m 0644 %s %s/initrd" % (initrd, isodir)
exec_cmd(install_cmd)
# Remove the temporary file created by _build_initramfs_path function
@@ -303,7 +303,7 @@ class IsoImagePlugin(SourcePlugin):
# Install bzImage
install_cmd = "install -m 0644 %s/bzImage %s/bzImage" % \
(kernel_dir, isodir)
(kernel_dir, isodir)
exec_cmd(install_cmd)
#Create bootloader for efi boot
@@ -362,7 +362,6 @@ class IsoImagePlugin(SourcePlugin):
exec_native_cmd(grub_cmd, native_sysroot)
else:
# TODO: insert gummiboot stuff
msger.error("unrecognized bootimg-efi loader: %s" \
% source_params['loader'])
except KeyError:

View File

@@ -84,4 +84,3 @@ class RawCopyPlugin(SourcePlugin):
part.size = filesize
part.source_file = dst

View File

@@ -79,5 +79,5 @@ class RootfsPlugin(SourcePlugin):
real_rootfs_dir = cls.__get_rootfs_dir(rootfs_dir)
part.rootfs_dir = real_rootfs_dir
part.prepare_rootfs(cr_workdir, oe_builddir, real_rootfs_dir, native_sysroot)
part.prepare_rootfs(cr_workdir, oe_builddir,
real_rootfs_dir, native_sysroot)