HEX
Server: Apache
System: Linux scp1.abinfocom.com 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User: confeduphaar (1010)
PHP: 8.1.33
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //usr/lib/python3/dist-packages/cloudinit/config/__pycache__/cc_grub_dpkg.cpython-38.pyc
U

��0h��@s�UdZddlZddlZddlmZmZddlmZddlm	Z	ddl
mZddlm
Z
ddlmZd	d
dge
gd�Zeed
<e�e�Zdd�Zed�dd�Zee	eedd�dd�Ze	ed�dd�ZdS)z5Grub Dpkg: Configure grub debconf installation device�N)�subp�util)�Cloud)�Config)�
MetaSchema)�PER_INSTANCE)�ProcessExecutionErrorZcc_grub_dpkgZubuntuZdebian)�idZdistrosZ	frequencyZactivate_by_schema_keys�metac
Cshd}g}d}d}t�rd}d}z tjdd||gdd	�j��}Wnptk
r�}z4t|jt�rht�	d
�nd|j
kr~t�	d�n�W5d
}~XYn tk
r�t�
td�YnX|r�tj�|�s�dSz&tjdddd|gdd	�j����}Wn$tk
�rt�
td|�YnXt�	dd�|��dd�|D�}t�	dd�|��|�rTt|�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/bootZdevicez	/boot/efiz
grub-probez-tT)Zcapturez'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_dpkgZudevadm�infoz--rootz--query=symlinkz3udevadm DEVLINKS symlink query failed for disk='%s'z%considering these device symlinks: %s�,cSsg|]}d|kr|�qS)z
disk/by-id�)�.0Zdevrr�?/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ZdevicesZprobe_targetZprobe_mount�e�idevsrrr�fetch_idevssP
�
���
r&)�returnc
CsHztj�d�WStk
rB}zt�d|�WY�dSd}~XYnXdS)z4
    Check if the system is booted in EFI mode.
    z/sys/firmware/efiz7Failed to determine if system is booted in EFI mode: %sFN)rrr �OSErrorr�error)r$rrrrcs
r)�name�cfg�cloud�argsr'c
Cs�|�d|�di��}|si}|�dd�}t�|�rDt�d||�dSt|�}t�d|�ztjdg|d�Wn0tk
r�}zt�td	|�W5d}~XYnXdS)
NZ	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)	�getrZis_falserr�get_debconf_configrrr)r*r+r,r-�mycfgr.Z	dconf_selr$rrr�handleos"
�r3)r2r'cCs�t�r*t�|dd�}|dkr"t�}d|St�|dd�}|dkrFt�}|�d�}|dkr`|}nt|t�stt�|�}t|��	�}d||fSdS)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
)
rrZget_cfg_option_strr&r0r�boolZtranslate_bool�str�lower)r2r%Zidevs_emptyrrrr1�s,�


��r1)�__doc__ZloggingrZ	cloudinitrrZcloudinit.cloudrZcloudinit.configrZcloudinit.config.schemarZcloudinit.settingsrZcloudinit.subprr
�__annotations__Z	getLogger�__name__rr&r4rr5�listr3r1rrrr�<module>	s$�
D