HEX
Server: LiteSpeed
System: Linux php-prod-1.spaceapp.ru 5.15.0-157-generic #167-Ubuntu SMP Wed Sep 17 21:35:53 UTC 2025 x86_64
User: xnsbb3110 (1041)
PHP: 8.1.33
Disabled: NONE
Upload Files
File: //lib/python3/dist-packages/cloudinit/config/__pycache__/cc_grub_dpkg.cpython-310.pyc
o

m[h��
@s�UdZddlZddlZddlmZmZddlmZddlm	Z	ddl
mZddlm
Z
ddlmZd	d
dge
gd�Zeed
<e�e�Zdd�Zdefdd�Zdede	dededdf
dd�Zde	defdd�ZdS)z5Grub Dpkg: Configure grub debconf installation device�N)�subp�util)�Cloud)�Config)�
MetaSchema)�PER_INSTANCE)�ProcessExecutionError�cc_grub_dpkg�ubuntu�debian)�id�distros�	frequency�activate_by_schema_keys�metac
Csbd}g}d}d}t�rd}d}ztjdd||gdd	�j��}Wn8tyI}zt|jt�r3t�	d
�nd|j
vr>t�	d�n�WYd
}~nd
}~wtyWt�
td�Ynw|r`tj�|�sbdSztjdddd|gdd	�j����}Wnty�t�
td|�Ynwt�	dd�|��dd�|D�}t�	dd�|��|r�t|�dn|}t�	d|�|S)z�
    Fetches the /dev/disk/by-id device grub is installed to.
    Falls back to plain disk name if no by-id entry is present.
    ��diskz/boot�devicez	/boot/efiz
grub-probez-tT)�capturez'grub-probe' not found in $PATHzfailed to get canonical pathz)grub-probe 'failed to get canonical path'Nz*grub-probe failed to execute for grub_dpkg�udevadm�infoz--rootz--query=symlinkz3udevadm DEVLINKS symlink query failed for disk='%s'z%considering these device symlinks: %s�,cSsg|]}d|vr|�qS)z
disk/by-id�)�.0�devrr�?/usr/lib/python3/dist-packages/cloudinit/config/cc_grub_dpkg.py�
<listcomp>Zszfetch_idevs.<locals>.<listcomp>z)filtered to these disk/by-id symlinks: %srzselected %s)�
is_efi_bootedr�stdout�stripr�
isinstance�reason�FileNotFoundError�LOG�debug�stderr�	Exceptionr�logexc�os�path�exists�split�join�sorted)r�devices�probe_target�probe_mount�e�idevsrrr�fetch_idevssX��
������r3�returnc
CsBztj�d�WSty }z
t�d|�WYd}~dSd}~ww)z4
    Check if the system is booted in EFI mode.
    z/sys/firmware/efiz7Failed to determine if system is booted in EFI mode: %sNF)r(r)r*�OSErrorr#�error)r1rrrrcs��r�name�cfg�cloud�argsc
Cs�|�d|�di��}|si}|�dd�}t�|�r"t�d||�dSt|�}t�d|�ztjdg|d�WdStyQ}zt�td	|�WYd}~dSd}~ww)
N�	grub_dpkgz	grub-dpkg�enabledTz*%s disabled by config grub_dpkg/enabled=%sz-Setting grub debconf-set-selections with '%s'zdebconf-set-selections)�dataz6Failed to run debconf-set-selections for grub_dpkg: %s)	�getr�is_falser#r$�get_debconf_configrr&r')r7r8r9r:�mycfgr<�	dconf_selr1rrr�handleos"
���rCrAcCs�t�rt�|dd�}|durt�}d|St�|dd�}|dur#t�}|�d�}|dur0|}n
t|t�s:t�|�}t|��	�}d||fS)zd
    Returns the debconf config for grub-pc or
    grub-efi depending on the systems boot mode.
    zgrub-efi/install_devicesNz+grub-pc grub-efi/install_devices string %s
zgrub-pc/install_deviceszgrub-pc/install_devices_emptyz[grub-pc grub-pc/install_devices string %s
grub-pc grub-pc/install_devices_empty boolean %s
)
rr�get_cfg_option_strr3r>r �bool�translate_bool�str�lower)rAr2�idevs_emptyrrrr@�s(�


��r@)�__doc__�loggingr(�	cloudinitrr�cloudinit.cloudr�cloudinit.configr�cloudinit.config.schemar�cloudinit.settingsr�cloudinit.subprr�__annotations__�	getLogger�__name__r#r3rErrG�listrCr@rrrr�<module>s&�
D