3
\me @ s U d Z ddlZddlZddlmZ ddlmZmZ ddlm Z ddl
mZ ddlm
Z
mZ ddlmZ dd lmZ d
ZddgZd
ddeeeedgg dZe
eeZ ejeZdd ZedddZeee eddddZeedddZdS )z5Grub Dpkg: Configure grub debconf installation device N)dedent)subputil)Cloud)Config)
MetaSchemaget_meta_doc)PER_INSTANCE)ProcessExecutionErrora Configure which device is used as the target for grub installation. This module
can be enabled/disabled using the ``enabled`` config key in the ``grub_dpkg``
config dict. This module automatically selects a disk using ``grub-probe`` if
no installation device is specified.
The value which is placed into the debconf database is in the format which the
grub postinstall script expects. Normally, this is a /dev/disk/by-id/ value,
but we do fallback to the plain disk name if a by-id name is not present.
If this module is executed inside a container, then the debconf database is
seeded with empty values, and install_devices_empty is set to true.
ZubuntuZdebianZcc_grub_dpkgz Grub Dpkgz*Configure grub debconf installation deviceaE grub_dpkg:
enabled: true
# BIOS mode (install_devices needs disk)
grub-pc/install_devices: /dev/sda
grub-pc/install_devices_empty: false
# EFI mode (install_devices needs partition)
grub-efi/install_devices: /dev/sda
)idnametitledescriptiondistrosZ frequencyZexamplesZactivate_by_schema_keysc C sl d} g }d}d}t rd}d}y tjdd||gdd jj } W np tk
r } z6t|jtrhtj d
nd|j
kr~tj d n W Y d
d
}~X n tk
r tj
td Y nX | stjj| rdS y&tjdddd| gdd jj j }W n$ tk
r tj
td| Y nX tj ddj| dd |D }tj ddj| |rXt|d n| }tj 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_dpkgZudevadminfoz--rootz--query=symlinkz3udevadm DEVLINKS symlink query failed for disk='%s'z%considering these device symlinks: %s,c S s g | ]}d |kr|qS )z
disk/by-id ).0Zdevr r "/usr/lib/python3.6/cc_grub_dpkg.py