wic improvements
cover wic improvements
Hi,
This patchset included various wic improvements:
- Fixed boot failure caused by switched off ext3 in the kernel
- Moved all wic modules to scripts/lib/wic
- Removed mic leftovers
- Removed 3rd party command line parser cmdln
- Covered building of all canned images with tests
- Code cleanup
The following changes since commit 71b0568fa43285f0946fae93fb43cea5f3bbecec:
rt-tests: drop unnecessary added-missing-dependencies.patch (2015-09-01 11:44:04 +0100)
are available in the git repository at:
git://git.yoctoproject.org/poky-contrib ed/wic/misc
http://git.yoctoproject.org/cgit.cgi/poky-contrib/log/?h=ed/wic/misc
Ed Bartosh (17):
wic: use ext4 in canned .wks files
wic: get rid of scripts/lib/image
oe-selftest: wic: configure a build
wic: add test cases for 3 images
wic: fix typo
wic: remove micpartition.py
wic: remove micboot.py
wic: fix errors in partition.py module
wic: get rid of wildcard imports
wic: fix pylint warning multiple-statements
wic: use optparse instead of cmdln
wic: fix pylint warning no-member
wic: fix pylint warning unused-variable
wic: fix pylint warning redefined-builtin
wic: get rid of listing properties
wic: fix short variable names
image.py: rename _write_env -> _write_wic_env
meta/lib/oe/image.py | 4 +-
meta/lib/oeqa/selftest/wic.py | 34 +-
scripts/lib/image/__init__.py | 22 -
.../{image => wic}/canned-wks/directdisk-gpt.wks | 4 +-
.../canned-wks/directdisk-multi-rootfs.wks | 6 +-
.../lib/{image => wic}/canned-wks/directdisk.wks | 4 +-
.../lib/{image => wic}/canned-wks/mkefidisk.wks | 4 +-
.../lib/{image => wic}/canned-wks/mkgummidisk.wks | 4 +-
.../lib/{image => wic}/canned-wks/mkhybridiso.wks | 2 +-
.../canned-wks/qemux86-directdisk.wks | 0
.../{image => wic}/canned-wks/sdimage-bootpart.wks | 0
scripts/lib/wic/conf.py | 5 +-
scripts/lib/{image => wic}/config/wic.conf | 0
scripts/lib/wic/creator.py | 115 +-
scripts/lib/{image => wic}/engine.py | 141 +-
scripts/lib/{image => wic}/help.py | 97 +-
scripts/lib/wic/imager/baseimager.py | 8 +-
scripts/lib/wic/imager/direct.py | 74 +-
scripts/lib/wic/kickstart/__init__.py | 66 +-
.../lib/wic/kickstart/custom_commands/__init__.py | 4 -
.../lib/wic/kickstart/custom_commands/micboot.py | 50 -
.../wic/kickstart/custom_commands/micpartition.py | 57 -
.../lib/wic/kickstart/custom_commands/partition.py | 108 +-
.../lib/wic/kickstart/custom_commands/wicboot.py | 31 +-
scripts/lib/wic/msger.py | 13 +-
scripts/lib/wic/plugin.py | 14 +-
scripts/lib/wic/pluginbase.py | 14 +-
scripts/lib/wic/plugins/imager/direct_plugin.py | 6 +-
scripts/lib/wic/plugins/source/bootimg-efi.py | 32 +-
scripts/lib/wic/plugins/source/bootimg-pcbios.py | 34 +-
.../lib/wic/plugins/source/isoimage-isohybrid.py | 32 +-
scripts/lib/wic/utils/cmdln.py | 1585 --------------------
scripts/lib/wic/utils/oe/misc.py | 2 +-
scripts/lib/wic/utils/partitionedfs.py | 154 +-
scripts/lib/wic/utils/runner.py | 19 +-
scripts/wic | 23 +-
36 files changed, 463 insertions(+), 2305 deletions(-)
delete mode 100644 scripts/lib/image/__init__.py
rename scripts/lib/{image => wic}/canned-wks/directdisk-gpt.wks (75%)
rename scripts/lib/{image => wic}/canned-wks/directdisk-multi-rootfs.wks (87%)
rename scripts/lib/{image => wic}/canned-wks/directdisk.wks (70%)
rename scripts/lib/{image => wic}/canned-wks/mkefidisk.wks (76%)
rename scripts/lib/{image => wic}/canned-wks/mkgummidisk.wks (76%)
rename scripts/lib/{image => wic}/canned-wks/mkhybridiso.wks (96%)
rename scripts/lib/{image => wic}/canned-wks/qemux86-directdisk.wks (100%)
rename scripts/lib/{image => wic}/canned-wks/sdimage-bootpart.wks (100%)
rename scripts/lib/{image => wic}/config/wic.conf (100%)
rename scripts/lib/{image => wic}/engine.py (59%)
rename scripts/lib/{image => wic}/help.py (88%)
delete mode 100644 scripts/lib/wic/kickstart/custom_commands/micboot.py
delete mode 100644 scripts/lib/wic/kickstart/custom_commands/micpartition.py
delete mode 100644 scripts/lib/wic/utils/cmdln.py--
Ed
PATCH 1/17 wic: use ext4 in canned .wks files
Latest kernel doesn't have ext3 compiled in. Wic images produced from canned .wks can't boot because of that. Switching to ext4 fixes this issue.
--- scripts/lib/image/canned-wks/directdisk-gpt.wks | 4 ++-- scripts/lib/image/canned-wks/directdisk-multi-rootfs.wks | 6 +++--- scripts/lib/image/canned-wks/directdisk.wks | 4 ++-- scripts/lib/image/canned-wks/mkefidisk.wks | 4 ++-- scripts/lib/image/canned-wks/mkgummidisk.wks | 4 ++-- scripts/lib/image/canned-wks/mkhybridiso.wks | 2 +- 6 files changed, 12 insertions(+), 12 deletions(-)
scripts/lib/image/canned-wks/directdisk-gpt.wks +2 -2
@@ -4,7 +4,7 @@ part /boot --source bootimg-pcbios --ondisk sda --label boot --active --align 1024 -part / --source rootfs --ondisk sda --fstype=ext3 --label platform --align 1024 --use-uuid +part / --source rootfs --ondisk sda --fstype=ext4 --label platform --align 1024 --use-uuid -bootloader --ptable gpt --timeout=0 --append="rootwait rootfstype=ext3 video=vesafb vga=0x318 console=tty0" +bootloader --ptable gpt --timeout=0 --append="rootwait rootfstype=ext4 video=vesafb vga=0x318 console=tty0"
scripts/lib/image/canned-wks/directdisk-multi-rootfs.wks +3 -3
@@ -16,8 +16,8 @@ # - or any combinations of -r and --rootfs command line options part /boot --source bootimg-pcbios --ondisk sda --label boot --active --align 1024 -part / --source rootfs --rootfs-dir=rootfs1 --ondisk sda --fstype=ext3 --label platform --align 1024 -part /rescue --source rootfs --rootfs-dir=rootfs2 --ondisk sda --fstype=ext3 --label secondary --align 1024 +part / --source rootfs --rootfs-dir=rootfs1 --ondisk sda --fstype=ext4 --label platform --align 1024 +part /rescue --source rootfs --rootfs-dir=rootfs2 --ondisk sda --fstype=ext4 --label secondary --align 1024 -bootloader --timeout=0 --append="rootwait rootfstype=ext3 video=vesafb vga=0x318 console=tty0" +bootloader --timeout=0 --append="rootwait rootfstype=ext4 video=vesafb vga=0x318 console=tty0"
scripts/lib/image/canned-wks/directdisk.wks +2 -2
@@ -4,7 +4,7 @@ part /boot --source bootimg-pcbios --ondisk sda --label boot --active --align 1024 -part / --source rootfs --ondisk sda --fstype=ext3 --label platform --align 1024 +part / --source rootfs --ondisk sda --fstype=ext4 --label platform --align 1024 -bootloader --timeout=0 --append="rootwait rootfstype=ext3 video=vesafb vga=0x318 console=tty0" +bootloader --timeout=0 --append="rootwait rootfstype=ext4 video=vesafb vga=0x318 console=tty0"
scripts/lib/image/canned-wks/mkefidisk.wks +2 -2
@@ -4,8 +4,8 @@ part /boot --source bootimg-efi --sourceparams="loader=grub-efi" --ondisk sda --label msdos --active --align 1024 -part / --source rootfs --ondisk sda --fstype=ext3 --label platform --align 1024 +part / --source rootfs --ondisk sda --fstype=ext4 --label platform --align 1024 part swap --ondisk sda --size 44 --label swap1 --fstype=swap -bootloader --timeout=10 --append="rootwait rootfstype=ext3 console=ttyPCH0,115200 console=tty0 vmalloc=256MB snd-hda-intel.enable_msi=0" +bootloader --timeout=10 --append="rootwait rootfstype=ext4 console=ttyPCH0,115200 console=tty0 vmalloc=256MB snd-hda-intel.enable_msi=0"
scripts/lib/image/canned-wks/mkgummidisk.wks +2 -2
@@ -4,8 +4,8 @@ part /boot --source bootimg-efi --sourceparams="loader=gummiboot" --ondisk sda --label msdos --active --align 1024 -part / --source rootfs --ondisk sda --fstype=ext3 --label platform --align 1024 +part / --source rootfs --ondisk sda --fstype=ext4 --label platform --align 1024 part swap --ondisk sda --size 44 --label swap1 --fstype=swap -bootloader --timeout=10 --append="rootwait rootfstype=ext3 console=ttyPCH0,115200 console=tty0 vmalloc=256MB snd-hda-intel.enable_msi=0" +bootloader --timeout=10 --append="rootwait rootfstype=ext4 console=ttyPCH0,115200 console=tty0 vmalloc=256MB snd-hda-intel.enable_msi=0"
scripts/lib/image/canned-wks/mkhybridiso.wks +1 -1
@@ -2,6 +2,6 @@ # long-description: Creates an EFI and legacy bootable hybrid ISO image # which can be used on optical media as well as USB media. -part /boot --source isoimage-isohybrid --sourceparams="loader=grub-efi,image_name=HYBRID_ISO_IMG" --ondisk cd --label HYBRIDISO --fstype=ext3 +part /boot --source isoimage-isohybrid --sourceparams="loader=grub-efi,image_name=HYBRID_ISO_IMG" --ondisk cd --label HYBRIDISO --fstype=ext4 bootloader --timeout=15 --append=""
Signature · 1 line
2.1.4
PATCH 2/17 wic: get rid of scripts/lib/image
In reply to Ed BartoshMoved content of scripts/lib/image/ to scripts/lib/wic as one directory with the same name as a tool is self-explanatory and less confusing than two.
---
scripts/lib/image/__init__.py | 22 ----------------------
.../{image => wic}/canned-wks/directdisk-gpt.wks | 0
.../canned-wks/directdisk-multi-rootfs.wks | 0
.../lib/{image => wic}/canned-wks/directdisk.wks | 0
.../lib/{image => wic}/canned-wks/mkefidisk.wks | 0
.../lib/{image => wic}/canned-wks/mkgummidisk.wks | 0
.../lib/{image => wic}/canned-wks/mkhybridiso.wks | 0
.../canned-wks/qemux86-directdisk.wks | 0
.../{image => wic}/canned-wks/sdimage-bootpart.wks | 0
scripts/lib/{image => wic}/config/wic.conf | 0
scripts/lib/{image => wic}/engine.py | 2 +-
scripts/lib/{image => wic}/help.py | 4 ++--
scripts/wic | 4 ++--
13 files changed, 5 insertions(+), 27 deletions(-)
delete mode 100644 scripts/lib/image/__init__.py
rename scripts/lib/{image => wic}/canned-wks/directdisk-gpt.wks (100%)
rename scripts/lib/{image => wic}/canned-wks/directdisk-multi-rootfs.wks (100%)
rename scripts/lib/{image => wic}/canned-wks/directdisk.wks (100%)
rename scripts/lib/{image => wic}/canned-wks/mkefidisk.wks (100%)
rename scripts/lib/{image => wic}/canned-wks/mkgummidisk.wks (100%)
rename scripts/lib/{image => wic}/canned-wks/mkhybridiso.wks (100%)
rename scripts/lib/{image => wic}/canned-wks/qemux86-directdisk.wks (100%)
rename scripts/lib/{image => wic}/canned-wks/sdimage-bootpart.wks (100%)
rename scripts/lib/{image => wic}/config/wic.conf (100%)
rename scripts/lib/{image => wic}/engine.py (99%)
rename scripts/lib/{image => wic}/help.py (99%)scripts/lib/image/__init__.py deleted +0 -22
@@ -1,22 +0,0 @@ -# -# OpenEmbedded Image tools library -# -# 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. -# -# AUTHORS -# Tom Zanussi <tom.zanussi (at] linux.intel.com> -#
scripts/lib/wic/canned-wks/directdisk-gpt.wks renamed from scripts/lib/image/canned-wks/directdisk-gpt.wks +0 -0
scripts/lib/wic/canned-wks/directdisk-multi-rootfs.wks renamed from scripts/lib/image/canned-wks/directdisk-multi-rootfs.wks +0 -0
scripts/lib/wic/canned-wks/directdisk.wks renamed from scripts/lib/image/canned-wks/directdisk.wks +0 -0
scripts/lib/wic/canned-wks/mkefidisk.wks renamed from scripts/lib/image/canned-wks/mkefidisk.wks +0 -0
scripts/lib/wic/canned-wks/mkgummidisk.wks renamed from scripts/lib/image/canned-wks/mkgummidisk.wks +0 -0
scripts/lib/wic/canned-wks/mkhybridiso.wks renamed from scripts/lib/image/canned-wks/mkhybridiso.wks +0 -0
scripts/lib/wic/canned-wks/qemux86-directdisk.wks renamed from scripts/lib/image/canned-wks/qemux86-directdisk.wks +0 -0
scripts/lib/wic/canned-wks/sdimage-bootpart.wks renamed from scripts/lib/image/canned-wks/sdimage-bootpart.wks +0 -0
scripts/lib/wic/config/wic.conf renamed from scripts/lib/image/config/wic.conf +0 -0
scripts/lib/wic/engine.py renamed from scripts/lib/image/engine.py +1 -1
@@ -52,7 +52,7 @@ def verify_build_env(): return True -CANNED_IMAGE_DIR = "lib/image/canned-wks" # relative to scripts +CANNED_IMAGE_DIR = "lib/wic/canned-wks" # relative to scripts SCRIPTS_CANNED_IMAGE_DIR = "scripts/" + CANNED_IMAGE_DIR def build_canned_image_list(dl):
scripts/lib/wic/help.py renamed from scripts/lib/image/help.py +2 -2
@@ -288,7 +288,7 @@ DESCRIPTION The first form enumerates all the available 'canned' images. These are actually just the set of .wks files that have been moved - into the /scripts/lib/image/canned-wks directory). + into the /scripts/lib/wic/canned-wks directory). The second form lists the detailed help information for a specific 'canned' image.
@@ -591,7 +591,7 @@ DESCRIPTION NATIVE_SYSROOT: ... The image(s) were created using OE kickstart file: - .../scripts/lib/image/canned-wks/directdisk.wks + .../scripts/lib/wic/canned-wks/directdisk.wks The output shows the name and location of the image created, and so that you know exactly what was used to generate the image, each
scripts/wic +2 -2
@@ -54,8 +54,8 @@ else: from wic.utils.oe.misc import get_bitbake_var, BB_VARS from wic.utils.errors import WicError -from image import engine -from image import help as hlp +from wic import engine +from wic import help as hlp def rootfs_dir_to_args(krootfs_dir): """
Signature · 1 line
2.1.4
PATCH 3/17 oe-selftest: wic: configure a build
In reply to Ed BartoshAdded MACHINE_FEATURES and IMAGE_FSTYPES variables to the build config to ensure that bootimg and efi artifacts are built. This is needed to build canned wic images that are using those artifacts.
Introduced class variable Wic.image_is_ready to avoid building image more than once. It would be better to build image in setUpClass, which is called only once, but add_config method can't be called in class method, so we have to use this trick with class variable in setUp method.
--- meta/lib/oeqa/selftest/wic.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)
meta/lib/oeqa/selftest/wic.py +11 -2
@@ -39,12 +39,21 @@ class Wic(oeSelfTest): @classmethod def setUpClass(cls): - """Build wic runtime dependencies and images used in the tests.""" + """Build wic runtime dependencies.""" bitbake('syslinux syslinux-native parted-native gptfdisk-native ' - 'dosfstools-native mtools-native core-image-minimal') + 'dosfstools-native mtools-native') + Wic.image_is_ready = False def setUp(self): """This code is executed before each test method.""" + if not Wic.image_is_ready: + # build core-image-minimal with required features + features = 'IMAGE_FSTYPES += " hddimg"\nMACHINE_FEATURES_append = " efi"\n' + self.append_config(features) + bitbake('core-image-minimal') + # set this class variable to avoid buiding image many times + Wic.image_is_ready = True + rmtree(self.resultdir, ignore_errors=True) def test01_help(self):
Signature · 1 line
2.1.4
PATCH 5/17 wic: fix typo
In reply to Ed BartoshFixed typo in tool name: mkswqp -> mkswap.
--- scripts/lib/wic/utils/oe/misc.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/lib/wic/utils/oe/misc.py +1 -1
@@ -41,7 +41,7 @@ NATIVE_RECIPES = {"mcopy": "mtools", "mkfs.ext4": "e2fsprogs", "mkfs.vfat": "dosfstools", "mksquashfs": "squashfs-tools", - "mkswqp": "util-linux", + "mkswap": "util-linux", "parted": "parted", "sgdisk": "gptfdisk", "syslinux": "syslinux"
Signature · 1 line
2.1.4
PATCH 6/17 wic: remove micpartition.py
In reply to Ed BartoshMoved functionality of Mic_Partition and Mic_PartData classes from micpartition.py to Wic_Partition and Wic_PartData classes of partition.py module.
Reduced level of inheritance.
Removed confusing mic legacy names.
--- .../lib/wic/kickstart/custom_commands/__init__.py | 4 -- .../wic/kickstart/custom_commands/micpartition.py | 57 ---------------------- .../lib/wic/kickstart/custom_commands/partition.py | 41 +++++++++++----- 3 files changed, 30 insertions(+), 72 deletions(-) delete mode 100644 scripts/lib/wic/kickstart/custom_commands/micpartition.py
scripts/lib/wic/kickstart/custom_commands/__init__.py +0 -4
@@ -1,11 +1,7 @@ -from micpartition import Mic_Partition -from micpartition import Mic_PartData from partition import Wic_Partition from partition import Wic_PartData __all__ = ( - "Mic_Partition", - "Mic_PartData", "Wic_Partition", "Wic_PartData", )
scripts/lib/wic/kickstart/custom_commands/micpartition.py deleted +0 -57
57 lines not on this page · raw message
scripts/lib/wic/kickstart/custom_commands/partition.py +30 -11
74 lines not on this page · raw message
Signature · 1 line
2.1.4
PATCH 4/17 wic: add test cases for 3 images
In reply to Ed BartoshAdded test cases to build qemux86_directdisk, mkgummidisk and mkefdisk images.
--- meta/lib/oeqa/selftest/wic.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+)
meta/lib/oeqa/selftest/wic.py +21 -0
@@ -213,3 +213,24 @@ class Wic(oeSelfTest): path = prefix + suffix self.assertTrue(os.path.islink(path)) self.assertTrue(os.path.isfile(os.path.realpath(path))) + + def test21_qemux86_directdisk(self): + """Test creation of qemux-86-directdisk image""" + image = "qemux86-directdisk" + self.assertEqual(0, runCmd("wic create %s -e core-image-minimal" \ + % image).status) + self.assertEqual(1, len(glob(self.resultdir + "%s-*direct" % image))) + + def test22_mkgummidisk(self): + """Test creation of mkgummidisk image""" + image = "mkgummidisk" + self.assertEqual(0, runCmd("wic create %s -e core-image-minimal" \ + % image).status) + self.assertEqual(1, len(glob(self.resultdir + "%s-*direct" % image))) + + def test23_mkefidisk(self): + """Test creation of mkefidisk image""" + image = "mkefidisk" + self.assertEqual(0, runCmd("wic create %s -e core-image-minimal" \ + % image).status) + self.assertEqual(1, len(glob(self.resultdir + "%s-*direct" % image)))
Signature · 1 line
2.1.4
PATCH 8/17 wic: fix errors in partition.py module
In reply to Ed BartoshFixed the followring errors found by pylint in partition.py:
E: 42, 0: class already defined line 33 (function-redefined) E:429,63: Undefined variable 'fs' (undefined-variable) E:432,37: Undefined variable 'fs' (undefined-variable) E:481, 0: class already defined line 33 (function-redefined) E:488,22: Undefined variable 'OptionValueError' (undefined-variable)
--- scripts/lib/wic/kickstart/custom_commands/partition.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
scripts/lib/wic/kickstart/custom_commands/partition.py +3 -3
@@ -27,10 +27,10 @@ import os import tempfile import uuid +from optparse import OptionValueError from pykickstart.commands.partition import FC4_PartData, FC4_Partition from wic.utils.oe.misc import * -from wic.kickstart.custom_commands import * from wic.plugin import pluginmgr partition_methods = {
@@ -426,10 +426,10 @@ class Wic_PartData(FC4_PartData): if self.label: label_str = "-n %s" % self.label - dosfs_cmd = "mkdosfs %s -S 512 -C %s %d" % (label_str, fs, blocks) + dosfs_cmd = "mkdosfs %s -S 512 -C %s %d" % (label_str, rootfs, blocks) exec_native_cmd(dosfs_cmd, native_sysroot) - chmod_cmd = "chmod 644 %s" % fs + chmod_cmd = "chmod 644 %s" % rootfs exec_cmd(chmod_cmd) def prepare_empty_partition_squashfs(self, cr_workdir, oe_builddir,
Signature · 1 line
2.1.4
PATCH 9/17 wic: get rid of wildcard imports
In reply to Ed BartoshUsed explicit imports in partitions.py and wicboot.py
--- scripts/lib/wic/kickstart/custom_commands/partition.py | 3 ++- scripts/lib/wic/kickstart/custom_commands/wicboot.py | 4 ---- 2 files changed, 2 insertions(+), 5 deletions(-)
scripts/lib/wic/kickstart/custom_commands/partition.py +2 -1
@@ -30,7 +30,8 @@ import uuid from optparse import OptionValueError from pykickstart.commands.partition import FC4_PartData, FC4_Partition -from wic.utils.oe.misc import * +from wic.utils.oe.misc import msger, parse_sourceparams +from wic.utils.oe.misc import exec_cmd, exec_native_cmd from wic.plugin import pluginmgr partition_methods = {
scripts/lib/wic/kickstart/custom_commands/wicboot.py +0 -4
@@ -23,10 +23,6 @@ # AUTHORS # Tom Zanussi <tom.zanussi (at] linux.intel.com> # - -from pykickstart.base import * -from pykickstart.errors import * -from pykickstart.options import * from pykickstart.commands.bootloader import F8_Bootloader class Wic_Bootloader(F8_Bootloader):
Signature · 1 line
2.1.4
PATCH 7/17 wic: remove micboot.py
In reply to Ed BartoshMoved functionaly of micboot.py Mic_Bootloader class to Wic_Bootloader class of wicboot.py module.
--- .../lib/wic/kickstart/custom_commands/micboot.py | 50 ---------------------- .../lib/wic/kickstart/custom_commands/wicboot.py | 23 ++++++---- 2 files changed, 15 insertions(+), 58 deletions(-) delete mode 100644 scripts/lib/wic/kickstart/custom_commands/micboot.py
scripts/lib/wic/kickstart/custom_commands/micboot.py deleted +0 -50
@@ -1,50 +0,0 @@ -#!/usr/bin/env python -tt -# -# Copyright (c) 2008, 2009, 2010 Intel, Inc. -# -# Anas Nashif -# -# This program is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by the Free -# Software Foundation; version 2 of the License -# -# 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., 59 -# Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -from pykickstart.base import * -from pykickstart.errors import * -from pykickstart.options import * -from pykickstart.commands.bootloader import * - -class Mic_Bootloader(F8_Bootloader): - def __init__(self, writePriority=10, appendLine="", driveorder=None, - forceLBA=False, location="", md5pass="", password="", - upgrade=False, menus=""): - F8_Bootloader.__init__(self, writePriority, appendLine, driveorder, - forceLBA, location, md5pass, password, upgrade) - - self.menus = "" - self.ptable = "msdos" - - def _getArgsAsStr(self): - ret = F8_Bootloader._getArgsAsStr(self) - - if self.menus == "": - ret += " --menus=%s" %(self.menus,) - if self.ptable: - ret += " --ptable=\"%s\"" %(self.ptable,) - return ret - - def _getParser(self): - op = F8_Bootloader._getParser(self) - op.add_option("--menus", dest="menus") - op.add_option("--ptable", dest="ptable", choices=("msdos", "gpt"), - default="msdos") - return op -
scripts/lib/wic/kickstart/custom_commands/wicboot.py +15 -8
@@ -27,29 +27,36 @@ from pykickstart.base import * from pykickstart.errors import * from pykickstart.options import * -from pykickstart.commands.bootloader import * +from pykickstart.commands.bootloader import F8_Bootloader -from wic.kickstart.custom_commands.micboot import * - -class Wic_Bootloader(Mic_Bootloader): +class Wic_Bootloader(F8_Bootloader): def __init__(self, writePriority=10, appendLine="", driveorder=None, forceLBA=False, location="", md5pass="", password="", upgrade=False, menus=""): - Mic_Bootloader.__init__(self, writePriority, appendLine, driveorder, - forceLBA, location, md5pass, password, upgrade) + F8_Bootloader.__init__(self, writePriority, appendLine, driveorder, + forceLBA, location, md5pass, password, upgrade) + self.menus = "" + self.ptable = "msdos" self.source = "" def _getArgsAsStr(self): - retval = Mic_Bootloader._getArgsAsStr(self) + retval = F8_Bootloader._getArgsAsStr(self) + if self.menus == "": + retval += " --menus=%s" %(self.menus,) + if self.ptable: + retval += " --ptable=\"%s\"" %(self.ptable,) if self.source: retval += " --source=%s" % self.source return retval def _getParser(self): - op = Mic_Bootloader._getParser(self) + op = F8_Bootloader._getParser(self) + op.add_option("--menus", dest="menus") + op.add_option("--ptable", dest="ptable", choices=("msdos", "gpt"), + default="msdos") # use specified source plugin to implement bootloader-specific methods op.add_option("--source", type="string", action="store", dest="source", default=None)
Signature · 1 line
2.1.4
PATCH 10/17 wic: fix pylint warning multiple-statements
In reply to Ed BartoshFixed pylint warning:
More than one statement on a single line (multiple-statements)
--- scripts/lib/wic/plugin.py | 3 ++- scripts/lib/wic/utils/cmdln.py | 57 +++++++++++++++++++++++++++-------------- scripts/lib/wic/utils/runner.py | 3 ++- 3 files changed, 42 insertions(+), 21 deletions(-)
scripts/lib/wic/plugin.py +2 -1
@@ -82,7 +82,8 @@ class PluginMgr(object): def _load_all(self): for (pdir, loaded) in self.plugin_dirs.iteritems(): - if loaded: continue + if loaded: + continue sys.path.insert(0, pdir) for mod in [x[:-3] for x in os.listdir(pdir) if x.endswith(".py")]:
scripts/lib/wic/utils/cmdln.py +38 -19
142 lines not on this page · raw message
scripts/lib/wic/utils/runner.py +2 -1
@@ -90,7 +90,8 @@ def show(cmdln_or_args): cmd = cmdln_or_args msg = 'running command: "%s"' % cmd - if out: out = out.strip() + if out: + out = out.strip() if out: msg += ', with output::' msg += '\n +----------------'
Signature · 1 line
2.1.4
PATCH 12/17 wic: fix pylint warning no-member
In reply to Ed BartoshFixed pylint warning:
Instance of 'ConfigMgr' has no 'create' member (no-member)
--- scripts/lib/wic/conf.py | 1 + 1 file changed, 1 insertion(+)
scripts/lib/wic/conf.py +1 -0
@@ -67,6 +67,7 @@ class ConfigMgr(object): def reset(self): self.__ksconf = None self.__siteconf = None + self.create = {} # initialize the values with defaults for sec, vals in self.DEFAULTS.iteritems():
Signature · 1 line
2.1.4
PATCH 13/17 wic: fix pylint warning unused-variable
In reply to Ed BartoshRemoved or reworked code with unused variables.
--- scripts/lib/wic/engine.py | 4 +--- scripts/lib/wic/imager/baseimager.py | 4 ++-- scripts/lib/wic/imager/direct.py | 2 +- scripts/lib/wic/plugin.py | 7 +------ scripts/lib/wic/plugins/source/bootimg-efi.py | 6 ------ scripts/wic | 2 +- 6 files changed, 6 insertions(+), 19 deletions(-)
scripts/lib/wic/engine.py +1 -3
@@ -43,9 +43,7 @@ def verify_build_env(): Returns True if it is, false otherwise """ - try: - builddir = os.environ["BUILDDIR"] - except KeyError: + if not os.environ.get("BUILDDIR"): print "BUILDDIR not found, exiting. (Did you forget to source oe-init-build-env?)" sys.exit(1)
scripts/lib/wic/imager/baseimager.py +2 -2
@@ -132,9 +132,9 @@ class BaseImageCreator(object): os.makedirs(self.workdir) self.__builddir = tempfile.mkdtemp(dir=self.workdir, prefix="imgcreate-") - except OSError, (err, msg): + except OSError as err: raise CreatorError("Failed create build directory in %s: %s" % - (self.tmpdir, msg)) + (self.tmpdir, err)) def __setup_tmpdir(self): if not self.enabletmpfs:
scripts/lib/wic/imager/direct.py +1 -1
@@ -327,7 +327,7 @@ class DirectImageCreator(BaseImageCreator): parts = self._get_parts() - for disk_name, disk in self.__image.disks.items(): + for disk_name in self.__image.disks: extension = "direct" + {"gzip": ".gz", "bzip2": ".bz2", "xz": ".xz",
scripts/lib/wic/plugin.py +1 -6
@@ -124,12 +124,7 @@ class PluginMgr(object): self.append_dirs(plugins_dir) - plugins = [] - - for _source_name, klass in self.get_plugins('source').iteritems(): - plugins.append(_source_name) - - return plugins + return self.get_plugins('source') def get_source_plugin_methods(self, source_name, methods):
scripts/lib/wic/plugins/source/bootimg-efi.py +0 -6
@@ -45,12 +45,6 @@ class BootimgEFIPlugin(SourcePlugin): """ Create loader-specific (grub-efi) config """ - splash = os.path.join(cr_workdir, "/EFI/boot/splash.jpg") - if os.path.exists(splash): - splashline = "menu background splash.jpg" - else: - splashline = "" - options = cr.ks.handler.bootloader.appendLine grubefi_conf = ""
scripts/wic +1 -1
@@ -308,7 +308,7 @@ def main(argv): parser.disable_interspersed_args() - (options, args) = parser.parse_args(argv) + args = parser.parse_args(argv)[1] if len(args): if args[0] == "help":
Signature · 1 line
2.1.4
PATCH 14/17 wic: fix pylint warning redefined-builtin
In reply to Ed BartoshRenamed variables named as Python builtin functions.
--- scripts/lib/wic/engine.py | 18 +++++++++--------- scripts/lib/wic/imager/baseimager.py | 4 ++-- scripts/lib/wic/imager/direct.py | 6 +++--- scripts/lib/wic/plugins/source/bootimg-pcbios.py | 6 +++--- 4 files changed, 17 insertions(+), 17 deletions(-)
scripts/lib/wic/engine.py +9 -9
@@ -77,11 +77,11 @@ def find_canned_image(scripts_path, wks_file): for canned_wks_dir in layers_canned_wks_dir: for root, dirs, files in os.walk(canned_wks_dir): - for file in files: - if file.endswith("~") or file.endswith("#"): + for fname in files: + if fname.endswith("~") or fname.endswith("#"): continue - if file.endswith(".wks") and wks_file + ".wks" == file: - fullpath = os.path.join(canned_wks_dir, file) + if fname.endswith(".wks") and wks_file + ".wks" == fname: + fullpath = os.path.join(canned_wks_dir, fname) return fullpath return None
@@ -94,11 +94,11 @@ def list_canned_images(scripts_path): for canned_wks_dir in layers_canned_wks_dir: for root, dirs, files in os.walk(canned_wks_dir): - for file in files: - if file.endswith("~") or file.endswith("#"): + for fname in files: + if fname.endswith("~") or fname.endswith("#"): continue - if file.endswith(".wks"): - fullpath = os.path.join(canned_wks_dir, file) + if fname.endswith(".wks"): + fullpath = os.path.join(canned_wks_dir, fname) f = open(fullpath, "r") lines = f.readlines() for line in lines:
@@ -107,7 +107,7 @@ def list_canned_images(scripts_path): if idx != -1: desc = line[idx + len("short-description:"):].strip() break - basename = os.path.splitext(file)[0] + basename = os.path.splitext(fname)[0] print " %s\t\t%s" % (basename.ljust(30), desc)
scripts/lib/wic/imager/baseimager.py +2 -2
@@ -186,7 +186,7 @@ class BaseImageCreator(object): def print_outimage_info(self): msg = "The new image can be found here:\n" self.outimage.sort() - for file in self.outimage: - msg += ' %s\n' % os.path.abspath(file) + for path in self.outimage: + msg += ' %s\n' % os.path.abspath(path) msger.info(msg)
scripts/lib/wic/imager/direct.py +3 -3
@@ -340,10 +340,10 @@ class DirectImageCreator(BaseImageCreator): if p.get_rootfs() is None: continue if p.mountpoint == '/': - str = ':' + suffix = ':' else: - str = '["%s"]:' % (p.mountpoint or p.label) - msg += ' ROOTFS_DIR%s%s\n' % (str.ljust(20), p.get_rootfs()) + suffix = '["%s"]:' % (p.mountpoint or p.label) + msg += ' ROOTFS_DIR%s%s\n' % (suffix.ljust(20), p.get_rootfs()) msg += ' BOOTIMG_DIR: %s\n' % self.bootimg_dir msg += ' KERNEL_DIR: %s\n' % self.kernel_dir
scripts/lib/wic/plugins/source/bootimg-pcbios.py +3 -3
@@ -127,9 +127,9 @@ class BootimgPcbiosPlugin(SourcePlugin): 'prepares' the partition to be incorporated into the image. In this case, prepare content for legacy bios boot partition. """ - def _has_syslinux(dir): - if dir: - syslinux = "%s/syslinux" % dir + def _has_syslinux(dirname): + if dirname: + syslinux = "%s/syslinux" % dirname if os.path.exists(syslinux): return True return False
Signature · 1 line
2.1.4
PATCH 15/17 wic: get rid of listing properties
In reply to Ed BartoshFunctionality of listing and using properties of wic images does not exist in the wic code. However, there are plenty of help and usage content about it, which is very confusing.
Removed everything regarding image properties from wic codebase.
--- scripts/lib/wic/engine.py | 55 ++++++++++------------------ scripts/lib/wic/help.py | 93 ++++------------------------------------------- scripts/wic | 13 ++----- 3 files changed, 30 insertions(+), 131 deletions(-)
scripts/lib/wic/engine.py +19 -36
@@ -194,46 +194,29 @@ def wic_create(wks_file, rootfs_dir, bootimg_dir, kernel_dir, print "\nThe image(s) were created using OE kickstart file:\n %s" % wks_file -def wic_list(args, scripts_path, properties_file): +def wic_list(args, scripts_path): """ - Print the complete list of properties defined by the image, or the - possible values for a particular image property. + Print the list of images or source plugins. """ if len(args) < 1: return False - if len(args) == 1: - if args[0] == "images": - list_canned_images(scripts_path) - return True - elif args[0] == "source-plugins": - list_source_plugins() - return True - elif args[0] == "properties": - return True - else: - return False - - if len(args) == 2: - if args[0] == "properties": - wks_file = args[1] - print "print properties contained in wks file: %s" % wks_file - return True - elif args[0] == "property": - print "print property values for property: %s" % args[1] - return True - elif args[1] == "help": - wks_file = args[0] - fullpath = find_canned_image(scripts_path, wks_file) - if not fullpath: - print "No image named %s found, exiting. "\ - "(Use 'wic list images' to list available images, or "\ - "specify a fully-qualified OE kickstart (.wks) "\ - "filename)\n" % wks_file - sys.exit(1) - list_canned_image_help(scripts_path, fullpath) - return True - else: - return False + if args == ["images"]: + list_canned_images(scripts_path) + return True + elif args == ["source-plugins"]: + list_source_plugins() + return True + elif len(args) == 2 and args[1] == "help": + wks_file = args[0] + fullpath = find_canned_image(scripts_path, wks_file) + if not fullpath: + print "No image named %s found, exiting. "\ + "(Use 'wic list images' to list available images, or "\ + "specify a fully-qualified OE kickstart (.wks) "\ + "filename)\n" % wks_file + sys.exit(1) + list_canned_image_help(scripts_path, fullpath) + return True return False
scripts/lib/wic/help.py +7 -86
141 lines not on this page · raw message
scripts/wic +4 -9
@@ -249,18 +249,13 @@ def wic_create_subcommand(args, usage_str): def wic_list_subcommand(args, usage_str): """ - Command-line handling for listing available image properties and - values. The real work is done by image.engine.wic_list() + Command-line handling for listing available images. + The real work is done by image.engine.wic_list() """ parser = optparse.OptionParser(usage=usage_str) + args = parser.parse_args(args)[1] - parser.add_option("-o", "--outfile", action="store", - dest="properties_file", - help="dump the possible values for image properties to a JSON file") - - (options, args) = parser.parse_args(args) - - if not engine.wic_list(args, scripts_path, options.properties_file): + if not engine.wic_list(args, scripts_path): logging.error("Bad list arguments, exiting\n") parser.print_help() sys.exit(1)
Signature · 1 line
2.1.4
PATCH 16/17 wic: fix short variable names
In reply to Ed BartoshMade short variable names longer and more readable.
Fixed pylint warnings "Invalid variable name" and
"Invalid argument name".
--- scripts/lib/wic/conf.py | 4 +- scripts/lib/wic/engine.py | 62 ++++----- scripts/lib/wic/imager/direct.py | 70 +++++----- scripts/lib/wic/kickstart/__init__.py | 66 ++++----- .../lib/wic/kickstart/custom_commands/partition.py | 72 +++++----- .../lib/wic/kickstart/custom_commands/wicboot.py | 12 +- scripts/lib/wic/msger.py | 13 +- scripts/lib/wic/plugin.py | 4 +- scripts/lib/wic/pluginbase.py | 14 +- scripts/lib/wic/plugins/imager/direct_plugin.py | 4 +- scripts/lib/wic/plugins/source/bootimg-efi.py | 26 ++-- scripts/lib/wic/plugins/source/bootimg-pcbios.py | 28 ++-- .../lib/wic/plugins/source/isoimage-isohybrid.py | 32 ++--- scripts/lib/wic/utils/partitionedfs.py | 154 ++++++++++----------- scripts/lib/wic/utils/runner.py | 16 +-- scripts/wic | 4 +- 16 files changed, 289 insertions(+), 292 deletions(-)
scripts/lib/wic/conf.py +2 -2
@@ -87,9 +87,9 @@ class ConfigMgr(object): if not ksconf: return - ks = kickstart.read_kickstart(ksconf) + ksobj = kickstart.read_kickstart(ksconf) - self.create['ks'] = ks + self.create['ks'] = ksobj self.create['name'] = os.path.splitext(os.path.basename(ksconf))[0] self.create['name'] = misc.build_name(ksconf,
scripts/lib/wic/engine.py +30 -32
95 lines not on this page · raw message
scripts/lib/wic/imager/direct.py +35 -35
117 lines not on this page · raw message
scripts/lib/wic/kickstart/__init__.py +33 -33
98 lines not on this page · raw message
scripts/lib/wic/kickstart/custom_commands/partition.py +36 -36
136 lines not on this page · raw message
scripts/lib/wic/kickstart/custom_commands/wicboot.py +6 -6
@@ -49,12 +49,12 @@ class Wic_Bootloader(F8_Bootloader): return retval def _getParser(self): - op = F8_Bootloader._getParser(self) - op.add_option("--menus", dest="menus") - op.add_option("--ptable", dest="ptable", choices=("msdos", "gpt"), - default="msdos") + parser = F8_Bootloader._getParser(self) + parser.add_option("--menus", dest="menus") + parser.add_option("--ptable", dest="ptable", choices=("msdos", "gpt"), + default="msdos") # use specified source plugin to implement bootloader-specific methods - op.add_option("--source", type="string", action="store", + parser.add_option("--source", type="string", action="store", dest="source", default=None) - return op + return parser
scripts/lib/wic/msger.py +6 -7
@@ -151,10 +151,10 @@ def _split_msg(head, msg): msg = msg.lstrip() head = '\r' + head - m = PREFIX_RE.match(msg) - if m: - head += ' <%s>' % m.group(1) - msg = m.group(2) + match = PREFIX_RE.match(msg) + if match: + head += ' <%s>' % match.group(1) + msg = match.group(2) return head, msg
@@ -271,9 +271,8 @@ def set_logfile(fpath): def _savelogf(): if LOG_FILE_FP: - fp = open(LOG_FILE_FP, 'w') - fp.write(LOG_CONTENT) - fp.close() + with open(LOG_FILE_FP, 'w') as log: + log.write(LOG_CONTENT) if LOG_FILE_FP is not None: warning('duplicate log file configuration')
scripts/lib/wic/plugin.py +2 -2
@@ -48,7 +48,7 @@ class PluginMgr(object): self.plugin_dir = scripts_path + PLUGIN_DIR self.layers_path = None - def _build_plugin_dir_list(self, dl, ptype): + def _build_plugin_dir_list(self, plugin_dir, ptype): if self.layers_path is None: self.layers_path = get_bitbake_var("BBLAYERS") layer_dirs = []
@@ -58,7 +58,7 @@ class PluginMgr(object): path = os.path.join(layer_path, SCRIPTS_PLUGIN_DIR, ptype) layer_dirs.append(path) - path = os.path.join(dl, ptype) + path = os.path.join(plugin_dir, ptype) layer_dirs.append(path) return layer_dirs
scripts/lib/wic/pluginbase.py +7 -7
@@ -51,7 +51,7 @@ class SourcePlugin(_Plugin): """ @classmethod - def do_install_disk(cls, disk, disk_name, cr, workdir, oe_builddir, + def do_install_disk(cls, disk, disk_name, creator, workdir, oe_builddir, bootimg_dir, kernel_dir, native_sysroot): """ Called after all partitions have been prepared and assembled into a
@@ -61,7 +61,7 @@ class SourcePlugin(_Plugin): msger.debug("SourcePlugin: do_install_disk: disk: %s" % disk_name) @classmethod - def do_stage_partition(cls, part, source_params, cr, cr_workdir, + def do_stage_partition(cls, part, source_params, creator, cr_workdir, oe_builddir, bootimg_dir, kernel_dir, native_sysroot): """
@@ -78,7 +78,7 @@ class SourcePlugin(_Plugin): msger.debug("SourcePlugin: do_stage_partition: part: %s" % part) @classmethod - def do_configure_partition(cls, part, source_params, cr, cr_workdir, + def do_configure_partition(cls, part, source_params, creator, cr_workdir, oe_builddir, bootimg_dir, kernel_dir, native_sysroot): """
@@ -89,7 +89,7 @@ class SourcePlugin(_Plugin): msger.debug("SourcePlugin: do_configure_partition: part: %s" % part) @classmethod - def do_prepare_partition(cls, part, source_params, cr, cr_workdir, + def do_prepare_partition(cls, part, source_params, creator, cr_workdir, oe_builddir, bootimg_dir, kernel_dir, rootfs_dir, native_sysroot): """
@@ -99,9 +99,9 @@ class SourcePlugin(_Plugin): msger.debug("SourcePlugin: do_prepare_partition: part: %s" % part) def get_plugins(typen): - ps = ImagerPlugin.get_plugins() - if typen in ps: - return ps[typen] + plugins = ImagerPlugin.get_plugins() + if typen in plugins: + return plugins[typen] else: return None
scripts/lib/wic/plugins/imager/direct_plugin.py +2 -2
@@ -50,8 +50,8 @@ class DirectPlugin(ImagerPlugin): """ krootfs_dir = {} for rootfs_dir in rootfs_dirs.split(' '): - k, v = rootfs_dir.split('=') - krootfs_dir[k] = v + key, val = rootfs_dir.split('=') + krootfs_dir[key] = val return krootfs_dir
scripts/lib/wic/plugins/source/bootimg-efi.py +13 -13
@@ -41,16 +41,16 @@ class BootimgEFIPlugin(SourcePlugin): name = 'bootimg-efi' @classmethod - def do_configure_grubefi(cls, hdddir, cr, cr_workdir): + def do_configure_grubefi(cls, hdddir, creator, cr_workdir): """ Create loader-specific (grub-efi) config """ - options = cr.ks.handler.bootloader.appendLine + options = creator.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) + timeout = kickstart.get_timeout(creator.ks) if not timeout: timeout = 0 grubefi_conf += "timeout=%s\n" % timeout
@@ -59,7 +59,7 @@ class BootimgEFIPlugin(SourcePlugin): kernel = "/bzImage" grubefi_conf += "linux %s root=%s rootwait %s\n" \ - % (kernel, cr.rootdev, options) + % (kernel, creator.rootdev, options) grubefi_conf += "}\n" msger.debug("Writing grubefi config %s/hdd/boot/EFI/BOOT/grub.cfg" \
@@ -69,7 +69,7 @@ class BootimgEFIPlugin(SourcePlugin): cfg.close() @classmethod - def do_configure_gummiboot(cls, hdddir, cr, cr_workdir): + def do_configure_gummiboot(cls, hdddir, creator, cr_workdir): """ Create loader-specific (gummiboot) config """
@@ -79,9 +79,9 @@ class BootimgEFIPlugin(SourcePlugin): install_cmd = "install -d %s/loader/entries" % hdddir exec_cmd(install_cmd) - options = cr.ks.handler.bootloader.appendLine + options = creator.ks.handler.bootloader.appendLine - timeout = kickstart.get_timeout(cr.ks) + timeout = kickstart.get_timeout(creator.ks) if not timeout: timeout = 0
@@ -100,7 +100,7 @@ class BootimgEFIPlugin(SourcePlugin): boot_conf = "" boot_conf += "title boot\n" boot_conf += "linux %s\n" % kernel - boot_conf += "options LABEL=Boot root=%s %s\n" % (cr.rootdev, options) + boot_conf += "options LABEL=Boot root=%s %s\n" % (creator.rootdev, options) msger.debug("Writing gummiboot config %s/hdd/boot/loader/entries/boot.conf" \ % cr_workdir)
@@ -110,7 +110,7 @@ class BootimgEFIPlugin(SourcePlugin): @classmethod - def do_configure_partition(cls, part, source_params, cr, cr_workdir, + def do_configure_partition(cls, part, source_params, creator, cr_workdir, oe_builddir, bootimg_dir, kernel_dir, native_sysroot): """
@@ -125,9 +125,9 @@ class BootimgEFIPlugin(SourcePlugin): try: if source_params['loader'] == 'grub-efi': - cls.do_configure_grubefi(hdddir, cr, cr_workdir) + cls.do_configure_grubefi(hdddir, creator, cr_workdir) elif source_params['loader'] == 'gummiboot': - cls.do_configure_gummiboot(hdddir, cr, cr_workdir) + cls.do_configure_gummiboot(hdddir, creator, cr_workdir) else: msger.error("unrecognized bootimg-efi loader: %s" % source_params['loader']) except KeyError:
@@ -135,7 +135,7 @@ class BootimgEFIPlugin(SourcePlugin): @classmethod - def do_prepare_partition(cls, part, source_params, cr, cr_workdir, + def do_prepare_partition(cls, part, source_params, creator, cr_workdir, oe_builddir, bootimg_dir, kernel_dir, rootfs_dir, native_sysroot): """
@@ -148,7 +148,7 @@ class BootimgEFIPlugin(SourcePlugin): 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) + creator.set_bootimg_dir(bootimg_dir) staging_kernel_dir = kernel_dir
scripts/lib/wic/plugins/source/bootimg-pcbios.py +14 -14
@@ -41,36 +41,36 @@ class BootimgPcbiosPlugin(SourcePlugin): name = 'bootimg-pcbios' @classmethod - def do_install_disk(cls, disk, disk_name, cr, workdir, oe_builddir, + def do_install_disk(cls, disk, disk_name, creator, 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': + if creator.ptable_format == 'msdos': mbrfile += "mbr.bin" - elif cr.ptable_format == 'gpt': + elif creator.ptable_format == 'gpt': mbrfile += "gptmbr.bin" else: - msger.error("Unsupported partition table: %s" % cr.ptable_format) + msger.error("Unsupported partition table: %s" % creator.ptable_format) 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") + full_path = creator._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: + rcode = runner.show(['dd', 'if=%s' % mbrfile, + 'of=%s' % full_path, 'conv=notrunc']) + if rcode != 0: raise ImageError("Unable to set MBR to %s" % full_path) @classmethod - def do_configure_partition(cls, part, source_params, cr, cr_workdir, + def do_configure_partition(cls, part, source_params, creator, cr_workdir, oe_builddir, bootimg_dir, kernel_dir, native_sysroot): """
@@ -89,11 +89,11 @@ class BootimgPcbiosPlugin(SourcePlugin): else: splashline = "" - options = cr.ks.handler.bootloader.appendLine + options = creator.ks.handler.bootloader.appendLine syslinux_conf = "" syslinux_conf += "PROMPT 0\n" - timeout = kickstart.get_timeout(cr.ks) + timeout = kickstart.get_timeout(creator.ks) if not timeout: timeout = 0 syslinux_conf += "TIMEOUT " + str(timeout) + "\n"
@@ -110,7 +110,7 @@ class BootimgPcbiosPlugin(SourcePlugin): syslinux_conf += "KERNEL " + kernel + "\n" syslinux_conf += "APPEND label=boot root=%s %s\n" % \ - (cr.rootdev, options) + (creator.rootdev, options) msger.debug("Writing syslinux config %s/hdd/boot/syslinux.cfg" \ % cr_workdir)
@@ -119,7 +119,7 @@ class BootimgPcbiosPlugin(SourcePlugin): cfg.close() @classmethod - def do_prepare_partition(cls, part, source_params, cr, cr_workdir, + def do_prepare_partition(cls, part, source_params, creator, cr_workdir, oe_builddir, bootimg_dir, kernel_dir, rootfs_dir, native_sysroot): """
@@ -141,7 +141,7 @@ class BootimgPcbiosPlugin(SourcePlugin): if not _has_syslinux(bootimg_dir): msger.error("Please build syslinux first\n") # just so the result notes display it - cr.set_bootimg_dir(bootimg_dir) + creator.set_bootimg_dir(bootimg_dir) staging_kernel_dir = kernel_dir
scripts/lib/wic/plugins/source/isoimage-isohybrid.py +16 -16
@@ -54,7 +54,7 @@ class IsoImagePlugin(SourcePlugin): name = 'isoimage-isohybrid' @classmethod - def do_configure_syslinux(cls, cr, cr_workdir): + def do_configure_syslinux(cls, creator, cr_workdir): """ Create loader-specific (syslinux) config """
@@ -64,9 +64,9 @@ class IsoImagePlugin(SourcePlugin): else: splashline = "" - options = cr.ks.handler.bootloader.appendLine + options = creator.ks.handler.bootloader.appendLine - timeout = kickstart.get_timeout(cr.ks, 10) + timeout = kickstart.get_timeout(creator.ks, 10) syslinux_conf = "" syslinux_conf += "PROMPT 0\n"
@@ -90,7 +90,7 @@ class IsoImagePlugin(SourcePlugin): cfg.write(syslinux_conf) @classmethod - def do_configure_grubefi(cls, part, cr, cr_workdir): + def do_configure_grubefi(cls, part, creator, cr_workdir): """ Create loader-specific (grub-efi) config """
@@ -100,13 +100,13 @@ class IsoImagePlugin(SourcePlugin): else: splashline = "" - options = cr.ks.handler.bootloader.appendLine + options = creator.ks.handler.bootloader.appendLine grubefi_conf = "" grubefi_conf += "serial --unit=0 --speed=115200 --word=8 " grubefi_conf += "--parity=no --stop=1\n" grubefi_conf += "default=boot\n" - timeout = kickstart.get_timeout(cr.ks, 10) + timeout = kickstart.get_timeout(creator.ks, 10) grubefi_conf += "timeout=%s\n" % timeout grubefi_conf += "\n" grubefi_conf += "search --set=root --label %s " % part.label
@@ -185,7 +185,7 @@ class IsoImagePlugin(SourcePlugin): return initrd @classmethod - def do_stage_partition(cls, part, source_params, cr, cr_workdir, + def do_stage_partition(cls, part, source_params, creator, cr_workdir, oe_builddir, bootimg_dir, kernel_dir, native_sysroot): """
@@ -231,7 +231,7 @@ class IsoImagePlugin(SourcePlugin): exec_cmd("bitbake mtools-native") @classmethod - def do_configure_partition(cls, part, source_params, cr, cr_workdir, + def do_configure_partition(cls, part, source_params, creator, cr_workdir, oe_builddir, bootimg_dir, kernel_dir, native_sysroot): """
@@ -249,11 +249,11 @@ class IsoImagePlugin(SourcePlugin): msger.debug("%s" % source_params) if 'image_name' in source_params and \ source_params['image_name'].strip(): - cr.name = source_params['image_name'].strip() - msger.debug("The name of the image is: %s" % cr.name) + creator.name = source_params['image_name'].strip() + msger.debug("The name of the image is: %s" % creator.name) @classmethod - def do_prepare_partition(cls, part, source_params, cr, cr_workdir, + def do_prepare_partition(cls, part, source_params, creator, cr_workdir, oe_builddir, bootimg_dir, kernel_dir, rootfs_dir, native_sysroot): """
@@ -353,7 +353,7 @@ class IsoImagePlugin(SourcePlugin): exec_cmd(install_cmd) if not os.path.isfile("%s/EFI/BOOT/boot.cfg" % bootimg_dir): - cls.do_configure_grubefi(part, cr, bootimg_dir) + cls.do_configure_grubefi(part, creator, bootimg_dir) # Builds bootx64.efi/bootia32.efi if ISODIR didn't exist or # didn't contains it
@@ -463,7 +463,7 @@ class IsoImagePlugin(SourcePlugin): install_cmd = "install -d %s/isolinux" % isodir exec_cmd(install_cmd) - cls.do_configure_syslinux(cr, cr_workdir) + cls.do_configure_syslinux(creator, cr_workdir) install_cmd = "install -m 444 %s/syslinux/ldlinux.sys " % syslinux_dir install_cmd += "%s/isolinux/ldlinux.sys" % isodir
@@ -508,7 +508,7 @@ class IsoImagePlugin(SourcePlugin): part.set_source_file(iso_img) @classmethod - def do_install_disk(cls, disk, disk_name, cr, workdir, oe_builddir, + def do_install_disk(cls, disk, disk_name, creator, workdir, oe_builddir, bootimg_dir, kernel_dir, native_sysroot): """ Called after all partitions have been prepared and assembled into a
@@ -516,9 +516,9 @@ class IsoImagePlugin(SourcePlugin): utility for booting via BIOS from disk storage devices. """ - full_path = cr._full_path(workdir, disk_name, "direct") + full_path = creator._full_path(workdir, disk_name, "direct") iso_img = "%s.p1" % full_path - full_path_iso = cr._full_path(workdir, disk_name, "iso") + full_path_iso = creator._full_path(workdir, disk_name, "iso") isohybrid_cmd = "isohybrid -u %s" % iso_img msger.debug("running command: %s" % \
scripts/lib/wic/utils/partitionedfs.py +77 -77
271 lines not on this page · raw message
scripts/lib/wic/utils/runner.py +8 -8
@@ -62,13 +62,13 @@ def runtool(cmdln_or_args, catch=1): serr = subprocess.STDOUT try: - p = subprocess.Popen(cmdln_or_args, stdout=sout, - stderr=serr, shell=shell) - (sout, serr) = p.communicate() + process = subprocess.Popen(cmdln_or_args, stdout=sout, + stderr=serr, shell=shell) + (sout, serr) = process.communicate() # combine stdout and stderr, filter None out out = ''.join(filter(None, [sout, serr])) - except OSError, e: - if e.errno == 2: + except OSError, err: + if err.errno == 2: # [Errno 2] No such file or directory msger.error('Cannot run command: %s, lost dependency?' % cmd) else:
@@ -77,12 +77,12 @@ def runtool(cmdln_or_args, catch=1): if catch != 3: os.close(dev_null) - return (p.returncode, out) + return (process.returncode, out) def show(cmdln_or_args): # show all the message using msger.verbose - rc, out = runtool(cmdln_or_args, catch=3) + rcode, out = runtool(cmdln_or_args, catch=3) if isinstance(cmdln_or_args, list): cmd = ' '.join(cmdln_or_args)
@@ -100,7 +100,7 @@ def show(cmdln_or_args): msg += '\n +----------------' msger.verbose(msg) - return rc + return rcode def outs(cmdln_or_args, catch=1): # get the outputs of tools
scripts/wic +2 -2
@@ -62,9 +62,9 @@ def rootfs_dir_to_args(krootfs_dir): Get a rootfs_dir dict and serialize to string """ rootfs_dir = '' - for k, v in krootfs_dir.items(): + for key, val in krootfs_dir.items(): rootfs_dir += ' ' - rootfs_dir += '='.join([k, v]) + rootfs_dir += '='.join([key, val]) return rootfs_dir.strip() def callback_rootfs_dir(option, opt, value, parser):
Signature · 1 line
2.1.4
PATCH 17/17 image.py: rename _write_env -> _write_wic_env
In reply to Ed BartoshRenamed this function as it's too generic name for it. It writes variables, which are used by wic to .env file, so _write_wic_env is better name for it.
Thanks Christopher Larson for poining out to this.
--- meta/lib/oe/image.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
meta/lib/oe/image.py +2 -2
@@ -326,7 +326,7 @@ class Image(ImageDepGraph): return image_cmd_groups - def _write_env(self): + def _write_wic_env(self): """ Write environment variables used by wic to tmp/sysroots/<machine>/imgdata/<image>.env
@@ -353,7 +353,7 @@ class Image(ImageDepGraph): image_cmd_groups = self._get_imagecmds() - self._write_env() + self._write_wic_env() for image_cmds in image_cmd_groups: # create the images in parallel
Signature · 1 line
2.1.4
PATCH 11/17 wic: use optparse instead of cmdln
In reply to Ed Bartoshcmdln.py https://pypi.python.org/pypi/cmdln was used in creator.py to parse image plugin options and arguments.
There is no need in such a sofisticated API to do this simple task. Standard option parser optparse.OptionParser can do it just fine.
Modified Creator class to work with option parser. Removed cmdln.py from the wic codebase.
--- scripts/lib/wic/creator.py | 115 +- scripts/lib/wic/plugins/imager/direct_plugin.py | 2 +- scripts/lib/wic/utils/cmdln.py | 1604 ----------------------- 3 files changed, 27 insertions(+), 1694 deletions(-) delete mode 100644 scripts/lib/wic/utils/cmdln.py
scripts/lib/wic/creator.py +26 -89
@@ -16,15 +16,15 @@ # Temple Place - Suite 330, Boston, MA 02111-1307, USA. import os, sys -from optparse import SUPPRESS_HELP +from optparse import OptionParser, SUPPRESS_HELP from wic import msger -from wic.utils import cmdln, errors +from wic.utils import errors from wic.conf import configmgr from wic.plugin import pluginmgr -class Creator(cmdln.Cmdln): +class Creator(object): """${name}: create an image Usage:
@@ -37,8 +37,7 @@ class Creator(cmdln.Cmdln): name = 'wic create(cr)' def __init__(self, *args, **kwargs): - cmdln.Cmdln.__init__(self, *args, **kwargs) - self._subcmds = [] + self._subcmds = {} # get cmds from pluginmgr # mix-in do_subcmd interface
@@ -48,11 +47,10 @@ class Creator(cmdln.Cmdln): continue func = getattr(klass, 'do_create') - setattr(self.__class__, "do_"+subcmd, func) - self._subcmds.append(subcmd) + self._subcmds[subcmd] = func def get_optparser(self): - optparser = cmdln.CmdlnOptionParser(self) + optparser = OptionParser() optparser.add_option('-d', '--debug', action='store_true', dest='debug', help=SUPPRESS_HELP)
@@ -73,69 +71,31 @@ class Creator(cmdln.Cmdln): ' feature, use it if you have more than 4G memory') return optparser - def preoptparse(self, argv): - optparser = self.get_optparser() - - largs = [] - rargs = [] - while argv: - arg = argv.pop(0) - - if arg in ('-h', '--help'): - rargs.append(arg) - - elif optparser.has_option(arg): - largs.append(arg) - - if optparser.get_option(arg).takes_value(): - try: - largs.append(argv.pop(0)) - except IndexError: - raise errors.Usage("option %s requires arguments" % arg) - - else: - if arg.startswith("--"): - if "=" in arg: - opt = arg.split("=")[0] - else: - opt = None - elif arg.startswith("-") and len(arg) > 2: - opt = arg[0:2] - else: - opt = None - - if opt and optparser.has_option(opt): - largs.append(arg) - else: - rargs.append(arg) - - return largs + rargs - - def postoptparse(self): + def postoptparse(self, options): abspath = lambda pth: os.path.abspath(os.path.expanduser(pth)) - if self.options.verbose: + if options.verbose: msger.set_loglevel('verbose') - if self.options.debug: + if options.debug: msger.set_loglevel('debug') - if self.options.logfile: - logfile_abs_path = abspath(self.options.logfile) + if options.logfile: + logfile_abs_path = abspath(options.logfile) if os.path.isdir(logfile_abs_path): raise errors.Usage("logfile's path %s should be file" - % self.options.logfile) + % options.logfile) if not os.path.exists(os.path.dirname(logfile_abs_path)): os.makedirs(os.path.dirname(logfile_abs_path)) msger.set_interactive(False) msger.set_logfile(logfile_abs_path) - configmgr.create['logfile'] = self.options.logfile + configmgr.create['logfile'] = options.logfile - if self.options.config: + if options.config: configmgr.reset() - configmgr._siteconf = self.options.config + configmgr._siteconf = options.config - if self.options.outdir is not None: - configmgr.create['outdir'] = abspath(self.options.outdir) + if options.outdir is not None: + configmgr.create['outdir'] = abspath(options.outdir) cdir = 'outdir' if os.path.exists(configmgr.create[cdir]) \
@@ -143,8 +103,8 @@ class Creator(cmdln.Cmdln): msger.error('Invalid directory specified: %s' \ % configmgr.create[cdir]) - if self.options.enabletmpfs: - configmgr.create['enabletmpfs'] = self.options.enabletmpfs + if options.enabletmpfs: + configmgr.create['enabletmpfs'] = options.enabletmpfs def main(self, argv=None): if argv is None:
@@ -152,36 +112,13 @@ class Creator(cmdln.Cmdln): else: argv = argv[:] # don't modify caller's list - self.optparser = self.get_optparser() - if self.optparser: - try: - argv = self.preoptparse(argv) - self.options, args = self.optparser.parse_args(argv) - - except cmdln.CmdlnUserError, ex: - msg = "%s: %s\nTry '%s help' for info.\n"\ - % (self.name, ex, self.name) - msger.error(msg) - - except cmdln.StopOptionProcessing, ex: - return 0 - else: - # optparser=None means no process for opts - self.options, args = None, argv[1:] - - if not args: - return self.emptyline() - - self.postoptparse() - - return self.cmd(args) + pname = argv[0] + if pname not in self._subcmds: + msger.error('Unknown plugin: %s' % pname) - def precmd(self, argv): # check help before cmd - - if '-h' in argv or '?' in argv or '--help' in argv or 'help' in argv: - return argv + optparser = self.get_optparser() + options, args = optparser.parse_args(argv) - if len(argv) == 1: - return ['help', argv[0]] + self.postoptparse(options) - return argv + return self._subcmds[pname](options, *args[1:])
scripts/lib/wic/plugins/imager/direct_plugin.py +1 -1
@@ -56,7 +56,7 @@ class DirectPlugin(ImagerPlugin): return krootfs_dir @classmethod - def do_create(cls, subcmd, opts, *args): + def do_create(cls, opts, *args): """ Create direct image, called from creator as 'direct' cmd """
scripts/lib/wic/utils/cmdln.py deleted +0 -1604
1,604 lines not on this page · raw message
Signature · 1 line
2.1.4