Mini Shell

Direktori : /lib64/python3.6/site-packages/pyanaconda/payload/__pycache__/
Upload File :
Current File : //lib64/python3.6/site-packages/pyanaconda/payload/__pycache__/rpmostreepayload.cpython-36.pyc

3

C��e~^�@s>ddlZddlZddlmZddljZddlmZddlm	Z	ddl
mZddlm
Z
mZddlmZmZddlmZdd	lmZdd
lmZddlmZddlmZmZdd
lmZddl m!Z!ddl"m#Z#m$Z$m%Z%m&Z&ddl'm(Z(ddl)Z)e)j*dd�ddl+m,Z,ddl-m.Z.e.e/�Z0Gdd�de�Z1Gdd�de1�Z2dS)�N)�CalledProcessError)�util)�PAYLOAD_TYPE_RPM_OSTREE)�_)�get_locale_map_from_ostree�strip_codeset_and_modifier)�
BOOTLOADER�DEVICE_TREE)�STORAGE)�	progressQ)�Payload)�utils)�PayloadInstallError�FlatpakInstallError)�FlatpakPayload)�conf)�format_size_full�create_new_context�Variant�GError)�Size�Gioz2.0)r)�get_module_loggercs�eZdZdZ�fdd�Zedd��Zedd��Zedd	��Zed
d��Z	edd
��Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zd+d!d"�Zd#d$�Z�fd%d&�Zd'd(�Z�fd)d*�Z�ZS),�RPMOSTreePayloadz_ A RPMOSTreePayload deploys a tree (possibly with layered packages)
    onto the target system.cs$t�j||�d|_g|_d|_dS)N)�super�__init__�_remoteOptions�_internal_mounts�_locale_map)�self�args�kwargs)�	__class__��(/usr/lib64/python3.6/rpmostreepayload.pyr5szRPMOSTreePayload.__init__cCstS)zThe DBus type of the payload.)r)rr#r#r$�type;szRPMOSTreePayload.typecCsdS)NTr#)rr#r#r$� handles_bootloader_configuration@sz1RPMOSTreePayload.handles_bootloader_configurationcCsgS)Nr#)rr#r#r$�kernel_version_listDsz$RPMOSTreePayload.kernel_version_listcCstd�S)Nz500 MB)r)rr#r#r$�space_requiredIszRPMOSTreePayload.space_requiredcCs|jjjo|jjjjd�S)z.Test ostree repository if it requires network.zfile://)�data�ostreesetup�url�
startswith)rr#r#r$�
needs_networkNszRPMOSTreePayload.needs_networkcCs(|jdkr"t|jjj|jjj�|_|jS)z0Return a map of supported languages and locales.N)rrr)r*r+�ref)rr#r#r$�_get_locale_mapSs

z RPMOSTreePayload._get_locale_mapcCstjjsdS||j�kS)z/Is the given language supported by the payload?T)r�payload�check_supported_localesr/)r�languager#r#r$�is_language_supported]sz&RPMOSTreePayload.is_language_supportedcCs,tjjsdS|j�}t|�}||j|g�kS)z-Is the given locale supported by the payload?T)rr0r1r/r�get)rr2ZlocaleZ
locale_mapr#r#r$�is_locale_supportedds
z$RPMOSTreePayload.is_locale_supportedcKsDtj||f|�}|dkr@td|||f�}tjj|�tjkr@|�dS)z5Like util.execWithRedirect, but treat errors as fatalrz%s %s exited with code %dN)r�execWithRedirectr�errors�errorHandler�cb�ERROR_RAISE)r�cmd�argvr!�rc�exnr#r#r$�_safe_exec_with_redirectms
z)RPMOSTreePayload._safe_exec_with_redirectc	Cs�|j�}|jd�}|r"tj|�nz|dkr�|jd�}|jd�}|jd�}t|d�}|dkr`d}n|d|d}tjtd	�||||d
��ntjtd��dS)Nzoutstanding-fetchesrzbytes-transferred�fetched�	requestedgg�?�dzFReceiving objects: %(percent)d%% (%(fetched)d/%(requested)d) %(bytes)s)�percentr@rA�byteszWriting objects)�
get_statusZget_uintr�send_messageZ
get_uint64rr)	rZ
asyncProgressZstatusZoutstanding_fetchesZbytes_transferredr@rAZformatted_bytesrCr#r#r$�_pull_progress_cbus 





z"RPMOSTreePayload._pull_progress_cbcCstjt�}|j�}tjjd}tjjd}tj	j
|�sBtjjd}x�tj|�D]�}tj	j||�}tj	j||�}tj	j
|�s|qN|dkr�|r�xdtj|�D]4}tj	j||�}	tj	j||�}
|j
ddd|	|
g�q�Wn tjd|�|j
ddd||g�|d}|rNtj	j|�rNtj|�qNWdS)	Nz/bootz/usr/lib/ostree-bootZefiZcpz-rz-pzCopying bootloader data: %sz/grub2/grubenv)r
�	get_proxyrZIsEFIr�target�
physical_root�system_root�os�path�isdir�listdir�joinr?�log�info�islink�unlink)r�
bootloaderZis_efiZphysbootZostree_boot_sourceZfnameZsrcpathZdestpathZsubnameZsub_srcpathZsub_destpathZefi_grubenv_linkr#r#r$�_copy_bootloader_data�s.

z&RPMOSTreePayload._copy_bootloader_datacCs|j�|j�dS)N)�_install�_prepare_mount_targets)rr#r#r$�install�szRPMOSTreePayload.installcCs�t�}|j�d}tjdd�tjdd�ddlm}m}|jj}t	j
d|�|jddd	tj
jd
tj
jg�tjjtj
j�}|jj|�}|j|�|jd�d}|jd�i|_t|d
�r�|jr�tdd�|jd<tjjs�tdd�|jd<|jd|jj|j |j!td|j�|�|j"|j#�}	t$j%t&d�|	|j d��|j'j�}
|
j(d|j)�dtd|	g�i}|j*dd��r�x2d,D]*}t+j,j-|d��rptd|g�|d<P�qpWy|j.|j td|�|
|�Wnvt/k
�r0}
zXt0d|
�}t	j1t2|��t3j4j5|�t3j6k�r t$j7d�t8j9|jj:d�t;j<d�WYdd}
~
XnXt	j
d |
j=��pDd!�t$j%t&d"�|	f�|j>|jjj d�|jddd	tj
jd#|j?g�dd	tj
jd$d%|j?g}|j@|j d&|	�t	j
d'�t$j%t&d(�|	f�|jd|�t	j
d)�t$j%t&d*�|	f�|jd�|jA�}tB|�dk�s&tC�|d}|jD|�}t8jE|jF��y|jG�WnztHtIfk
�r�}
zXt0d+|
�}t	j1t2|��t3j4j5|�t3j6k�r�t$j7d�t8j9|jj:d�t;j<d�WYdd}
~
XnX|jJ�dS)-N�OSTreez1.0�	RpmOstreer)rZr[zexecuting ostreesetup=%r�ostree�adminz
--sysroot=zinit-fs�T�nogpg�bFz
gpg-verifyztls-permissiveza{sv}z/Starting pull of %(branchName)s from %(source)s)Z
branchName�sourceZchangedZrefs�asi���/ostree/repo�/install/ostree/repoz/objectszlocalcache-reposz"Failed to pull from repository: %s)�scriptszostree pull: %s�zPreparing deployment of %szos-initZdeployz--os=�:zostree admin deploy startingzDeployment starting: %szostree admin deploy completezDeployment complete: %sz"Failed to copy bootloader data: %s)rdre)KrZpush_thread_default�gi�require_version�
gi.repositoryrZr[r)r*rQrRr?rrIrJr�File�new_for_path�Sysroot�new�load�get_repoZset_disable_fsyncr�hasattrr_rr0Z
verify_ssl�
remote_change�RepoRemoteChange�ADD_IF_NOT_EXISTS�remoter+Zvarsubst_basearchr.rrFrZ
AsyncProgressZconnectrGZ
check_versionrLrMrNZpull_with_optionsrr�error�strr7r8r9r:�	send_quitr�
ipmi_abortrf�sys�exitrEZ
remote_delete�osname�appendZget_deployments�len�AssertionErrorZget_deployment_directoryZset_system_root�get_pathrV�OSError�RuntimeErrorZpop_thread_default)rZmainctx�cancellablerZr[r*�sysroot_file�sysroot�repor.ZprogressZ	pull_optsrM�er>Zadmin_deploy_argsZdeploymentsZ
deploymentZdeployment_pathr#r#r$rW�s�











zRPMOSTreePayload._installNTFcCs�|dkr|}|rtjj|}ntjj|}tjj|}|rd|jdd||g�|jdddd||g�n |rnd}nd}|jd|||g�|jj|r�|n|�dS)a%Internal API for setting up bind mounts between the physical root and
           sysroot, also ensures we track them in self._internal_mounts so we can
           cleanly unmount them.

           :param src: Source path, will be prefixed with physical or sysroot
           :param dest: Destination, will be prefixed with sysroot (defaults to same as src)
           :param src_physical: Prefix src with physical root
           :param bind_ro: Make mount read-only
           :param recurse: Use --rbind to recurse, otherwise plain --bind
        N�mountz--bindz-oz
remount,roz--rbind)rrIrJrKr?rr~)r�src�dest�src_physical�bind_ro�recurseZbindoptr#r#r$�_setup_internal_bindmount9s"z*RPMOSTreePayload._setup_internal_bindmountc
CsH|jj}tj�}|jdddd�ddddg}x|D]}|j|�q2Wd	|jd
}|jd
�dkrr|j|d
dd�n|jd
dd
�tjt	j
jd�d}x^d$D]V}dddt	j
jd|g}tj||�}	|	d%kr�t
d j||��}
tjj|
�tjkr�|
�q�Wx<t|td!�D],}|d&k�s||k�r �q|j|dd
��qW|jd"d#dd�dS)'z Prepare the ostree root z/usrTF)r�r�z/devz/procz/runz/sysz/ostree/deploy/�/varN)r�r�)r�z/var/libzsystemd-tmpfiles�home�roothome�lib/rpm�opt�srv�usrlocal�mnt�media�spool�
spool/mailz--createz--bootz--root=z--prefix=/var/r�Az{} failed for /var/{})�key�/z/sysroot)
r�r�r�r�r�r�r�r�r�r�)rr�)r�r�)r)r*�
payload_utilsZget_mount_pointsr�r}r4rZ
mkdirChainrrIrKr6r�formatr7r8r9r:�sortedr)rr*Zmount_pointsZ
api_mountsrMZvar_rootr;Z	varsubdirr<r=r>r�r#r#r$rXas6
	
	z'RPMOSTreePayload._prepare_mount_targetscsft�j�xVt|j�D]H}ytj|�Wqtk
r\}ztjd|t	|��WYdd}~XqXqWdS)Nzunmounting %s failed: %s)
r�unsetup�reversedrr�ZunmountrrQ�debugrx)rr�r�)r"r#r$r��s
zRPMOSTreePayload.unsetupcCsdS)Nr#)rr#r#r$�recreate_initrds�sz!RPMOSTreePayload.recreate_initrdscsFt�j�tjdd�ddlm}d}tjjt	j
j�}|jj
|�}|j|�|jd�d}|j||jj|jjj|jjjtd|j�|�t	j
jd}|d}tjj|�r�|d	}|d
}	tjd||	�tj||	�tjd|�t	j
j �sBt!j"t#�}
t!j"t$�}|j%�}d
ddg}
|
j&|
j'��|
j(d|j)|��|j*d|
t	j
jd�dS)NrZz1.0r)rZr^za{sv}z/bootz/grub2/grub.cfgz/loaderz	/grub.cfgzMoving %s -> %sz../loader/grub.cfgr]Zinstutilz	set-kargszroot=r\)�root)+r�post_installrirjrkrZrrlrmrrIrKrnrorprqrsrtrur)r*rvr+rrrLrM�isfilerQrR�rename�symlinkZis_directoryr
rHrr	Z
GetRootDevice�extendZGetArgumentsr~ZGetFstabSpecr?)rrZr�r�r�r�ZbootZboot_grub2_cfgZboot_loaderZtarget_grub_cfgrUZdevice_treeZroot_deviceZset_kargs_args)r"r#r$r��s:






zRPMOSTreePayload.post_install)NTFT)�__name__�
__module__�__qualname__�__doc__r�propertyr%r&r'r(r-r/r3r5r?rGrVrYrWr�rXr�r�r��
__classcell__r#r#)r"r$r2s.
	.
t
%M	rcs@eZdZ�fdd�Ze�fdd��Z�fdd�Zdd�Z�ZS)	�RPMOSTreePayloadWithFlatpakscs,t�j||�ttjj�|_|jjd�dS)z�Variant of rpmostree payload with flatpak support.

        This variant will be used if flatpaks are available for system.
        z/var/tmp/anaconda-flatpak-tempN)rrrrrIrK�_flatpak_payloadZinitialize_with_path)rr r!)r"r#r$r�sz%RPMOSTreePayloadWithFlatpaks.__init__cst�jt|jj��S)N)rr(rr�Zget_required_size)r)r"r#r$r(sz+RPMOSTreePayloadWithFlatpaks.space_requiredcst�j�|j�dS)N)rrY�_flatpak_install)r)r"r#r$rYs
z$RPMOSTreePayloadWithFlatpaks.installcCs�tjtd��|jj�|jj�y|jj�Wnrtk
r�}zVtd|�}t	j
t|��tj
j|�tjkr�tjd�tj|jjd�tjd�WYdd}~XnXtjtd��|jjdd�|jjd�|jjtj�tjtd��dS)	NzStarting Flatpak installationzFailed to install flatpaks: %sr^)rfzPost-installation flatpak tasksZfedoraz&oci+https://registry.fedoraproject.orgz!Flatpak installation has finished)rrFrr�ZcleanupZinitialize_with_system_pathZinstall_allrrrQrwrxr7r8r9r:ryrrzr)rfr{r|Z
add_remoteZreplace_installed_refs_remoteZ
remove_remoterZLOCAL_REMOTE_NAME)rr�r>r#r#r$r�s"


z-RPMOSTreePayloadWithFlatpaks._flatpak_install)	r�r�r�rr�r(rYr�r�r#r#)r"r$r��sr�)3rLr{�
subprocessrZpyanaconda.errorsr7Zpyanaconda.corerZpyanaconda.core.constantsrZpyanaconda.core.i18nrZpyanaconda.localizationrrZ+pyanaconda.modules.common.constants.objectsrr	Z,pyanaconda.modules.common.constants.servicesr
Zpyanaconda.progressrZpyanaconda.payload.baserZpyanaconda.payloadr
r�Zpyanaconda.payload.errorsrrZpyanaconda.payload.flatpakrZ&pyanaconda.core.configuration.anacondarZpyanaconda.core.glibrrrrZblivet.sizerrirjrkrZpyanaconda.anaconda_loggersrr�rQrr�r#r#r#r$�<module>s6
D