diff options
Diffstat (limited to 'scripts/lib')
| -rw-r--r-- | scripts/lib/wic/plugins/imager/direct.py | 6 | ||||
| -rw-r--r-- | scripts/lib/wic/plugins/source/bootimg-efi.py | 32 | ||||
| -rw-r--r-- | scripts/lib/wic/plugins/source/bootimg-partition.py | 11 | ||||
| -rw-r--r-- | scripts/lib/wic/plugins/source/bootimg-pcbios.py | 20 | ||||
| -rw-r--r-- | scripts/lib/wic/plugins/source/fsimage.py | 8 | ||||
| -rw-r--r-- | scripts/lib/wic/plugins/source/isoimage-isohybrid.py | 63 | ||||
| -rw-r--r-- | scripts/lib/wic/plugins/source/rawcopy.py | 8 | ||||
| -rw-r--r-- | scripts/lib/wic/plugins/source/rootfs.py | 17 | ||||
| -rw-r--r-- | scripts/lib/wic/plugins/source/rootfs_pcbios_ext.py | 34 |
9 files changed, 75 insertions, 124 deletions
diff --git a/scripts/lib/wic/plugins/imager/direct.py b/scripts/lib/wic/plugins/imager/direct.py index e51c8be298..9c8a2304a7 100644 --- a/scripts/lib/wic/plugins/imager/direct.py +++ b/scripts/lib/wic/plugins/imager/direct.py | |||
| @@ -27,13 +27,12 @@ | |||
| 27 | import logging | 27 | import logging |
| 28 | import os | 28 | import os |
| 29 | import shutil | 29 | import shutil |
| 30 | import sys | ||
| 31 | import tempfile | 30 | import tempfile |
| 32 | import uuid | 31 | import uuid |
| 33 | 32 | ||
| 34 | from time import strftime | 33 | from time import strftime |
| 35 | 34 | ||
| 36 | from wic.errors import ImageError | 35 | from wic.errors import ImageError, WicError |
| 37 | from wic.filemap import sparse_copy | 36 | from wic.filemap import sparse_copy |
| 38 | from wic.ksparser import KickStart, KickStartError | 37 | from wic.ksparser import KickStart, KickStartError |
| 39 | from wic.plugin import pluginmgr | 38 | from wic.plugin import pluginmgr |
| @@ -58,8 +57,7 @@ class DirectPlugin(ImagerPlugin): | |||
| 58 | try: | 57 | try: |
| 59 | self.ks = KickStart(wks_file) | 58 | self.ks = KickStart(wks_file) |
| 60 | except KickStartError as err: | 59 | except KickStartError as err: |
| 61 | logger.error(str(err)) | 60 | raise WicError(str(err)) |
| 62 | sys.exit(1) | ||
| 63 | 61 | ||
| 64 | # parse possible 'rootfs=name' items | 62 | # parse possible 'rootfs=name' items |
| 65 | self.rootfs_dir = dict(rdir.split('=') for rdir in rootfs_dir.split(' ')) | 63 | self.rootfs_dir = dict(rdir.split('=') for rdir in rootfs_dir.split(' ')) |
diff --git a/scripts/lib/wic/plugins/source/bootimg-efi.py b/scripts/lib/wic/plugins/source/bootimg-efi.py index e4c845129e..1f018fabf4 100644 --- a/scripts/lib/wic/plugins/source/bootimg-efi.py +++ b/scripts/lib/wic/plugins/source/bootimg-efi.py | |||
| @@ -27,8 +27,8 @@ | |||
| 27 | import logging | 27 | import logging |
| 28 | import os | 28 | import os |
| 29 | import shutil | 29 | import shutil |
| 30 | import sys | ||
| 31 | 30 | ||
| 31 | from wic.errors import WicError | ||
| 32 | from wic.engine import get_custom_config | 32 | from wic.engine import get_custom_config |
| 33 | from wic.pluginbase import SourcePlugin | 33 | from wic.pluginbase import SourcePlugin |
| 34 | from wic.utils.misc import (exec_cmd, exec_native_cmd, get_bitbake_var, | 34 | from wic.utils.misc import (exec_cmd, exec_native_cmd, get_bitbake_var, |
| @@ -59,9 +59,8 @@ class BootimgEFIPlugin(SourcePlugin): | |||
| 59 | logger.debug("Using custom configuration file " | 59 | logger.debug("Using custom configuration file " |
| 60 | "%s for grub.cfg", configfile) | 60 | "%s for grub.cfg", configfile) |
| 61 | else: | 61 | else: |
| 62 | logger.error("configfile is specified but failed to " | 62 | raise WicError("configfile is specified but failed to " |
| 63 | "get it from %s.", configfile) | 63 | "get it from %s." % configfile) |
| 64 | sys.exit(1) | ||
| 65 | 64 | ||
| 66 | if not custom_cfg: | 65 | if not custom_cfg: |
| 67 | # Create grub configuration using parameters from wks file | 66 | # Create grub configuration using parameters from wks file |
| @@ -108,8 +107,7 @@ class BootimgEFIPlugin(SourcePlugin): | |||
| 108 | # obviously we need to have a common common deploy var | 107 | # obviously we need to have a common common deploy var |
| 109 | bootimg_dir = get_bitbake_var("DEPLOY_DIR_IMAGE") | 108 | bootimg_dir = get_bitbake_var("DEPLOY_DIR_IMAGE") |
| 110 | if not bootimg_dir: | 109 | if not bootimg_dir: |
| 111 | logger.error("Couldn't find DEPLOY_DIR_IMAGE, exiting\n") | 110 | raise WicError("Couldn't find DEPLOY_DIR_IMAGE, exiting") |
| 112 | sys.exit(1) | ||
| 113 | 111 | ||
| 114 | cp_cmd = "cp %s/%s %s" % (bootimg_dir, initrd, hdddir) | 112 | cp_cmd = "cp %s/%s %s" % (bootimg_dir, initrd, hdddir) |
| 115 | exec_cmd(cp_cmd, True) | 113 | exec_cmd(cp_cmd, True) |
| @@ -132,9 +130,8 @@ class BootimgEFIPlugin(SourcePlugin): | |||
| 132 | logger.debug("Using custom configuration file " | 130 | logger.debug("Using custom configuration file " |
| 133 | "%s for systemd-boots's boot.conf", configfile) | 131 | "%s for systemd-boots's boot.conf", configfile) |
| 134 | else: | 132 | else: |
| 135 | logger.error("configfile is specified but failed to " | 133 | raise WicError("configfile is specified but failed to " |
| 136 | "get it from %s.", configfile) | 134 | "get it from %s.", configfile) |
| 137 | sys.exit(1) | ||
| 138 | 135 | ||
| 139 | if not custom_cfg: | 136 | if not custom_cfg: |
| 140 | # Create systemd-boot configuration using parameters from wks file | 137 | # Create systemd-boot configuration using parameters from wks file |
| @@ -174,11 +171,9 @@ class BootimgEFIPlugin(SourcePlugin): | |||
| 174 | elif source_params['loader'] == 'systemd-boot': | 171 | elif source_params['loader'] == 'systemd-boot': |
| 175 | cls.do_configure_systemdboot(hdddir, creator, cr_workdir, source_params) | 172 | cls.do_configure_systemdboot(hdddir, creator, cr_workdir, source_params) |
| 176 | else: | 173 | else: |
| 177 | logger.error("unrecognized bootimg-efi loader: %s", source_params['loader']) | 174 | raise WicError("unrecognized bootimg-efi loader: %s" % source_params['loader']) |
| 178 | sys.exit(1) | ||
| 179 | except KeyError: | 175 | except KeyError: |
| 180 | logger.error("bootimg-efi requires a loader, none specified") | 176 | raise WicError("bootimg-efi requires a loader, none specified") |
| 181 | sys.exit(1) | ||
| 182 | 177 | ||
| 183 | 178 | ||
| 184 | @classmethod | 179 | @classmethod |
| @@ -193,8 +188,7 @@ class BootimgEFIPlugin(SourcePlugin): | |||
| 193 | if not bootimg_dir: | 188 | if not bootimg_dir: |
| 194 | bootimg_dir = get_bitbake_var("DEPLOY_DIR_IMAGE") | 189 | bootimg_dir = get_bitbake_var("DEPLOY_DIR_IMAGE") |
| 195 | if not bootimg_dir: | 190 | if not bootimg_dir: |
| 196 | logger.error("Couldn't find DEPLOY_DIR_IMAGE, exiting\n") | 191 | raise WicError("Couldn't find DEPLOY_DIR_IMAGE, exiting") |
| 197 | sys.exit(1) | ||
| 198 | # just so the result notes display it | 192 | # just so the result notes display it |
| 199 | creator.bootimg_dir = bootimg_dir | 193 | creator.bootimg_dir = bootimg_dir |
| 200 | 194 | ||
| @@ -221,12 +215,10 @@ class BootimgEFIPlugin(SourcePlugin): | |||
| 221 | cp_cmd = "cp %s/%s %s/EFI/BOOT/%s" % (bootimg_dir, mod, hdddir, mod[8:]) | 215 | cp_cmd = "cp %s/%s %s/EFI/BOOT/%s" % (bootimg_dir, mod, hdddir, mod[8:]) |
| 222 | exec_cmd(cp_cmd, True) | 216 | exec_cmd(cp_cmd, True) |
| 223 | else: | 217 | else: |
| 224 | logger.error("unrecognized bootimg-efi loader: %s", | 218 | raise WicError("unrecognized bootimg-efi loader: %s" % |
| 225 | source_params['loader']) | 219 | source_params['loader']) |
| 226 | sys.exit(1) | ||
| 227 | except KeyError: | 220 | except KeyError: |
| 228 | logger.error("bootimg-efi requires a loader, none specified") | 221 | raise WicError("bootimg-efi requires a loader, none specified") |
| 229 | sys.exit(1) | ||
| 230 | 222 | ||
| 231 | startup = os.path.join(bootimg_dir, "startup.nsh") | 223 | startup = os.path.join(bootimg_dir, "startup.nsh") |
| 232 | if os.path.exists(startup): | 224 | if os.path.exists(startup): |
diff --git a/scripts/lib/wic/plugins/source/bootimg-partition.py b/scripts/lib/wic/plugins/source/bootimg-partition.py index b4869154fe..e9724a63a3 100644 --- a/scripts/lib/wic/plugins/source/bootimg-partition.py +++ b/scripts/lib/wic/plugins/source/bootimg-partition.py | |||
| @@ -26,10 +26,10 @@ | |||
| 26 | import logging | 26 | import logging |
| 27 | import os | 27 | import os |
| 28 | import re | 28 | import re |
| 29 | import sys | ||
| 30 | 29 | ||
| 31 | from glob import glob | 30 | from glob import glob |
| 32 | 31 | ||
| 32 | from wic.errors import WicError | ||
| 33 | from wic.pluginbase import SourcePlugin | 33 | from wic.pluginbase import SourcePlugin |
| 34 | from wic.utils.misc import exec_cmd, get_bitbake_var | 34 | from wic.utils.misc import exec_cmd, get_bitbake_var |
| 35 | 35 | ||
| @@ -81,16 +81,14 @@ class BootimgPartitionPlugin(SourcePlugin): | |||
| 81 | if not bootimg_dir: | 81 | if not bootimg_dir: |
| 82 | bootimg_dir = get_bitbake_var("DEPLOY_DIR_IMAGE") | 82 | bootimg_dir = get_bitbake_var("DEPLOY_DIR_IMAGE") |
| 83 | if not bootimg_dir: | 83 | if not bootimg_dir: |
| 84 | logger.error("Couldn't find DEPLOY_DIR_IMAGE, exiting\n") | 84 | raise WicError("Couldn't find DEPLOY_DIR_IMAGE, exiting") |
| 85 | sys.exit(1) | ||
| 86 | 85 | ||
| 87 | logger.debug('Bootimg dir: %s', bootimg_dir) | 86 | logger.debug('Bootimg dir: %s', bootimg_dir) |
| 88 | 87 | ||
| 89 | boot_files = get_bitbake_var("IMAGE_BOOT_FILES") | 88 | boot_files = get_bitbake_var("IMAGE_BOOT_FILES") |
| 90 | 89 | ||
| 91 | if not boot_files: | 90 | if not boot_files: |
| 92 | logger.error('No boot files defined, IMAGE_BOOT_FILES unset') | 91 | raise WicError('No boot files defined, IMAGE_BOOT_FILES unset') |
| 93 | sys.exit(1) | ||
| 94 | 92 | ||
| 95 | logger.debug('Boot files: %s', boot_files) | 93 | logger.debug('Boot files: %s', boot_files) |
| 96 | 94 | ||
| @@ -100,8 +98,7 @@ class BootimgPartitionPlugin(SourcePlugin): | |||
| 100 | if ';' in src_entry: | 98 | if ';' in src_entry: |
| 101 | dst_entry = tuple(src_entry.split(';')) | 99 | dst_entry = tuple(src_entry.split(';')) |
| 102 | if not dst_entry[0] or not dst_entry[1]: | 100 | if not dst_entry[0] or not dst_entry[1]: |
| 103 | logger.error('Malformed boot file entry: %s', src_entry) | 101 | raise WicError('Malformed boot file entry: %s' % src_entry) |
| 104 | sys.exit(1) | ||
| 105 | else: | 102 | else: |
| 106 | dst_entry = (src_entry, src_entry) | 103 | dst_entry = (src_entry, src_entry) |
| 107 | 104 | ||
diff --git a/scripts/lib/wic/plugins/source/bootimg-pcbios.py b/scripts/lib/wic/plugins/source/bootimg-pcbios.py index 8f53fa2a48..2ded2dac52 100644 --- a/scripts/lib/wic/plugins/source/bootimg-pcbios.py +++ b/scripts/lib/wic/plugins/source/bootimg-pcbios.py | |||
| @@ -26,10 +26,9 @@ | |||
| 26 | 26 | ||
| 27 | import logging | 27 | import logging |
| 28 | import os | 28 | import os |
| 29 | import sys | ||
| 30 | 29 | ||
| 31 | from wic.engine import get_custom_config | 30 | from wic.engine import get_custom_config |
| 32 | from wic.errors import ImageError | 31 | from wic.errors import ImageError, WicError |
| 33 | from wic.utils import runner | 32 | from wic.utils import runner |
| 34 | from wic.pluginbase import SourcePlugin | 33 | from wic.pluginbase import SourcePlugin |
| 35 | from wic.utils.misc import (exec_cmd, exec_native_cmd, | 34 | from wic.utils.misc import (exec_cmd, exec_native_cmd, |
| @@ -57,14 +56,13 @@ class BootimgPcbiosPlugin(SourcePlugin): | |||
| 57 | elif creator.ptable_format == 'gpt': | 56 | elif creator.ptable_format == 'gpt': |
| 58 | mbrfile += "gptmbr.bin" | 57 | mbrfile += "gptmbr.bin" |
| 59 | else: | 58 | else: |
| 60 | logger.error("Unsupported partition table: %s", creator.ptable_format) | 59 | raise WicError("Unsupported partition table: %s" % |
| 61 | sys.exit(1) | 60 | creator.ptable_format) |
| 62 | 61 | ||
| 63 | if not os.path.exists(mbrfile): | 62 | if not os.path.exists(mbrfile): |
| 64 | logger.error("Couldn't find %s. If using the -e option, do you " | 63 | raise WicError("Couldn't find %s. If using the -e option, do you " |
| 65 | "have the right MACHINE set in local.conf? If not, " | 64 | "have the right MACHINE set in local.conf? If not, " |
| 66 | "is the bootimg_dir path correct?", mbrfile) | 65 | "is the bootimg_dir path correct?" % mbrfile) |
| 67 | sys.exit(1) | ||
| 68 | 66 | ||
| 69 | full_path = creator._full_path(workdir, disk_name, "direct") | 67 | full_path = creator._full_path(workdir, disk_name, "direct") |
| 70 | logger.debug("Installing MBR on disk %s as %s with size %s bytes", | 68 | logger.debug("Installing MBR on disk %s as %s with size %s bytes", |
| @@ -152,11 +150,9 @@ class BootimgPcbiosPlugin(SourcePlugin): | |||
| 152 | if not _has_syslinux(bootimg_dir): | 150 | if not _has_syslinux(bootimg_dir): |
| 153 | bootimg_dir = get_bitbake_var("STAGING_DATADIR", "wic-tools") | 151 | bootimg_dir = get_bitbake_var("STAGING_DATADIR", "wic-tools") |
| 154 | if not bootimg_dir: | 152 | if not bootimg_dir: |
| 155 | logger.error("Couldn't find STAGING_DATADIR, exiting\n") | 153 | raise WicError("Couldn't find STAGING_DATADIR, exiting") |
| 156 | sys.exit(1) | ||
| 157 | if not _has_syslinux(bootimg_dir): | 154 | if not _has_syslinux(bootimg_dir): |
| 158 | logger.error("Please build syslinux first\n") | 155 | raise WicError("Please build syslinux first") |
| 159 | sys.exit(1) | ||
| 160 | # just so the result notes display it | 156 | # just so the result notes display it |
| 161 | creator.bootimg_dir = bootimg_dir | 157 | creator.bootimg_dir = bootimg_dir |
| 162 | 158 | ||
diff --git a/scripts/lib/wic/plugins/source/fsimage.py b/scripts/lib/wic/plugins/source/fsimage.py index 35fb78b832..67fc6d1b04 100644 --- a/scripts/lib/wic/plugins/source/fsimage.py +++ b/scripts/lib/wic/plugins/source/fsimage.py | |||
| @@ -17,8 +17,8 @@ | |||
| 17 | 17 | ||
| 18 | import logging | 18 | import logging |
| 19 | import os | 19 | import os |
| 20 | import sys | ||
| 21 | 20 | ||
| 21 | from wic.errors import WicError | ||
| 22 | from wic.pluginbase import SourcePlugin | 22 | from wic.pluginbase import SourcePlugin |
| 23 | from wic.utils.misc import get_bitbake_var | 23 | from wic.utils.misc import get_bitbake_var |
| 24 | 24 | ||
| @@ -61,14 +61,12 @@ class FSImagePlugin(SourcePlugin): | |||
| 61 | if not bootimg_dir: | 61 | if not bootimg_dir: |
| 62 | bootimg_dir = get_bitbake_var("DEPLOY_DIR_IMAGE") | 62 | bootimg_dir = get_bitbake_var("DEPLOY_DIR_IMAGE") |
| 63 | if not bootimg_dir: | 63 | if not bootimg_dir: |
| 64 | logger.error("Couldn't find DEPLOY_DIR_IMAGE, exiting\n") | 64 | raise WicError("Couldn't find DEPLOY_DIR_IMAGE, exiting") |
| 65 | sys.exit(1) | ||
| 66 | 65 | ||
| 67 | logger.debug('Bootimg dir: %s', bootimg_dir) | 66 | logger.debug('Bootimg dir: %s', bootimg_dir) |
| 68 | 67 | ||
| 69 | if 'file' not in source_params: | 68 | if 'file' not in source_params: |
| 70 | logger.error("No file specified\n") | 69 | raise WicError("No file specified") |
| 71 | sys.exit(1) | ||
| 72 | 70 | ||
| 73 | src = os.path.join(bootimg_dir, source_params['file']) | 71 | src = os.path.join(bootimg_dir, source_params['file']) |
| 74 | 72 | ||
diff --git a/scripts/lib/wic/plugins/source/isoimage-isohybrid.py b/scripts/lib/wic/plugins/source/isoimage-isohybrid.py index 33de6d8db5..df86acc0e0 100644 --- a/scripts/lib/wic/plugins/source/isoimage-isohybrid.py +++ b/scripts/lib/wic/plugins/source/isoimage-isohybrid.py | |||
| @@ -25,8 +25,8 @@ import logging | |||
| 25 | import os | 25 | import os |
| 26 | import re | 26 | import re |
| 27 | import shutil | 27 | import shutil |
| 28 | import sys | ||
| 29 | 28 | ||
| 29 | from wic.errors import WicError | ||
| 30 | from wic.engine import get_custom_config | 30 | from wic.engine import get_custom_config |
| 31 | from wic.pluginbase import SourcePlugin | 31 | from wic.pluginbase import SourcePlugin |
| 32 | from wic.utils.misc import exec_cmd, exec_native_cmd, get_bitbake_var | 32 | from wic.utils.misc import exec_cmd, exec_native_cmd, get_bitbake_var |
| @@ -106,9 +106,8 @@ class IsoImagePlugin(SourcePlugin): | |||
| 106 | logger.debug("Using custom configuration file %s for grub.cfg", | 106 | logger.debug("Using custom configuration file %s for grub.cfg", |
| 107 | configfile) | 107 | configfile) |
| 108 | else: | 108 | else: |
| 109 | logger.error("configfile is specified " | 109 | raise WicError("configfile is specified " |
| 110 | "but failed to get it from %s", configfile) | 110 | "but failed to get it from %s", configfile) |
| 111 | sys.exit(1) | ||
| 112 | else: | 111 | else: |
| 113 | splash = os.path.join(cr_workdir, "EFI/boot/splash.jpg") | 112 | splash = os.path.join(cr_workdir, "EFI/boot/splash.jpg") |
| 114 | if os.path.exists(splash): | 113 | if os.path.exists(splash): |
| @@ -153,23 +152,19 @@ class IsoImagePlugin(SourcePlugin): | |||
| 153 | if not initrd: | 152 | if not initrd: |
| 154 | initrd_dir = get_bitbake_var("DEPLOY_DIR_IMAGE") | 153 | initrd_dir = get_bitbake_var("DEPLOY_DIR_IMAGE") |
| 155 | if not initrd_dir: | 154 | if not initrd_dir: |
| 156 | logger.error("Couldn't find DEPLOY_DIR_IMAGE, exiting.\n") | 155 | raise WicError("Couldn't find DEPLOY_DIR_IMAGE, exiting.") |
| 157 | sys.exit(1) | ||
| 158 | 156 | ||
| 159 | image_name = get_bitbake_var("IMAGE_BASENAME") | 157 | image_name = get_bitbake_var("IMAGE_BASENAME") |
| 160 | if not image_name: | 158 | if not image_name: |
| 161 | logger.error("Couldn't find IMAGE_BASENAME, exiting.\n") | 159 | raise WicError("Couldn't find IMAGE_BASENAME, exiting.") |
| 162 | sys.exit(1) | ||
| 163 | 160 | ||
| 164 | image_type = get_bitbake_var("INITRAMFS_FSTYPES") | 161 | image_type = get_bitbake_var("INITRAMFS_FSTYPES") |
| 165 | if not image_type: | 162 | if not image_type: |
| 166 | logger.error("Couldn't find INITRAMFS_FSTYPES, exiting.\n") | 163 | raise WicError("Couldn't find INITRAMFS_FSTYPES, exiting.") |
| 167 | sys.exit(1) | ||
| 168 | 164 | ||
| 169 | target_arch = get_bitbake_var("TRANSLATED_TARGET_ARCH") | 165 | target_arch = get_bitbake_var("TRANSLATED_TARGET_ARCH") |
| 170 | if not target_arch: | 166 | if not target_arch: |
| 171 | logger.error("Couldn't find TRANSLATED_TARGET_ARCH, exiting.\n") | 167 | raise WicError("Couldn't find TRANSLATED_TARGET_ARCH, exiting.") |
| 172 | sys.exit(1) | ||
| 173 | 168 | ||
| 174 | initrd = glob.glob('%s/%s*%s.%s' % (initrd_dir, image_name, target_arch, image_type))[0] | 169 | initrd = glob.glob('%s/%s*%s.%s' % (initrd_dir, image_name, target_arch, image_type))[0] |
| 175 | 170 | ||
| @@ -192,8 +187,7 @@ class IsoImagePlugin(SourcePlugin): | |||
| 192 | os.symlink(os.readlink("%s/sbin/init" % rootfs_dir), \ | 187 | os.symlink(os.readlink("%s/sbin/init" % rootfs_dir), \ |
| 193 | "%s/init" % initrd_dir) | 188 | "%s/init" % initrd_dir) |
| 194 | else: | 189 | else: |
| 195 | logger.error("Couldn't find or build initrd, exiting.\n") | 190 | raise WicError("Couldn't find or build initrd, exiting.") |
| 196 | sys.exit(1) | ||
| 197 | 191 | ||
| 198 | exec_cmd("cd %s && find . | cpio -o -H newc -R +0:+0 >./initrd.cpio " \ | 192 | exec_cmd("cd %s && find . | cpio -o -H newc -R +0:+0 >./initrd.cpio " \ |
| 199 | % initrd_dir, as_shell=True) | 193 | % initrd_dir, as_shell=True) |
| @@ -239,8 +233,7 @@ class IsoImagePlugin(SourcePlugin): | |||
| 239 | 233 | ||
| 240 | if part.rootfs_dir is None: | 234 | if part.rootfs_dir is None: |
| 241 | if not 'ROOTFS_DIR' in rootfs_dir: | 235 | if not 'ROOTFS_DIR' in rootfs_dir: |
| 242 | logger.error("Couldn't find --rootfs-dir, exiting.\n") | 236 | raise WicError("Couldn't find --rootfs-dir, exiting.") |
| 243 | sys.exit(1) | ||
| 244 | rootfs_dir = rootfs_dir['ROOTFS_DIR'] | 237 | rootfs_dir = rootfs_dir['ROOTFS_DIR'] |
| 245 | else: | 238 | else: |
| 246 | if part.rootfs_dir in rootfs_dir: | 239 | if part.rootfs_dir in rootfs_dir: |
| @@ -248,16 +241,14 @@ class IsoImagePlugin(SourcePlugin): | |||
| 248 | elif part.rootfs_dir: | 241 | elif part.rootfs_dir: |
| 249 | rootfs_dir = part.rootfs_dir | 242 | rootfs_dir = part.rootfs_dir |
| 250 | else: | 243 | else: |
| 251 | logger.error("Couldn't find --rootfs-dir=%s connection " | 244 | raise WicError("Couldn't find --rootfs-dir=%s connection " |
| 252 | "or it is not a valid path, exiting.\n", | 245 | "or it is not a valid path, exiting." % |
| 253 | part.rootfs_dir) | 246 | part.rootfs_dir) |
| 254 | sys.exit(1) | ||
| 255 | 247 | ||
| 256 | if not os.path.isdir(rootfs_dir): | 248 | if not os.path.isdir(rootfs_dir): |
| 257 | rootfs_dir = get_bitbake_var("IMAGE_ROOTFS") | 249 | rootfs_dir = get_bitbake_var("IMAGE_ROOTFS") |
| 258 | if not os.path.isdir(rootfs_dir): | 250 | if not os.path.isdir(rootfs_dir): |
| 259 | logger.error("Couldn't find IMAGE_ROOTFS, exiting.\n") | 251 | raise WicError("Couldn't find IMAGE_ROOTFS, exiting.") |
| 260 | sys.exit(1) | ||
| 261 | 252 | ||
| 262 | part.rootfs_dir = rootfs_dir | 253 | part.rootfs_dir = rootfs_dir |
| 263 | 254 | ||
| @@ -296,8 +287,7 @@ class IsoImagePlugin(SourcePlugin): | |||
| 296 | if source_params.get('initrd'): | 287 | if source_params.get('initrd'): |
| 297 | initrd = source_params['initrd'] | 288 | initrd = source_params['initrd'] |
| 298 | if not deploy_dir: | 289 | if not deploy_dir: |
| 299 | logger.error("Couldn't find DEPLOY_DIR_IMAGE, exiting\n") | 290 | raise WicError("Couldn't find DEPLOY_DIR_IMAGE, exiting") |
| 300 | sys.exit(1) | ||
| 301 | cp_cmd = "cp %s/%s %s" % (deploy_dir, initrd, cr_workdir) | 291 | cp_cmd = "cp %s/%s %s" % (deploy_dir, initrd, cr_workdir) |
| 302 | exec_cmd(cp_cmd) | 292 | exec_cmd(cp_cmd) |
| 303 | else: | 293 | else: |
| @@ -340,8 +330,7 @@ class IsoImagePlugin(SourcePlugin): | |||
| 340 | # didn't contains it | 330 | # didn't contains it |
| 341 | target_arch = get_bitbake_var("TARGET_SYS") | 331 | target_arch = get_bitbake_var("TARGET_SYS") |
| 342 | if not target_arch: | 332 | if not target_arch: |
| 343 | logger.error("Coludn't find target architecture\n") | 333 | raise WicError("Coludn't find target architecture") |
| 344 | sys.exit(1) | ||
| 345 | 334 | ||
| 346 | if re.match("x86_64", target_arch): | 335 | if re.match("x86_64", target_arch): |
| 347 | grub_target = 'x86_64-efi' | 336 | grub_target = 'x86_64-efi' |
| @@ -350,21 +339,18 @@ class IsoImagePlugin(SourcePlugin): | |||
| 350 | grub_target = 'i386-efi' | 339 | grub_target = 'i386-efi' |
| 351 | grub_image = "bootia32.efi" | 340 | grub_image = "bootia32.efi" |
| 352 | else: | 341 | else: |
| 353 | logger.error("grub-efi is incompatible with target %s\n", | 342 | raise WicError("grub-efi is incompatible with target %s" % |
| 354 | target_arch) | 343 | target_arch) |
| 355 | sys.exit(1) | ||
| 356 | 344 | ||
| 357 | if not os.path.isfile("%s/EFI/BOOT/%s" \ | 345 | if not os.path.isfile("%s/EFI/BOOT/%s" \ |
| 358 | % (bootimg_dir, grub_image)): | 346 | % (bootimg_dir, grub_image)): |
| 359 | grub_path = get_bitbake_var("STAGING_LIBDIR", "wic-tools") | 347 | grub_path = get_bitbake_var("STAGING_LIBDIR", "wic-tools") |
| 360 | if not grub_path: | 348 | if not grub_path: |
| 361 | logger.error("Couldn't find STAGING_LIBDIR, exiting.\n") | 349 | raise WicError("Couldn't find STAGING_LIBDIR, exiting.") |
| 362 | sys.exit(1) | ||
| 363 | 350 | ||
| 364 | grub_core = "%s/grub/%s" % (grub_path, grub_target) | 351 | grub_core = "%s/grub/%s" % (grub_path, grub_target) |
| 365 | if not os.path.exists(grub_core): | 352 | if not os.path.exists(grub_core): |
| 366 | logger.error("Please build grub-efi first\n") | 353 | raise WicError("Please build grub-efi first") |
| 367 | sys.exit(1) | ||
| 368 | 354 | ||
| 369 | grub_cmd = "grub-mkimage -p '/EFI/BOOT' " | 355 | grub_cmd = "grub-mkimage -p '/EFI/BOOT' " |
| 370 | grub_cmd += "-d %s " % grub_core | 356 | grub_cmd += "-d %s " % grub_core |
| @@ -380,12 +366,10 @@ class IsoImagePlugin(SourcePlugin): | |||
| 380 | exec_native_cmd(grub_cmd, native_sysroot) | 366 | exec_native_cmd(grub_cmd, native_sysroot) |
| 381 | 367 | ||
| 382 | else: | 368 | else: |
| 383 | logger.error("unrecognized bootimg-efi loader: %s", | 369 | raise WicError("unrecognized bootimg-efi loader: %s" % |
| 384 | source_params['loader']) | 370 | source_params['loader']) |
| 385 | sys.exit(1) | ||
| 386 | except KeyError: | 371 | except KeyError: |
| 387 | logger.error("bootimg-efi requires a loader, none specified") | 372 | raise WicError("bootimg-efi requires a loader, none specified") |
| 388 | sys.exit(1) | ||
| 389 | 373 | ||
| 390 | if os.path.exists("%s/EFI/BOOT" % isodir): | 374 | if os.path.exists("%s/EFI/BOOT" % isodir): |
| 391 | shutil.rmtree("%s/EFI/BOOT" % isodir) | 375 | shutil.rmtree("%s/EFI/BOOT" % isodir) |
| @@ -431,8 +415,7 @@ class IsoImagePlugin(SourcePlugin): | |||
| 431 | # Prepare files for legacy boot | 415 | # Prepare files for legacy boot |
| 432 | syslinux_dir = get_bitbake_var("STAGING_DATADIR", "wic-tools") | 416 | syslinux_dir = get_bitbake_var("STAGING_DATADIR", "wic-tools") |
| 433 | if not syslinux_dir: | 417 | if not syslinux_dir: |
| 434 | logger.error("Couldn't find STAGING_DATADIR, exiting.\n") | 418 | raise WicError("Couldn't find STAGING_DATADIR, exiting.") |
| 435 | sys.exit(1) | ||
| 436 | 419 | ||
| 437 | if os.path.exists("%s/isolinux" % isodir): | 420 | if os.path.exists("%s/isolinux" % isodir): |
| 438 | shutil.rmtree("%s/isolinux" % isodir) | 421 | shutil.rmtree("%s/isolinux" % isodir) |
diff --git a/scripts/lib/wic/plugins/source/rawcopy.py b/scripts/lib/wic/plugins/source/rawcopy.py index c5c3be3c2e..561280977a 100644 --- a/scripts/lib/wic/plugins/source/rawcopy.py +++ b/scripts/lib/wic/plugins/source/rawcopy.py | |||
| @@ -17,8 +17,8 @@ | |||
| 17 | 17 | ||
| 18 | import logging | 18 | import logging |
| 19 | import os | 19 | import os |
| 20 | import sys | ||
| 21 | 20 | ||
| 21 | from wic.errors import WicError | ||
| 22 | from wic.pluginbase import SourcePlugin | 22 | from wic.pluginbase import SourcePlugin |
| 23 | from wic.utils.misc import exec_cmd, get_bitbake_var | 23 | from wic.utils.misc import exec_cmd, get_bitbake_var |
| 24 | from wic.filemap import sparse_copy | 24 | from wic.filemap import sparse_copy |
| @@ -62,14 +62,12 @@ class RawCopyPlugin(SourcePlugin): | |||
| 62 | if not bootimg_dir: | 62 | if not bootimg_dir: |
| 63 | bootimg_dir = get_bitbake_var("DEPLOY_DIR_IMAGE") | 63 | bootimg_dir = get_bitbake_var("DEPLOY_DIR_IMAGE") |
| 64 | if not bootimg_dir: | 64 | if not bootimg_dir: |
| 65 | logger.error("Couldn't find DEPLOY_DIR_IMAGE, exiting\n") | 65 | raise WicError("Couldn't find DEPLOY_DIR_IMAGE, exiting") |
| 66 | sys.exit(1) | ||
| 67 | 66 | ||
| 68 | logger.debug('Bootimg dir: %s', bootimg_dir) | 67 | logger.debug('Bootimg dir: %s', bootimg_dir) |
| 69 | 68 | ||
| 70 | if 'file' not in source_params: | 69 | if 'file' not in source_params: |
| 71 | logger.error("No file specified\n") | 70 | raise WicError("No file specified") |
| 72 | sys.exit(1) | ||
| 73 | 71 | ||
| 74 | src = os.path.join(bootimg_dir, source_params['file']) | 72 | src = os.path.join(bootimg_dir, source_params['file']) |
| 75 | dst = os.path.join(cr_workdir, "%s.%s" % (source_params['file'], part.lineno)) | 73 | dst = os.path.join(cr_workdir, "%s.%s" % (source_params['file'], part.lineno)) |
diff --git a/scripts/lib/wic/plugins/source/rootfs.py b/scripts/lib/wic/plugins/source/rootfs.py index 21b653925c..f7ca569604 100644 --- a/scripts/lib/wic/plugins/source/rootfs.py +++ b/scripts/lib/wic/plugins/source/rootfs.py | |||
| @@ -28,10 +28,10 @@ | |||
| 28 | import logging | 28 | import logging |
| 29 | import os | 29 | import os |
| 30 | import shutil | 30 | import shutil |
| 31 | import sys | ||
| 32 | 31 | ||
| 33 | from oe.path import copyhardlinktree | 32 | from oe.path import copyhardlinktree |
| 34 | 33 | ||
| 34 | from wic.errors import WicError | ||
| 35 | from wic.pluginbase import SourcePlugin | 35 | from wic.pluginbase import SourcePlugin |
| 36 | from wic.utils.misc import get_bitbake_var, exec_cmd | 36 | from wic.utils.misc import get_bitbake_var, exec_cmd |
| 37 | 37 | ||
| @@ -51,10 +51,9 @@ class RootfsPlugin(SourcePlugin): | |||
| 51 | 51 | ||
| 52 | image_rootfs_dir = get_bitbake_var("IMAGE_ROOTFS", rootfs_dir) | 52 | image_rootfs_dir = get_bitbake_var("IMAGE_ROOTFS", rootfs_dir) |
| 53 | if not os.path.isdir(image_rootfs_dir): | 53 | if not os.path.isdir(image_rootfs_dir): |
| 54 | logger.error("No valid artifact IMAGE_ROOTFS from image named %s " | 54 | raise WicError("No valid artifact IMAGE_ROOTFS from image " |
| 55 | "has been found at %s, exiting.\n", | 55 | "named %s has been found at %s, exiting." % |
| 56 | rootfs_dir, image_rootfs_dir) | 56 | (rootfs_dir, image_rootfs_dir)) |
| 57 | sys.exit(1) | ||
| 58 | 57 | ||
| 59 | return image_rootfs_dir | 58 | return image_rootfs_dir |
| 60 | 59 | ||
| @@ -69,8 +68,7 @@ class RootfsPlugin(SourcePlugin): | |||
| 69 | """ | 68 | """ |
| 70 | if part.rootfs_dir is None: | 69 | if part.rootfs_dir is None: |
| 71 | if not 'ROOTFS_DIR' in krootfs_dir: | 70 | if not 'ROOTFS_DIR' in krootfs_dir: |
| 72 | logger.error("Couldn't find --rootfs-dir, exiting") | 71 | raise WicError("Couldn't find --rootfs-dir, exiting") |
| 73 | sys.exit(1) | ||
| 74 | 72 | ||
| 75 | rootfs_dir = krootfs_dir['ROOTFS_DIR'] | 73 | rootfs_dir = krootfs_dir['ROOTFS_DIR'] |
| 76 | else: | 74 | else: |
| @@ -79,9 +77,8 @@ class RootfsPlugin(SourcePlugin): | |||
| 79 | elif part.rootfs_dir: | 77 | elif part.rootfs_dir: |
| 80 | rootfs_dir = part.rootfs_dir | 78 | rootfs_dir = part.rootfs_dir |
| 81 | else: | 79 | else: |
| 82 | logger.error("Couldn't find --rootfs-dir=%s connection or " | 80 | raise WicError("Couldn't find --rootfs-dir=%s connection or " |
| 83 | "it is not a valid path, exiting", part.rootfs_dir) | 81 | "it is not a valid path, exiting" % part.rootfs_dir) |
| 84 | sys.exit(1) | ||
| 85 | 82 | ||
| 86 | real_rootfs_dir = cls.__get_rootfs_dir(rootfs_dir) | 83 | real_rootfs_dir = cls.__get_rootfs_dir(rootfs_dir) |
| 87 | 84 | ||
diff --git a/scripts/lib/wic/plugins/source/rootfs_pcbios_ext.py b/scripts/lib/wic/plugins/source/rootfs_pcbios_ext.py index 850aa5aaf1..4cc3a39856 100644 --- a/scripts/lib/wic/plugins/source/rootfs_pcbios_ext.py +++ b/scripts/lib/wic/plugins/source/rootfs_pcbios_ext.py | |||
| @@ -21,9 +21,8 @@ | |||
| 21 | import logging | 21 | import logging |
| 22 | import os | 22 | import os |
| 23 | import re | 23 | import re |
| 24 | import sys | ||
| 25 | 24 | ||
| 26 | from wic.errors import ImageError | 25 | from wic.errors import ImageError, WicError |
| 27 | from wic.utils import runner | 26 | from wic.utils import runner |
| 28 | from wic.utils.misc import get_bitbake_var, exec_cmd, exec_native_cmd | 27 | from wic.utils.misc import get_bitbake_var, exec_cmd, exec_native_cmd |
| 29 | from wic.pluginbase import SourcePlugin | 28 | from wic.pluginbase import SourcePlugin |
| @@ -99,10 +98,9 @@ class RootfsPlugin(SourcePlugin): | |||
| 99 | 98 | ||
| 100 | image_rootfs_dir = get_bitbake_var("IMAGE_ROOTFS", rootfs_dir) | 99 | image_rootfs_dir = get_bitbake_var("IMAGE_ROOTFS", rootfs_dir) |
| 101 | if not os.path.isdir(image_rootfs_dir): | 100 | if not os.path.isdir(image_rootfs_dir): |
| 102 | logger.error("No valid artifact IMAGE_ROOTFS from image named %s " | 101 | raise WicError("No valid artifact IMAGE_ROOTFS from image named %s " |
| 103 | "has been found at %s, exiting.\n", | 102 | "has been found at %s, exiting." % |
| 104 | rootfs_dir, image_rootfs_dir) | 103 | (rootfs_dir, image_rootfs_dir)) |
| 105 | sys.exit(1) | ||
| 106 | 104 | ||
| 107 | return image_rootfs_dir | 105 | return image_rootfs_dir |
| 108 | 106 | ||
| @@ -160,14 +158,12 @@ class RootfsPlugin(SourcePlugin): | |||
| 160 | logger.info("building syslinux-native...") | 158 | logger.info("building syslinux-native...") |
| 161 | exec_cmd("bitbake syslinux-native") | 159 | exec_cmd("bitbake syslinux-native") |
| 162 | if not is_exe(native_syslinux_nomtools): | 160 | if not is_exe(native_syslinux_nomtools): |
| 163 | logger.error("Couldn't find syslinux-nomtools (%s), exiting\n", | 161 | raise WicError("Couldn't find syslinux-nomtools (%s), exiting" % |
| 164 | native_syslinux_nomtools) | 162 | native_syslinux_nomtools) |
| 165 | sys.exit(1) | ||
| 166 | 163 | ||
| 167 | if part.rootfs is None: | 164 | if part.rootfs is None: |
| 168 | if 'ROOTFS_DIR' not in krootfs_dir: | 165 | if 'ROOTFS_DIR' not in krootfs_dir: |
| 169 | logger.error("Couldn't find --rootfs-dir, exiting") | 166 | raise WicError("Couldn't find --rootfs-dir, exiting") |
| 170 | sys.exit(1) | ||
| 171 | rootfs_dir = krootfs_dir['ROOTFS_DIR'] | 167 | rootfs_dir = krootfs_dir['ROOTFS_DIR'] |
| 172 | else: | 168 | else: |
| 173 | if part.rootfs in krootfs_dir: | 169 | if part.rootfs in krootfs_dir: |
| @@ -175,9 +171,8 @@ class RootfsPlugin(SourcePlugin): | |||
| 175 | elif part.rootfs: | 171 | elif part.rootfs: |
| 176 | rootfs_dir = part.rootfs | 172 | rootfs_dir = part.rootfs |
| 177 | else: | 173 | else: |
| 178 | logger.error("Couldn't find --rootfs-dir=%s connection or " | 174 | raise WicError("Couldn't find --rootfs-dir=%s connection or " |
| 179 | "it is not a valid path, exiting", part.rootfs) | 175 | "it is not a valid path, exiting" % part.rootfs) |
| 180 | sys.exit(1) | ||
| 181 | 176 | ||
| 182 | real_rootfs_dir = cls._get_rootfs_dir(rootfs_dir) | 177 | real_rootfs_dir = cls._get_rootfs_dir(rootfs_dir) |
| 183 | 178 | ||
| @@ -203,15 +198,12 @@ class RootfsPlugin(SourcePlugin): | |||
| 203 | elif image_creator.ptable_format == 'gpt': | 198 | elif image_creator.ptable_format == 'gpt': |
| 204 | mbrfile += "gptmbr.bin" | 199 | mbrfile += "gptmbr.bin" |
| 205 | else: | 200 | else: |
| 206 | logger.error("Unsupported partition table: %s", | 201 | raise WicError("Unsupported partition table: %s" % |
| 207 | image_creator.ptable_format) | 202 | image_creator.ptable_format) |
| 208 | sys.exit(1) | ||
| 209 | 203 | ||
| 210 | if not os.path.exists(mbrfile): | 204 | if not os.path.exists(mbrfile): |
| 211 | logger.error("Couldn't find %s. Has syslinux-native been baked?", | 205 | raise WicError("Couldn't find %s. Has syslinux-native been baked?", |
| 212 | mbrfile) | 206 | mbrfile) |
| 213 | sys.exit(1) | ||
| 214 | |||
| 215 | full_path = disk.path | 207 | full_path = disk.path |
| 216 | logger.debug("Installing MBR on disk %s as %s with size %s bytes", | 208 | logger.debug("Installing MBR on disk %s as %s with size %s bytes", |
| 217 | disk_name, full_path, disk.min_size) | 209 | disk_name, full_path, disk.min_size) |
