Example #1
0
 def test_create_hybrid_with_multiple_errors(self, mock_command):
     command = mock.Mock()
     command.error = \
         'isohybrid: Warning: more than 1024 cylinders: 1817\n' + \
         'isohybrid: Not all BIOSes will be able to boot this device\n' + \
         'isohybrid: some other error we do not ignore'
     mock_command.return_value = command
     Iso.create_hybrid(42, '0x0815', 'some-iso', 'efi')
Example #2
0
 def test_create_hybrid_with_multiple_errors(self, mock_command):
     command = mock.Mock()
     command.error = \
         'isohybrid: Warning: more than 1024 cylinders: 1817\n' + \
         'isohybrid: Not all BIOSes will be able to boot this device\n' + \
         'isohybrid: some other error we do not ignore'
     mock_command.return_value = command
     Iso.create_hybrid(42, '0x0815', 'some-iso', 'efi')
Example #3
0
 def test_create_hybrid(self, mock_command):
     command = mock.Mock()
     command.error = None
     mock_command.return_value = command
     Iso.create_hybrid(42, '0x0815', 'some-iso', 'efi')
     mock_command.assert_called_once_with([
         'isohybrid', '--offset', '42', '--id', '0x0815', '--type', '0x83',
         '--uefi', 'some-iso'
     ])
Example #4
0
 def test_create_hybrid_with_cylinders_warning(self, mock_command):
     command = mock.Mock()
     command.error = \
         'isohybrid: Warning: more than 1024 cylinders: 1817\n' + \
         'isohybrid: Not all BIOSes will be able to boot this device\n'
     mock_command.return_value = command
     Iso.create_hybrid(42, '0x0815', 'some-iso', 'efi')
     mock_command.assert_called_once_with([
         'isohybrid', '--offset', '42', '--id', '0x0815', '--type', '0x83',
         '--uefi', 'some-iso'
     ])
Example #5
0
 def test_create_hybrid(self, mock_command):
     command = mock.Mock()
     command.error = None
     mock_command.return_value = command
     Iso.create_hybrid(42, '0x0815', 'some-iso', 'efi')
     mock_command.assert_called_once_with(
         [
             'isohybrid', '--offset', '42',
             '--id', '0x0815', '--type', '0x83',
             '--uefi', 'some-iso'
         ]
     )
Example #6
0
    def create_on_file(self, filename, label=None, exclude=None):
        """
        Create iso filesystem from data tree

        There is no label which could be set for iso filesystem
        thus this parameter is not used

        :param string filename: result file path name
        :param string label: unused
        :param string exclude: unused
        """
        meta_data = self.custom_args['meta_data']
        efi_mode = meta_data.get('efi_mode')
        ofw_mode = meta_data.get('ofw_mode')
        iso_tool = IsoTools(self.root_dir)

        iso = Iso(self.root_dir)
        if not efi_mode and not ofw_mode:
            iso.setup_isolinux_boot_path()

        if not iso_tool.has_iso_hybrid_capability():
            iso.create_header_end_marker()

        iso_tool.init_iso_creation_parameters(meta_data)

        iso_tool.add_efi_loader_parameters()

        iso_tool.create_iso(filename)

        if not iso_tool.has_iso_hybrid_capability():
            if not efi_mode and not ofw_mode:
                hybrid_offset = iso.create_header_end_block(filename)
                iso_tool.create_iso(
                    filename, hidden_files=[iso.header_end_name]
                )
                iso.relocate_boot_catalog(filename)
                iso.fix_boot_catalog(filename)
                mbr_id = meta_data['mbr_id'] if 'mbr_id' in meta_data else \
                    '0xffffffff'
                iso.create_hybrid(
                    hybrid_offset, mbr_id, filename
                )
            else:
                message = dedent('''
                    Can't create hybrid ISO in EFI mode with cdrtools

                    isohybrid requires isolinux as loader. In EFI mode
                    the configured bootloader e.g grub is used and no
                    isolinux signature exists.
                ''').strip() + os.linesep
                log.warning(message)
Example #7
0
 def test_create_hybrid_with_cylinders_warning(self, mock_command):
     command = mock.Mock()
     command.error = \
         'isohybrid: Warning: more than 1024 cylinders: 1817\n' + \
         'isohybrid: Not all BIOSes will be able to boot this device\n'
     mock_command.return_value = command
     Iso.create_hybrid(42, '0x0815', 'some-iso', 'efi')
     mock_command.assert_called_once_with(
         [
             'isohybrid', '--offset', '42',
             '--id', '0x0815', '--type', '0x83',
             '--uefi', 'some-iso'
         ]
     )
Example #8
0
    def create_on_file(self, filename, label=None, exclude=None):
        """
        Create iso filesystem from data tree

        There is no label which could be set for iso filesystem
        thus this parameter is not used

        :param string filename: result file path name
        :param string label: unused
        :param string exclude: unused
        """
        meta_data = self.custom_args['meta_data']
        iso_tool = IsoTools(self.root_dir)

        iso = Iso(self.root_dir)
        iso.setup_isolinux_boot_path()

        if not iso_tool.has_iso_hybrid_capability():
            iso.create_header_end_marker()

        iso_tool.init_iso_creation_parameters(meta_data)

        iso_tool.add_efi_loader_parameters()

        iso_tool.create_iso(filename)

        if not iso_tool.has_iso_hybrid_capability():
            hybrid_offset = iso.create_header_end_block(filename)
            iso_tool.create_iso(
                filename, hidden_files=[iso.header_end_name]
            )
            iso.relocate_boot_catalog(filename)
            iso.fix_boot_catalog(filename)
            efi_mode = meta_data['efi_mode'] if 'efi_mode' in meta_data else \
                False
            mbr_id = meta_data['mbr_id'] if 'mbr_id' in meta_data else \
                '0xffffffff'
            iso.create_hybrid(
                hybrid_offset, mbr_id, filename, efi_mode
            )
Example #9
0
    def create_on_file(self, filename, label=None, exclude=None):
        """
        Create iso filesystem from data tree

        There is no label which could be set for iso filesystem
        thus this parameter is not used

        :param string filename: result file path name
        :param string label: unused
        :param string exclude: unused
        """
        arch = platform.machine()
        meta_data = self.custom_args['meta_data']
        iso_tool = IsoTools(self.root_dir)

        iso = Iso(self.root_dir)
        if re.match(r'x86_64|i[56]86', arch):
            iso.setup_isolinux_boot_path()

        if not iso_tool.has_iso_hybrid_capability():
            iso.create_header_end_marker()

        iso_tool.init_iso_creation_parameters(meta_data)

        iso_tool.add_efi_loader_parameters()

        iso_tool.create_iso(filename)

        if not iso_tool.has_iso_hybrid_capability():
            hybrid_offset = iso.create_header_end_block(filename)
            iso_tool.create_iso(filename, hidden_files=[iso.header_end_name])
            iso.relocate_boot_catalog(filename)
            iso.fix_boot_catalog(filename)
            efi_mode = meta_data['efi_mode'] if 'efi_mode' in meta_data else \
                False
            mbr_id = meta_data['mbr_id'] if 'mbr_id' in meta_data else \
                '0xffffffff'
            iso.create_hybrid(hybrid_offset, mbr_id, filename, efi_mode)
Example #10
0
 def test_create_hybrid_with_error(self, mock_command):
     command = mock.Mock()
     command.error = 'some error message'
     mock_command.return_value = command
     with raises(KiwiCommandError):
         Iso.create_hybrid(42, '0x0815', 'some-iso', 'efi')
Example #11
0
 def test_create_hybrid_with_error(self, mock_command):
     command = mock.Mock()
     command.error = 'some error message'
     mock_command.return_value = command
     Iso.create_hybrid(42, '0x0815', 'some-iso', 'efi')