本文整理汇总了Python中wic.misc.exec_cmd函数的典型用法代码示例。如果您正苦于以下问题:Python exec_cmd函数的具体用法?Python exec_cmd怎么用?Python exec_cmd使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了exec_cmd函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: finalize
def finalize(self):
"""
Finalize the disk image.
For example, prepare the image to be bootable by e.g.
creating and installing a bootloader configuration.
"""
source_plugin = self.ks.bootloader.source
disk_name = self.parts[0].disk
if source_plugin:
plugin = PluginMgr.get_plugins('source')[source_plugin]
plugin.do_install_disk(self._image, disk_name, self, self.workdir,
self.oe_builddir, self.bootimg_dir,
self.kernel_dir, self.native_sysroot)
full_path = self._image.path
# Generate .bmap
if self.bmap:
logger.debug("Generating bmap file for %s", disk_name)
python = os.path.join(self.native_sysroot, 'usr/bin/python3-native/python3')
bmaptool = os.path.join(self.native_sysroot, 'usr/bin/bmaptool')
exec_native_cmd("%s %s create %s -o %s.bmap" % \
(python, bmaptool, full_path, full_path), self.native_sysroot)
# Compress the image
if self.compressor:
logger.debug("Compressing disk %s with %s", disk_name, self.compressor)
exec_cmd("%s %s" % (self.compressor, full_path))
开发者ID:ISI-apex,项目名称:hpsc-bsp,代码行数:27,代码来源:direct.py
示例2: copy
def copy(self, src, pnum, path):
"""Copy partition image into wic image."""
cmd = "{} -i {} -snop {} ::{}".format(self.mcopy,
self._get_part_image(pnum),
src, path)
exec_cmd(cmd)
self._put_part_image(pnum)
开发者ID:darander,项目名称:openembedded-core,代码行数:7,代码来源:engine.py
示例3: do_prepare_partition
def do_prepare_partition(cls, 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.%d" % (cr_workdir, part.lineno)
if not kernel_dir:
kernel_dir = get_bitbake_var("DEPLOY_DIR_IMAGE")
if not kernel_dir:
raise WicError("Couldn't find DEPLOY_DIR_IMAGE, exiting")
logger.debug('Kernel dir: %s', bootimg_dir)
for task in cls.install_task:
src_path, dst_path = task
logger.debug('Install %s as %s', src_path, dst_path)
install_cmd = "install -m 0644 -D %s %s" \
% (os.path.join(kernel_dir, src_path),
os.path.join(hdddir, dst_path))
exec_cmd(install_cmd)
logger.debug('Prepare boot partition using rootfs in %s', hdddir)
part.prepare_rootfs(cr_workdir, oe_builddir, hdddir,
native_sysroot, False)
开发者ID:openembedded,项目名称:openembedded-core,代码行数:31,代码来源:bootimg-partition.py
示例4: prepare_rootfs_msdos
def prepare_rootfs_msdos(self, rootfs, oe_builddir, rootfs_dir,
native_sysroot, pseudo):
"""
Prepare content for a msdos/vfat rootfs partition.
"""
du_cmd = "du -bks %s" % rootfs_dir
out = exec_cmd(du_cmd)
blocks = int(out.split()[0])
rootfs_size = self.get_rootfs_size(blocks)
label_str = "-n boot"
if self.label:
label_str = "-n %s" % self.label
size_str = ""
if self.fstype == 'msdos':
size_str = "-F 16" # FAT 16
extraopts = self.mkfs_extraopts or '-S 512'
dosfs_cmd = "mkdosfs %s %s %s -C %s %d" % \
(label_str, size_str, extraopts, rootfs, rootfs_size)
exec_native_cmd(dosfs_cmd, native_sysroot)
mcopy_cmd = "mcopy -i %s -s %s/* ::/" % (rootfs, rootfs_dir)
exec_native_cmd(mcopy_cmd, native_sysroot)
chmod_cmd = "chmod 644 %s" % rootfs
exec_cmd(chmod_cmd)
开发者ID:ISI-apex,项目名称:hpsc-bsp,代码行数:30,代码来源:partition.py
示例5: do_install_disk
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.
"""
bootimg_dir = cls._get_bootimg_dir(bootimg_dir, 'syslinux')
mbrfile = "%s/syslinux/" % bootimg_dir
if creator.ptable_format == 'msdos':
mbrfile += "mbr.bin"
elif creator.ptable_format == 'gpt':
mbrfile += "gptmbr.bin"
else:
raise WicError("Unsupported partition table: %s" %
creator.ptable_format)
if not os.path.exists(mbrfile):
raise WicError("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 = creator._full_path(workdir, disk_name, "direct")
logger.debug("Installing MBR on disk %s as %s with size %s bytes",
disk_name, full_path, disk.min_size)
dd_cmd = "dd if=%s of=%s conv=notrunc" % (mbrfile, full_path)
exec_cmd(dd_cmd, native_sysroot)
开发者ID:openembedded,项目名称:openembedded-core,代码行数:27,代码来源:bootimg-pcbios.py
示例6: prepare_empty_partition_msdos
def prepare_empty_partition_msdos(self, rootfs, oe_builddir,
native_sysroot):
"""
Prepare an empty vfat partition.
"""
blocks = self.disk_size
label_str = "-n boot"
if self.label:
label_str = "-n %s" % self.label
size_str = ""
if self.fstype == 'msdos':
size_str = "-F 16" # FAT 16
extraopts = self.mkfs_extraopts or '-S 512'
dosfs_cmd = "mkdosfs %s -i %s %s %s -C %s %d" % \
(label_str, self.fsuuid, extraopts, size_str, rootfs,
blocks)
exec_native_cmd(dosfs_cmd, native_sysroot)
chmod_cmd = "chmod 644 %s" % rootfs
exec_cmd(chmod_cmd)
开发者ID:Herrie82,项目名称:openembedded-core,代码行数:25,代码来源:partition.py
示例7: dir
def dir(self, pnum, path):
if self.partitions[pnum].fstype.startswith('ext'):
return exec_cmd("{} {} -R 'ls -l {}'".format(self.debugfs,
self._get_part_image(pnum),
path), as_shell=True)
else: # fat
return exec_cmd("{} -i {} ::{}".format(self.mdir,
self._get_part_image(pnum),
path))
开发者ID:01org,项目名称:luv-yocto,代码行数:9,代码来源:engine.py
示例8: do_configure_partition
def do_configure_partition(cls, part, source_params, creator, cr_workdir,
oe_builddir, bootimg_dir, kernel_dir,
native_sysroot):
"""
Called before do_prepare_partition(), creates syslinux config
"""
hdddir = "%s/hdd/boot" % cr_workdir
install_cmd = "install -d %s" % hdddir
exec_cmd(install_cmd)
bootloader = creator.ks.bootloader
custom_cfg = None
if bootloader.configfile:
custom_cfg = get_custom_config(bootloader.configfile)
if custom_cfg:
# Use a custom configuration for grub
syslinux_conf = custom_cfg
logger.debug("Using custom configuration file %s "
"for syslinux.cfg", bootloader.configfile)
else:
raise WicError("configfile is specified but failed to "
"get it from %s." % bootloader.configfile)
if not custom_cfg:
# Create syslinux configuration using parameters from wks file
splash = os.path.join(cr_workdir, "/hdd/boot/splash.jpg")
if os.path.exists(splash):
splashline = "menu background splash.jpg"
else:
splashline = ""
syslinux_conf = ""
syslinux_conf += "PROMPT 0\n"
syslinux_conf += "TIMEOUT " + str(bootloader.timeout) + "\n"
syslinux_conf += "\n"
syslinux_conf += "ALLOWOPTIONS 1\n"
syslinux_conf += "SERIAL 0 115200\n"
syslinux_conf += "\n"
if splashline:
syslinux_conf += "%s\n" % splashline
syslinux_conf += "DEFAULT boot\n"
syslinux_conf += "LABEL boot\n"
kernel = "/vmlinuz"
syslinux_conf += "KERNEL " + kernel + "\n"
syslinux_conf += "APPEND label=boot root=%s %s\n" % \
(creator.rootdev, bootloader.append)
logger.debug("Writing syslinux config %s/hdd/boot/syslinux.cfg",
cr_workdir)
cfg = open("%s/hdd/boot/syslinux.cfg" % cr_workdir, "w")
cfg.write(syslinux_conf)
cfg.close()
开发者ID:openembedded,项目名称:openembedded-core,代码行数:56,代码来源:bootimg-pcbios.py
示例9: do_configure_grubefi
def do_configure_grubefi(cls, hdddir, creator, cr_workdir, source_params):
"""
Create loader-specific (grub-efi) config
"""
configfile = creator.ks.bootloader.configfile
custom_cfg = None
if configfile:
custom_cfg = get_custom_config(configfile)
if custom_cfg:
# Use a custom configuration for grub
grubefi_conf = custom_cfg
logger.debug("Using custom configuration file "
"%s for grub.cfg", configfile)
else:
raise WicError("configfile is specified but failed to "
"get it from %s." % configfile)
initrd = source_params.get('initrd')
if initrd:
bootimg_dir = get_bitbake_var("DEPLOY_DIR_IMAGE")
if not bootimg_dir:
raise WicError("Couldn't find DEPLOY_DIR_IMAGE, exiting")
cp_cmd = "cp %s/%s %s" % (bootimg_dir, initrd, hdddir)
exec_cmd(cp_cmd, True)
else:
logger.debug("Ignoring missing initrd")
if not custom_cfg:
# Create grub configuration using parameters from wks file
bootloader = creator.ks.bootloader
grubefi_conf = ""
grubefi_conf += "serial --unit=0 --speed=115200 --word=8 --parity=no --stop=1\n"
grubefi_conf += "default=boot\n"
grubefi_conf += "timeout=%s\n" % bootloader.timeout
grubefi_conf += "menuentry 'boot'{\n"
kernel = "/bzImage"
grubefi_conf += "linux %s root=%s rootwait %s\n" \
% (kernel, creator.rootdev, bootloader.append)
if initrd:
grubefi_conf += "initrd /%s\n" % initrd
grubefi_conf += "}\n"
logger.debug("Writing grubefi config %s/hdd/boot/EFI/BOOT/grub.cfg",
cr_workdir)
cfg = open("%s/hdd/boot/EFI/BOOT/grub.cfg" % cr_workdir, "w")
cfg.write(grubefi_conf)
cfg.close()
开发者ID:01org,项目名称:luv-yocto,代码行数:54,代码来源:bootimg-efi.py
示例10: _build_initramfs_path
def _build_initramfs_path(rootfs_dir, cr_workdir):
"""
Create path for initramfs image
"""
initrd = get_bitbake_var("INITRD_LIVE") or get_bitbake_var("INITRD")
if not initrd:
initrd_dir = get_bitbake_var("DEPLOY_DIR_IMAGE")
if not initrd_dir:
raise WicError("Couldn't find DEPLOY_DIR_IMAGE, exiting.")
image_name = get_bitbake_var("IMAGE_BASENAME")
if not image_name:
raise WicError("Couldn't find IMAGE_BASENAME, exiting.")
image_type = get_bitbake_var("INITRAMFS_FSTYPES")
if not image_type:
raise WicError("Couldn't find INITRAMFS_FSTYPES, exiting.")
machine = os.path.basename(initrd_dir)
pattern = '%s/%s*%s.%s' % (initrd_dir, image_name, machine, image_type)
files = glob.glob(pattern)
if files:
initrd = files[0]
if not initrd or not os.path.exists(initrd):
# Create initrd from rootfs directory
initrd = "%s/initrd.cpio.gz" % cr_workdir
initrd_dir = "%s/INITRD" % cr_workdir
shutil.copytree("%s" % rootfs_dir, \
"%s" % initrd_dir, symlinks=True)
if os.path.isfile("%s/init" % rootfs_dir):
shutil.copy2("%s/init" % rootfs_dir, "%s/init" % initrd_dir)
elif os.path.lexists("%s/init" % rootfs_dir):
os.symlink(os.readlink("%s/init" % rootfs_dir), \
"%s/init" % initrd_dir)
elif os.path.isfile("%s/sbin/init" % rootfs_dir):
shutil.copy2("%s/sbin/init" % rootfs_dir, \
"%s" % initrd_dir)
elif os.path.lexists("%s/sbin/init" % rootfs_dir):
os.symlink(os.readlink("%s/sbin/init" % rootfs_dir), \
"%s/init" % initrd_dir)
else:
raise WicError("Couldn't find or build initrd, exiting.")
exec_cmd("cd %s && find . | cpio -o -H newc -R +0:+0 >./initrd.cpio " \
% initrd_dir, as_shell=True)
exec_cmd("gzip -f -9 -c %s/initrd.cpio > %s" \
% (cr_workdir, initrd), as_shell=True)
shutil.rmtree(initrd_dir)
return initrd
开发者ID:Herrie82,项目名称:openembedded-core,代码行数:54,代码来源:isoimage-isohybrid.py
示例11: copy
def copy(self, src, pnum, path):
"""Copy partition image into wic image."""
if self.partitions[pnum].fstype.startswith('ext'):
cmd = "echo -e 'cd {}\nwrite {} {}' | {} -w {}".\
format(path, src, os.path.basename(src),
self.debugfs, self._get_part_image(pnum))
else: # fat
cmd = "{} -i {} -snop {} ::{}".format(self.mcopy,
self._get_part_image(pnum),
src, path)
exec_cmd(cmd, as_shell=True)
self._put_part_image(pnum)
开发者ID:01org,项目名称:luv-yocto,代码行数:12,代码来源:engine.py
示例12: remove
def remove(self, pnum, path):
"""Remove files/dirs from the partition."""
partimg = self._get_part_image(pnum)
cmd = "{} -i {} ::{}".format(self.mdel, partimg, path)
try:
exec_cmd(cmd)
except WicError as err:
if "not found" in str(err) or "non empty" in str(err):
# mdel outputs 'File ... not found' or 'directory .. non empty"
# try to use mdeltree as path could be a directory
cmd = "{} -i {} ::{}".format(self.mdeltree,
partimg, path)
exec_cmd(cmd)
else:
raise err
self._put_part_image(pnum)
开发者ID:darander,项目名称:openembedded-core,代码行数:16,代码来源:engine.py
示例13: do_prepare_partition
def do_prepare_partition(cls, 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.
"""
if not kernel_dir:
kernel_dir = get_bitbake_var("DEPLOY_DIR_IMAGE")
if not kernel_dir:
raise WicError("Couldn't find DEPLOY_DIR_IMAGE, exiting")
logger.debug('Kernel dir: %s', kernel_dir)
if 'file' not in source_params:
raise WicError("No file specified")
src = os.path.join(kernel_dir, source_params['file'])
dst = os.path.join(cr_workdir, "%s.%s" % (source_params['file'], part.lineno))
if 'skip' in source_params:
sparse_copy(src, dst, skip=int(source_params['skip']))
else:
sparse_copy(src, dst)
# get the size in the right units for kickstart (kB)
du_cmd = "du -Lbks %s" % dst
out = exec_cmd(du_cmd)
filesize = int(out.split()[0])
if filesize > part.size:
part.size = filesize
part.source_file = dst
开发者ID:VCTLabs,项目名称:poky,代码行数:34,代码来源:rawcopy.py
示例14: prepare_rootfs_ext
def prepare_rootfs_ext(self, rootfs, oe_builddir, rootfs_dir,
native_sysroot, pseudo):
"""
Prepare content for an ext2/3/4 rootfs partition.
"""
du_cmd = "du -ks %s" % rootfs_dir
out = exec_cmd(du_cmd)
actual_rootfs_size = int(out.split()[0])
rootfs_size = self.get_rootfs_size(actual_rootfs_size)
with open(rootfs, 'w') as sparse:
os.ftruncate(sparse.fileno(), rootfs_size * 1024)
extraopts = self.mkfs_extraopts or "-F -i 8192"
label_str = ""
if self.label:
label_str = "-L %s" % self.label
mkfs_cmd = "mkfs.%s %s %s %s -d %s" % \
(self.fstype, extraopts, rootfs, label_str, rootfs_dir)
exec_native_cmd(mkfs_cmd, native_sysroot, pseudo=pseudo)
mkfs_cmd = "fsck.%s -pvfD %s" % (self.fstype, rootfs)
exec_native_cmd(mkfs_cmd, native_sysroot, pseudo=pseudo)
开发者ID:ISI-apex,项目名称:hpsc-bsp,代码行数:26,代码来源:partition.py
示例15: do_image_label
def do_image_label(fstype, dst, label):
if fstype.startswith('ext'):
cmd = 'tune2fs -L %s %s' % (label, dst)
elif fstype in ('msdos', 'vfat'):
cmd = 'dosfslabel %s %s' % (dst, label)
elif fstype == 'btrfs':
cmd = 'btrfs filesystem label %s %s' % (dst, label)
elif fstype == 'swap':
cmd = 'mkswap -L %s %s' % (label, dst)
elif fstype == 'squashfs':
raise WicError("It's not possible to update a squashfs "
"filesystem label '%s'" % (label))
else:
raise WicError("Cannot update filesystem label: "
"Unknown fstype: '%s'" % (fstype))
exec_cmd(cmd)
开发者ID:openembedded,项目名称:openembedded-core,代码行数:17,代码来源:rawcopy.py
示例16: do_configure_partition
def do_configure_partition(cls, part, source_params, creator, cr_workdir,
oe_builddir, bootimg_dir, kernel_dir,
native_sysroot):
"""
Called before do_prepare_partition(), creates loader-specific config
"""
isodir = "%s/ISO/" % cr_workdir
if os.path.exists(isodir):
shutil.rmtree(isodir)
install_cmd = "install -d %s " % isodir
exec_cmd(install_cmd)
# Overwrite the name of the created image
logger.debug(source_params)
if 'image_name' in source_params and \
source_params['image_name'].strip():
creator.name = source_params['image_name'].strip()
logger.debug("The name of the image is: %s", creator.name)
开发者ID:Herrie82,项目名称:openembedded-core,代码行数:20,代码来源:isoimage-isohybrid.py
示例17: do_configure_partition
def do_configure_partition(cls, part, source_params, creator, cr_workdir,
oe_builddir, bootimg_dir, kernel_dir,
native_sysroot):
"""
Called before do_prepare_partition(), creates loader-specific config
"""
hdddir = "%s/hdd/boot" % cr_workdir
install_cmd = "install -d %s/EFI/BOOT" % hdddir
exec_cmd(install_cmd)
try:
if source_params['loader'] == 'grub-efi':
cls.do_configure_grubefi(creator, cr_workdir)
elif source_params['loader'] == 'systemd-boot':
cls.do_configure_systemdboot(hdddir, creator, cr_workdir, source_params)
else:
raise WicError("unrecognized bootimg-efi loader: %s" % source_params['loader'])
except KeyError:
raise WicError("bootimg-efi requires a loader, none specified")
开发者ID:Herrie82,项目名称:openembedded-core,代码行数:20,代码来源:bootimg-efi.py
示例18: partitions
def partitions(self):
if self._partitions is None:
self._partitions = OrderedDict()
out = exec_cmd("%s -sm %s unit B print" % (self.parted, self.imagepath))
parttype = namedtuple("Part", "pnum start end size fstype")
for line in out.splitlines()[2:]:
pnum, start, end, size, fstype = line.split(':')[:5]
partition = parttype(pnum, int(start[:-1]), int(end[:-1]),
int(size[:-1]), fstype)
self._partitions[pnum] = partition
return self._partitions
开发者ID:darander,项目名称:openembedded-core,代码行数:12,代码来源:engine.py
示例19: remove
def remove(self, pnum, path):
"""Remove files/dirs from the partition."""
partimg = self._get_part_image(pnum)
if self.partitions[pnum].fstype.startswith('ext'):
cmd = "{} {} -wR 'rm {}'".format(self.debugfs,
self._get_part_image(pnum),
path)
out = exec_cmd(cmd , as_shell=True)
for line in out.splitlines():
if line.startswith("rm:"):
if "file is a directory" in line:
# Try rmdir to see if this is an empty directory. This won't delete
# any non empty directory so let user know about any error that this might
# generate.
print(exec_cmd("{} {} -wR 'rmdir {}'".format(self.debugfs,
self._get_part_image(pnum),
path), as_shell=True))
else:
raise WicError("Could not complete operation: wic %s" % str(line))
else: # fat
cmd = "{} -i {} ::{}".format(self.mdel, partimg, path)
try:
exec_cmd(cmd)
except WicError as err:
if "not found" in str(err) or "non empty" in str(err):
# mdel outputs 'File ... not found' or 'directory .. non empty"
# try to use mdeltree as path could be a directory
cmd = "{} -i {} ::{}".format(self.mdeltree,
partimg, path)
exec_cmd(cmd)
else:
raise err
self._put_part_image(pnum)
开发者ID:01org,项目名称:luv-yocto,代码行数:33,代码来源:engine.py
示例20: get_partitions
def get_partitions(self):
if self._partitions is None:
self._partitions = OrderedDict()
out = exec_cmd("%s -sm %s unit B print" % (self.parted, self.imagepath))
parttype = namedtuple("Part", "pnum start end size fstype")
splitted = out.splitlines()
lsector_size, psector_size, self._ptable_format = splitted[1].split(":")[3:6]
self._lsector_size = int(lsector_size)
self._psector_size = int(psector_size)
for line in splitted[2:]:
pnum, start, end, size, fstype = line.split(':')[:5]
partition = parttype(int(pnum), int(start[:-1]), int(end[:-1]),
int(size[:-1]), fstype)
self._partitions[pnum] = partition
return self._partitions
开发者ID:Herrie82,项目名称:openembedded-core,代码行数:16,代码来源:engine.py
注:本文中的wic.misc.exec_cmd函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论