Fixed indentation, unused imports, trailing lines etc.
[YOCTO #10619]
Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com>
+++ /dev/null
-VERSION = "2.00"
crobj = creator.Creator()
cmdline = ["direct", native_sysroot, kernel_dir, bootimg_dir, rootfs_dir,
- wks_file, image_output_dir, oe_builddir, compressor or ""]
+ wks_file, image_output_dir, oe_builddir, compressor or ""]
if bmap:
cmdline.append('--bmap')
from wic.plugin import pluginmgr, PLUGIN_TYPES
def subcommand_error(args):
- logging.info("invalid subcommand %s" % args[0])
+ logging.info("invalid subcommand %s", args[0])
def display_help(subcommand, subcommands):
elif args[0] == "help":
wic_help(args, main_command_usage, subcommands)
elif args[0] not in subcommands:
- logging.error("Unsupported subcommand %s, exiting\n" % (args[0]))
+ logging.error("Unsupported subcommand %s, exiting\n", args[0])
parser.print_help()
return 1
else:
# further processing required Partition.size to be an integer, make
# sure that it is one
- if type(self.size) is not int:
+ if not isinstance(self.size, int):
msger.error("Partition %s internal size is not an integer. " \
"This a bug in source plugin %s and needs to be fixed." \
% (self.mountpoint, self.source))
# IMAGE_OVERHEAD_FACTOR and IMAGE_ROOTFS_EXTRA_SPACE
rsize_bb = get_bitbake_var('ROOTFS_SIZE')
if rsize_bb:
- msger.warning('overhead-factor was specified, but size was not, so bitbake variables will be used for the size. In this case both IMAGE_OVERHEAD_FACTOR and --overhead-factor will be applied')
+ msger.warning('overhead-factor was specified, but size was not,'
+ ' so bitbake variables will be used for the size.'
+ ' In this case both IMAGE_OVERHEAD_FACTOR and '
+ '--overhead-factor will be applied')
self.size = int(round(float(rsize_bb)))
for prefix in ("ext", "btrfs", "vfat", "squashfs"):
"Proceeding as requested." % self.mountpoint)
path = "%s/fs_%s.%s" % (cr_workdir, self.label, self.fstype)
- os.path.isfile(path) and os.remove(path)
+ if os.path.isfile(path):
+ os.remove(path)
# it is not possible to create a squashfs without source data,
# thus prepare an empty temp dir that is used as source
label_str = "-L %s" % self.label
mkswap_cmd = "mkswap %s -U %s %s" % (label_str, str(uuid.uuid1()), path)
exec_native_cmd(mkswap_cmd, native_sysroot)
-
# with this program; if not, write to the Free Software Foundation, Inc., 59
# Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-import os, sys
+import os
+import sys
from wic import msger
from wic import pluginbase
__all__ = ['ImagerPlugin', 'SourcePlugin', 'get_plugins']
-import sys
from collections import defaultdict
from wic import msger
import tempfile
from time import strftime
-from os.path import basename, splitext
from wic import msger
from wic.ksparser import KickStart, KickStartError
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
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
"""
# 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
# 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
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:
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)
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):
"""
msger.debug('Prepare boot partition using rootfs in %s' % (hdddir))
part.prepare_rootfs(cr_workdir, oe_builddir, hdddir,
native_sysroot)
-
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
-
-
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):
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
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
# 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
exec_native_cmd(grub_cmd, native_sysroot)
else:
- # TODO: insert gummiboot stuff
msger.error("unrecognized bootimg-efi loader: %s" \
% source_params['loader'])
except KeyError:
part.size = filesize
part.source_file = dst
-
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)
msger.debug("_exec_cmd: output for %s (rc = %d): %s" % \
(cmd_and_args, ret, out))
- return (ret, out)
+ return ret, out
def exec_cmd(cmd_and_args, as_shell=False, catch=3):
"""
- Execute command, catching stderr, stdout
-
- Exits if rc non-zero
+ Execute command, return output
"""
- ret, out = _exec_cmd(cmd_and_args, as_shell, catch)
+ return _exec_cmd(cmd_and_args, as_shell, catch)[1]
- return out
def exec_native_cmd(cmd_and_args, native_sysroot, catch=3, pseudo=""):
"""
import os
from wic import msger
from wic.utils.errors import ImageError
-from wic.utils.misc import exec_cmd, exec_native_cmd
+from wic.utils.misc import exec_native_cmd
from wic.filemap import sparse_copy
# Overhead of the MBR partitioning scheme (just one sector)
if self.disks:
for dev in self.disks:
disk = self.disks[dev]
- try:
+ if hasattr(disk['disk'], 'cleanup'):
disk['disk'].cleanup()
- except:
- pass
+
# remove partition images
for image in self.partimages:
if os.path.isfile(image):