def __init__(self, xml_state, target_dir, root_dir): self.media_dir = None self.arch = platform.machine() self.root_dir = root_dir self.target_dir = target_dir self.xml_state = xml_state self.live_type = xml_state.build_type.get_flags() self.types = Defaults.get_live_iso_types() self.hybrid = xml_state.build_type.get_hybrid() self.volume_id = xml_state.build_type.get_volid() self.machine = xml_state.get_build_type_machine_section() self.mbrid = ImageIdentifier() self.mbrid.calculate_id() if not self.live_type: self.live_type = Defaults.get_default_live_iso_type() self.boot_image_task = BootImageTask('kiwi', xml_state, target_dir) self.firmware = FirmWare(xml_state) self.system_setup = SystemSetup(xml_state=xml_state, description_dir=None, root_dir=self.root_dir) self.isoname = ''.join([ target_dir, '/', xml_state.xml_data.get_name(), '.' + platform.machine(), '-' + xml_state.get_image_version(), '.iso' ]) self.live_image_file = ''.join([ target_dir, '/', xml_state.xml_data.get_name(), '-read-only.', self.arch, '-', xml_state.get_image_version() ]) self.result = Result()
def prepare(self): """ prepare new root system suitable to create an initrd from it """ self.__load_boot_xml_description() boot_image_name = self.boot_xml_state.xml_data.get_name() self.__import_system_description_elements() log.info('Preparing boot image') system = System(xml_state=self.boot_xml_state, root_dir=self.boot_root_directory, allow_existing=True) manager = system.setup_repositories() system.install_bootstrap(manager) system.install_system(manager) profile = Profile(self.boot_xml_state) profile.add('kiwi_initrdname', boot_image_name) defaults = Defaults() defaults.to_profile(profile) setup = SystemSetup(self.boot_xml_state, self.__boot_description_directory(), self.boot_root_directory) setup.import_shell_environment(profile) setup.import_description() setup.import_overlay_files(follow_links=True) setup.call_config_script() system.pinch_system(manager=manager, force=True) setup.call_image_script() setup.create_init_link_from_linuxrc()
def process(self): self.manual = Help() if self.__help(): return Privileges.check_for_root_permissions() self.load_xml_description(self.command_args['--description']) if self.command_args['--set-repo']: (repo_source, repo_type, repo_alias, repo_prio) = \ self.quadruple_token(self.command_args['--set-repo']) self.xml_state.set_repository(repo_source, repo_type, repo_alias, repo_prio) if self.command_args['--add-repo']: for add_repo in self.command_args['--add-repo']: (repo_source, repo_type, repo_alias, repo_prio) = \ self.quadruple_token(add_repo) self.xml_state.add_repository(repo_source, repo_type, repo_alias, repo_prio) if os.path.exists('/.buildenv'): # This build runs inside of a buildservice worker. Therefore # the repo defintions is adapted accordingly self.xml_state.translate_obs_to_suse_repositories() elif self.command_args['--obs-repo-internal']: # This build should use the internal SUSE buildservice # Be aware that the buildhost has to provide access self.xml_state.translate_obs_to_ibs_repositories() log.info('Preparing system') system = System(self.xml_state, self.command_args['--root'], self.command_args['--allow-existing-root']) manager = system.setup_repositories() system.install_bootstrap(manager) system.install_system(manager) profile = Profile(self.xml_state) defaults = Defaults() defaults.to_profile(profile) setup = SystemSetup(self.xml_state, self.command_args['--description'], self.command_args['--root']) setup.import_shell_environment(profile) setup.import_description() setup.import_overlay_files() setup.call_config_script() setup.import_image_identifier() setup.setup_groups() setup.setup_users() setup.setup_keyboard_map() setup.setup_locale() setup.setup_timezone() system.pinch_system(manager)
def __init__(self, xml_state, target_dir, root_dir): self.target_dir = target_dir self.compressed = xml_state.build_type.get_compressed() self.image_name = xml_state.xml_data.get_name() self.machine = xml_state.get_build_type_machine_section() self.pxedeploy = xml_state.get_build_type_pxedeploy_section() self.filesystem = FileSystemBuilder(xml_state, target_dir, root_dir) self.system_setup = SystemSetup(xml_state=xml_state, description_dir=None, root_dir=root_dir) self.boot_image_task = BootImageTask('kiwi', xml_state, target_dir) self.kernel_filename = None self.hypervisor_filename = None self.result = Result()
def process(self): self.manual = Help() if self.__help(): return Privileges.check_for_root_permissions() self.load_xml_description(self.command_args['--root']) log.info('Creating system image') if not os.path.exists(self.command_args['--target-dir']): Path.create(self.command_args['--target-dir']) setup = SystemSetup(xml_state=self.xml_state, description_dir=self.command_args['--root'], root_dir=self.command_args['--root']) setup.call_image_script() image_builder = ImageBuilder(self.xml_state, self.command_args['--target-dir'], self.command_args['--root']) result = image_builder.create() result.print_results() result.dump(self.command_args['--target-dir'] + '/kiwi.result')
def process(self): self.manual = Help() if self.__help(): return Privileges.check_for_root_permissions() image_root = self.command_args['--target-dir'] + '/build/image-root' Path.create(image_root) if not self.global_args['--logfile']: log.set_logfile(self.command_args['--target-dir'] + '/build/image-root.log') self.load_xml_description(self.command_args['--description']) if self.command_args['--set-repo']: (repo_source, repo_type, repo_alias, repo_prio) = \ self.quadruple_token(self.command_args['--set-repo']) self.xml_state.set_repository(repo_source, repo_type, repo_alias, repo_prio) if self.command_args['--add-repo']: for add_repo in self.command_args['--add-repo']: (repo_source, repo_type, repo_alias, repo_prio) = \ self.quadruple_token(add_repo) self.xml_state.add_repository(repo_source, repo_type, repo_alias, repo_prio) Path.create(self.command_args['--target-dir']) if os.path.exists('/.buildenv'): # This build runs inside of a buildservice worker. Therefore # the repo defintions is adapted accordingly self.xml_state.translate_obs_to_suse_repositories() elif self.command_args['--obs-repo-internal']: # This build should use the internal SUSE buildservice # Be aware that the buildhost has to provide access self.xml_state.translate_obs_to_ibs_repositories() log.info('Preparing new root system') system = System(self.xml_state, image_root, True) manager = system.setup_repositories() system.install_bootstrap(manager) system.install_system(manager) profile = Profile(self.xml_state) defaults = Defaults() defaults.to_profile(profile) setup = SystemSetup(self.xml_state, self.command_args['--description'], image_root) setup.import_shell_environment(profile) setup.import_description() setup.import_overlay_files() setup.call_config_script() setup.import_image_identifier() setup.setup_groups() setup.setup_users() setup.setup_keyboard_map() setup.setup_locale() setup.setup_timezone() system.pinch_system(manager) # make sure system instance is cleaned up now del system setup.call_image_script() # make sure setup instance is cleaned up now del setup log.info('Creating system image') image_builder = ImageBuilder(self.xml_state, self.command_args['--target-dir'], image_root) result = image_builder.create() result.print_results() result.dump(self.command_args['--target-dir'] + '/kiwi.result')
def __init__(self, xml_state, target_dir, root_dir): self.root_dir = root_dir self.target_dir = target_dir self.xml_state = xml_state self.custom_filesystem_args = None self.build_type_name = xml_state.get_build_type_name() self.image_format = xml_state.build_type.get_format() self.install_iso = xml_state.build_type.get_installiso() self.install_stick = xml_state.build_type.get_installstick() self.install_pxe = xml_state.build_type.get_installpxe() self.blocksize = xml_state.build_type.get_target_blocksize() self.volume_manager_name = xml_state.get_volume_management() self.volumes = xml_state.get_volumes() self.volume_group_name = xml_state.get_volume_group_name() self.mdraid = xml_state.build_type.get_mdraid() self.luks = xml_state.build_type.get_luks() self.luks_os = xml_state.build_type.get_luksOS() self.machine = xml_state.get_build_type_machine_section() self.requested_filesystem = xml_state.build_type.get_filesystem() self.requested_boot_filesystem = \ xml_state.build_type.get_bootfilesystem() self.bootloader = xml_state.build_type.get_bootloader() self.disk_setup = DiskSetup( xml_state, root_dir ) self.boot_image_task = BootImageTask( 'kiwi', xml_state, target_dir ) self.firmware = FirmWare( xml_state ) self.system_setup = SystemSetup( xml_state=xml_state, description_dir=None, root_dir=self.root_dir ) self.diskname = ''.join( [ target_dir, '/', xml_state.xml_data.get_name(), '.' + platform.machine(), '-' + xml_state.get_image_version(), '.raw' ] ) self.install_media = self.__install_image_requested() self.install_image = InstallImageBuilder( xml_state, target_dir, self.boot_image_task ) # an instance of a class with the sync_data capability # representing the entire image system except for the boot/ area # which could live on another part of the disk self.system = None # an instance of a class with the sync_data capability # representing the boot/ area of the disk if not part of # self.system self.system_boot = None # an instance of a class with the sync_data capability # representing the boot/efi area of the disk self.system_efi = None # result store self.result = Result()