summaryrefslogtreecommitdiffstats
path: root/scripts/lib/wic
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/lib/wic')
-rw-r--r--scripts/lib/wic/3rdparty/pykickstart/parser.py87
-rw-r--r--scripts/lib/wic/3rdparty/pykickstart/version.py29
-rw-r--r--scripts/lib/wic/conf.py2
-rw-r--r--scripts/lib/wic/creator.py2
-rw-r--r--scripts/lib/wic/imager/baseimager.py2
-rw-r--r--scripts/lib/wic/imager/direct.py21
-rw-r--r--scripts/lib/wic/kickstart/__init__.py2
-rw-r--r--scripts/lib/wic/kickstart/custom_commands/micboot.py2
-rw-r--r--scripts/lib/wic/kickstart/custom_commands/micpartition.py2
-rw-r--r--scripts/lib/wic/kickstart/custom_commands/partition.py38
-rw-r--r--scripts/lib/wic/msger.py2
-rw-r--r--scripts/lib/wic/plugin.py2
-rw-r--r--scripts/lib/wic/pluginbase.py2
-rw-r--r--scripts/lib/wic/plugins/imager/direct_plugin.py20
-rw-r--r--scripts/lib/wic/plugins/source/bootimg-efi.py5
-rw-r--r--scripts/lib/wic/plugins/source/bootimg-partition.py138
-rw-r--r--scripts/lib/wic/plugins/source/bootimg-pcbios.py14
-rw-r--r--scripts/lib/wic/utils/errors.py2
-rw-r--r--scripts/lib/wic/utils/fs_related.py2
-rw-r--r--scripts/lib/wic/utils/misc.py2
-rw-r--r--scripts/lib/wic/utils/oe/misc.py1
-rw-r--r--scripts/lib/wic/utils/partitionedfs.py24
-rw-r--r--scripts/lib/wic/utils/runner.py2
23 files changed, 226 insertions, 177 deletions
diff --git a/scripts/lib/wic/3rdparty/pykickstart/parser.py b/scripts/lib/wic/3rdparty/pykickstart/parser.py
index 840a448673..9c9674bf73 100644
--- a/scripts/lib/wic/3rdparty/pykickstart/parser.py
+++ b/scripts/lib/wic/3rdparty/pykickstart/parser.py
@@ -38,8 +38,6 @@ import sys
import tempfile
from copy import copy
from optparse import *
-from urlgrabber import urlread
-import urlgrabber.grabber as grabber
import constants
from errors import KickstartError, KickstartParseError, KickstartValueError, formatErrorMsg
@@ -55,87 +53,6 @@ STATE_COMMANDS = "commands"
ver = version.DEVEL
-def _preprocessStateMachine (lineIter):
- l = None
- lineno = 0
-
- # Now open an output kickstart file that we are going to write to one
- # line at a time.
- (outF, outName) = tempfile.mkstemp("-ks.cfg", "", "/tmp")
-
- while True:
- try:
- l = lineIter.next()
- except StopIteration:
- break
-
- # At the end of the file?
- if l == "":
- break
-
- lineno += 1
- url = None
-
- ll = l.strip()
- if not ll.startswith("%ksappend"):
- os.write(outF, l)
- continue
-
- # Try to pull down the remote file.
- try:
- ksurl = ll.split(' ')[1]
- except:
- raise KickstartParseError, formatErrorMsg(lineno, msg=_("Illegal url for %%ksappend: %s") % ll)
-
- try:
- url = grabber.urlopen(ksurl)
- except grabber.URLGrabError, e:
- raise KickstartError, formatErrorMsg(lineno, msg=_("Unable to open %%ksappend file: %s") % e.strerror)
- else:
- # Sanity check result. Sometimes FTP doesn't catch a file
- # is missing.
- try:
- if url.size < 1:
- raise KickstartError, formatErrorMsg(lineno, msg=_("Unable to open %%ksappend file"))
- except:
- raise KickstartError, formatErrorMsg(lineno, msg=_("Unable to open %%ksappend file"))
-
- # If that worked, write the remote file to the output kickstart
- # file in one burst. Then close everything up to get ready to
- # read ahead in the input file. This allows multiple %ksappend
- # lines to exist.
- if url is not None:
- os.write(outF, url.read())
- url.close()
-
- # All done - close the temp file and return its location.
- os.close(outF)
- return outName
-
-def preprocessFromString (s):
- """Preprocess the kickstart file, provided as the string str. This
- method is currently only useful for handling %ksappend lines,
- which need to be fetched before the real kickstart parser can be
- run. Returns the location of the complete kickstart file.
- """
- i = iter(s.splitlines(True) + [""])
- rc = _preprocessStateMachine (i.next)
- return rc
-
-def preprocessKickstart (f):
- """Preprocess the kickstart file, given by the filename file. This
- method is currently only useful for handling %ksappend lines,
- which need to be fetched before the real kickstart parser can be
- run. Returns the location of the complete kickstart file.
- """
- try:
- fh = urlopen(f)
- except grabber.URLGrabError, e:
- raise KickstartError, formatErrorMsg(0, msg=_("Unable to open input kickstart file: %s") % e.strerror)
-
- rc = _preprocessStateMachine (iter(fh.readlines()))
- fh.close()
- return rc
class PutBackIterator(Iterator):
def __init__(self, iterable):
@@ -682,8 +599,8 @@ class KickstartParser:
self.currentdir[self._includeDepth] = cd
try:
- s = urlread(f)
- except grabber.URLGrabError, e:
+ s = file(f).read()
+ except IOError, e:
raise KickstartError, formatErrorMsg(0, msg=_("Unable to open input kickstart file: %s") % e.strerror)
self.readKickstartFromString(s, reset=False)
diff --git a/scripts/lib/wic/3rdparty/pykickstart/version.py b/scripts/lib/wic/3rdparty/pykickstart/version.py
index 102cc37d80..8a8e6aad22 100644
--- a/scripts/lib/wic/3rdparty/pykickstart/version.py
+++ b/scripts/lib/wic/3rdparty/pykickstart/version.py
@@ -44,7 +44,6 @@ This module also exports several functions:
have a version= comment in it.
"""
import imputil, re, sys
-from urlgrabber import urlopen
import gettext
_ = lambda x: gettext.ldgettext("pykickstart", x)
@@ -132,34 +131,6 @@ def versionToString(version, skipDevel=False):
raise KickstartVersionError(_("Unsupported version specified: %s") % version)
-def versionFromFile(f):
- """Given a file or URL, look for a line starting with #version= and
- return the version number. If no version is found, return DEVEL.
- """
- v = DEVEL
-
- fh = urlopen(f)
-
- while True:
- try:
- l = fh.readline()
- except StopIteration:
- break
-
- # At the end of the file?
- if l == "":
- break
-
- if l.isspace() or l.strip() == "":
- continue
-
- if l[:9] == "#version=":
- v = stringToVersion(l[9:].rstrip())
- break
-
- fh.close()
- return v
-
def returnClassForVersion(version=DEVEL):
"""Return the class of the syntax handler for version. version can be
either a string or the matching constant. Raises KickstartValueError
diff --git a/scripts/lib/wic/conf.py b/scripts/lib/wic/conf.py
index d5419f8e94..be34355ce4 100644
--- a/scripts/lib/wic/conf.py
+++ b/scripts/lib/wic/conf.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python -tt
+#!/usr/bin/env python -tt
#
# Copyright (c) 2011 Intel, Inc.
#
diff --git a/scripts/lib/wic/creator.py b/scripts/lib/wic/creator.py
index a4b19ac6e0..2219377b38 100644
--- a/scripts/lib/wic/creator.py
+++ b/scripts/lib/wic/creator.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python -tt
+#!/usr/bin/env python -tt
#
# Copyright (c) 2011 Intel, Inc.
#
diff --git a/scripts/lib/wic/imager/baseimager.py b/scripts/lib/wic/imager/baseimager.py
index 5bcd2f7529..e8305272a2 100644
--- a/scripts/lib/wic/imager/baseimager.py
+++ b/scripts/lib/wic/imager/baseimager.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python -tt
+#!/usr/bin/env python -tt
#
# Copyright (c) 2007 Red Hat Inc.
# Copyright (c) 2009, 2010, 2011 Intel, Inc.
diff --git a/scripts/lib/wic/imager/direct.py b/scripts/lib/wic/imager/direct.py
index 5b12856289..b1dc3e96f4 100644
--- a/scripts/lib/wic/imager/direct.py
+++ b/scripts/lib/wic/imager/direct.py
@@ -52,8 +52,7 @@ class DirectImageCreator(BaseImageCreator):
"""
def __init__(self, oe_builddir, image_output_dir, rootfs_dir, bootimg_dir,
- kernel_dir, native_sysroot, hdddir, staging_data_dir,
- creatoropts=None):
+ kernel_dir, native_sysroot, creatoropts=None):
"""
Initialize a DirectImageCreator instance.
@@ -74,8 +73,6 @@ class DirectImageCreator(BaseImageCreator):
self.bootimg_dir = bootimg_dir
self.kernel_dir = kernel_dir
self.native_sysroot = native_sysroot
- self.hdddir = hdddir
- self.staging_data_dir = staging_data_dir
def __write_fstab(self, image_rootfs):
"""overriden to generate fstab (temporarily) in rootfs. This is called
@@ -103,10 +100,18 @@ class DirectImageCreator(BaseImageCreator):
for num, p in enumerate(parts, 1):
if not p.mountpoint or p.mountpoint == "/" or p.mountpoint == "/boot":
continue
- if self._ptable_format == 'msdos' and num > 3:
- device_name = "/dev/" + p.disk + str(num + 1)
- else:
- device_name = "/dev/" + p.disk + str(num)
+
+ part = ''
+ # mmc device partitions are named mmcblk0p1, mmcblk0p2..
+ if p.disk.startswith('mmcblk'):
+ part = 'p'
+
+ pnum = num
+ if self._ptable_format == 'msdos' and pnum > 3:
+ # account for logical partition numbering, ex. sda5..
+ pnum += 1
+
+ device_name = "/dev/" + p.disk + part + str(pnum)
opts = "defaults"
if p.fsopts:
diff --git a/scripts/lib/wic/kickstart/__init__.py b/scripts/lib/wic/kickstart/__init__.py
index 4f5b778b5d..600098293a 100644
--- a/scripts/lib/wic/kickstart/__init__.py
+++ b/scripts/lib/wic/kickstart/__init__.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python -tt
+#!/usr/bin/env python -tt
#
# Copyright (c) 2007 Red Hat, Inc.
# Copyright (c) 2009, 2010, 2011 Intel, Inc.
diff --git a/scripts/lib/wic/kickstart/custom_commands/micboot.py b/scripts/lib/wic/kickstart/custom_commands/micboot.py
index 66d1678aa7..d162142506 100644
--- a/scripts/lib/wic/kickstart/custom_commands/micboot.py
+++ b/scripts/lib/wic/kickstart/custom_commands/micboot.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python -tt
+#!/usr/bin/env python -tt
#
# Copyright (c) 2008, 2009, 2010 Intel, Inc.
#
diff --git a/scripts/lib/wic/kickstart/custom_commands/micpartition.py b/scripts/lib/wic/kickstart/custom_commands/micpartition.py
index 59a87fb486..43d04f1294 100644
--- a/scripts/lib/wic/kickstart/custom_commands/micpartition.py
+++ b/scripts/lib/wic/kickstart/custom_commands/micpartition.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python -tt
+#!/usr/bin/env python -tt
#
# Marko Saukko <marko.saukko@cybercom.com>
#
diff --git a/scripts/lib/wic/kickstart/custom_commands/partition.py b/scripts/lib/wic/kickstart/custom_commands/partition.py
index abf3498134..54a494e033 100644
--- a/scripts/lib/wic/kickstart/custom_commands/partition.py
+++ b/scripts/lib/wic/kickstart/custom_commands/partition.py
@@ -184,7 +184,7 @@ class Wic_PartData(Mic_PartData):
Prepare content for a rootfs partition i.e. create a partition
and fill it from a /rootfs dir.
- Currently handles ext2/3/4 and btrfs.
+ Currently handles ext2/3/4, btrfs and vfat.
"""
pseudo = "export PSEUDO_PREFIX=%s/usr;" % native_sysroot
pseudo += "export PSEUDO_LOCALSTATEDIR=%s/../pseudo;" % rootfs_dir
@@ -229,6 +229,7 @@ class Wic_PartData(Mic_PartData):
extra_blocks = IMAGE_EXTRA_SPACE
rootfs_size = actual_rootfs_size + extra_blocks
+ rootfs_size *= IMAGE_OVERHEAD_FACTOR
msger.debug("Added %d extra blocks to %s to get to %d total blocks" % \
(extra_blocks, self.mountpoint, rootfs_size))
@@ -241,8 +242,10 @@ class Wic_PartData(Mic_PartData):
mkfs_cmd = "mkfs.%s -F %s %s -d %s" % \
(self.fstype, extra_imagecmd, rootfs, image_rootfs)
- exec_native_cmd(pseudo + mkfs_cmd, native_sysroot)
-
+ (rc, out) = exec_native_cmd(pseudo + mkfs_cmd, native_sysroot)
+ if rc:
+ print "rootfs_dir: %s" % rootfs_dir
+ msger.error("ERROR: mkfs.%s returned '%s' instead of 0 (which you probably don't want to ignore, use --debug for details) when creating filesystem from rootfs directory: %s" % (self.fstype, rc, rootfs_dir))
# get the rootfs size in the right units for kickstart (Mb)
du_cmd = "du -Lbms %s" % rootfs
@@ -274,6 +277,7 @@ class Wic_PartData(Mic_PartData):
extra_blocks = IMAGE_EXTRA_SPACE
rootfs_size = actual_rootfs_size + extra_blocks
+ rootfs_size *= IMAGE_OVERHEAD_FACTOR
msger.debug("Added %d extra blocks to %s to get to %d total blocks" % \
(extra_blocks, self.mountpoint, rootfs_size))
@@ -284,7 +288,9 @@ class Wic_PartData(Mic_PartData):
mkfs_cmd = "mkfs.%s -b %d -r %s %s" % \
(self.fstype, rootfs_size * 1024, image_rootfs, rootfs)
- exec_native_cmd(pseudo + mkfs_cmd, native_sysroot)
+ (rc, out) = exec_native_cmd(pseudo + mkfs_cmd, native_sysroot)
+ if rc:
+ msger.error("ERROR: mkfs.%s returned '%s' instead of 0 (which you probably don't want to ignore, use --debug for details) when creating filesystem from rootfs directory: %s" % (self.fstype, rc, rootfs_dir))
# get the rootfs size in the right units for kickstart (Mb)
du_cmd = "du -Lbms %s" % rootfs
@@ -308,8 +314,8 @@ class Wic_PartData(Mic_PartData):
extra_blocks = self.get_extra_block_count(blocks)
- if extra_blocks < BOOTDD_EXTRA_SPACE:
- extra_blocks = BOOTDD_EXTRA_SPACE
+ if extra_blocks < IMAGE_EXTRA_SPACE:
+ extra_blocks = IMAGE_EXTRA_SPACE
blocks += extra_blocks
@@ -318,9 +324,11 @@ class Wic_PartData(Mic_PartData):
# 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))
+ # generate images with 32 sectors per track. This calculation
+ # is done in blocks, thus the mod by 16 instead of 32. Apply
+ # sector count fix only when needed.
+ if blocks % 16 != 0:
+ blocks += (16 - (blocks % 16))
dosfs_cmd = "mkdosfs -n boot -S 512 -C %s %d" % (rootfs, blocks)
exec_native_cmd(dosfs_cmd, native_sysroot)
@@ -394,7 +402,9 @@ class Wic_PartData(Mic_PartData):
extra_imagecmd = "-i 8192"
mkfs_cmd = "mkfs.%s -F %s %s" % (self.fstype, extra_imagecmd, fs)
- exec_native_cmd(mkfs_cmd, native_sysroot)
+ (rc, out) = exec_native_cmd(mkfs_cmd, native_sysroot)
+ if rc:
+ msger.error("ERROR: mkfs.%s returned '%s' instead of 0 (which you probably don't want to ignore, use --debug for details)" % (self.fstype, rc))
self.source_file = fs
@@ -412,10 +422,14 @@ class Wic_PartData(Mic_PartData):
exec_cmd(dd_cmd)
mkfs_cmd = "mkfs.%s -b %d %s" % (self.fstype, self.size * 1024, rootfs)
- exec_native_cmd(mkfs_cmd, native_sysroot)
+ (rc, out) = exec_native_cmd(mkfs_cmd, native_sysroot)
+ if rc:
+ msger.error("ERROR: mkfs.%s returned '%s' instead of 0 (which you probably don't want to ignore, use --debug for details)" % (self.fstype, rc))
mkfs_cmd = "mkfs.%s -F %s %s" % (self.fstype, extra_imagecmd, fs)
- exec_native_cmd(mkfs_cmd, native_sysroot)
+ (rc, out) = exec_native_cmd(mkfs_cmd, native_sysroot)
+ if rc:
+ msger.error("ERROR: mkfs.%s returned '%s' instead of 0 (which you probably don't want to ignore, use --debug for details)" % (self.fstype, rc))
self.source_file = fs
diff --git a/scripts/lib/wic/msger.py b/scripts/lib/wic/msger.py
index 9afc85be93..9f557e7b9a 100644
--- a/scripts/lib/wic/msger.py
+++ b/scripts/lib/wic/msger.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python -tt
+#!/usr/bin/env python -tt
# vim: ai ts=4 sts=4 et sw=4
#
# Copyright (c) 2009, 2010, 2011 Intel, Inc.
diff --git a/scripts/lib/wic/plugin.py b/scripts/lib/wic/plugin.py
index 61c5859bac..41a80175ca 100644
--- a/scripts/lib/wic/plugin.py
+++ b/scripts/lib/wic/plugin.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python -tt
+#!/usr/bin/env python -tt
#
# Copyright (c) 2011 Intel, Inc.
#
diff --git a/scripts/lib/wic/pluginbase.py b/scripts/lib/wic/pluginbase.py
index b8b3a46354..e3de9bacb8 100644
--- a/scripts/lib/wic/pluginbase.py
+++ b/scripts/lib/wic/pluginbase.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python -tt
+#!/usr/bin/env python -tt
#
# Copyright (c) 2011 Intel, Inc.
#
diff --git a/scripts/lib/wic/plugins/imager/direct_plugin.py b/scripts/lib/wic/plugins/imager/direct_plugin.py
index dabd6fc3e0..5601c3f1c9 100644
--- a/scripts/lib/wic/plugins/imager/direct_plugin.py
+++ b/scripts/lib/wic/plugins/imager/direct_plugin.py
@@ -58,21 +58,19 @@ class DirectPlugin(ImagerPlugin):
"""
Create direct image, called from creator as 'direct' cmd
"""
- if len(args) != 9:
+ if len(args) != 7:
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]
+ native_sysroot = args[0]
+ kernel_dir = args[1]
+ bootimg_dir = args[2]
+ rootfs_dir = args[3]
creatoropts = configmgr.create
- ksconf = args[6]
+ ksconf = args[4]
- image_output_dir = args[7]
- oe_builddir = args[8]
+ image_output_dir = args[5]
+ oe_builddir = args[6]
krootfs_dir = self.__rootfs_dir_to_dict(rootfs_dir)
@@ -84,8 +82,6 @@ class DirectPlugin(ImagerPlugin):
bootimg_dir,
kernel_dir,
native_sysroot,
- hdddir,
- staging_data_dir,
creatoropts)
try:
diff --git a/scripts/lib/wic/plugins/source/bootimg-efi.py b/scripts/lib/wic/plugins/source/bootimg-efi.py
index 855bbc2ce2..e4067b6dbf 100644
--- a/scripts/lib/wic/plugins/source/bootimg-efi.py
+++ b/scripts/lib/wic/plugins/source/bootimg-efi.py
@@ -173,7 +173,6 @@ class BootimgEFIPlugin(SourcePlugin):
cr.set_bootimg_dir(bootimg_dir)
staging_kernel_dir = kernel_dir
- staging_data_dir = bootimg_dir
hdddir = "%s/hdd/boot" % cr_workdir
@@ -185,12 +184,12 @@ class BootimgEFIPlugin(SourcePlugin):
if source_params['loader'] == 'grub-efi':
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)
+ cp_cmd = "cp %s/EFI/BOOT/* %s/EFI/BOOT" % (bootimg_dir, hdddir)
exec_cmd(cp_cmd, True)
shutil.move("%s/grub.cfg" % cr_workdir,
"%s/hdd/boot/EFI/BOOT/grub.cfg" % cr_workdir)
elif source_params['loader'] == 'gummiboot':
- cp_cmd = "cp %s/EFI/BOOT/* %s/EFI/BOOT" % (staging_data_dir, hdddir)
+ cp_cmd = "cp %s/EFI/BOOT/* %s/EFI/BOOT" % (bootimg_dir, hdddir)
exec_cmd(cp_cmd, True)
else:
msger.error("unrecognized bootimg-efi loader: %s" % source_params['loader'])
diff --git a/scripts/lib/wic/plugins/source/bootimg-partition.py b/scripts/lib/wic/plugins/source/bootimg-partition.py
new file mode 100644
index 0000000000..6ba39a01f7
--- /dev/null
+++ b/scripts/lib/wic/plugins/source/bootimg-partition.py
@@ -0,0 +1,138 @@
+# ex:ts=4:sw=4:sts=4:et
+# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
+#
+# 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-partition' source plugin class for
+# 'wic'. The plugin creates an image of boot partition, copying over
+# files listed in IMAGE_BOOT_FILES bitbake variable.
+#
+# AUTHORS
+# Maciej Borzecki <maciej.borzecki (at] open-rnd.pl>
+#
+
+import os
+import re
+
+from wic import msger
+from wic.pluginbase import SourcePlugin
+from wic.utils.oe.misc import *
+from glob import glob
+
+class BootimgPartitionPlugin(SourcePlugin):
+ name = 'bootimg-partition'
+
+ @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. Do nothing.
+ """
+ pass
+
+ @classmethod
+ def do_configure_partition(self, part, source_params, cr, cr_workdir,
+ oe_builddir, bootimg_dir, kernel_dir,
+ native_sysroot):
+ """
+ Called before do_prepare_partition(). Possibly prepare
+ configuration files of some sort.
+
+ """
+ pass
+
+ @classmethod
+ def do_prepare_partition(self, part, source_params, 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, does the following:
+ - sets up a vfat partition
+ - copies all files listed in IMAGE_BOOT_FILES variable
+ """
+ hdddir = "%s/boot" % cr_workdir
+ rm_cmd = "rm -rf %s" % cr_workdir
+ exec_cmd(rm_cmd)
+
+ install_cmd = "install -d %s" % hdddir
+ exec_cmd(install_cmd)
+
+ 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.debug('Bootimg dir: %s' % bootimg_dir)
+
+ boot_files = get_bitbake_var("IMAGE_BOOT_FILES")
+
+ if not boot_files:
+ msger.error('No boot files defined, IMAGE_BOOT_FILES unset')
+
+ msger.debug('Boot files: %s' % boot_files)
+
+ # list of tuples (src_name, dst_name)
+ deploy_files = []
+ for src_entry in re.findall(r'[\w;\-\./\*]+', boot_files):
+ if ';' in src_entry:
+ dst_entry = tuple(src_entry.split(';'))
+ if not dst_entry[0] or not dst_entry[1]:
+ msger.error('Malformed boot file entry: %s' % (src_entry))
+ else:
+ dst_entry = (src_entry, src_entry)
+
+ msger.debug('Destination entry: %r' % (dst_entry,))
+ deploy_files.append(dst_entry)
+
+ for deploy_entry in deploy_files:
+ src, dst = deploy_entry
+ install_task = []
+ if '*' in src:
+ # by default install files under their basename
+ entry_name_fn = os.path.basename
+ if dst != src:
+ # unless a target name was given, then treat name
+ # as a directory and append a basename
+ entry_name_fn = lambda name: \
+ os.path.join(dst,
+ os.path.basename(name))
+
+ srcs = glob(os.path.join(bootimg_dir, src))
+
+ msger.debug('Globbed sources: %s' % (', '.join(srcs)))
+ for entry in srcs:
+ entry_dst_name = entry_name_fn(entry)
+ install_task.append((entry,
+ os.path.join(hdddir,
+ entry_dst_name)))
+ else:
+ install_task = [(os.path.join(bootimg_dir, src),
+ os.path.join(hdddir, dst))]
+
+ for task in install_task:
+ src_path, dst_path = task
+ msger.debug('Install %s as %s' % (os.path.basename(src_path),
+ dst_path))
+ install_cmd = "install -m 0644 -D %s %s" \
+ % (src_path, dst_path)
+ exec_cmd(install_cmd)
+
+ msger.debug('Prepare boot partition using rootfs in %s' % (hdddir))
+ part.prepare_rootfs(cr_workdir, oe_builddir, hdddir,
+ native_sysroot)
+
diff --git a/scripts/lib/wic/plugins/source/bootimg-pcbios.py b/scripts/lib/wic/plugins/source/bootimg-pcbios.py
index aceed20428..8a1aca1ad1 100644
--- a/scripts/lib/wic/plugins/source/bootimg-pcbios.py
+++ b/scripts/lib/wic/plugins/source/bootimg-pcbios.py
@@ -127,15 +127,23 @@ class BootimgPcbiosPlugin(SourcePlugin):
'prepares' the partition to be incorporated into the image.
In this case, prepare content for legacy bios boot partition.
"""
- if not bootimg_dir:
+ def _has_syslinux(dir):
+ if dir:
+ syslinux = "%s/syslinux" % dir
+ if os.path.exists(syslinux):
+ return True
+ return False
+
+ if not _has_syslinux(bootimg_dir):
bootimg_dir = get_bitbake_var("STAGING_DATADIR")
if not bootimg_dir:
msger.error("Couldn't find STAGING_DATADIR, exiting\n")
+ 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)
staging_kernel_dir = kernel_dir
- staging_data_dir = bootimg_dir
hdddir = "%s/hdd/boot" % cr_workdir
@@ -144,7 +152,7 @@ class BootimgPcbiosPlugin(SourcePlugin):
exec_cmd(install_cmd)
install_cmd = "install -m 444 %s/syslinux/ldlinux.sys %s/ldlinux.sys" \
- % (staging_data_dir, hdddir)
+ % (bootimg_dir, hdddir)
exec_cmd(install_cmd)
du_cmd = "du -bks %s" % hdddir
diff --git a/scripts/lib/wic/utils/errors.py b/scripts/lib/wic/utils/errors.py
index 86e230ac19..9410311875 100644
--- a/scripts/lib/wic/utils/errors.py
+++ b/scripts/lib/wic/utils/errors.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python -tt
+#!/usr/bin/env python -tt
#
# Copyright (c) 2007 Red Hat, Inc.
# Copyright (c) 2011 Intel, Inc.
diff --git a/scripts/lib/wic/utils/fs_related.py b/scripts/lib/wic/utils/fs_related.py
index 79cc1d52a7..ea9f85c60f 100644
--- a/scripts/lib/wic/utils/fs_related.py
+++ b/scripts/lib/wic/utils/fs_related.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python -tt
+#!/usr/bin/env python -tt
#
# Copyright (c) 2007, Red Hat, Inc.
# Copyright (c) 2009, 2010, 2011 Intel, Inc.
diff --git a/scripts/lib/wic/utils/misc.py b/scripts/lib/wic/utils/misc.py
index 194b88f691..6e56316608 100644
--- a/scripts/lib/wic/utils/misc.py
+++ b/scripts/lib/wic/utils/misc.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python -tt
+#!/usr/bin/env python -tt
#
# Copyright (c) 2010, 2011 Intel Inc.
#
diff --git a/scripts/lib/wic/utils/oe/misc.py b/scripts/lib/wic/utils/oe/misc.py
index aa9b23582b..b0b5baab73 100644
--- a/scripts/lib/wic/utils/oe/misc.py
+++ b/scripts/lib/wic/utils/oe/misc.py
@@ -123,6 +123,7 @@ def add_wks_var(key, val):
BOOTDD_EXTRA_SPACE = 16384
IMAGE_EXTRA_SPACE = 10240
+IMAGE_OVERHEAD_FACTOR = 1.3
__bitbake_env_lines = ""
diff --git a/scripts/lib/wic/utils/partitionedfs.py b/scripts/lib/wic/utils/partitionedfs.py
index 76aa42135b..fb95cc790e 100644
--- a/scripts/lib/wic/utils/partitionedfs.py
+++ b/scripts/lib/wic/utils/partitionedfs.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python -tt
+#!/usr/bin/env python -tt
#
# Copyright (c) 2009, 2010, 2011 Intel, Inc.
# Copyright (c) 2007, 2008 Red Hat, Inc.
@@ -155,9 +155,6 @@ class Image:
# Skip one sector required for the partitioning scheme overhead
d['offset'] += overhead
- # Steal few sectors from the first partition to offset for the
- # partitioning overhead
- p['size'] -= overhead
if p['align']:
# If not first partition and we do have alignment set we need
@@ -167,16 +164,19 @@ class Image:
# Calc how much the alignment is off.
align_sectors = d['offset'] % (p['align'] * 1024 / self.sector_size)
- # We need to move forward to the next alignment point
- align_sectors = (p['align'] * 1024 / self.sector_size) - align_sectors
- msger.debug("Realignment for %s%s with %s sectors, original"
- " offset %s, target alignment is %sK." %
- (p['disk_name'], d['numpart'], align_sectors,
- d['offset'], p['align']))
+ if align_sectors:
+ # If partition is not aligned as required, we need
+ # to move forward to the next alignment point
+ align_sectors = (p['align'] * 1024 / self.sector_size) - align_sectors
- # increase the offset so we actually start the partition on right alignment
- d['offset'] += align_sectors
+ msger.debug("Realignment for %s%s with %s sectors, original"
+ " offset %s, target alignment is %sK." %
+ (p['disk_name'], d['numpart'], align_sectors,
+ d['offset'], p['align']))
+
+ # increase the offset so we actually start the partition on right alignment
+ d['offset'] += align_sectors
p['start'] = d['offset']
d['offset'] += p['size']
diff --git a/scripts/lib/wic/utils/runner.py b/scripts/lib/wic/utils/runner.py
index e740dad253..2ae9f417c5 100644
--- a/scripts/lib/wic/utils/runner.py
+++ b/scripts/lib/wic/utils/runner.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python -tt
+#!/usr/bin/env python -tt
#
# Copyright (c) 2011 Intel, Inc.
#