Mini Shell
3
C��e� � @ s d dl Z d dlZ d dlZd dlZd dlZd dlZd dlmZ d dl m
Z
d dlmZm
Z
mZmZ d dlmZ d dlmZ d dlmZ d dlmZmZ d d lmZ d d
lmZ d dlmZ d dl m!Z! e!e"�Z#ej$j%� Z&ddd�Z'dd� Z(dd� Z)dd� Z*dd� Z+dd� Z,dd� Z-dd� Z.dS )� N)�Size)�isys)�errorHandler�ERROR_RAISE�InvalidImageSizeError�MissingImageError)�DEVICE_TREE)�STORAGE)�MountFilesystemError)�
DeviceData�DeviceFormatData)�utils)�InstallTreeMetadata)�DiscInfo)�get_module_logger�/mnt/install/cdimagec # C s yt j| � W n tk
r" dS X t}t jj|d�}t jj| �rh| jd�rht jj| �g}t jj | �} n
t j
| �}�x�|D �]�}t jj| |�}tjd|� t
j|�s�qztjd||� ytjj||ddd� W n tk
r� wzY nX t j|t j��stjj|� qztjd � t� }y|j|� |j}W n2 tk
�rX } ztjd
| � wzW Y dd} ~ X nX tjd|� ||k�r�tjd||� tjj|� qzt|��s�tjd
|� tjj|� qzt j|�tj d �r�tjd|� td|�}
tj|
�tk�r�|
�tj d|� tjj|� |S W dS )a� Find the first iso image in path.
:param str path: path to the directory with iso image(s); this also supports pointing to
a specific .iso image
:param str mount_path: path for mounting the ISO when checking it is valid
FIXME once payloads are modularized:
- this should move somewhere else
- mount_path should lose the legacy default
:return: basename of the image - file name without path
:rtype: str or None
Nz .discinfoz.isozChecking %szMounting %s on %s�iso9660�ro)�fstype�optionszReading .discinfoz".discinfo file can't be loaded: %sz
discArch = %sz8Architectures mismatch in find_first_iso_image: %s != %sz*%s doesn't have a valid repodata, skippingi z%s appears to be corruptedz$size is not a multiple of 2048 byteszFound disc at %s)!�os�stat�OSError�_arch�path�join�isfile�endswith�basename�dirname�listdir�log�debugr Z
isIsoImage�blivet�util�mount�access�R_OKZumountr �load�arch� Exception�warning�_check_repodata�ST_SIZEr r �cbr �info)r �
mount_pathr) Z
discinfo_path�files�fnZwhatZ disc_infoZ disc_archZex�exn� r4 �/usr/lib64/python3.6/image.py�find_first_iso_image/ sd
r6 c C sb t � }|j| �stjd� |j� }|s6|j� }t|�}|sHtjd� dS |j� rTdS tjd� dS )Nz!Can't read install tree metadata!z'There is no usable repository availableFTz'There is no valid repository available.) r Z load_filer! r+ Zget_base_repo_metadataZget_metadata_repos�#_search_for_install_root_repositoryr"