summaryrefslogtreecommitdiff
path: root/scripts/lib/mic/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/lib/mic/plugins')
-rw-r--r--scripts/lib/mic/plugins/imager/direct_plugin.py103
-rw-r--r--scripts/lib/mic/plugins/source/bootimg-efi.py166
-rw-r--r--scripts/lib/mic/plugins/source/bootimg-pcbios.py190
-rw-r--r--scripts/lib/mic/plugins/source/rootfs.py91
4 files changed, 0 insertions, 550 deletions
diff --git a/scripts/lib/mic/plugins/imager/direct_plugin.py b/scripts/lib/mic/plugins/imager/direct_plugin.py
deleted file mode 100644
index c05a400768..0000000000
--- a/scripts/lib/mic/plugins/imager/direct_plugin.py
+++ /dev/null
@@ -1,103 +0,0 @@
-# ex:ts=4:sw=4:sts=4:et
-# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
-#
-# Copyright (c) 2013, Intel Corporation.
-# All rights reserved.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License version 2 as
-# published by the Free Software Foundation.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License along
-# with this program; if not, write to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# DESCRIPTION
-# This implements the 'direct' imager plugin class for 'wic', based
-# loosely on the raw imager plugin from 'mic'
-#
-# AUTHORS
-# Tom Zanussi <tom.zanussi (at] linux.intel.com>
-#
-
-import os
-import shutil
-import re
-import tempfile
-
-from mic import msger
-from mic.utils import misc, fs_related, errors, runner, cmdln
-from mic.conf import configmgr
-from mic.plugin import pluginmgr
-
-import mic.imager.direct as direct
-from mic.pluginbase import ImagerPlugin
-
-class DirectPlugin(ImagerPlugin):
- name = 'direct'
-
- @classmethod
- def __rootfs_dir_to_dict(self, rootfs_dirs):
- """
- Gets a string that contain 'connection=dir' splitted by
- space and return a dict
- """
- krootfs_dir = {}
- for rootfs_dir in rootfs_dirs.split(' '):
- k, v = rootfs_dir.split('=')
- krootfs_dir[k] = v
-
- return krootfs_dir
-
- @classmethod
- def do_create(self, subcmd, opts, *args):
- """
- Create direct image, called from creator as 'direct' cmd
- """
- if len(args) != 9:
- raise errors.Usage("Extra arguments given")
-
- staging_data_dir = args[0]
- hdddir = args[1]
- native_sysroot = args[2]
- kernel_dir = args[3]
- bootimg_dir = args[4]
- rootfs_dir = args[5]
-
- creatoropts = configmgr.create
- ksconf = args[6]
-
- image_output_dir = args[7]
- oe_builddir = args[8]
-
- krootfs_dir = self.__rootfs_dir_to_dict(rootfs_dir)
-
- configmgr._ksconf = ksconf
-
- creator = direct.DirectImageCreator(oe_builddir,
- image_output_dir,
- krootfs_dir,
- bootimg_dir,
- kernel_dir,
- native_sysroot,
- hdddir,
- staging_data_dir,
- creatoropts)
-
- try:
- creator.create()
- creator.assemble()
- creator.finalize()
- creator.print_outimage_info()
-
- except errors.CreatorError:
- raise
- finally:
- creator.cleanup()
-
- return 0
diff --git a/scripts/lib/mic/plugins/source/bootimg-efi.py b/scripts/lib/mic/plugins/source/bootimg-efi.py
deleted file mode 100644
index 5b1a5332c4..0000000000
--- a/scripts/lib/mic/plugins/source/bootimg-efi.py
+++ /dev/null
@@ -1,166 +0,0 @@
-# ex:ts=4:sw=4:sts=4:et
-# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
-#
-# Copyright (c) 2014, Intel Corporation.
-# All rights reserved.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License version 2 as
-# published by the Free Software Foundation.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License along
-# with this program; if not, write to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# DESCRIPTION
-# This implements the 'bootimg-efi' source plugin class for 'wic'
-#
-# AUTHORS
-# Tom Zanussi <tom.zanussi (at] linux.intel.com>
-#
-
-import os
-import shutil
-import re
-import tempfile
-
-from mic import kickstart, msger
-from mic.utils import misc, fs_related, errors, runner, cmdln
-from mic.conf import configmgr
-from mic.plugin import pluginmgr
-import mic.imager.direct as direct
-from mic.pluginbase import SourcePlugin
-from mic.utils.oe.misc import *
-from mic.imager.direct import DirectImageCreator
-
-class BootimgEFIPlugin(SourcePlugin):
- name = 'bootimg-efi'
-
- @classmethod
- def do_configure_partition(self, part, cr, cr_workdir, oe_builddir,
- bootimg_dir, kernel_dir, native_sysroot):
- """
- Called before do_prepare_partition(), creates grubefi config
- """
- hdddir = "%s/hdd/boot" % cr_workdir
- rm_cmd = "rm -rf %s" % cr_workdir
- exec_cmd(rm_cmd)
-
- install_cmd = "install -d %s/EFI/BOOT" % hdddir
- exec_cmd(install_cmd)
-
- splash = os.path.join(cr_workdir, "/EFI/boot/splash.jpg")
- if os.path.exists(splash):
- splashline = "menu background splash.jpg"
- else:
- splashline = ""
-
- (rootdev, root_part_uuid) = cr._get_boot_config()
- options = cr.ks.handler.bootloader.appendLine
-
- grubefi_conf = ""
- grubefi_conf += "serial --unit=0 --speed=115200 --word=8 --parity=no --stop=1\n"
- grubefi_conf += "default=boot\n"
- timeout = kickstart.get_timeout(cr.ks)
- if not timeout:
- timeout = 0
- grubefi_conf += "timeout=%s\n" % timeout
- grubefi_conf += "menuentry 'boot'{\n"
-
- kernel = "/vmlinuz"
-
- if cr._ptable_format == 'msdos':
- rootstr = rootdev
- else:
- raise ImageError("Unsupported partition table format found")
-
- grubefi_conf += "linux %s root=%s rootwait %s\n" \
- % (kernel, rootstr, options)
- grubefi_conf += "}\n"
- if splashline:
- syslinux_conf += "%s\n" % splashline
-
- msger.debug("Writing grubefi config %s/hdd/boot/EFI/BOOT/grub.cfg" \
- % cr_workdir)
- cfg = open("%s/hdd/boot/EFI/BOOT/grub.cfg" % cr_workdir, "w")
- cfg.write(grubefi_conf)
- cfg.close()
-
- @classmethod
- def do_prepare_partition(self, part, cr, cr_workdir, oe_builddir, bootimg_dir,
- kernel_dir, rootfs_dir, native_sysroot):
- """
- Called to do the actual content population for a partition i.e. it
- 'prepares' the partition to be incorporated into the image.
- In this case, prepare content for an EFI (grub) boot partition.
- """
- if not bootimg_dir:
- bootimg_dir = get_bitbake_var("HDDDIR")
- if not bootimg_dir:
- msger.error("Couldn't find HDDDIR, exiting\n")
- # just so the result notes display it
- cr.set_bootimg_dir(bootimg_dir)
-
- staging_kernel_dir = kernel_dir
- staging_data_dir = bootimg_dir
-
- hdddir = "%s/hdd/boot" % cr_workdir
-
- install_cmd = "install -m 0644 %s/bzImage %s/bzImage" % \
- (staging_kernel_dir, hdddir)
- exec_cmd(install_cmd)
-
- shutil.copyfile("%s/hdd/boot/EFI/BOOT/grub.cfg" % cr_workdir,
- "%s/grub.cfg" % cr_workdir)
-
- cp_cmd = "cp %s/EFI/BOOT/* %s/EFI/BOOT" % (staging_data_dir, hdddir)
- exec_cmd(cp_cmd, True)
-
- shutil.move("%s/grub.cfg" % cr_workdir,
- "%s/hdd/boot/EFI/BOOT/grub.cfg" % cr_workdir)
-
- du_cmd = "du -bks %s" % hdddir
- out = exec_cmd(du_cmd)
- blocks = int(out.split()[0])
-
- extra_blocks = part.get_extra_block_count(blocks)
-
- if extra_blocks < BOOTDD_EXTRA_SPACE:
- extra_blocks = BOOTDD_EXTRA_SPACE
-
- blocks += extra_blocks
-
- msger.debug("Added %d extra blocks to %s to get to %d total blocks" % \
- (extra_blocks, part.mountpoint, blocks))
-
- # Ensure total sectors is an integral number of sectors per
- # track or mcopy will complain. Sectors are 512 bytes, and we
- # generate images with 32 sectors per track. This calculation is
- # done in blocks, thus the mod by 16 instead of 32.
- blocks += (16 - (blocks % 16))
-
- # dosfs image, created by mkdosfs
- bootimg = "%s/boot.img" % cr_workdir
-
- dosfs_cmd = "mkdosfs -n efi -C %s %d" % (bootimg, blocks)
- exec_native_cmd(dosfs_cmd, native_sysroot)
-
- mcopy_cmd = "mcopy -i %s -s %s/* ::/" % (bootimg, hdddir)
- exec_native_cmd(mcopy_cmd, native_sysroot)
-
- chmod_cmd = "chmod 644 %s" % bootimg
- exec_cmd(chmod_cmd)
-
- du_cmd = "du -Lbms %s" % bootimg
- out = exec_cmd(du_cmd)
- bootimg_size = out.split()[0]
-
- part.set_size(bootimg_size)
- part.set_source_file(bootimg)
-
-
diff --git a/scripts/lib/mic/plugins/source/bootimg-pcbios.py b/scripts/lib/mic/plugins/source/bootimg-pcbios.py
deleted file mode 100644
index 959cf411bf..0000000000
--- a/scripts/lib/mic/plugins/source/bootimg-pcbios.py
+++ /dev/null
@@ -1,190 +0,0 @@
-# ex:ts=4:sw=4:sts=4:et
-# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
-#
-# Copyright (c) 2014, Intel Corporation.
-# All rights reserved.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License version 2 as
-# published by the Free Software Foundation.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License along
-# with this program; if not, write to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# DESCRIPTION
-# This implements the 'bootimg-pcbios' source plugin class for 'wic'
-#
-# AUTHORS
-# Tom Zanussi <tom.zanussi (at] linux.intel.com>
-#
-
-import os
-import shutil
-import re
-import tempfile
-
-from mic import kickstart, msger
-from mic.utils import misc, fs_related, errors, runner, cmdln
-from mic.conf import configmgr
-from mic.plugin import pluginmgr
-import mic.imager.direct as direct
-from mic.pluginbase import SourcePlugin
-from mic.utils.oe.misc import *
-from mic.imager.direct import DirectImageCreator
-
-class BootimgPcbiosPlugin(SourcePlugin):
- name = 'bootimg-pcbios'
-
- @classmethod
- def do_install_disk(self, disk, disk_name, cr, workdir, oe_builddir,
- bootimg_dir, kernel_dir, native_sysroot):
- """
- Called after all partitions have been prepared and assembled into a
- disk image. In this case, we install the MBR.
- """
- mbrfile = "%s/syslinux/" % bootimg_dir
- if cr._ptable_format == 'msdos':
- mbrfile += "mbr.bin"
-
- if not os.path.exists(mbrfile):
- msger.error("Couldn't find %s. If using the -e option, do you have the right MACHINE set in local.conf? If not, is the bootimg_dir path correct?" % mbrfile)
-
- full_path = cr._full_path(workdir, disk_name, "direct")
- msger.debug("Installing MBR on disk %s as %s with size %s bytes" \
- % (disk_name, full_path, disk['min_size']))
-
- rc = runner.show(['dd', 'if=%s' % mbrfile,
- 'of=%s' % full_path, 'conv=notrunc'])
- if rc != 0:
- raise ImageError("Unable to set MBR to %s" % full_path)
-
- @classmethod
- def do_configure_partition(self, part, cr, cr_workdir, oe_builddir,
- bootimg_dir, kernel_dir, native_sysroot):
- """
- Called before do_prepare_partition(), creates syslinux config
- """
- hdddir = "%s/hdd/boot" % cr_workdir
- rm_cmd = "rm -rf " + cr_workdir
- exec_cmd(rm_cmd)
-
- install_cmd = "install -d %s" % hdddir
- exec_cmd(install_cmd)
-
- splash = os.path.join(cr_workdir, "/hdd/boot/splash.jpg")
- if os.path.exists(splash):
- splashline = "menu background splash.jpg"
- else:
- splashline = ""
-
- (rootdev, root_part_uuid) = cr._get_boot_config()
- options = cr.ks.handler.bootloader.appendLine
-
- syslinux_conf = ""
- syslinux_conf += "PROMPT 0\n"
- timeout = kickstart.get_timeout(cr.ks)
- if not timeout:
- timeout = 0
- syslinux_conf += "TIMEOUT " + str(timeout) + "\n"
- syslinux_conf += "\n"
- syslinux_conf += "ALLOWOPTIONS 1\n"
- syslinux_conf += "SERIAL 0 115200\n"
- syslinux_conf += "\n"
- if splashline:
- syslinux_conf += "%s\n" % splashline
- syslinux_conf += "DEFAULT boot\n"
- syslinux_conf += "LABEL boot\n"
-
- kernel = "/vmlinuz"
- syslinux_conf += "KERNEL " + kernel + "\n"
-
- if cr._ptable_format == 'msdos':
- rootstr = rootdev
- else:
- raise ImageError("Unsupported partition table format found")
-
- syslinux_conf += "APPEND label=boot root=%s %s\n" % (rootstr, options)
-
- msger.debug("Writing syslinux config %s/hdd/boot/syslinux.cfg" \
- % cr_workdir)
- cfg = open("%s/hdd/boot/syslinux.cfg" % cr_workdir, "w")
- cfg.write(syslinux_conf)
- cfg.close()
-
- @classmethod
- def do_prepare_partition(self, part, cr, cr_workdir, oe_builddir, bootimg_dir,
- kernel_dir, rootfs_dir, native_sysroot):
- """
- Called to do the actual content population for a partition i.e. it
- 'prepares' the partition to be incorporated into the image.
- In this case, prepare content for legacy bios boot partition.
- """
- if not bootimg_dir:
- bootimg_dir = get_bitbake_var("STAGING_DATADIR")
- if not bootimg_dir:
- msger.error("Couldn't find STAGING_DATADIR, exiting\n")
- # just so the result notes display it
- cr.set_bootimg_dir(bootimg_dir)
-
- staging_kernel_dir = kernel_dir
- staging_data_dir = bootimg_dir
-
- hdddir = "%s/hdd/boot" % cr_workdir
-
- install_cmd = "install -m 0644 %s/bzImage %s/vmlinuz" \
- % (staging_kernel_dir, hdddir)
- exec_cmd(install_cmd)
-
- install_cmd = "install -m 444 %s/syslinux/ldlinux.sys %s/ldlinux.sys" \
- % (staging_data_dir, hdddir)
- exec_cmd(install_cmd)
-
- du_cmd = "du -bks %s" % hdddir
- out = exec_cmd(du_cmd)
- blocks = int(out.split()[0])
-
- extra_blocks = part.get_extra_block_count(blocks)
-
- if extra_blocks < BOOTDD_EXTRA_SPACE:
- extra_blocks = BOOTDD_EXTRA_SPACE
-
- blocks += extra_blocks
-
- msger.debug("Added %d extra blocks to %s to get to %d total blocks" % \
- (extra_blocks, part.mountpoint, blocks))
-
- # Ensure total sectors is an integral number of sectors per
- # track or mcopy will complain. Sectors are 512 bytes, and we
- # generate images with 32 sectors per track. This calculation is
- # done in blocks, thus the mod by 16 instead of 32.
- blocks += (16 - (blocks % 16))
-
- # dosfs image, created by mkdosfs
- bootimg = "%s/boot.img" % cr_workdir
-
- dosfs_cmd = "mkdosfs -n boot -S 512 -C %s %d" % (bootimg, blocks)
- exec_native_cmd(dosfs_cmd, native_sysroot)
-
- mcopy_cmd = "mcopy -i %s -s %s/* ::/" % (bootimg, hdddir)
- exec_native_cmd(mcopy_cmd, native_sysroot)
-
- syslinux_cmd = "syslinux %s" % bootimg
- exec_native_cmd(syslinux_cmd, native_sysroot)
-
- chmod_cmd = "chmod 644 %s" % bootimg
- exec_cmd(chmod_cmd)
-
- du_cmd = "du -Lbms %s" % bootimg
- out = exec_cmd(du_cmd)
- bootimg_size = out.split()[0]
-
- part.set_size(bootimg_size)
- part.set_source_file(bootimg)
-
-
diff --git a/scripts/lib/mic/plugins/source/rootfs.py b/scripts/lib/mic/plugins/source/rootfs.py
deleted file mode 100644
index 8ebf62c10b..0000000000
--- a/scripts/lib/mic/plugins/source/rootfs.py
+++ /dev/null
@@ -1,91 +0,0 @@
-# ex:ts=4:sw=4:sts=4:et
-# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
-#
-# Copyright (c) 2014, Intel Corporation.
-# All rights reserved.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License version 2 as
-# published by the Free Software Foundation.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License along
-# with this program; if not, write to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# DESCRIPTION
-# This implements the 'rootfs' source plugin class for 'wic'
-#
-# AUTHORS
-# Tom Zanussi <tom.zanussi (at] linux.intel.com>
-# Joao Henrique Ferreira de Freitas <joaohf (at] gmail.com>
-#
-
-import os
-import shutil
-import re
-import tempfile
-
-from mic import kickstart, msger
-from mic.utils import misc, fs_related, errors, runner, cmdln
-from mic.conf import configmgr
-from mic.plugin import pluginmgr
-import mic.imager.direct as direct
-from mic.pluginbase import SourcePlugin
-from mic.utils.oe.misc import *
-from mic.imager.direct import DirectImageCreator
-
-class RootfsPlugin(SourcePlugin):
- name = 'rootfs'
-
- @staticmethod
- def __get_rootfs_dir(rootfs_dir):
- if os.path.isdir(rootfs_dir):
- return rootfs_dir
-
- bitbake_env_lines = find_bitbake_env_lines(rootfs_dir)
- if not bitbake_env_lines:
- msg = "Couldn't get bitbake environment, exiting."
- msger.error(msg)
-
- image_rootfs_dir = find_artifact(bitbake_env_lines, "IMAGE_ROOTFS")
- if not os.path.isdir(image_rootfs_dir):
- msg = "No valid artifact IMAGE_ROOTFS from image named"
- msg += " %s has been found at %s, exiting.\n" % \
- (rootfs_dir, image_rootfs_dir)
- msger.error(msg)
-
- return image_rootfs_dir
-
- @classmethod
- def do_prepare_partition(self, part, cr, cr_workdir, oe_builddir, bootimg_dir,
- kernel_dir, krootfs_dir, native_sysroot):
- """
- Called to do the actual content population for a partition i.e. it
- 'prepares' the partition to be incorporated into the image.
- In this case, prepare content for legacy bios boot partition.
- """
- if part.rootfs is None:
- if not 'ROOTFS_DIR' in krootfs_dir:
- msg = "Couldn't find --rootfs-dir, exiting"
- msger.error(msg)
- rootfs_dir = krootfs_dir['ROOTFS_DIR']
- else:
- if part.rootfs in krootfs_dir:
- rootfs_dir = krootfs_dir[part.rootfs]
- elif part.rootfs:
- rootfs_dir = part.rootfs
- else:
- msg = "Couldn't find --rootfs-dir=%s connection"
- msg += " or it is not a valid path, exiting"
- msger.error(msg % part.rootfs)
-
- real_rootfs_dir = self.__get_rootfs_dir(rootfs_dir)
-
- part.set_rootfs(real_rootfs_dir)
- part.prepare_rootfs(cr_workdir, oe_builddir, real_rootfs_dir, native_sysroot)
-