܍~c UdZddlZddlmZddlmZddlmZmZddl m Z ddl m Z ddl mZmZdd lmZdd lmZd Zd d gZdddeeeedggdZeed<eeZdZdede de dededdf dZdS)z5Grub Dpkg: Configure grub debconf installation deviceN)Logger)dedent)subputil)Cloud)Config) MetaSchema get_meta_doc) PER_INSTANCE)ProcessExecutionErroraConfigure 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. The global config key ``grub-dpkg`` is an alias for ``grub_dpkg``. If no installation device is specified this module will execute grub-probe to determine which disk the /boot directory is associated with. 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. ubuntudebian cc_grub_dpkgz Grub Dpkgz*Configure grub debconf installation devicez grub_dpkg: enabled: true grub-pc/install_devices: /dev/sda grub-pc/install_devices_empty: false )idnametitle descriptiondistros frequencyexamplesactivate_by_schema_keysmetacd}g} tjgddd}n#t$rZ}t|jt r|dn d|jvr|dnYd }~n(d }~wt$rtj |d YnwxYw|rtj |sdS tjd d d d|gdd}n&#t$rtj |d|YnwxYw|dd|d|D}|dd||rt!|dn|}|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. )z grub-probez-tdiskz/bootT)capturerz'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-dpkgudevadminfoz--rootz--query=symlinkz3udevadm DEVLINKS symlink query failed for disk='%s'z%considering these device symlinks: %s,cg|]}d|v| S)z disk/by-id).0devs ?/usr/lib/python3/dist-packages/cloudinit/config/cc_grub_dpkg.py zfetch_idevs..os"===s)<)>>MMM  %''  !    ah 1 2 2  II7 8 8 8 8 ,qx 7 7 IIA B B B B  GGG CEFFFFFG rw~~d++r   IFH.?F    UWW UWW      F      II5sxx7H7HIII==g===GII9388G;L;LMMM") 3F7OOA  tEIImU### Ls/07 B;AB"B;:B;"AD(( E  E rcfgcloudr5argsreturnc|d|di}|si}|dd}tj|r|d||dStj|dd}|t |}|d}|| }n)t |tstj|}t| }d|d |d } |d |d |d  tj dg| dS#t$rtj |dYdSwxYw)N grub_dpkgz grub-dpkgenabledTz*%s disabled by config grub_dpkg/enabled=%szgrub-pc/install_deviceszgrub-pc/install_devices_emptyz'grub-pc grub-pc/install_devices string z/ grub-pc grub-pc/install_devices_empty boolean  z*Setting grub debconf-set-selections with 'z',''zdebconf-set-selectionsz2Failed to run debconf-set-selections for grub-dpkg)getris_falser+get_cfg_option_strr9r(booltranslate_boolstrlowerrr-r.) rr:r;r5r<mycfgr@r8 idevs_empty dconf_sels r$handlerMxs GGKb!9!9 : :E ii 4((G }W >gNNN  #E+Dd K KE }C  ));<rZs<;;  !!!!!!######<<<<<<<<++++++000000  X    9%     "#j( ,t  999x)O )O)O#()O/5)O=A)O )O)O)O)O)O)Or&