On Thu, Sep 07, 2017 at 10:34:32AM +0200, Jan Kiszka wrote: > On 2017-09-07 10:30, Andreas Reichel wrote: > > On Wed, Sep 06, 2017 at 08:17:34PM +0200, Jan Kiszka wrote: > >> On 2017-09-06 13:34, [ext] Andreas J. Reichel wrote: > >>> From: Andreas Reichel <[email protected]> > >>> > >>> Add wic plugins for > >>> * efibootguard EFI partition > >>> * efibootguard config partition(s) > >>> > >>> Signed-off-by: Andreas Reichel <[email protected]> > >>> --- > >>> .../lib/wic/plugins/source/efibootguard-boot.py | 139 > >>> +++++++++++++++++++++ > >>> scripts/lib/wic/plugins/source/efibootguard-efi.py | 106 ++++++++++++++++ > >>> 2 files changed, 245 insertions(+) > >>> create mode 100644 scripts/lib/wic/plugins/source/efibootguard-boot.py > >>> create mode 100644 scripts/lib/wic/plugins/source/efibootguard-efi.py > >>> > >>> diff --git a/scripts/lib/wic/plugins/source/efibootguard-boot.py > >>> b/scripts/lib/wic/plugins/source/efibootguard-boot.py > >>> new file mode 100644 > >>> index 0000000..de584ba > >>> --- /dev/null > >>> +++ b/scripts/lib/wic/plugins/source/efibootguard-boot.py > >>> @@ -0,0 +1,139 @@ > >>> +# ex:ts=4:sw=4:sts=4:et > >>> +# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- > >>> +# > >>> +# Copyright (c) 2017, Siemens AG. > >>> +# 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> > >>> +# Claudius Heine <ch (at] denx.de> > >>> +# Andreas Reichel <andreas.reichel (at] tngtech.com> > >>> + > >>> +import os > >>> +import shutil > >>> + > >>> +from wic import msger > >>> +from wic.pluginbase import SourcePlugin > >>> +from wic.utils.misc import get_custom_config > >>> +from wic.utils.oe.misc import exec_cmd, exec_native_cmd, > >>> get_bitbake_var, \ > >>> + BOOTDD_EXTRA_SPACE > >>> + > >>> +class EfibootguardBootPlugin(SourcePlugin): > >>> + """ > >>> + Create boot partition. > >>> + This plugin supports efibootguard bootloader. > >>> + """ > >>> + > >>> + name = 'efibootguard-boot' > >>> + > >>> + @classmethod > >>> + def do_configure_partition(cls, part, source_params, creator, > >>> cr_workdir, > >>> + oe_builddir, bootimg_dir, kernel_dir, > >>> + native_sysroot): > >>> + """ > >>> + Called before do_prepare_partition(), creates loader-specific > >>> config > >>> + """ > >>> + hdddir = "%s/hdd/%s.%s" % (cr_workdir, part.label, part.lineno) > >>> + > >>> + install_cmd = "install -d %s" % hdddir > >>> + exec_cmd(install_cmd) > >>> + > >>> + bootloader = creator.ks.bootloader > >>> + > >>> + cmdline = "root=%s %s\n" % \ > >>> + (creator.rootdev, bootloader.append) > >>> + > >>> + cwd = os.getcwd() > >>> + os.chdir(hdddir) > >>> + config_cmd = 'bg_setenv -f -k "C:%s:bzImage" -a "%s" -r %s -w > >>> %s' % \ > >>> + (part.label.upper(), \ > >>> + cmdline.strip(), \ > >>> + source_params.get("revision", 1), \ > >>> + source_params.get("watchdog", 5)) > >>> + > >>> + exec_native_cmd(config_cmd, native_sysroot) > >>> + os.chdir(cwd) > >>> + > >>> + @classmethod > >>> + def do_prepare_partition(cls, part, source_params, creator, > >>> 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("HDDDIR not set, exiting\n") > >>> + os.exit(1) > >>> + > >>> + # just so the result notes display it > >>> + creator.set_bootimg_dir(bootimg_dir) > >>> + > >>> + staging_kernel_dir = kernel_dir > >>> + > >>> + hdddir = "%s/hdd/%s.%s" % (cr_workdir, part.label, part.lineno) > >>> + > >>> + install_cmd = "install -m 0644 %s/bzImage %s/bzImage" % \ > >>> + (staging_kernel_dir, hdddir) > >>> + exec_cmd(install_cmd) > >>> + > >>> + # Write label as utf-16le to EFILABEL file > >>> + fd = open("%s/EFILABEL" % hdddir, 'wb') > >>> + fd.write(part.label.upper().encode("utf-16le")) > >>> + fd.close() > >>> + > >>> + du_cmd = "du -bks %s" % hdddir > >>> + out = exec_cmd(du_cmd) > >>> + blocks = int(out.split()[0]) > >>> + > >>> + # Calculate number of extra blocks to be sure that the resulting > >>> + # partition image has the wanted size. > >>> + 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)) > >>> + > >>> + # dosfs image, created by mkdosfs > >>> + bootimg = "%s/%s.%s.img" % (cr_workdir, part.label, part.lineno) > >>> + > >>> + dosfs_cmd = "mkdosfs -F 16 -n %s -C %s %d" % > >>> (part.label.upper(), \ > >>> + 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 -Lbks %s" % bootimg > >>> + out = exec_cmd(du_cmd) > >>> + bootimg_size = out.split()[0] > >>> + > >>> + part.size = int(bootimg_size) > >>> + part.source_file = bootimg > >>> diff --git a/scripts/lib/wic/plugins/source/efibootguard-efi.py > >>> b/scripts/lib/wic/plugins/source/efibootguard-efi.py > >>> new file mode 100644 > >>> index 0000000..9fe50b0 > >>> --- /dev/null > >>> +++ b/scripts/lib/wic/plugins/source/efibootguard-efi.py > >>> @@ -0,0 +1,106 @@ > >>> +# ex:ts=4:sw=4:sts=4:et > >>> +# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- > >>> +# > >>> +# Copyright (c) 2017, Siemens AG. > >>> +# All rights reserved. > >> > >> Are you missing Intel here? The authors list below suggests this. > > > > The code in the file is a rewrite. Intel is replaced > > because of that. But I do not know, how to proceed here correctly... > > If it is a rewrite, leaving no worth mentioning code of the original > file behind, then Tom is no longer an author. Otherwise, leave in the > original copyright notice AND his name. > > What's the file your copied at least this header from? >
Claudius originally wrote on this version and it stems from poky/scripts/lib/wic/plugins/source/bootimg-efi.py Having a look at the last part of the file, we should keep Intel and Tom Zanussi. Andreas > >> > >>> +# > >>> +# 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> > >>> +# Claudius Heine <ch (at] denx.de> > >>> +# Andreas Reichel <andreas.reichel (at] tngtech.com> > >> > >> Is this formatting OE practice? Otherwise, I would prefer using our > >> default pattern consistently (copyright line, then Authors list). > >> > > Yes, this is OE practise. > > OK. > > Jan > > -- > Siemens AG, Corporate Technology, CT RDA ITP SES-DE > Corporate Competence Center Embedded Linux -- Andreas Reichel Dipl.-Phys. (Univ.) Software Consultant [email protected], +49-174-3180074 TNG Technology Consulting GmbH, Betastr. 13a, 85774 Unterfoehring Geschaeftsfuehrer: Henrik Klagges, Dr. Robert Dahlke, Gerhard Mueller Sitz: Unterfoehring * Amtsgericht Muenchen * HRB 135082 -- You received this message because you are subscribed to the Google Groups "EFI Boot Guard" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/efibootguard-dev/20170907084441.GA1480%40iiotirae. For more options, visit https://groups.google.com/d/optout.
