本文整理汇总了Python中kiwi.path.Path.wipe方法的典型用法代码示例。如果您正苦于以下问题:Python Path.wipe方法的具体用法?Python Path.wipe怎么用?Python Path.wipe使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kiwi.path.Path
的用法示例。
在下文中一共展示了Path.wipe方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: pack_image_to_file
# 需要导入模块: from kiwi.path import Path [as 别名]
# 或者: from kiwi.path.Path import wipe [as 别名]
def pack_image_to_file(self, filename):
"""
Packs the given oci image into the given filename.
:param string filename: file name of the resulting packed image
"""
oci_image = os.sep.join([
self.oci_dir, ':'.join(['umoci_layout', self.container_tag])
])
additional_tags = []
for tag in self.additional_tags:
additional_tags.extend([
'--additional-tag', '{0}:{1}'.format(self.container_name, tag)
])
# make sure the target tar file does not exist
# skopeo doesn't support force overwrite
Path.wipe(filename)
Command.run(
[
'skopeo', 'copy', 'oci:{0}'.format(
oci_image
),
'docker-archive:{0}:{1}:{2}'.format(
filename, self.container_name, self.container_tag
)
] + additional_tags
)
container_compressor = self.runtime_config.get_container_compression()
if container_compressor:
compressor = Compress(filename)
return compressor.xz(self.runtime_config.get_xz_options())
else:
return filename
示例2: setup_keyboard_map
# 需要导入模块: from kiwi.path import Path [as 别名]
# 或者: from kiwi.path.Path import wipe [as 别名]
def setup_keyboard_map(self):
"""
Setup console keyboard
"""
if 'keytable' in self.preferences:
log.info(
'Setting up keytable: %s', self.preferences['keytable']
)
if CommandCapabilities.has_option_in_help(
'systemd-firstboot', '--keymap',
root=self.root_dir, raise_on_error=False
):
Path.wipe(self.root_dir + '/etc/vconsole.conf')
Command.run([
'chroot', self.root_dir, 'systemd-firstboot',
'--keymap=' + self.preferences['keytable']
])
elif os.path.exists(self.root_dir + '/etc/sysconfig/keyboard'):
Shell.run_common_function(
'baseUpdateSysConfig', [
self.root_dir + '/etc/sysconfig/keyboard', 'KEYTABLE',
'"' + self.preferences['keytable'] + '"'
]
)
else:
log.warning(
'keyboard setup skipped no capable '
'systemd-firstboot or etc/sysconfig/keyboard found'
)
示例3: setup_locale
# 需要导入模块: from kiwi.path import Path [as 别名]
# 或者: from kiwi.path.Path import wipe [as 别名]
def setup_locale(self):
"""
Setup UTF8 system wide locale
"""
if 'locale' in self.preferences:
if 'POSIX' in self.preferences['locale'].split(','):
locale = 'POSIX'
else:
locale = '{0}.UTF-8'.format(
self.preferences['locale'].split(',')[0]
)
log.info('Setting up locale: %s', self.preferences['locale'])
if CommandCapabilities.has_option_in_help(
'systemd-firstboot', '--locale',
root=self.root_dir, raise_on_error=False
):
Path.wipe(self.root_dir + '/etc/locale.conf')
Command.run([
'chroot', self.root_dir, 'systemd-firstboot',
'--locale=' + locale
])
elif os.path.exists(self.root_dir + '/etc/sysconfig/language'):
Shell.run_common_function(
'baseUpdateSysConfig', [
self.root_dir + '/etc/sysconfig/language',
'RC_LANG', locale
]
)
else:
log.warning(
'locale setup skipped no capable '
'systemd-firstboot or etc/sysconfig/language not found'
)
示例4: process_install_requests_bootstrap
# 需要导入模块: from kiwi.path import Path [as 别名]
# 或者: from kiwi.path.Path import wipe [as 别名]
def process_install_requests_bootstrap(self):
"""
Process package install requests for bootstrap phase (no chroot)
The debootstrap program is used to bootstrap a new system with
a collection of predefined packages. The kiwi bootstrap section
information is not used in this case
"""
if not self.distribution:
raise KiwiDebootstrapError(
'No main distribution repository is configured'
)
bootstrap_script = '/usr/share/debootstrap/scripts/' + \
self.distribution
if not os.path.exists(bootstrap_script):
raise KiwiDebootstrapError(
'debootstrap script for %s distribution not found' %
self.distribution
)
bootstrap_dir = self.root_dir + '.debootstrap'
if 'apt-get' in self.package_requests:
# debootstrap takes care to install apt-get
self.package_requests.remove('apt-get')
try:
dev_mount = MountManager(
device='/dev', mountpoint=self.root_dir + '/dev'
)
dev_mount.umount()
if self.repository.unauthenticated == 'false':
log.warning(
'KIWI does not support signature checks for apt-get '
'package manager during the bootstrap procedure, any '
'provided key will only be used inside the chroot '
'environment'
)
Command.run(
[
'debootstrap', '--no-check-gpg', self.distribution,
bootstrap_dir, self.distribution_path
], self.command_env
)
data = DataSync(
bootstrap_dir + '/', self.root_dir
)
data.sync_data(
options=['-a', '-H', '-X', '-A']
)
for key in self.repository.signing_keys:
Command.run([
'chroot', self.root_dir, 'apt-key', 'add', key
], self.command_env)
except Exception as e:
raise KiwiDebootstrapError(
'%s: %s' % (type(e).__name__, format(e))
)
finally:
Path.wipe(bootstrap_dir)
return self.process_install_requests()
示例5: __del__
# 需要导入模块: from kiwi.path import Path [as 别名]
# 或者: from kiwi.path.Path import wipe [as 别名]
def __del__(self):
if self.media_dir or self.live_container_dir:
log.info(
'Cleaning up {0} instance'.format(type(self).__name__)
)
if self.media_dir:
Path.wipe(self.media_dir)
if self.live_container_dir:
Path.wipe(self.live_container_dir)
示例6: delete_repo
# 需要导入模块: from kiwi.path import Path [as 别名]
# 或者: from kiwi.path.Path import wipe [as 别名]
def delete_repo(self, name):
"""
Delete apt-get repository
:param string name: repository base file name
"""
Path.wipe(
self.shared_apt_get_dir['sources-dir'] + '/' + name + '.list'
)
示例7: delete_repo
# 需要导入模块: from kiwi.path import Path [as 别名]
# 或者: from kiwi.path.Path import wipe [as 别名]
def delete_repo(self, name):
"""
Delete yum repository
:param string name: repository base file name
"""
Path.wipe(
self.shared_yum_dir['reposd-dir'] + '/' + name + '.repo'
)
示例8: _cleanup
# 需要导入模块: from kiwi.path import Path [as 别名]
# 或者: from kiwi.path.Path import wipe [as 别名]
def _cleanup(self):
"""
Delete all temporary directories
"""
for metadata_dir in self.repository_metadata_dirs:
Path.wipe(metadata_dir)
if self.repository_solvable_dir:
Path.wipe(self.repository_solvable_dir)
self._init_temporary_dir_names()
示例9: __del__
# 需要导入模块: from kiwi.path import Path [as 别名]
# 或者: from kiwi.path.Path import wipe [as 别名]
def __del__(self):
if self.volume_group:
log.info('Cleaning up %s instance', type(self).__name__)
if self.umount_volumes():
Path.wipe(self.mountpoint)
try:
Command.run(['vgchange', '-an', self.volume_group])
except Exception:
log.warning(
'volume group %s still busy', self.volume_group
)
示例10: cleanup_unused_repos
# 需要导入模块: from kiwi.path import Path [as 别名]
# 或者: from kiwi.path.Path import wipe [as 别名]
def cleanup_unused_repos(self):
"""
Delete unused yum repositories
Repository configurations which are not used for this build
must be removed otherwise they are taken into account for
the package installations
"""
repos_dir = self.shared_yum_dir['reposd-dir']
repo_files = list(os.walk(repos_dir))[0][2]
for repo_file in repo_files:
if repo_file not in self.repo_names:
Path.wipe(repos_dir + '/' + repo_file)
示例11: delete_repo_cache
# 需要导入模块: from kiwi.path import Path [as 别名]
# 或者: from kiwi.path.Path import wipe [as 别名]
def delete_repo_cache(self, name):
"""
Delete yum repository cache
The cache data for each repository is stored in a directory
of the same name as the repository name. The method deletes
this directory to cleanup the cache information
:param string name: repository name
"""
Path.wipe(
os.sep.join([self.shared_yum_dir['cache-dir'], name])
)
示例12: delete_repo_cache
# 需要导入模块: from kiwi.path import Path [as 别名]
# 或者: from kiwi.path.Path import wipe [as 别名]
def delete_repo_cache(self, name):
"""
Delete apt-get repository cache
Apt stores the package cache in a collection of binary files
and deb archives. As of now I couldn't came across a solution
which allows for deleting only the cache data for a specific
repository. Thus the repo cache cleanup affects all cache
data
:param string name: unused
"""
for cache_file in ['archives', 'pkgcache.bin', 'srcpkgcache.bin']:
Path.wipe(os.sep.join([self.manager_base, cache_file]))
示例13: _load_boot_image_instance
# 需要导入模块: from kiwi.path import Path [as 别名]
# 或者: from kiwi.path.Path import wipe [as 别名]
def _load_boot_image_instance(self):
boot_image_dump_file = self.target_dir + '/boot_image.pickledump'
if not os.path.exists(boot_image_dump_file):
raise KiwiInstallMediaError(
'No boot image instance dump %s found' % boot_image_dump_file
)
try:
with open(boot_image_dump_file, 'rb') as boot_image_dump:
boot_image = pickle.load(boot_image_dump)
boot_image.enable_cleanup()
Path.wipe(boot_image_dump_file)
except Exception as e:
raise KiwiInstallMediaError(
'Failed to load boot image dump: %s' % type(e).__name__
)
return boot_image
示例14: delete_repo_cache
# 需要导入模块: from kiwi.path import Path [as 别名]
# 或者: from kiwi.path.Path import wipe [as 别名]
def delete_repo_cache(self, name):
"""
Delete dnf repository cache
The cache data for each repository is stored in a directory
and additional files all starting with the repository name.
The method glob deletes all files and directories matching
the repository name followed by any characters to cleanup
the cache information
:param str name: repository name
"""
dnf_cache_glob_pattern = ''.join(
[self.shared_dnf_dir['cache-dir'], os.sep, name, '*']
)
for dnf_cache_file in glob.iglob(dnf_cache_glob_pattern):
Path.wipe(dnf_cache_file)
示例15: cleanup_unused_repos
# 需要导入模块: from kiwi.path import Path [as 别名]
# 或者: from kiwi.path.Path import wipe [as 别名]
def cleanup_unused_repos(self):
"""
Delete unused zypper repositories
zypper creates a system solvable which is unwanted for the
purpose of building images. In addition zypper fails with
an error message 'Failed to cache rpm database' if such a
system solvable exists and a new root system is created
All other repository configurations which are not used for
this build must be removed too, otherwise they are taken into
account for the package installations
"""
solv_dir = self.shared_zypper_dir['solv-cache-dir']
Path.wipe(solv_dir + '/@System')
repos_dir = self.shared_zypper_dir['reposd-dir']
repo_files = list(os.walk(repos_dir))[0][2]
for repo_file in repo_files:
if repo_file not in self.repo_names:
Path.wipe(repos_dir + '/' + repo_file)