a '¡Dg­ã@sÊUdZddlZddlZddlmZmZddlmZddlm Z ddl m Z ddl m Z ddlmZd d d ge d d gdœZe ed<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Ú grub_dpkgú grub-dpkg)ÚidZdistrosZ frequencyZactivate_by_schema_keysÚmetac Csfd}g}d}d}tƒrd}d}z tjdd||gdd �j ¡}Wnpty’}zZózfetch_idevs..z)filtered to these disk/by-id symlinks: %srz selected %s)Ú is_efi_bootedrÚstdoutÚstriprÚ isinstanceÚreasonÚFileNotFoundErrorÚLOGÚdebugÚstderrÚ ExceptionrÚlogexcÚosÚpathÚexistsÚsplitÚjoinÚsorted)rZdevicesZ probe_targetZ probe_mountÚeÚidevsrrrÚ fetch_idevssJ ÿ      þÿÿ  r*)Úreturnc CsFztj d¡WSty@}zt d|¡WYd}~dSd}~00dS)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)r(rrrrcs  r)ÚnameÚcfgÚcloudÚargsr+c Cs¤| d| di¡¡}|si}| dd¡}t |¡rDt d||¡dSt|ƒ}t d|¡ztjdg|d�Wn2tyž}zt td |¡WYd}~n d}~00dS) Nr r ÚenabledFz*%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_configrr r!)r.r/r0r1Úmycfgr2Z dconf_selr(rrrÚhandleos   ÿr7)r6r+cCs�tƒr*t |dd¡}|dur"tƒ}d|St |dd¡}|durFtƒ}| d¡}|dur`| }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*r4rÚboolZtranslate_boolÚstrÚlower)r6r)Z idevs_emptyrrrr5„s(ÿ    þÿr5)Ú__doc__Zloggingr"Z cloudinitrrZcloudinit.cloudrZcloudinit.configrZcloudinit.config.schemarZcloudinit.settingsrZcloudinit.subprr Ú__annotations__Z getLoggerÚ__name__rr*r8rr9Úlistr7r5rrrrÚ s$     ü D