wic: Remove special-case bootimg_dir
The first iterations of wic very shortsightedly catered to two specific use-cases and added special-purpose params for those cases so that they could be directly given their corresponding boot artifacts. (hdddir and staging_data_dir). As more use-cases are added, it becomes rather obvious that such a scheme doens't scale, and additionally causes confusion for plugin writers. This removes those special cases and states explicitly in the help text that plugins are responsible for locating their own boot artifacts. (From OE-Core rev: 6ba3eb5ff7c47aee6b3419fb3a348a634fe74ac9) Signed-off-by: Tom Zanussi <tom.zanussi@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
parent
38400617fe
commit
42d0334aa8
|
@ -67,7 +67,7 @@ def find_artifacts(image_name):
|
||||||
"""
|
"""
|
||||||
bitbake_env_lines = get_bitbake_env_lines()
|
bitbake_env_lines = get_bitbake_env_lines()
|
||||||
|
|
||||||
rootfs_dir = kernel_dir = hdddir = staging_data_dir = native_sysroot = ""
|
rootfs_dir = kernel_dir = bootimg_dir = native_sysroot = ""
|
||||||
|
|
||||||
for line in bitbake_env_lines.split('\n'):
|
for line in bitbake_env_lines.split('\n'):
|
||||||
if (get_line_val(line, "IMAGE_ROOTFS")):
|
if (get_line_val(line, "IMAGE_ROOTFS")):
|
||||||
|
@ -76,17 +76,11 @@ def find_artifacts(image_name):
|
||||||
if (get_line_val(line, "STAGING_KERNEL_DIR")):
|
if (get_line_val(line, "STAGING_KERNEL_DIR")):
|
||||||
kernel_dir = get_line_val(line, "STAGING_KERNEL_DIR")
|
kernel_dir = get_line_val(line, "STAGING_KERNEL_DIR")
|
||||||
continue
|
continue
|
||||||
if (get_line_val(line, "HDDDIR")):
|
|
||||||
hdddir = get_line_val(line, "HDDDIR")
|
|
||||||
continue
|
|
||||||
if (get_line_val(line, "STAGING_DATADIR")):
|
|
||||||
staging_data_dir = get_line_val(line, "STAGING_DATADIR")
|
|
||||||
continue
|
|
||||||
if (get_line_val(line, "STAGING_DIR_NATIVE")):
|
if (get_line_val(line, "STAGING_DIR_NATIVE")):
|
||||||
native_sysroot = get_line_val(line, "STAGING_DIR_NATIVE")
|
native_sysroot = get_line_val(line, "STAGING_DIR_NATIVE")
|
||||||
continue
|
continue
|
||||||
|
|
||||||
return (rootfs_dir, kernel_dir, hdddir, staging_data_dir, native_sysroot)
|
return (rootfs_dir, kernel_dir, bootimg_dir, native_sysroot)
|
||||||
|
|
||||||
|
|
||||||
CANNED_IMAGE_DIR = "lib/image/canned-wks" # relative to scripts
|
CANNED_IMAGE_DIR = "lib/image/canned-wks" # relative to scripts
|
||||||
|
@ -185,18 +179,15 @@ def list_source_plugins():
|
||||||
|
|
||||||
|
|
||||||
def wic_create(args, wks_file, rootfs_dir, bootimg_dir, kernel_dir,
|
def wic_create(args, wks_file, rootfs_dir, bootimg_dir, kernel_dir,
|
||||||
native_sysroot, hdddir, staging_data_dir, scripts_path,
|
native_sysroot, scripts_path, image_output_dir, debug,
|
||||||
image_output_dir, debug, properties_file, properties=None):
|
properties_file, properties=None):
|
||||||
"""
|
"""Create image
|
||||||
Create image
|
|
||||||
|
|
||||||
wks_file - user-defined OE kickstart file
|
wks_file - user-defined OE kickstart file
|
||||||
rootfs_dir - absolute path to the build's /rootfs dir
|
rootfs_dir - absolute path to the build's /rootfs dir
|
||||||
bootimg_dir - absolute path to the build's boot artifacts directory
|
bootimg_dir - absolute path to the build's boot artifacts directory
|
||||||
kernel_dir - absolute path to the build's kernel directory
|
kernel_dir - absolute path to the build's kernel directory
|
||||||
native_sysroot - absolute path to the build's native sysroots dir
|
native_sysroot - absolute path to the build's native sysroots dir
|
||||||
hdddir - absolute path to the build's HDDDIR dir
|
|
||||||
staging_data_dir - absolute path to the build's STAGING_DATA_DIR dir
|
|
||||||
scripts_path - absolute path to /scripts dir
|
scripts_path - absolute path to /scripts dir
|
||||||
image_output_dir - dirname to create for image
|
image_output_dir - dirname to create for image
|
||||||
properties_file - use values from this file if nonempty i.e no prompting
|
properties_file - use values from this file if nonempty i.e no prompting
|
||||||
|
@ -211,22 +202,14 @@ def wic_create(args, wks_file, rootfs_dir, bootimg_dir, kernel_dir,
|
||||||
rootfs_dir: IMAGE_ROOTFS
|
rootfs_dir: IMAGE_ROOTFS
|
||||||
kernel_dir: STAGING_KERNEL_DIR
|
kernel_dir: STAGING_KERNEL_DIR
|
||||||
native_sysroot: STAGING_DIR_NATIVE
|
native_sysroot: STAGING_DIR_NATIVE
|
||||||
hdddir: HDDDIR
|
|
||||||
staging_data_dir: STAGING_DATA_DIR
|
|
||||||
|
|
||||||
In the above case, bootimg_dir remains unset and the image
|
In the above case, bootimg_dir remains unset and the
|
||||||
creation code determines which of the passed-in directories to
|
plugin-specific image creation code is responsible for finding the
|
||||||
use.
|
bootimg artifacts.
|
||||||
|
|
||||||
In the case where the values are passed in explicitly i.e 'wic -e'
|
In the case where the values are passed in explicitly i.e 'wic -e'
|
||||||
is not used but rather the individual 'wic' options are used to
|
is not used but rather the individual 'wic' options are used to
|
||||||
explicitly specify these values, hdddir and staging_data_dir will
|
explicitly specify these values.
|
||||||
be unset, but bootimg_dir must be explicit i.e. explicitly set to
|
|
||||||
either hdddir or staging_data_dir, depending on the image being
|
|
||||||
generated. The other values (rootfs_dir, kernel_dir, and
|
|
||||||
native_sysroot) correspond to the same values found above via
|
|
||||||
'bitbake -e').
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
oe_builddir = os.environ["BUILDDIR"]
|
oe_builddir = os.environ["BUILDDIR"]
|
||||||
|
@ -242,8 +225,6 @@ def wic_create(args, wks_file, rootfs_dir, bootimg_dir, kernel_dir,
|
||||||
direct_args.insert(0, bootimg_dir)
|
direct_args.insert(0, bootimg_dir)
|
||||||
direct_args.insert(0, kernel_dir)
|
direct_args.insert(0, kernel_dir)
|
||||||
direct_args.insert(0, native_sysroot)
|
direct_args.insert(0, native_sysroot)
|
||||||
direct_args.insert(0, hdddir)
|
|
||||||
direct_args.insert(0, staging_data_dir)
|
|
||||||
direct_args.insert(0, "direct")
|
direct_args.insert(0, "direct")
|
||||||
|
|
||||||
if debug:
|
if debug:
|
||||||
|
|
|
@ -189,7 +189,7 @@ DESCRIPTION
|
||||||
-r: IMAGE_ROOTFS
|
-r: IMAGE_ROOTFS
|
||||||
-k: STAGING_KERNEL_DIR
|
-k: STAGING_KERNEL_DIR
|
||||||
-n: STAGING_DIR_NATIVE
|
-n: STAGING_DIR_NATIVE
|
||||||
-b: HDDDIR and STAGING_DATA_DIR (handlers decide which to use)
|
-b: empty (plugin-specific handlers must determine this)
|
||||||
|
|
||||||
If 'wic -e' is not used, the user needs to select the appropriate
|
If 'wic -e' is not used, the user needs to select the appropriate
|
||||||
value for -b (as well as -r, -k, and -n).
|
value for -b (as well as -r, -k, and -n).
|
||||||
|
|
|
@ -52,8 +52,7 @@ class DirectImageCreator(BaseImageCreator):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, oe_builddir, image_output_dir, rootfs_dir, bootimg_dir,
|
def __init__(self, oe_builddir, image_output_dir, rootfs_dir, bootimg_dir,
|
||||||
kernel_dir, native_sysroot, hdddir, staging_data_dir,
|
kernel_dir, native_sysroot, creatoropts=None):
|
||||||
creatoropts=None):
|
|
||||||
"""
|
"""
|
||||||
Initialize a DirectImageCreator instance.
|
Initialize a DirectImageCreator instance.
|
||||||
|
|
||||||
|
@ -74,8 +73,6 @@ class DirectImageCreator(BaseImageCreator):
|
||||||
self.bootimg_dir = bootimg_dir
|
self.bootimg_dir = bootimg_dir
|
||||||
self.kernel_dir = kernel_dir
|
self.kernel_dir = kernel_dir
|
||||||
self.native_sysroot = native_sysroot
|
self.native_sysroot = native_sysroot
|
||||||
self.hdddir = hdddir
|
|
||||||
self.staging_data_dir = staging_data_dir
|
|
||||||
|
|
||||||
def __write_fstab(self, image_rootfs):
|
def __write_fstab(self, image_rootfs):
|
||||||
"""overriden to generate fstab (temporarily) in rootfs. This is called
|
"""overriden to generate fstab (temporarily) in rootfs. This is called
|
||||||
|
|
|
@ -58,21 +58,19 @@ class DirectPlugin(ImagerPlugin):
|
||||||
"""
|
"""
|
||||||
Create direct image, called from creator as 'direct' cmd
|
Create direct image, called from creator as 'direct' cmd
|
||||||
"""
|
"""
|
||||||
if len(args) != 9:
|
if len(args) != 7:
|
||||||
raise errors.Usage("Extra arguments given")
|
raise errors.Usage("Extra arguments given")
|
||||||
|
|
||||||
staging_data_dir = args[0]
|
native_sysroot = args[0]
|
||||||
hdddir = args[1]
|
kernel_dir = args[1]
|
||||||
native_sysroot = args[2]
|
bootimg_dir = args[2]
|
||||||
kernel_dir = args[3]
|
rootfs_dir = args[3]
|
||||||
bootimg_dir = args[4]
|
|
||||||
rootfs_dir = args[5]
|
|
||||||
|
|
||||||
creatoropts = configmgr.create
|
creatoropts = configmgr.create
|
||||||
ksconf = args[6]
|
ksconf = args[4]
|
||||||
|
|
||||||
image_output_dir = args[7]
|
image_output_dir = args[5]
|
||||||
oe_builddir = args[8]
|
oe_builddir = args[6]
|
||||||
|
|
||||||
krootfs_dir = self.__rootfs_dir_to_dict(rootfs_dir)
|
krootfs_dir = self.__rootfs_dir_to_dict(rootfs_dir)
|
||||||
|
|
||||||
|
@ -84,8 +82,6 @@ class DirectPlugin(ImagerPlugin):
|
||||||
bootimg_dir,
|
bootimg_dir,
|
||||||
kernel_dir,
|
kernel_dir,
|
||||||
native_sysroot,
|
native_sysroot,
|
||||||
hdddir,
|
|
||||||
staging_data_dir,
|
|
||||||
creatoropts)
|
creatoropts)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -173,7 +173,6 @@ class BootimgEFIPlugin(SourcePlugin):
|
||||||
cr.set_bootimg_dir(bootimg_dir)
|
cr.set_bootimg_dir(bootimg_dir)
|
||||||
|
|
||||||
staging_kernel_dir = kernel_dir
|
staging_kernel_dir = kernel_dir
|
||||||
staging_data_dir = bootimg_dir
|
|
||||||
|
|
||||||
hdddir = "%s/hdd/boot" % cr_workdir
|
hdddir = "%s/hdd/boot" % cr_workdir
|
||||||
|
|
||||||
|
@ -185,12 +184,12 @@ class BootimgEFIPlugin(SourcePlugin):
|
||||||
if source_params['loader'] == 'grub-efi':
|
if source_params['loader'] == 'grub-efi':
|
||||||
shutil.copyfile("%s/hdd/boot/EFI/BOOT/grub.cfg" % cr_workdir,
|
shutil.copyfile("%s/hdd/boot/EFI/BOOT/grub.cfg" % cr_workdir,
|
||||||
"%s/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)
|
exec_cmd(cp_cmd, True)
|
||||||
shutil.move("%s/grub.cfg" % cr_workdir,
|
shutil.move("%s/grub.cfg" % cr_workdir,
|
||||||
"%s/hdd/boot/EFI/BOOT/grub.cfg" % cr_workdir)
|
"%s/hdd/boot/EFI/BOOT/grub.cfg" % cr_workdir)
|
||||||
elif source_params['loader'] == 'gummiboot':
|
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)
|
exec_cmd(cp_cmd, True)
|
||||||
else:
|
else:
|
||||||
msger.error("unrecognized bootimg-efi loader: %s" % source_params['loader'])
|
msger.error("unrecognized bootimg-efi loader: %s" % source_params['loader'])
|
||||||
|
|
|
@ -144,7 +144,6 @@ class BootimgPcbiosPlugin(SourcePlugin):
|
||||||
cr.set_bootimg_dir(bootimg_dir)
|
cr.set_bootimg_dir(bootimg_dir)
|
||||||
|
|
||||||
staging_kernel_dir = kernel_dir
|
staging_kernel_dir = kernel_dir
|
||||||
staging_data_dir = bootimg_dir
|
|
||||||
|
|
||||||
hdddir = "%s/hdd/boot" % cr_workdir
|
hdddir = "%s/hdd/boot" % cr_workdir
|
||||||
|
|
||||||
|
@ -153,7 +152,7 @@ class BootimgPcbiosPlugin(SourcePlugin):
|
||||||
exec_cmd(install_cmd)
|
exec_cmd(install_cmd)
|
||||||
|
|
||||||
install_cmd = "install -m 444 %s/syslinux/ldlinux.sys %s/ldlinux.sys" \
|
install_cmd = "install -m 444 %s/syslinux/ldlinux.sys %s/ldlinux.sys" \
|
||||||
% (staging_data_dir, hdddir)
|
% (bootimg_dir, hdddir)
|
||||||
exec_cmd(install_cmd)
|
exec_cmd(install_cmd)
|
||||||
|
|
||||||
du_cmd = "du -bks %s" % hdddir
|
du_cmd = "du -bks %s" % hdddir
|
||||||
|
|
12
scripts/wic
12
scripts/wic
|
@ -131,11 +131,11 @@ def wic_create_subcommand(args, usage_str):
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
set_bitbake_env_lines(bitbake_env_lines)
|
set_bitbake_env_lines(bitbake_env_lines)
|
||||||
|
|
||||||
bootimg_dir = staging_data_dir = hdddir = ""
|
bootimg_dir = ""
|
||||||
|
|
||||||
if options.image_name:
|
if options.image_name:
|
||||||
(rootfs_dir, kernel_dir, hdddir, staging_data_dir, native_sysroot) = \
|
(rootfs_dir, kernel_dir, bootimg_dir, native_sysroot) \
|
||||||
find_artifacts(options.image_name)
|
= find_artifacts(options.image_name)
|
||||||
|
|
||||||
wks_file = args[0]
|
wks_file = args[0]
|
||||||
|
|
||||||
|
@ -172,8 +172,6 @@ def wic_create_subcommand(args, usage_str):
|
||||||
not_found = not_found_dir = ""
|
not_found = not_found_dir = ""
|
||||||
if not os.path.isdir(rootfs_dir):
|
if not os.path.isdir(rootfs_dir):
|
||||||
(not_found, not_found_dir) = ("rootfs-dir", rootfs_dir)
|
(not_found, not_found_dir) = ("rootfs-dir", rootfs_dir)
|
||||||
elif not os.path.isdir(hdddir) and not os.path.isdir(staging_data_dir):
|
|
||||||
(not_found, not_found_dir) = ("bootimg-dir", bootimg_dir)
|
|
||||||
elif not os.path.isdir(kernel_dir):
|
elif not os.path.isdir(kernel_dir):
|
||||||
(not_found, not_found_dir) = ("kernel-dir", kernel_dir)
|
(not_found, not_found_dir) = ("kernel-dir", kernel_dir)
|
||||||
elif not os.path.isdir(native_sysroot):
|
elif not os.path.isdir(native_sysroot):
|
||||||
|
@ -197,8 +195,8 @@ def wic_create_subcommand(args, usage_str):
|
||||||
rootfs_dir = rootfs_dir_to_args(krootfs_dir)
|
rootfs_dir = rootfs_dir_to_args(krootfs_dir)
|
||||||
|
|
||||||
wic_create(args, wks_file, rootfs_dir, bootimg_dir, kernel_dir,
|
wic_create(args, wks_file, rootfs_dir, bootimg_dir, kernel_dir,
|
||||||
native_sysroot, hdddir, staging_data_dir, scripts_path,
|
native_sysroot, scripts_path, image_output_dir,
|
||||||
image_output_dir, options.debug, options.properties_file)
|
options.debug, options.properties_file)
|
||||||
|
|
||||||
|
|
||||||
def wic_list_subcommand(args, usage_str):
|
def wic_list_subcommand(args, usage_str):
|
||||||
|
|
Loading…
Reference in New Issue