本文整理汇总了Python中kiwi.path.Path.create方法的典型用法代码示例。如果您正苦于以下问题:Python Path.create方法的具体用法?Python Path.create怎么用?Python Path.create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kiwi.path.Path
的用法示例。
在下文中一共展示了Path.create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: process_install_requests
# 需要导入模块: from kiwi.path import Path [as 别名]
# 或者: from kiwi.path.Path import create [as 别名]
def process_install_requests(self):
"""
Process package install requests for image phase (chroot)
:return: process results in command type
:rtype: namedtuple
"""
if self.exclude_requests:
# For zypper excluding a package means, removing it from
# the solver operation. This is done by adding a package
# lock. This means that if the package is hard required
# by another package, it will break the transaction.
metadata_dir = ''.join([self.root_dir, '/etc/zypp'])
if not os.path.exists(metadata_dir):
Path.create(metadata_dir)
for package in self.exclude_requests:
Command.run(
['chroot', self.root_dir, 'zypper'] +
self.chroot_zypper_args + ['al'] + [package],
self.chroot_command_env
)
return Command.call(
['chroot', self.root_dir, 'zypper'] + self.chroot_zypper_args + [
'install', '--auto-agree-with-licenses'
] + self.custom_args + self._install_items(),
self.chroot_command_env
)
示例2: mount_volumes
# 需要导入模块: from kiwi.path import Path [as 别名]
# 或者: from kiwi.path.Path import create [as 别名]
def mount_volumes(self):
"""
Mount btrfs subvolumes
"""
self.toplevel_mount.mount(
self.custom_filesystem_args['mount_options']
)
for volume_mount in self.subvol_mount_list:
if self.volumes_mounted_initially:
volume_mount.mountpoint = os.path.normpath(
volume_mount.mountpoint.replace(self.toplevel_volume, '', 1)
)
if not os.path.exists(volume_mount.mountpoint):
Path.create(volume_mount.mountpoint)
subvol_name = self._get_subvol_name_from_mountpoint(volume_mount)
subvol_options = ','.join(
[
'subvol=' + subvol_name
] + self.custom_filesystem_args['mount_options']
)
volume_mount.mount(
options=[subvol_options]
)
self.volumes_mounted_initially = True
示例3: _create_iso_install_kernel_and_initrd
# 需要导入模块: from kiwi.path import Path [as 别名]
# 或者: from kiwi.path.Path import create [as 别名]
def _create_iso_install_kernel_and_initrd(self):
boot_path = self.media_dir + '/boot/' + self.arch + '/loader'
Path.create(boot_path)
kernel = Kernel(self.boot_image_task.boot_root_directory)
if kernel.get_kernel():
kernel.copy_kernel(boot_path, '/linux')
else:
raise KiwiInstallBootImageError(
'No kernel in boot image tree %s found' %
self.boot_image_task.boot_root_directory
)
if self.xml_state.is_xen_server():
if kernel.get_xen_hypervisor():
kernel.copy_xen_hypervisor(boot_path, '/xen.gz')
else:
raise KiwiInstallBootImageError(
'No hypervisor in boot image tree %s found' %
self.boot_image_task.boot_root_directory
)
if self.initrd_system == 'dracut':
self._create_dracut_install_config()
self._add_system_image_boot_options_to_boot_image()
self.boot_image_task.create_initrd(self.mbrid, 'initrd_kiwi_install')
Command.run(
[
'mv', self.boot_image_task.initrd_filename,
boot_path + '/initrd'
]
)
示例4: sync_data
# 需要导入模块: from kiwi.path import Path [as 别名]
# 或者: from kiwi.path.Path import create [as 别名]
def sync_data(self):
"""
Synchronize data from the given base image to the target root
directory.
"""
self.extract_oci_image()
Command.run([
'umoci', 'unpack', '--image',
'{0}:base_layer'.format(self.oci_layout_dir), self.oci_unpack_dir
])
synchronizer = DataSync(
os.sep.join([self.oci_unpack_dir, 'rootfs', '']),
''.join([self.root_dir, os.sep])
)
synchronizer.sync_data(options=['-a', '-H', '-X', '-A'])
# A copy of the uncompressed image and its checksum are
# kept inside the root_dir in order to ensure the later steps
# i.e. system create are atomic and don't need any third
# party archive.
image_copy = Defaults.get_imported_root_image(self.root_dir)
Path.create(os.path.dirname(image_copy))
image_tar = ArchiveTar(image_copy)
image_tar.create(self.oci_layout_dir)
self._make_checksum(image_copy)
示例5: mount_shared_directory
# 需要导入模块: from kiwi.path import Path [as 别名]
# 或者: from kiwi.path.Path import create [as 别名]
def mount_shared_directory(self, host_dir=None):
"""
Bind mount shared location
The shared location is a directory which shares data from
the image buildsystem host with the image root system. It
is used for the repository setup and the package manager
cache to allow chroot operations without being forced to
duplicate this data
:param str host_dir: directory to share between image root and build
system root
:raises KiwiMountSharedDirectoryError: if mount fails
"""
if not host_dir:
host_dir = self.shared_location
try:
Path.create(self.root_dir + host_dir)
Path.create('/' + host_dir)
shared_mount = MountManager(
device=host_dir, mountpoint=self.root_dir + host_dir
)
shared_mount.bind_mount()
self.mount_stack.append(shared_mount)
self.dir_stack.append(host_dir)
except Exception as e:
self.cleanup()
raise KiwiMountSharedDirectoryError(
'%s: %s' % (type(e).__name__, format(e))
)
示例6: _create_zypper_runtime_environment
# 需要导入模块: from kiwi.path import Path [as 别名]
# 或者: from kiwi.path.Path import create [as 别名]
def _create_zypper_runtime_environment(self):
for zypper_dir in list(self.shared_zypper_dir.values()):
Path.create(zypper_dir)
return dict(
os.environ,
LANG='C',
ZYPP_CONF=self.runtime_zypp_config_file.name
)
示例7: mount_volumes
# 需要导入模块: from kiwi.path import Path [as 别名]
# 或者: from kiwi.path.Path import create [as 别名]
def mount_volumes(self):
"""
Mount lvm volumes
"""
for volume_mount in self.mount_list:
Path.create(volume_mount.mountpoint)
volume_mount.mount(
options=[self.mount_options]
)
self.volumes_mounted_initially = True
示例8: create_volumes
# 需要导入模块: from kiwi.path import Path [as 别名]
# 或者: from kiwi.path.Path import create [as 别名]
def create_volumes(self, filesystem_name):
"""
Create configured btrfs subvolumes
Any btrfs subvolume is of the same btrfs filesystem. There is no
way to have different filesystems per btrfs subvolume. Thus
the filesystem_name has no effect for btrfs
:param string filesystem_name: unused
"""
log.info(
'Creating %s sub volumes', filesystem_name
)
self.create_volume_paths_in_root_dir()
canonical_volume_list = self.get_canonical_volume_list()
if canonical_volume_list.full_size_volume:
# put an eventual fullsize volume to the volume list
# because there is no extra handling required for it on btrfs
canonical_volume_list.volumes.append(
canonical_volume_list.full_size_volume
)
for volume in canonical_volume_list.volumes:
if volume.name == 'LVRoot':
# the btrfs root volume named '@' has been created as
# part of the setup procedure
pass
else:
log.info('--> sub volume %s', volume.realpath)
toplevel = self.mountpoint + '/@/'
volume_parent_path = os.path.normpath(
toplevel + os.path.dirname(volume.realpath)
)
if not os.path.exists(volume_parent_path):
Path.create(volume_parent_path)
Command.run(
[
'btrfs', 'subvolume', 'create',
os.path.normpath(toplevel + volume.realpath)
]
)
self.apply_attributes_on_volume(
toplevel, volume
)
if self.custom_args['root_is_snapshot']:
snapshot = self.mountpoint + '/@/.snapshots/1/snapshot/'
volume_mount = MountManager(
device=self.device,
mountpoint=os.path.normpath(snapshot + volume.realpath)
)
self.subvol_mount_list.append(
volume_mount
)
示例9: create_efi_path
# 需要导入模块: from kiwi.path import Path [as 别名]
# 或者: from kiwi.path.Path import create [as 别名]
def create_efi_path(self, in_sub_dir='boot/efi'):
"""
Create standard EFI boot directory structure
:param string in_sub_dir: toplevel directory
:return: Full qualified EFI boot path
:rtype: string
"""
efi_boot_path = self.root_dir + '/' + in_sub_dir + '/EFI/BOOT'
Path.create(efi_boot_path)
return efi_boot_path
示例10: create_volume_paths_in_root_dir
# 需要导入模块: from kiwi.path import Path [as 别名]
# 或者: from kiwi.path.Path import create [as 别名]
def create_volume_paths_in_root_dir(self):
"""
Implements creation of volume paths in the given root directory
"""
for volume in self.volumes:
if volume.realpath and not volume.realpath == os.sep:
volume_image_path = os.path.normpath(
self.root_dir + os.sep + volume.realpath
)
if not os.path.exists(volume_image_path):
# not existing volume paths will be created in the image
# root directory. This happens hidden to the user but is
# imho ok because the path is explicitly configured as a
# volume
Path.create(volume_image_path)
示例11: import_description
# 需要导入模块: from kiwi.path import Path [as 别名]
# 或者: from kiwi.path.Path import create [as 别名]
def import_description(self):
"""
Import XML descriptions, custom scripts, archives and
script helper methods
"""
log.info('Importing Image description to system tree')
description = self.root_dir + '/image/config.xml'
log.info('--> Importing state XML description as image/config.xml')
Path.create(self.root_dir + '/image')
with open(description, 'w') as config:
config.write('<?xml version="1.0" encoding="utf-8"?>')
self.xml_state.xml_data.export(outfile=config, level=0)
self._import_custom_scripts()
self._import_custom_archives()
示例12: process
# 需要导入模块: from kiwi.path import Path [as 别名]
# 或者: from kiwi.path.Path import create [as 别名]
def process(self):
"""
Create a system image from the specified root directory
the root directory is the result of a system prepare
command
"""
self.manual = Help()
if self._help():
return
Privileges.check_for_root_permissions()
abs_target_dir_path = os.path.abspath(
self.command_args['--target-dir']
)
abs_root_path = os.path.abspath(self.command_args['--root'])
self.load_xml_description(
abs_root_path
)
self.runtime_checker.check_target_directory_not_in_shared_cache(
abs_target_dir_path
)
log.info('Creating system image')
if not os.path.exists(abs_target_dir_path):
Path.create(abs_target_dir_path)
setup = SystemSetup(
xml_state=self.xml_state,
root_dir=abs_root_path
)
setup.call_image_script()
image_builder = ImageBuilder(
self.xml_state,
abs_target_dir_path,
abs_root_path,
custom_args={
'signing_keys': self.command_args['--signing-key'],
'xz_options': self.runtime_config.get_xz_options()
}
)
result = image_builder.create()
result.print_results()
result.dump(
os.sep.join([abs_target_dir_path, 'kiwi.result'])
)
示例13: write
# 需要导入模块: from kiwi.path import Path [as 别名]
# 或者: from kiwi.path.Path import create [as 别名]
def write(self):
"""
Write isolinux.cfg and isolinux.msg file
"""
log.info('Writing isolinux.cfg file')
config_dir = self._get_iso_boot_path()
config_file = config_dir + '/isolinux.cfg'
if self.config:
Path.create(config_dir)
with open(config_file, 'w') as config:
config.write(self.config)
config_file_message = config_dir + '/isolinux.msg'
if self.config_message:
with open(config_file_message, 'w') as config:
config.write(self.config_message)
示例14: export_modprobe_setup
# 需要导入模块: from kiwi.path import Path [as 别名]
# 或者: from kiwi.path.Path import create [as 别名]
def export_modprobe_setup(self, target_root_dir):
"""
Export etc/modprobe.d to given root_dir
:param string target_root_dir: path name
"""
modprobe_config = self.root_dir + '/etc/modprobe.d'
if os.path.exists(modprobe_config):
log.info('Export modprobe configuration')
Path.create(target_root_dir + '/etc')
data = DataSync(
modprobe_config, target_root_dir + '/etc/'
)
data.sync_data(
options=['-z', '-a']
)
示例15: setup
# 需要导入模块: from kiwi.path import Path [as 别名]
# 或者: from kiwi.path.Path import create [as 别名]
def setup(self, name=None):
"""
Setup btrfs volume management
In case of btrfs a toplevel(@) subvolume is created and marked
as default volume. If snapshots are activated via the custom_args
the setup method also created the @/.snapshots/1/snapshot
subvolumes. There is no concept of a volume manager name, thus
the name argument is not used for btrfs
:param string name: unused
"""
self.setup_mountpoint()
filesystem = FileSystem(
name='btrfs',
device_provider=MappedDevice(
device=self.device, device_provider=self
),
custom_args=self.custom_filesystem_args
)
filesystem.create_on_device(
label=self.custom_args['root_label']
)
self.toplevel_mount = MountManager(
device=self.device, mountpoint=self.mountpoint
)
self.toplevel_mount.mount(
self.custom_filesystem_args['mount_options']
)
root_volume = self.mountpoint + '/@'
Command.run(
['btrfs', 'subvolume', 'create', root_volume]
)
if self.custom_args['root_is_snapshot']:
snapshot_volume = self.mountpoint + '/@/.snapshots'
Command.run(
['btrfs', 'subvolume', 'create', snapshot_volume]
)
Path.create(snapshot_volume + '/1')
snapshot = self.mountpoint + '/@/.snapshots/1/snapshot'
Command.run(
['btrfs', 'subvolume', 'snapshot', root_volume, snapshot]
)
self._set_default_volume('@/.snapshots/1/snapshot')
else:
self._set_default_volume('@')