def _scan_primary_vol(self, data): """ Scan one sector for a Primary Volume Descriptor and extract the Volume ID from the table """ primary_vol_data = data[0:-1] info = self._unpack(IsoImage.VOL_DESC, primary_vol_data) (vd_type, vd_ident, vd_ver, pad0, sys_id, vol_id) = info if vd_type != 1: raise IsoFormatError("KCHISO0006E", {'filename': self.path}) if vd_ident != 'CD001' or vd_ver != 1: raise IsoFormatError("KCHISO0007E", {'filename': self.path}) self.volume_id = vol_id
def _scan_el_torito(self, data): """ Search the Volume Descriptor Table for an El Torito boot record. If found, the boot record will provide a link to a boot catalogue. The first entry in the boot catalogue is a validation entry. The next entry contains the default boot entry. The default boot entry will indicate whether the image is considered bootable. """ vd_type = -1 for i in xrange(1, 4): fmt = IsoImage.EL_TORITO_BOOT_RECORD ptr = i * IsoImage.SECTOR_SIZE tmp_data = data[ptr:ptr + fmt.size] if len(tmp_data) < fmt.size: return (vd_type, vd_ident, vd_ver, et_ident, pad0, boot_cat) = self._unpack(fmt, tmp_data) if vd_type == 255: # Volume record terminator return if vd_type == 0: # Found El-Torito Boot Record break if not et_ident.startswith('EL TORITO SPECIFICATION'): raise IsoFormatError("KCHISO0003E", {'filename': self.path}) offset = IsoImage.SECTOR_SIZE * boot_cat size = IsoImage.EL_TORITO_VALIDATION_ENTRY.size + \ IsoImage.EL_TORITO_BOOT_ENTRY.size data = self._get_iso_data(offset, size) fmt = IsoImage.EL_TORITO_VALIDATION_ENTRY tmp_data = data[0:fmt.size] ptr = fmt.size (hdr_id, platform_id, pad0, ident, csum, key55, keyAA) = self._unpack(fmt, tmp_data) if key55 != 0x55 or keyAA != 0xaa: raise IsoFormatError("KCHISO0004E", {'filename': self.path}) fmt = IsoImage.EL_TORITO_BOOT_ENTRY tmp_data = data[ptr:ptr + fmt.size] (boot, media_type, load_seg, sys_type, pad0, sectors, load_rba) = self._unpack(fmt, tmp_data) if boot == 0x88: self.bootable = True elif boot == 0: self.bootable = False else: raise IsoFormatError("KCHISO0005E", {'filename': self.path})
def _is_iso_remote(self): if os.path.isfile(self.path): return False if check_url_path(self.path): return True raise IsoFormatError("KCHISO0001E", {'filename': self.path})
def _scan_primary_vol(self, data): """ Scan one sector for a Primary Volume Descriptor and extract the Volume ID from the table """ primary_vol_data = data[0:-1] info = self._unpack(IsoImage.VOL_DESC, primary_vol_data) (vd_type, vd_ident, vd_ver, pad0, sys_id, vol_id) = info if vd_type != 1: raise IsoFormatError("KCHISO0006E", {'filename': self.path}) if vd_ident != 'CD001' or vd_ver != 1: raise IsoFormatError("KCHISO0007E", {'filename': self.path}) if vol_id.strip() == 'RED_HAT': # Some RHEL ISO images store the infomation of volume id in the # location of volume set id mistakenly. self.volume_id = self._get_volume_set_id(data) else: self.volume_id = vol_id
def _is_iso_remote(self): if os.path.exists(self.path): st_mode = os.stat(self.path).st_mode if stat.S_ISREG(st_mode) or stat.S_ISBLK(st_mode): return False if check_url_path(self.path): return True raise IsoFormatError("KCHISO0001E", {'filename': self.path})
def probe(self): if not self.bootable: raise IsoFormatError("KCHISO0002E", {'filename': self.path}) matcher = Matcher(self.volume_id) for d, v, regex in iso_dir: if matcher.search(regex): distro = d if hasattr(v, '__call__'): version = v(matcher) else: version = v return (distro, version) msg = "probe_iso: Unable to identify ISO %s with Volume ID: %s" kimchi_log.debug(msg, self.path, self.volume_id) return ('unknown', 'unknown')