
    i                     v    d dl Z d dlmZmZ d dlmZ  e j                  e      Z G d dej                        Z	y)    N)netsubp)debianc                   N     e Zd Zdedededef fdZd
dZdef fdZd	 Z xZ	S )Distrolayoutmodelvariantoptionsc                    t         |   ||||       t        j                  g d       t        j                  g d       | j                  dd       t        j                  d      rt        j                  g d       y y )N)/usr/bin/raspi-confignonintupdate_labwc_keyboard)r   r   update_squeekboardrestartr   zkeyboard-setupudevadm)r   triggerz--subsystem-match=inputz--action=change)super
set_keymapr   manage_servicewhich)selfr   r	   r
   r   	__class__s        C/usr/lib/python3/dist-packages/cloudinit/distros/raspberry_pi_os.pyr   zDistro.set_keymap   so    65'7;			
 				
 	I'78::i II !    c                 "   	 t        j                   ddd| g       y # t         j                  $ r^ |j                  d      s4t        j	                  d|       t        j                   ddd| dg       Y y t        j                  d|       Y y w xY w)Nr   r   do_change_localez.UTF-8zTrying to set locale %s.UTF-8zFailed to set locale %s)r   ProcessExecutionErrorendswithLOGinfoerror)r   localeout_fnkeynames       r   apply_localezDistro.apply_locale.   s    	=II+&h	 )) 	=??8,8&A		/ *!(&)	 		3V<	=s    AB5BBreturnc                     t        |   |fi |}|s|S 	 t        j                  g dd|i       y# t        j                  $ r }t        j                  d|       Y d}~yd}~ww xY w)z
        Add a user to the system using standard GNU tools

        This should be overridden on distros where useradd is not desirable or
        not available.

        Returns False if user already exists, otherwise True.
        )z/usr/bin/rename-userz-fz-s	SUDO_USER)
update_envzFailed to setup user: %sNFT)r   add_userr   r   r    r"   )r   namekwargsresulter   s        r   r+   zDistro.add_userF   sp     !$1&1M	II
 (. 	 )) 	II0!4	s   3 A&A!!A&c                     d}| j                   j                  |d      }t        j                  d||       |st	        j
                         S t        j                  d       y )Ndisable_fallback_netcfgTz%s value is: %sz}Skipping generation of fallback network config as per configuration. Rely on Raspberry Pi OS's default network configuration.)_cfggetr    debugr   generate_fallback_configr!   )r   keyr1   s      r   r5   zDistro.generate_fallback_configd   sV    '"&))--T":		#S*AB&//11%	

 r   )NLANG)
__name__
__module____qualname__strr   r&   boolr+   r5   __classcell__)r   s   @r   r   r      s:     S 3  <=0$ <r   r   )
logging	cloudinitr   r   cloudinit.distrosr   	getLoggerr8   r    r    r   r   <module>rC      s4      $g!cV]] cr   