def create(self): """ Create new system root directory The method creates a temporary directory and initializes it for the purpose of building a system image from it. This includes the following setup: * create static core device nodes * create core system paths On success the contents of the temporary location are synced to the specified root_dir and the temporary location will be deleted. That way we never work on an incomplete initial setup """ root = mkdtemp(prefix='kiwi_root.') Path.create(self.root_dir) try: self._create_base_directories(root) self._create_device_nodes(root) self._create_base_links(root) self._setup_config_templates(root) data = DataSync(root + '/', self.root_dir) data.sync_data(options=['-a', '--ignore-existing']) if Defaults.is_buildservice_worker(): copy(os.sep + Defaults.get_buildservice_env_name(), self.root_dir) except Exception as e: self.delete() raise KiwiRootInitCreationError('%s: %s' % (type(e).__name__, format(e))) finally: rmtree(root, ignore_errors=True)
def _append_buildservice_disturl_label(self): with open(os.sep + Defaults.get_buildservice_env_name()) as env: for line in env: if line.startswith('BUILD_DISTURL') and '=' in line: disturl = line.split('=')[1].lstrip('\'\"').rstrip('\n\'\"') if disturl: self.oci_config['labels'] = { 'org.openbuildservice.disturl': disturl } return log.warning('Could not find BUILD_DISTURL inside .buildenv')
def _append_buildservice_disturl_label(self): with open(os.sep + Defaults.get_buildservice_env_name()) as env: for line in env: if line.startswith('BUILD_DISTURL') and '=' in line: disturl = line.split('=')[1].strip() if disturl: self.labels.append(''.join([ '--config.label=' 'org.openbuildservice.disturl=', line.split('=')[1].strip() ])) log.warning('Could not find BUILD_DISTURL inside .buildenv')
def _append_buildservice_disturl_label(self): with open(os.sep + Defaults.get_buildservice_env_name()) as env: for line in env: if line.startswith('BUILD_DISTURL') and '=' in line: disturl = line.split('=')[1].strip() if disturl: self.labels.append( ''.join([ '--config.label=' 'org.openbuildservice.disturl=', line.split('=')[1].strip() ]) ) log.warning('Could not find BUILD_DISTURL inside .buildenv')
def create(self): """ Create new system root directory The method creates a temporary directory and initializes it for the purpose of building a system image from it. This includes the following setup: * create static core device nodes * create core system paths On success the contents of the temporary location are synced to the specified root_dir and the temporary location will be deleted. That way we never work on an incomplete initial setup :raises KiwiRootInitCreationError: if the init creation fails at some point """ root = mkdtemp(prefix='kiwi_root.') Path.create(self.root_dir) try: self._create_base_directories(root) self._create_base_links(root) self._setup_config_templates(root) data = DataSync(root + '/', self.root_dir) data.sync_data( options=['-a', '--ignore-existing'] ) if Defaults.is_buildservice_worker(): copy( os.sep + Defaults.get_buildservice_env_name(), self.root_dir) except Exception as e: self.delete() raise KiwiRootInitCreationError( '%s: %s' % (type(e).__name__, format(e)) ) finally: rmtree(root, ignore_errors=True)