Beispiel #1
0
    def __init__(self, should_perform_task_setup=True):
        from logger import log

        self.cli = Cli()

        # want some help
        self.cli.show_and_exit_on_help_request()

        # load/import task module
        self.task = self.cli.load_command()

        # get command specific args
        self.command_args = self.cli.get_command_args()

        # get global args
        self.global_args = self.cli.get_global_args()

        if should_perform_task_setup:
            # set log level
            if self.global_args['--debug']:
                log.setLogLevel(logging.DEBUG)
            else:
                log.setLogLevel(logging.INFO)

            # set log file
            if self.global_args['--logfile']:
                log.set_logfile(
                    self.global_args['--logfile']
                )
Beispiel #2
0
    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'
        )
Beispiel #3
0
    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')