示例#1
0
    def import_description(self):
        """
            import XML descriptions, custom scripts 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)

        need_script_helper_functions = False
        config_script = self.description_dir + '/config.sh'
        image_script = self.description_dir + '/images.sh'

        bootloader_scripts = {
            'edit_boot_config.sh':
                self.xml_state.build_type.get_editbootconfig(),
            'edit_boot_install.sh':
                self.xml_state.build_type.get_editbootinstall()
        }
        sorted_bootloader_scripts = OrderedDict(
            sorted(bootloader_scripts.items())
        )

        script_target = self.root_dir + '/image/'

        for name, bootloader_script in sorted_bootloader_scripts.iteritems():
            if bootloader_script:
                script_file = self.description_dir + '/' + bootloader_script
                if os.path.exists(script_file):
                    log.info(
                        '--> Importing %s script as %s',
                        bootloader_script, 'image/' + name
                    )
                    Command.run(
                        [
                            'cp', script_file, script_target + name
                        ]
                    )
                else:
                    raise KiwiScriptFailed(
                        'Specified script %s does not exist' % script_file
                    )

        if os.path.exists(config_script):
            log.info('--> Importing config script as image/config.sh')
            Command.run(['cp', config_script, script_target])
            need_script_helper_functions = True

        if os.path.exists(image_script):
            log.info('--> Importing image script as image/images.sh')
            Command.run(['cp', image_script, script_target])
            need_script_helper_functions = True

        if need_script_helper_functions:
            script_functions = Defaults.get_common_functions_file()
            script_functions_target = self.root_dir + '/.kconfig'
            log.info('--> Importing script helper functions')
            Command.run([
                'cp', script_functions, script_functions_target
            ])
示例#2
0
文件: shell.py 项目: k0da/kiwi-1
 def run_common_function(self, name, parameters):
     Command.run([
         'bash', '-c',
         'source ' + Defaults.get_common_functions_file() +
         '; ' + name + ' ' + ' '.join(parameters)
     ])