+
    h8  c                   s    ^ RI t ^ RIt^ RIt^ RIt^ RIt^ RIt^ RIHt ^RIH	t	 ^RIH
t
 ^RIHt R tR tR t ! R	 R
4      t ! R R4      tR tR tR tR tR tR# )    N)	Libosinfo)
urlfetcher)progress)logc                 s    V R 8g  # )Zroot )login   &6/usr/share/virt-manager/virtinst/install/unattended.py_is_user_login_safer	      s    F?    c                  s    \         P                  ! 4       p \        P                  ! V 4      P                  p\        V 4      '       g   R# W3# )N)NN)getpassZgetuserpwdZgetpwnamZpw_gecosr	   )Zhostuserrealnames     r   _login_from_hostuserr      s<     H||H%..Hx((r
   c                sd	   R pR p\         P                  ! 4       pVP                  p	VP                  p
V	'       g   \        4       w  rV	'       dm   V	P	                  4       p	\        V	4      '       g*   \        \        R4      RVP                  RV	/,          4      hVP                  V	4       VP                  V
4       V P                  4       '       d<   VP                  4       '       g&   \        \        R4      VP                  ,          4      hTP                  VP                  4       ;'       g    R4       V P                  4       '       d<   VP                  4       '       g&   \        \        R4      VP                  ,          4      hTP!                  VP                  4       ;'       g    R4       VP#                  4       '       d   R	MR
pVP%                  4       '       d   RpVP'                  V4       VP)                  V4       \*        P,                  ! RRV4      pVP/                  V4       V! 4       pV'       d   VP1                  V4       V! 4       pV'       d#   VP3                  V4       VP5                  V4       V'       d   VP7                  V4       VP8                  '       d   VP;                  VP8                  4       VP<                  '       d   VP?                  VP<                  4       \@        PB                  ! R4       \@        PB                  ! RVPE                  4       4       \@        PB                  ! RVPG                  4       4       \@        PB                  ! RVPI                  4       4       \@        PB                  ! RVPK                  4       4       \@        PB                  ! RVPM                  4       4       \@        PB                  ! RVPO                  4       4       \@        PB                  ! RVPQ                  4       4       \@        PB                  ! RVPS                  4       4       \U        VR4      '       d&   \@        PB                  ! RVPW                  4       4       \@        PB                  ! RVPY                  4       4       \@        PB                  ! RVP[                  4       4       V# )z*
Build a Libosinfo.InstallConfig instance
c                  s    R p \         P                  P                  V 4      pVP                  R4      p\	        V4      ^8  d
   V^,          # R# )z/etc/localtimez	zoneinfo/N)osZpathZrealpathZsplitZlen)ZTZ_FILEZlinkpathZtokens      r   get_timezoneZ)_make_installconfig.<locals>.get_timezone(   sC    "77##G,,v;?!9 r
   c                  s:    \         P                  ! 4       ^ ,          # )r    )localeZ	getlocaler   r
   r   get_languageZ)_make_installconfig.<locals>.get_language/   s    !!$$r
   z4%(osname)s cannot use '%(loginname)s' as user-login.osnameZ	loginnamez(%s requires the user-password to be set. z)%s requires the admin-password to be set.z/dev/vdaz/dev/sdaZCz![{|}~[\]^':; <=>?@!"#$%`()+/.,*&]Z-z6InstallScriptConfig created with the following params:zusername: %szrealname: %sztarget disk: %szhardware arch: %szhostname: %sztimezone: %szlanguage: %szkeyboard: %sget_installation_urlzurl: %szreg-login %szproduct-key: %s).r   InstallConfig
user_loginr   Zlowerr	   RuntimeError_nameZset_user_loginZset_user_realnamerequires_user_passwordget_user_passwordset_user_passwordrequires_admin_passwordget_admin_passwordset_admin_passwordZsupports_virtiodiskZ
is_windowsZset_target_diskZset_hardware_archreZsubZset_hostnameZset_l10n_timezoneZset_l10n_languageZset_l10n_keyboardset_installation_url	reg_loginZset_reg_loginproduct_keyZset_reg_product_keyr   debugZget_user_loginZget_user_realnameZget_target_diskZget_hardware_archZget_hostnameZget_l10n_timezoneZget_l10n_languageZget_l10n_keyboardhasattrr   Zget_reg_loginZget_reg_product_key)scriptosobjunattended_dataarchZhostnameurlr   r   configr   r   ZtgtZtimezoneZlanguages   &&&&&&        r   _make_installconfigr.   #   sr   
% $$&F
 &&E))H.0"5))HIUZZe<= 
 	e$  * $$&&/P/P/R/R1GH5::UVV
_>>@FFBG %%''0R0R0T0T1HIEJJVWW
o@@BHHbI 1133*C
3 T" vv;S(KH
! ~H  * ~H  *  *
##C(   _667"""""?#>#>?IIFGIInf3356IInf6689II!7!7!9:II!6#;#;#=>IInf1134IInf6689IInf6689IInf6689v-..		)V88:;IInf2245II!;!;!=>Mr
   c                   s   a  ] tR t^t o Rt]R 4       t]R 4       tR tR t	R t
R tR tR	 tR
 tR tR tR tR tR tRtV tR# )OSInstallScriptz2
Wrapper for Libosinfo.InstallScript interactions
c                 s    ^RI Hp  V P                  R4      pVP                  4        F;  p\        P
                  P                  VP                  4       ,          '       g   K:   R# 	  R# )i   )OSDBwin7TF)Zosdictr0   Z	lookup_osget_install_script_listr   InstallScriptInjectionMethodCDROMget_injection_methods)r0   r1   r(   r   r   have_new_libosinfoZ"OSInstallScript.have_new_libosinfo   sN    !~~f%224F55;;f>Z>Z>\\\ 5 r
   c                 s6    \        \        P                  R 4      # )r#   )r'   r   r   r   r
   r   have_libosinfo_installation_urlZ/OSInstallScript.have_libosinfo_installation_url   s    y..0FGGr
   c                s    Wn         W n        W0n        W@n        R V n        \
        P                  4       '       g   \        \        R4      4      hR # )NzAlibosinfo or osinfo-db is too old to support unattended installs.)	_script_osobj_osinfomediaobj_osinfotreeobj_configr/   r6   r   r   )selfr(   r)   osinfomediaobjosinfotreeobjs   &&&&&r   __init__ZOSInstallScript.__init__   sI    -+1133UV  4r
   c                s6    V P                   P                  4       # N)r8   get_expected_filenamer=   r   r   rB   Z%OSInstallScript.get_expected_filename   s    ||1133r
   c                s   R \         P                  P                  R\         P                  P                  /p\        P
                  ! RV4       W!,          pV P                  P                  4       pW4,          ^ 8X  d4   \        \        R4      RV P                  P                  RV/,          4      hV P                  P                  V4       R# )ZcdromZinitrdzUsing '%s' injection methodzKOS '%(osname)s' does not support required injection method '%(methodname)s'r   Z
methodnameN)r   r3   r4   ZINITRDr   r&   r8   r5   r   r   r9   r   set_preferred_injection_method)r=   namestrnamesinjection_methodZsupported_injection_methodss   &&   r   rD   Z.OSInstallScript.set_preferred_injection_method   s     Y;;AAi<<CC

 			/9 >&*ll&H&H&J#9Q>_`T[[--|WEF 
 	334DEr
   c                s    R \         P                  P                  R\         P                  P                  /p\        P
                  ! RV4       V P                  P                  W!,          4       R# )medianetworkzUsing '%s' installation sourceN)r   ZInstallScriptInstallationSourceZMEDIAZNETWORKr   r&   r8   set_installation_source)r=   rE   rF      && r   rJ   Z'OSInstallScript.set_installation_source   sR     Y>>DDy@@HH

 			2G<,,U^<r
   c                s    V P                   P                  V4      p\        T;'       d    VP                  4       '       * 4      # rA   )r8   Zget_config_paramZboolZis_optional)r=   Zconfig_paramZparamrK   r   _requires_paramZOSInstallScript._requires_param   s5    --l;E55%"3"3"5566r
   c                @    V P                  \        P                  4      # rA   )rL   r   Z!INSTALL_CONFIG_PROP_USER_PASSWORDrC   r   r   r   Z&OSInstallScript.requires_user_password   s    ##I$O$OPPr
   c                rM   rA   )rL   r   Z"INSTALL_CONFIG_PROP_ADMIN_PASSWORDrC   r   r   r   Z'OSInstallScript.requires_admin_password   s    ##I$P$PQQr
   c                s    Wn         R # rA   )r<   )r=   r-   s   &&r   
set_configZOSInstallScript.set_config   s    r
   c                   V P                   '       d1   V P                  P                  V P                   V P                  4      # \	        V P                  R 4      '       dC   V P
                  '       d1   V P                  P                  V P
                  V P                  4      # V P                  P                  V P                  P                  4       V P                  4      # )generate_for_tree)
r:   r8   Zgenerate_for_mediar<   r'   r;   rP   generater9   
get_handlerC   r   r   rQ   ZOSInstallScript.generate   s    <<2243G3GVV4<<!455$:M:M:M <<11$2E2Et||TT||$$T[[%;%;%=t||LLr
   c                rO   )generate_command_line_for_tree)
r:   r8   Zgenerate_command_line_for_mediar<   r'   r;   rS   Zgenerate_command_liner9   rR   rC   r   r   generate_cmdlineZ OSInstallScript.generate_cmdline   s    <<??@T@TVZVbVbcc4<<!ABBtGZGZGZ <<>>t?R?RTXT`T`aa||11$++2H2H2JDLLYYr
   c                sf   V P                   P                  4       pV P                   P                  4       pV P                   P                  R 4       V P                   P	                  R 4       V P                  4       pV P                   P                  V4       V P                   P	                  V4       V# )z[SCRUBBLED])r<   r   r    r   r!   rQ   )r=   Zoriginal_user_passwordZoriginal_admin_passworddebug_content   &   r   _generate_debugZOSInstallScript._generate_debug   s    !%!?!?!A"&,,"A"A"C&&}5''6&&'=>''(?@r
   c                s    \         P                  ! R RR7      pVP                  pV P                  4       p\	        VR4      P                  V4       V P                  4       p\        P                  ! RV4       \        P                  ! RV4       V# )zvirtinst-unattended-scriptF)ZprefixZdeleteZwzGenerated unattended script: %szGenerated script contents:
%s)	tempfileZNamedTemporaryFiler   rQ   openwriterW   r   r&   )r=   ZfileobjZ
scriptpathZcontentrU   s   &    r   rZ   ZOSInstallScript.write   sq    --5QZ_`\\
--/Z##G,,,.		3Z@		2MBr
   )r<   r:   r;   r9   r8   N)__name__
__module____qualname____firstlineno__Z__doc__Zstaticmethodr6   r7   r@   rB   rD   rJ   rL   r   r   rN   rQ   rT   rW   rZ   __static_attributes____classdictcell__Z__classdict__   @r   r/   r/      sz        H H
4F$=7QRMZ r
   r/   c                   sJ   a  ] tR tRt o RtRtRtRtRtRt	R t
R tR tRtV tR# )UnattendedDatai  Nc                s    \        VR 4      ;_uu_ 4       pVP                  4       P                  R4      uuRRR4       #   + '       g   i     R# ; i)Zrz
N)rY   ZreadlineZrstrip)r=   ZpwdfileZfobjrK   r   _get_passwordZUnattendedData._get_password  s4    '34==?))&1  s	   ?A	c                `    V P                   '       d   V P                  V P                   4      # R # rA   )user_password_filerd   rC   r   r   r   Z UnattendedData.get_user_password  s*    """%%d&=&=>> #r
   c                re   rA   )admin_password_filerd   rC   r   r   r    Z!UnattendedData.get_admin_password  s*    ###%%d&>&>?? $r
   r   )r[   r\   r]   r^   profilerg   r   rf   r%   r$   rd   r   r    r_   r`   ra   rb   r   rc   rc     s;     GJKI2?@ @r
   rc   c                s~    / pV  F4  pVP                  4       pW19  d   . W&   W,          P                  V4       K6  	  V# )z>
Generate a mapping of profile name -> [list, of, rawscripts]
)Zget_profileappend)script_list
script_mapr(   rh   rV   r   _make_scriptmaprl   $  sH     J$$&$"$J""6*	 
 r
   c                 sX    R .pRpV F  pW09   g   K  Tp M	  T;'       g
    V ^ ,          # )ZdesktopNr   )profile_namesZprofile_prefsZfoundZprV   r   _find_default_profilern   1  s;    KMEE  $$M!$$r
   c                 sV   . pV'       dL   VP                  4       '       g&   \        \        R 4      V P                  ,          4      hVP	                  4       pV'       g   V P	                  4       pV'       g&   \        \        R4      V P                  ,          4      h\        V4      p\        \        VP                  4       4      4      pV'       dV   VP                  V. 4      pV'       g;   \        \        R4      RV P                  RVRRP                  V4      /,          4      hM3\        V4      p\        P                  ! \        R4      V4       WA,          p. pV F"  pVP                  VP                  4       4       K$  	  \        P                   ! RVRP                  V4      4       V# )	z6OS '%s' media does not support unattended installationz1OS '%s' does not support unattended installation.z|OS '%(osname)s' does not support unattended installation for the '%(profilename)s' profile. Available profiles: %(profiles)sr   ZprofilenameZprofilesz, zUsing unattended profile '%s'z*Install scripts found for profile '%s': %s)Zsupports_installer_scriptr   r   r   r2   rl   ZlistZsortedZkeysZgetZjoinrn   r   Zwarningri   Zget_idr&   )	osinforh   os_mediarj   rk   rm   
rawscriptsZids	rawscript	   &&&      r   _lookup_rawscriptsrt   ;  sg   K1133 JKv{{[  6684461PQTZT_T__`` -J
 123M^^GR0
7 fkk!7		- 8	   (6A56@(

 C	

9##%&   II:GTYYs^Tr
   c           	      s   R  p. p\        V P                  VP                  V4      pV'       d   VP                  4       MRp	V'       d   VP	                  4       MRp
V F  p\        WP                  W4      pVP                  V4       V! V4      pVP                  V4       \        WP                  WP                  P                  V P                  V4      pVP                  V4       VP                  V4       K  	  V# )c                 s    V '       g   R # R# )rI   rH   r   )rp   r   r   _get_installation_sourceZ9prepare_install_scripts.<locals>._get_installation_sourceq  s    r
   N)rt   ro   rh   Zget_osinfo_mediaZget_osinfo_treer/   rD   rJ   r.   r   r+   r   rN   ri   )Zguestr*   r,   rp   Zos_treerG   ru   Zscriptsrq   r>   r?   rr   r(   Zinstallationsourcer-   s   &&&&&&         r   prepare_install_scriptsrv   p  s    
 G#ELL/2I2I8TJ4<X..0$N18G++-dM	 LL.X--.>?5h?&&'9:$LL/88==%**c
 	&!v   Nr
   c                 sh   \         P                  ! V4      p\        P                  ! R W4      pW#n        . p V  F?  pVP                  R^4      ^,          pVP                  V4      pVP                  Wv34       KA  	  V#   \         d)    T F   p\        P                  ! T^ ,          4       K"  	  h i ; i)NZ/)r   Zensure_meterr   ZDirectFetchermeterZrsplitZacquireFileri   Z	Exceptionr   Zunlink)	Z	locationsZ
scratchdirrw   ZfetcherZdriversZlocationZfilenameZdriverZ
driverpairrs   r   download_driversrx     s    !!%(E&&tZ?GMG!HsA.q1H((2FNNF-. " N  !JIIjm$ "s   AA> >3B1)r   r   r   r   r"   rX   Zgi.repositoryr   r   r   r   Zloggerr   r	   r   r.   r/   rc   rl   rn   rt   rv   rx   r   r
   r   <module>ry      si      	 
 	  #   nbx xv@ @*
%2j8r
   