예제 #1
0
    def test_iso_metadata_path_table_sector_invalid(self, mock_open):
        mock_open.return_value = self.context_manager_mock
        read_results = [bytes(b'EL TORITO SPECIFICATION'), bytes(b'CD001')]

        def side_effect(arg):
            return read_results.pop()

        self.file_mock.read.side_effect = side_effect
        Iso.fix_boot_catalog('isofile')
예제 #2
0
    def test_iso_metadata_path_table_sector_invalid(self, mock_open):
        mock_open.return_value = self.context_manager_mock
        read_results = [bytes(b'EL TORITO SPECIFICATION'), bytes(b'CD001')]

        def side_effect(arg):
            return read_results.pop()

        self.file_mock.read.side_effect = side_effect
        Iso.fix_boot_catalog('isofile')
예제 #3
0
    def test_iso_metadata_catalog_sector_invalid(self, mock_open):
        mock_open.return_value = self.context_manager_mock
        volume_descriptor = \
            bytes(b'CD001') + bytes(b'_') * (0x08c - 0x5) + bytes(b'0x1d5f23a')
        read_results = [bytes(b'EL TORITO SPECIFICATION'), volume_descriptor]

        def side_effect(arg):
            return read_results.pop()

        self.file_mock.read.side_effect = side_effect
        Iso.fix_boot_catalog('isofile')
예제 #4
0
    def test_iso_metadata_path_table_sector_invalid(self):
        read_results = [bytes(b'EL TORITO SPECIFICATION'), bytes(b'CD001')]

        def side_effect(arg):
            return read_results.pop()

        m_open = mock_open()
        with patch('builtins.open', m_open, create=True):
            m_open.return_value.read.side_effect = side_effect
            with raises(KiwiIsoMetaDataError):
                Iso.fix_boot_catalog('isofile')
예제 #5
0
    def test_iso_metadata_catalog_sector_invalid(self, mock_open):
        mock_open.return_value = self.context_manager_mock
        volume_descriptor = \
            bytes(b'CD001') + bytes(b'_') * (0x08c - 0x5) + bytes(b'0x1d5f23a')
        read_results = [bytes(b'EL TORITO SPECIFICATION'), volume_descriptor]

        def side_effect(arg):
            return read_results.pop()

        self.file_mock.read.side_effect = side_effect
        Iso.fix_boot_catalog('isofile')
예제 #6
0
    def test_iso_metadata_catalog_sector_invalid(self):
        volume_descriptor = \
            bytes(b'CD001') + bytes(b'_') * (0x08c - 0x5) + bytes(b'0x1d5f23a')
        read_results = [bytes(b'EL TORITO SPECIFICATION'), volume_descriptor]

        def side_effect(arg):
            return read_results.pop()

        m_open = mock_open()
        with patch('builtins.open', m_open, create=True):
            m_open.return_value.read.side_effect = side_effect
            with raises(KiwiIsoMetaDataError):
                Iso.fix_boot_catalog('isofile')
예제 #7
0
파일: isofs.py 프로젝트: sitedata/kiwi-1
    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)
예제 #8
0
    def test_fix_boot_catalog(self, mock_open):
        mock_open.return_value = self.context_manager_mock
        volume_descriptor = \
            bytes(b'CD001') + bytes(b'_') * (0x08c - 0x5) + bytes(b'0x1d5f23a')
        eltorito_descriptor = \
            bytes(b'EL TORITO SPECIFICATION') + \
            bytes(b'_') * (0x47 - 0x17) + bytes(b'0x1d5f23a')
        boot_catalog = bytes(b'_') * 64 + struct.pack('B', 0x88) + \
            bytes(b'_') * 32
        read_results = [
            boot_catalog,
            eltorito_descriptor,
            volume_descriptor
        ]

        def side_effect(arg):
            return read_results.pop()

        self.file_mock.read.side_effect = side_effect

        Iso.fix_boot_catalog('isofile')

        if sys.byteorder == 'big':
            assert self.file_mock.write.call_args_list == [
                call(
                    bytes(
                        b'_'
                    ) * 44 + bytes(
                        b'\x01Legacy (isolinux)\x00\x00\x91\xef\x00\x01'
                    ) + bytes(
                        b'\x00'
                    ) * 28 + bytes(
                        b'\x88___________\x01UEFI (grub)'
                    ) + bytes(b'\x00') * 8
                )
            ]
        else:
            assert self.file_mock.write.call_args_list == [
                call(
                    bytes(
                        b'_'
                    ) * 44 + bytes(
                        b'\x01Legacy (isolinux)\x00\x00\x91\xef\x01'
                    ) + bytes(
                        b'\x00'
                    ) * 29 + bytes(
                        b'\x88___________\x01UEFI (grub)'
                    ) + bytes(b'\x00') * 8
                )
            ]
예제 #9
0
    def test_fix_boot_catalog(self, mock_open):
        mock_open.return_value = self.context_manager_mock
        volume_descriptor = \
            bytes(b'CD001') + bytes(b'_') * (0x08c - 0x5) + bytes(b'0x1d5f23a')
        eltorito_descriptor = \
            bytes(b'EL TORITO SPECIFICATION') + \
            bytes(b'_') * (0x47 - 0x17) + bytes(b'0x1d5f23a')
        boot_catalog = bytes(b'_') * 64 + struct.pack('B', 0x88) + \
            bytes(b'_') * 32
        read_results = [
            boot_catalog,
            eltorito_descriptor,
            volume_descriptor
        ]

        def side_effect(arg):
            return read_results.pop()

        self.file_mock.read.side_effect = side_effect

        Iso.fix_boot_catalog('isofile')

        if sys.byteorder == 'big':
            assert self.file_mock.write.call_args_list == [
                call(
                    bytes(b'_') * 44 +
                    bytes(b'\x01Legacy (isolinux)\x00\x00\x91\xef\x00\x01') +
                    bytes(b'\x00') * 28 +
                    bytes(b'\x88___________\x01UEFI (grub)') +
                    bytes(b'\x00') * 8
                )
            ]
        else:
            assert self.file_mock.write.call_args_list == [
                call(
                    bytes(b'_') * 44 +
                    bytes(b'\x01Legacy (isolinux)\x00\x00\x91\xef\x01') +
                    bytes(b'\x00') * 29 +
                    bytes(b'\x88___________\x01UEFI (grub)') +
                    bytes(b'\x00') * 8
                )
            ]
예제 #10
0
파일: isofs.py 프로젝트: Conan-Kudo/kiwi
    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
            )
예제 #11
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)
예제 #12
0
 def test_iso_metadata_not_bootable(self, mock_open):
     mock_open.return_value = self.context_manager_mock
     self.file_mock.read.return_value = bytes(b'CD001')
     Iso.fix_boot_catalog('isofile')
예제 #13
0
 def test_iso_metadata_iso9660_invalid(self, mock_open):
     mock_open.return_value = self.context_manager_mock
     self.file_mock.read.return_value = bytes(b'bogus')
     Iso.fix_boot_catalog('isofile')
예제 #14
0
 def test_iso_metadata_not_bootable(self):
     m_open = mock_open(read_data=b'CD001')
     with patch('builtins.open', m_open, create=True):
         with raises(KiwiIsoMetaDataError):
             Iso.fix_boot_catalog('isofile')
예제 #15
0
 def test_iso_metadata_iso9660_invalid(self):
     m_open = mock_open(read_data=b'bogus')
     with patch('builtins.open', m_open, create=True):
         with raises(KiwiIsoMetaDataError):
             Iso.fix_boot_catalog('isofile')
예제 #16
0
 def test_iso_metadata_not_bootable(self, mock_open):
     mock_open.return_value = self.context_manager_mock
     self.file_mock.read.return_value = bytes(b'CD001')
     Iso.fix_boot_catalog('isofile')
예제 #17
0
 def test_iso_metadata_iso9660_invalid(self, mock_open):
     mock_open.return_value = self.context_manager_mock
     self.file_mock.read.return_value = bytes(b'bogus')
     Iso.fix_boot_catalog('isofile')