예제 #1
0
 def setup_keyboard_map(self):
     """
     Setup console keyboard
     """
     if 'keytable' in self.preferences:
         log.info('Setting up keytable: {0}'.format(
             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')
예제 #2
0
파일: setup.py 프로젝트: AdamMajer/kiwi-ng
 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
0
파일: setup.py 프로젝트: AdamMajer/kiwi-ng
 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
0
 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
             ])
         if os.path.exists(self.root_dir + '/etc/sysconfig/language'):
             Shell.run_common_function('baseUpdateSysConfig', [
                 self.root_dir + '/etc/sysconfig/language', 'RC_LANG',
                 locale
             ])
예제 #5
0
파일: shell_test.py 프로젝트: ChrisBr/kiwi
 def test_run_common_function(self, mock_command):
     Shell.run_common_function('foo', ['"param1"', '"param2"'])
     command_string = ' '.join([
         'source',
         Defaults.project_file('config/functions.sh') + ';', 'foo',
         '"param1"', '"param2"'
     ])
     mock_command.assert_called_once_with(['bash', '-c', command_string])
예제 #6
0
 def test_format_to_variable_value(self):
     assert Shell.format_to_variable_value('text') == 'text'
     assert Shell.format_to_variable_value(True) == 'true'
     assert Shell.format_to_variable_value(False) == 'false'
     assert Shell.format_to_variable_value('42') == '42'
     assert Shell.format_to_variable_value(0) == '0'
     assert Shell.format_to_variable_value(42) == '42'
     assert Shell.format_to_variable_value(None) == ''
     assert Shell.format_to_variable_value(b"42") == '42'
     with raises(KiwiShellVariableValueError):
         Shell.format_to_variable_value(['foo', 'bar'])
예제 #7
0
파일: shell_test.py 프로젝트: SUSE/kiwi
 def test_run_common_function(self, mock_command):
     Shell.run_common_function('foo', ['"param1"', '"param2"'])
     command_string = ' '.join(
         [
             'source', Defaults.project_file('config/functions.sh') + ';',
             'foo', '"param1"', '"param2"'
         ]
     )
     mock_command.assert_called_once_with(
         ['bash', '-c', command_string]
     )
예제 #8
0
 def setup_locale(self):
     """
     Setup etc/sysconfig/language UTF8 locale
     """
     if 'locale' in self.preferences:
         lang_config = self.root_dir + '/etc/sysconfig/language'
         if os.path.exists(lang_config):
             log.info('Setting up locale: %s', self.preferences['locale'])
             Shell.run_common_function('baseUpdateSysConfig', [
                 lang_config, 'RC_LANG',
                 self.preferences['locale'].split(',')[0] + '.UTF-8'
             ])
         else:
             log.warning(
                 'locale setup skipped etc/sysconfig/language not found')
예제 #9
0
 def setup_keyboard_map(self):
     """
     Setup etc/sysconfig/keyboard console keyboard
     """
     if 'keytable' in self.preferences:
         keyboard_config = self.root_dir + '/etc/sysconfig/keyboard'
         if os.path.exists(keyboard_config):
             log.info('Setting up keytable: %s',
                      self.preferences['keytable'])
             Shell.run_common_function('baseUpdateSysConfig', [
                 keyboard_config, 'KEYTABLE',
                 '"' + self.preferences['keytable'] + '"'
             ])
         else:
             log.warning(
                 'keyboard setup skipped etc/sysconfig/keyboard not found')
예제 #10
0
파일: shell_test.py 프로젝트: ChrisBr/kiwi
 def test_quote_key_value_file(self):
     assert Shell.quote_key_value_file("../data/key_value") == [
         "foo='bar'",
         "bar='xxx'",
         "name='bob'",
         "strange='$a_foo'",
     ]
예제 #11
0
파일: profile.py 프로젝트: rabueker/kiwi
 def get_settings(self) -> Dict:
     """
     Return all profile elements that has a value
     """
     profile = {}
     for key, value in list(self.dot_profile.items()):
         profile[key] = Shell.format_to_variable_value(value)
     return collections.OrderedDict(sorted(profile.items()))
예제 #12
0
 def test_quote_key_value_file(self, mock_which):
     mock_which.return_value = 'cp'
     assert Shell.quote_key_value_file('../data/key_value') == [
         "foo='bar'",
         "bar='xxx'",
         "name='bob'",
         "strange='$a_foo'"
     ]
예제 #13
0
파일: shell_test.py 프로젝트: SUSE/kiwi
 def test_quote_key_value_file(self, mock_which):
     mock_which.return_value = 'cp'
     assert Shell.quote_key_value_file('../data/key_value') == [
         "foo='bar'",
         "bar='xxx'",
         "name='bob'",
         "strange='$a_foo'"
     ]
예제 #14
0
파일: profile.py 프로젝트: pyzh/kiwi
    def create(self):
        """
        Create bash quoted profile

        :return: profile dump for bash
        :rtype: string
        """
        sorted_profile = collections.OrderedDict(
            sorted(self.dot_profile.items()))
        temp_profile = NamedTemporaryFile()
        with open(temp_profile.name, 'w') as profile:
            for key, value in list(sorted_profile.items()):
                if value:
                    profile.write(
                        format(key) + '=' + self._format(value) + '\n')
        return Shell.quote_key_value_file(temp_profile.name)
예제 #15
0
파일: profile.py 프로젝트: rabueker/kiwi
    def create(self, filename: str) -> None:
        """
        Create bash quoted profile

        :param str filename: file path name
        """
        sorted_profile = self.get_settings()
        temp_profile = Temporary().new_file()
        with open(temp_profile.name, 'w') as profile:
            for key, value in list(sorted_profile.items()):
                profile.write('{0}={1}{2}'.format(key, value, os.linesep))
        profile_environment = Shell.quote_key_value_file(temp_profile.name)
        with open(filename, 'w') as profile:
            for line in profile_environment:
                profile.write(line + os.linesep)
                log.debug('--> {0}'.format(line))
예제 #16
0
파일: profile.py 프로젝트: patjak/kiwi
    def create(self, filename):
        """
        Create bash quoted profile

        :param str filename: file path name
        """
        sorted_profile = collections.OrderedDict(
            sorted(self.dot_profile.items()))
        temp_profile = NamedTemporaryFile()
        with open(temp_profile.name, 'w') as profile:
            for key, value in list(sorted_profile.items()):
                if value:
                    profile.write(
                        format(key) + '=' + self._format(value) + '\n')
        profile_environment = Shell.quote_key_value_file(temp_profile.name)
        with open(filename, 'w') as profile:
            for line in profile_environment:
                profile.write(line + os.linesep)
                log.debug('--> {0}'.format(line))
예제 #17
0
파일: profile.py 프로젝트: Conan-Kudo/kiwi
    def create(self):
        """
        Create bash quoted profile

        :return: profile dump for bash

        :rtype: str
        """
        Defaults.set_python_default_encoding_to_utf8()

        sorted_profile = collections.OrderedDict(
            sorted(self.dot_profile.items())
        )
        temp_profile = NamedTemporaryFile()
        with open(temp_profile.name, 'w') as profile:
            for key, value in list(sorted_profile.items()):
                if value:
                    profile.write(
                        format(key) + '=' + self._format(value) + '\n'
                    )
        return Shell.quote_key_value_file(temp_profile.name)
예제 #18
0
파일: shell_test.py 프로젝트: ChrisBr/kiwi
 def test_quote_key_value_file(self):
     assert Shell.quote_key_value_file('../data/key_value') == [
         "foo='bar'", "bar='xxx'", "name='bob'", "strange='$a_foo'"
     ]
예제 #19
0
파일: shell_test.py 프로젝트: SUSE/kiwi
 def test_quote(self):
     assert Shell.quote('aa\!') == 'aa\\\\\\!'
예제 #20
0
파일: shell_test.py 프로젝트: ChrisBr/kiwi
 def test_quote(self):
     assert Shell.quote("aa\!") == "aa\\\\\\!"
예제 #21
0
파일: shell_test.py 프로젝트: ChrisBr/kiwi
 def test_run_common_function(self, mock_command):
     Shell.run_common_function("foo", ['"param1"', '"param2"'])
     command_string = " ".join(
         ["source", Defaults.project_file("config/functions.sh") + ";", "foo", '"param1"', '"param2"']
     )
     mock_command.assert_called_once_with(["bash", "-c", command_string])
예제 #22
0
파일: shell_test.py 프로젝트: ChrisBr/kiwi
 def test_quote(self):
     assert Shell.quote('aa\!') == 'aa\\\\\\!'