o x[h~@shddlZddlmZmZmZmZddlmZddlm Z ddl m Z m Z e eZGdddejZdS)N)distroshelperssubputil) PackageList) HostnameConf) PER_ALWAYS PER_INSTANCEc@seZdZdZdZddgZddZddd Zd efd d Z d dZ ddZ e ddZ dddZddZdddZddddZdS)Distroz/etc/locale.genz en_US.UTF-8z C.UTF8 UTF-8zen_US.UTF-8 UTF-8cCs>tj||||trd|_nd|_t||_d|_dS)Nz /etc/hostnamez/etc/conf.d/hostnamegentoo) rr __init__ uses_systemdhostname_conf_fnrRunners_runnerosfamily)selfnamecfgpathsr:/usr/lib/python3/dist-packages/cloudinit/distros/gentoo.pyr s   zDistro.__init__NcCsFtj|jd|jddtjdgddtjddd |jgddd S) zLocales need to be added to /etc/locale.gen and generated prior to selection. Default to en_US.UTF-8 for simplicity.  i)modez locale-genFcaptureeselectlocalesetN)r write_file locale_gen_fnjoinlocalesrdefault_locale)r_out_fnrrr apply_locale+s  zDistro.apply_localepkglistcCs||jd|ddS)N)pkgs)update_package_sourcespackage_command)rr'rrrinstall_packages9szDistro.install_packagescCsd}z||}Wnty%t|jdd}|rntdYdSYnw|s,td}t r6| |n| d|t |t |ddS)Ncreate_hostname_fileTz8create_hostname_file is False; hostname file not createdr(z hostname="%s"i) _read_hostname_confIOErrorrget_cfg_option_bool_cfgLOGinforrr set_hostnamerstr)rhostnamefilenameconfr-rrr_write_hostname=s*   zDistro._write_hostnamecCs||j}|j|fSN)_read_hostnamer)r sys_hostnamerrr_read_system_hostname^s  zDistro._read_system_hostnamecCstt|}||Sr:)rrload_text_fileparse)r7r8rrrr.bszDistro._read_hostname_confcCs8d}z ||}|j}Wn tyYnw|s|S|Sr:)r.r6r/)rr7defaultr6r8rrrr;hs   zDistro._read_hostnamecCstj|||ddS)N)tztz_file)rset_etc_timezone _find_tz_file)rrArrr set_timezonesszDistro.set_timezonecCsdg}|d|dkr|ddgn1|durg}|r't|tr'||n |r3t|tr3|||r:||td|}||tj|dddS) Nemergez--quietupgradez--updateworldz%s-%sFr)appendextend isinstancer5listrexpand_package_listr)rcommandargsr)cmdr'rrrr+vs      zDistro.package_commandF)forcecCs$|jjd|jdg|r tntddS)Nzupdate-sourcesz--sync)freq)rrunr+rr )rrQrrrr*s   zDistro.update_package_sourcesr:)NN)__name__ __module__ __qualname__r r#r"r r&rr,r9r= staticmethodr.r;rEr+r*rrrrr s !   r )logging cloudinitrrrrcloudinit.distrosr"cloudinit.distros.parsers.hostnamercloudinit.settingsrr getLoggerrTr2r rrrrs