本文整理汇总了Python中wic.utils.oe.misc.exec_cmd函数的典型用法代码示例。如果您正苦于以下问题:Python exec_cmd函数的具体用法?Python exec_cmd怎么用?Python exec_cmd使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了exec_cmd函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: prepare_rootfs_vfat
def prepare_rootfs_vfat(self, rootfs, oe_builddir, rootfs_dir,
native_sysroot, pseudo):
"""
Prepare content for a vfat rootfs partition.
"""
du_cmd = "du -bks %s" % rootfs_dir
out = exec_cmd(du_cmd)
blocks = int(out.split()[0])
extra_blocks = self.get_extra_block_count(blocks)
if extra_blocks < self.extra_space:
extra_blocks = self.extra_space
blocks += extra_blocks
msger.debug("Added %d extra blocks to %s to get to %d total blocks" % \
(extra_blocks, self.mountpoint, blocks))
label_str = "-n boot"
if self.label:
label_str = "-n %s" % self.label
dosfs_cmd = "mkdosfs %s -S 512 -C %s %d" % (label_str, rootfs, blocks)
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:sat8,项目名称:yocto-tinkerboard,代码行数:30,代码来源:partition.py
示例2: prepare_rootfs_btrfs
def prepare_rootfs_btrfs(self, rootfs, oe_builddir, rootfs_dir,
native_sysroot, pseudo):
"""
Prepare content for a btrfs rootfs partition.
Currently handles ext2/3/4 and btrfs.
"""
du_cmd = "du -ks %s" % rootfs_dir
out = exec_cmd(du_cmd)
actual_rootfs_size = int(out.split()[0])
extra_blocks = self.get_extra_block_count(actual_rootfs_size)
if extra_blocks < self.extra_space:
extra_blocks = self.extra_space
rootfs_size = actual_rootfs_size + extra_blocks
rootfs_size *= self.overhead_factor
msger.debug("Added %d extra blocks to %s to get to %d total blocks" % \
(extra_blocks, self.mountpoint, rootfs_size))
exec_cmd("truncate %s -s %d" % (rootfs, rootfs_size * 1024))
label_str = ""
if self.label:
label_str = "-L %s" % self.label
mkfs_cmd = "mkfs.%s -b %d -r %s %s %s" % \
(self.fstype, rootfs_size * 1024, rootfs_dir, label_str, rootfs)
exec_native_cmd(mkfs_cmd, native_sysroot, pseudo=pseudo)
开发者ID:biannm,项目名称:Poky,代码行数:30,代码来源:partition.py
示例3: 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.get_default_source_plugin()
if source_plugin:
self._source_methods = pluginmgr.get_source_plugin_methods(source_plugin, disk_methods)
for disk_name, disk in self.__image.disks.items():
self._source_methods["do_install_disk"](disk, disk_name, self,
self.workdir,
self.oe_builddir,
self.bootimg_dir,
self.kernel_dir,
self.native_sysroot)
# Compress the image
if self.compressor:
for disk_name, disk in self.__image.disks.items():
full_path = self._full_path(self.__imgdir, disk_name, "direct")
msger.debug("Compressing disk %s with %s" % \
(disk_name, self.compressor))
exec_cmd("%s %s" % (self.compressor, full_path))
开发者ID:Technux,项目名称:poky,代码行数:25,代码来源:direct.py
示例4: 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])
extra_blocks = self.get_extra_block_count(actual_rootfs_size)
if extra_blocks < self.extra_space:
extra_blocks = self.extra_space
rootfs_size = actual_rootfs_size + extra_blocks
rootfs_size *= self.overhead_factor
msger.debug("Added %d extra blocks to %s to get to %d total blocks" % \
(extra_blocks, self.mountpoint, rootfs_size))
dd_cmd = "dd if=/dev/zero of=%s bs=1024 seek=%d count=0 bs=1k" % \
(rootfs, rootfs_size)
exec_cmd(dd_cmd)
extra_imagecmd = "-i 8192"
label_str = ""
if self.label:
label_str = "-L %s" % self.label
mkfs_cmd = "mkfs.%s -F %s %s %s -d %s" % \
(self.fstype, extra_imagecmd, rootfs, label_str, rootfs_dir)
exec_native_cmd(mkfs_cmd, native_sysroot, pseudo=pseudo)
开发者ID:KenChenIEC,项目名称:openbmc,代码行数:32,代码来源:partition.py
示例5: create
def create(self):
if self.created:
return
# create sparse disk image
cmd = "truncate %s -s %s" % (self.device, self.size)
exec_cmd(cmd)
self.created = True
开发者ID:agangidi53,项目名称:openbmc,代码行数:7,代码来源:direct.py
示例6: 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
rm_cmd = "rm -rf " + cr_workdir
exec_cmd(rm_cmd)
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
msger.debug("Using custom configuration file "
"%s for syslinux.cfg" % bootloader.configfile)
else:
msger.error("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)
msger.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:carosio,项目名称:poky,代码行数:58,代码来源:bootimg-pcbios.py
示例7: _build_initramfs_path
def _build_initramfs_path(rootfs_dir, cr_workdir):
"""
Create path for initramfs image
"""
initrd = get_bitbake_var("INITRD")
if not initrd:
initrd_dir = get_bitbake_var("DEPLOY_DIR_IMAGE")
if not initrd_dir:
msger.error("Couldn't find DEPLOY_DIR_IMAGE, exiting.\n")
image_name = get_bitbake_var("IMAGE_BASENAME")
if not image_name:
msger.error("Couldn't find IMAGE_BASENAME, exiting.\n")
image_type = get_bitbake_var("INITRAMFS_FSTYPES")
if not image_type:
msger.error("Couldn't find INITRAMFS_FSTYPES, exiting.\n")
machine_arch = get_bitbake_var("MACHINE_ARCH")
if not machine_arch:
msger.error("Couldn't find MACHINE_ARCH, exiting.\n")
initrd = "%s/%s-initramfs-%s.%s" \
% (initrd_dir, image_name, machine_arch, image_type)
if 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:
msger.error("Couldn't find or build initrd, exiting.\n")
exec_cmd("cd %s && find . | cpio -o -H newc >%s/initrd.cpio " \
% (initrd_dir, cr_workdir), 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:rofehr,项目名称:openembedded-core,代码行数:54,代码来源:isoimage-isohybrid.py
示例8: do_configure_gummiboot
def do_configure_gummiboot(cls, hdddir, creator, cr_workdir):
"""
Create loader-specific (gummiboot) config
"""
install_cmd = "install -d %s/loader" % hdddir
exec_cmd(install_cmd)
install_cmd = "install -d %s/loader/entries" % hdddir
exec_cmd(install_cmd)
options = creator.ks.handler.bootloader.appendLine
timeout = kickstart.get_timeout(creator.ks)
if not timeout:
timeout = 0
loader_conf = ""
loader_conf += "default boot\n"
loader_conf += "timeout %d\n" % timeout
msger.debug("Writing gummiboot config %s/hdd/boot/loader/loader.conf" \
% cr_workdir)
cfg = open("%s/hdd/boot/loader/loader.conf" % cr_workdir, "w")
cfg.write(loader_conf)
cfg.close()
configfile = kickstart.get_bootloader_file(creator.ks)
custom_cfg = None
if configfile:
custom_cfg = get_custom_config(configfile)
if custom_cfg:
# Use a custom configuration for gummiboot
boot_conf = custom_cfg
msger.debug("Using custom configuration file "
"%s for gummiboots's boot.conf" % configfile)
else:
msger.error("configfile is specified but failed to "
"get it from %s." % configfile)
if not custom_cfg:
# Create gummiboot configuration using parameters from wks file
kernel = "/bzImage"
boot_conf = ""
boot_conf += "title boot\n"
boot_conf += "linux %s\n" % kernel
boot_conf += "options LABEL=Boot root=%s %s\n" % (creator.rootdev, options)
msger.debug("Writing gummiboot config %s/hdd/boot/loader/entries/boot.conf" \
% cr_workdir)
cfg = open("%s/hdd/boot/loader/entries/boot.conf" % cr_workdir, "w")
cfg.write(boot_conf)
cfg.close()
开发者ID:jhofstee,项目名称:openembedded-core,代码行数:53,代码来源:bootimg-efi.py
示例9: do_configure_partition
def do_configure_partition(self, part, source_params, cr, cr_workdir,
oe_builddir, bootimg_dir, kernel_dir,
native_sysroot):
"""
Called before do_prepare_partition(), creates syslinux config
"""
hdddir = "%s/hdd/boot" % cr_workdir
rm_cmd = "rm -rf " + cr_workdir
exec_cmd(rm_cmd)
install_cmd = "install -d %s" % hdddir
exec_cmd(install_cmd)
splash = os.path.join(cr_workdir, "/hdd/boot/splash.jpg")
if os.path.exists(splash):
splashline = "menu background splash.jpg"
else:
splashline = ""
(rootdev, root_part_uuid) = cr._get_boot_config()
options = cr.ks.handler.bootloader.appendLine
syslinux_conf = ""
syslinux_conf += "PROMPT 0\n"
timeout = kickstart.get_timeout(cr.ks)
if not timeout:
timeout = 0
syslinux_conf += "TIMEOUT " + str(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"
if cr._ptable_format == 'msdos':
rootstr = rootdev
else:
raise ImageError("Unsupported partition table format found")
syslinux_conf += "APPEND label=boot root=%s %s\n" % (rootstr, options)
msger.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:RafaelPalomar,项目名称:poky,代码行数:52,代码来源:bootimg-pcbios.py
示例10: prepare_empty_partition_btrfs
def prepare_empty_partition_btrfs(self, rootfs, oe_builddir, native_sysroot):
"""
Prepare an empty btrfs partition.
"""
dd_cmd = "dd if=/dev/zero of=%s bs=1k seek=%d count=0" % (rootfs, self.size)
exec_cmd(dd_cmd)
label_str = ""
if self.label:
label_str = "-L %s" % self.label
mkfs_cmd = "mkfs.%s -b %d %s %s" % (self.fstype, self.size * 1024, label_str, rootfs)
exec_native_cmd(mkfs_cmd, native_sysroot)
开发者ID:shenki,项目名称:poky,代码行数:13,代码来源:partition.py
示例11: create
def create(self):
if self.device is not None:
return
blocks = self.size / 1024
if self.size - blocks * 1024:
blocks += 1
# create disk image
dd_cmd = "dd if=/dev/zero of=%s bs=1024 seek=%d count=1" % \
(self.image_file, blocks)
exec_cmd(dd_cmd)
self.device = self.image_file
开发者ID:32bitmicro,项目名称:riscv-poky,代码行数:14,代码来源:fs_related.py
示例12: __write_partition
def __write_partition(self, num, source_file, start, size):
"""
Install source_file contents into a partition.
"""
if not source_file: # nothing to write
return
# Start is included in the size so need to substract one from the end.
end = start + size - 1
msger.debug("Installed %s in partition %d, sectors %d-%d, size %d sectors" % (source_file, num, start, end, size))
dd_cmd = "dd if=%s of=%s bs=%d seek=%d count=%d conv=notrunc" % \
(source_file, self.image_file, self.sector_size, start, size)
exec_cmd(dd_cmd)
开发者ID:RafaelPalomar,项目名称:poky,代码行数:14,代码来源:partitionedfs.py
示例13: prepare_empty_partition_btrfs
def prepare_empty_partition_btrfs(self, rootfs, oe_builddir,
native_sysroot):
"""
Prepare an empty btrfs partition.
"""
exec_cmd("truncate %s -s %d" % (rootfs, self.size * 1024))
label_str = ""
if self.label:
label_str = "-L %s" % self.label
mkfs_cmd = "mkfs.%s -b %d %s %s" % \
(self.fstype, self.size * 1024, label_str, rootfs)
exec_native_cmd(mkfs_cmd, native_sysroot)
开发者ID:biannm,项目名称:Poky,代码行数:14,代码来源:partition.py
示例14: prepare_swap_partition
def prepare_swap_partition(self, cr_workdir, oe_builddir, native_sysroot):
"""
Prepare a swap partition.
"""
path = "%s/fs.%s" % (cr_workdir, self.fstype)
exec_cmd("truncate %s -s %d" % (path, self.size * 1024))
import uuid
label_str = ""
if self.label:
label_str = "-L %s" % self.label
mkswap_cmd = "mkswap %s -U %s %s" % (label_str, str(uuid.uuid1()), path)
exec_native_cmd(mkswap_cmd, native_sysroot)
开发者ID:biannm,项目名称:Poky,代码行数:14,代码来源:partition.py
示例15: prepare_empty_partition_vfat
def prepare_empty_partition_vfat(self, rootfs, oe_builddir, native_sysroot):
"""
Prepare an empty vfat partition.
"""
blocks = self.size
label_str = "-n boot"
if self.label:
label_str = "-n %s" % self.label
dosfs_cmd = "mkdosfs %s -S 512 -C %s %d" % (label_str, rootfs, blocks)
exec_native_cmd(dosfs_cmd, native_sysroot)
chmod_cmd = "chmod 644 %s" % rootfs
exec_cmd(chmod_cmd)
开发者ID:shenki,项目名称:poky,代码行数:15,代码来源:partition.py
示例16: prepare_empty_partition_ext
def prepare_empty_partition_ext(self, rootfs, oe_builddir, native_sysroot):
"""
Prepare an empty ext2/3/4 partition.
"""
dd_cmd = "dd if=/dev/zero of=%s bs=1k seek=%d count=0" % (rootfs, self.size)
exec_cmd(dd_cmd)
extra_imagecmd = "-i 8192"
label_str = ""
if self.label:
label_str = "-L %s" % self.label
mkfs_cmd = "mkfs.%s -F %s %s %s" % (self.fstype, extra_imagecmd, label_str, rootfs)
exec_native_cmd(mkfs_cmd, native_sysroot)
开发者ID:shenki,项目名称:poky,代码行数:15,代码来源:partition.py
示例17: prepare_swap_partition
def prepare_swap_partition(self, cr_workdir, oe_builddir, native_sysroot):
"""
Prepare a swap partition.
"""
path = "%s/fs.%s" % (cr_workdir, self.fstype)
dd_cmd = "dd if=/dev/zero of=%s bs=1k seek=%d count=0" % \
(path, self.size)
exec_cmd(dd_cmd)
import uuid
label_str = ""
if self.label:
label_str = "-L %s" % self.label
mkswap_cmd = "mkswap %s -U %s %s" % (label_str, str(uuid.uuid1()), path)
exec_native_cmd(mkswap_cmd, native_sysroot)
开发者ID:KenChenIEC,项目名称:openbmc,代码行数:16,代码来源:partition.py
示例18: 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 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)
if 'file' not in source_params:
msger.error("No file specified\n")
return
src = os.path.join(bootimg_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=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 = out.split()[0]
if int(filesize) > int(part.size):
part.size = filesize
part.source_file = dst
开发者ID:agangidi53,项目名称:openbmc,代码行数:35,代码来源:rawcopy.py
示例19: 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])
extra_blocks = self.get_extra_block_count(actual_rootfs_size)
if extra_blocks < self.extra_space:
extra_blocks = self.extra_space
rootfs_size = actual_rootfs_size + extra_blocks
rootfs_size *= self.overhead_factor
msger.debug("Added %d extra blocks to %s to get to %d total blocks" % \
(extra_blocks, self.mountpoint, rootfs_size))
with open(rootfs, 'w') as sparse:
os.ftruncate(sparse.fileno(), rootfs_size * 1024)
extra_imagecmd = "-i 8192"
label_str = ""
if self.label:
label_str = "-L %s" % self.label
mkfs_cmd = "mkfs.%s -F %s %s %s -d %s" % \
(self.fstype, extra_imagecmd, rootfs, label_str, rootfs_dir)
exec_native_cmd(mkfs_cmd, native_sysroot, pseudo=pseudo)
开发者ID:ostroproject,项目名称:ostro-os,代码行数:31,代码来源:partition.py
示例20: prepare_rootfs
def prepare_rootfs(self, cr_workdir, oe_builddir, rootfs_dir, native_sysroot):
"""
Prepare content for a rootfs partition i.e. create a partition
and fill it from a /rootfs dir.
Currently handles ext2/3/4, btrfs and vfat.
"""
p_prefix = os.environ.get("PSEUDO_PREFIX", "%s/usr" % native_sysroot)
p_localstatedir = os.environ.get("PSEUDO_LOCALSTATEDIR", "%s/../pseudo" % rootfs_dir)
p_passwd = os.environ.get("PSEUDO_PASSWD", rootfs_dir)
p_nosymlinkexp = os.environ.get("PSEUDO_NOSYMLINKEXP", "1")
pseudo = "export PSEUDO_PREFIX=%s;" % p_prefix
pseudo += "export PSEUDO_LOCALSTATEDIR=%s;" % p_localstatedir
pseudo += "export PSEUDO_PASSWD=%s;" % p_passwd
pseudo += "export PSEUDO_NOSYMLINKEXP=%s;" % p_nosymlinkexp
pseudo += "%s/usr/bin/pseudo " % native_sysroot
rootfs = "%s/rootfs_%s.%s.%s" % (cr_workdir, self.label, self.lineno, self.fstype)
if os.path.isfile(rootfs):
os.remove(rootfs)
for prefix in ("ext", "btrfs", "vfat", "squashfs"):
if self.fstype.startswith(prefix):
method = getattr(self, "prepare_rootfs_" + prefix)
method(rootfs, oe_builddir, rootfs_dir, native_sysroot, pseudo)
self.source_file = rootfs
# get the rootfs size in the right units for kickstart (kB)
du_cmd = "du -Lbks %s" % rootfs
out = exec_cmd(du_cmd)
self.size = out.split()[0]
break
开发者ID:shenki,项目名称:poky,代码行数:34,代码来源:partition.py
注:本文中的wic.utils.oe.misc.exec_cmd函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论