+
    Ki<  c                   s   R t ^ RIt^ RIHt ^ RIHt ^ RIHt ^ RIH	t	H
t
 ^ RIHtHt ^ RIHtHt ^ RIHtHt ^ R	IHt ^ R
IHt ^ RIHt ^ RIHt ^ RIHtHt ^ RIH t H!t!H"t" ^ RI#H$t$ ^ RI%H&t&H't' ^ RI(H)t)  ! R R4      t*R# )zLutris installer classN)cached_property)gettext)Path)LutrisConfigwrite_game_config)add_or_updateget_game_by_field)AuthenticationErrorUnavailableGameError)AUTO_ELF_EXEAUTO_WIN32_EXE)ScriptingError)InstallerFile)import_runner)SERVICES)find_linux_game_executablefind_windows_game_executable)convert_gog_config_to_lutrisget_gog_config_from_pathget_gog_game_path)logger)ModDBis_moddb_url)fix_path_casec                   s   a  ] tR t^t o RtR t]R 4       tRR ltRR lt	]
R 4       tR t]
R	 4       tR
 tRR ltR tR tR tR tRtV tR# )LutrisInstallerzRepresents a Lutris installerc                s   W n         Wn        R V n         VR,          V n        VR,          V n        VP                  R4      V n        VR,          V n        VP                  R4      V n        VR,          V n	        VR,          V n
        T P                  TR
7      T n        T P#                  YR
7      T n        T P                  P                  R/ 4      T n        T P                  P                  R. 4       UUUu. uF2  pTP)                  4        F  w  rx\+        T P                  Yx4      NK  	  K4  	  upppT n        . T n        . T n        T P                  P                  R4      T n        T P                  P                  R4      T n        T P7                  4       T n        R T n        TP                  R4      T n        R	#   \         d3   p\        \        R4      TP                  ^ ,          ,          4      ThR	p?ii ; iu upppi )Fversionslugyearrunnerscriptname	game_slugz7The script was missing the '%s' key, which is required.N)initial	variablesfilesrequiresextends
discord_id)interpreter	installer	is_updater   r   getr   r   r   	game_namer   ZKeyErrorr   _Zargsget_serviceservice	get_appidservice_appidr!   itemsr   script_filesr"   extra_file_pathsr#   r$   get_game_idgame_idis_gogr%   )	selfr'   r&   r-   appidexZ	file_descZfile_idZ	file_metas	   &&&&&    ?/usr/lib/python3.14/site-packages/lutris/installer/installer.py__init__ZLutrisInstaller.__init__   s   &"		t$Y/DL!&)DI!f-DI#H-DK#--1DK&v.DN&{3DN '''8!^^I^Eb9 "[[__Wb9
9	&/oo&7" $..'=&7 >9

 
 "
3{{y1'')#--5#  	t #\!]`b`g`ghi`j!jkqss	t
s   A2F: 68G::G7-G22G7c                s   V P                   P                  R 4      pV'       g   R# \        V4      P                  4       pVP	                  4       '       g   R# VP                  4       '       d   \        VP                  4      # \        V4      # )installer_file )r'   r)   r   ZresolveZexistsZis_filestrZparent)r6   r;   file   &  r9   	scriptdirZLutrisInstaller.scriptdir:   s`    ++,<=N#++-{{}}#'<<>>s4;;@s4y@    Nc                s   V'       d   V# R V P                   9   d   R \        9   d   \        R ,          ! 4       # V P                  P                  4       pRV9   d   R\        9   d   \        R,          ! 4       # RV9   d   R\        9   d   \        R,          ! 4       # RV9   d    R\        9   d   \        R,          ! 4       # R# R# )steamZhumblehumblebundlegogzitch.ioitchioN)r   r   r   lower)r6   r    r   s   && r9   r,   ZLutrisInstaller.get_serviceD   s    Ndkk!g&9G$&&,,$$&w>X#=N+--G 1E?$$H$8H%'' %9rA   c                s   VP                  R 4      '       d   VP                  R4      # V'       d   V# V P                  '       g   R# RpV P                  P                  R8X  d+   VP                  R4      ;'       g    VP                  R4      pV P                  P                  R/ 4      pV P                  P                  R8X  dD   VP                  R4      ;'       g+    VP                  R4      ;'       g    VP                  R4      pV P                  P                  R	8X  dD   VP                  R
4      ;'       g+    VP                  R4      ;'       g    VP                  R4      pV P                  P                  R8X  dD   VP                  R4      ;'       g+    VP                  R4      ;'       g    VP                  R4      pV'       d   V# R# )Zis_dlcZdlcidNrB   Zsteamid
service_idgamerD   ZgogidrC   ZhumbleidZhumblestoreidrE   Zitchid)r)   r-   idr   )r6   r'   r    rG   game_configs   &&&  r9   r.   ZLutrisInstaller.get_appidQ   sQ   ==""==))N|||
<<??g%"y1PPY]]<5PJkkoofb1<<??e#$1jjY]]75Kjjy}}]iOjJ<<??n,$4uu	o8VuuZcZgZghtZuJ<<??h&$2llimmH6MllQZQ^Q^_kQlJrA   c                sF    \         P                  ! V P                  ^R7      # )z#Return a pretty print of the script)Zindent)jsonZdumpsr   )r6   s   &r9   script_prettyZLutrisInstaller.script_prettyf   s     zz$++a00rA   c                s    \        V P                  R4      pV'       d-   V P                  '       g   VR,          '       g
   VR,          # R# R# )z7Return the ID of the game in the local DB if one existsr   	installedrI   N)r   r   r$   )r6   Zexisting_game   & r9   r3   ZLutrisInstaller.get_game_idk   s<     *$..&Adlll-2L2L && 3M=rA   c                sZ   V P                   '       g   V P                  '       d   R# V P                  R8X  d   R# V P                  P	                  R4      '       g   R# V P
                  '       gc   V P                  P	                  R/ 4      P	                  R4      '       g2   V P                  P	                  R/ 4      P	                  R4      '       d   R# V P                  P	                  R. 4       Uu. uF$  qP                  P                  V4      ^ ,          NK&  	  ppRV9   d   R# R# u upi )	zHDetermines if an install script should create a game folder for the gameFrB   r'   rH   rD   ZprefixTZinsert_disc)r#   r$   r   r   r)   r1   r&   Z_get_command_name_and_params)r6   ZcZcommand_namesr?   r9   creates_game_folderZ#LutrisInstaller.creates_game_folders   s     ===DLLL;;'!{{{++ ; ? ? F F$++//Z`bdJeJiJijrJsJsVZVaVaVeVefqsuVvwVvQR))FFqI!LLVvwM) xs   1*D(c                s   . p\        V P                  \        4      '       g   VP                  R4       V# R F?  p\	        W4      '       d   \        W4      '       d   K'  VP                  RV,          4       KA  	  V P                  R8X  d;   RV P                  9  g   RV P                  R,          9  d   VP                  R4       V P                  R8X  dC   V P                  P                  R/ 4      P                  R4      '       g   VP                  R	4       V P                  P                  R
4      '       d3   V P                  P                  R4      '       d   VP                  R4       V# )z%Return potential errors in the scriptzScript must be a dictionaryzMissing field '%s'ZlibretrorH   Zcorez%Missing libretro core in game sectionrB   r7   zMissing appid for Steam gamer#   r$   z,Scripts can't have both extends and requires)r   r*   r   )
isinstancer   dictappendZhasattrZgetattrr   r)   )r6   Zerrorsfieldr?   r9   
get_errorsZLutrisInstaller.get_errors   s   $++t,,MM78M :E4''wt/C/C2U:; :
 ;;*$T[[(F$++f:M,MEF ;;'!;;??62.227;;<= ;;??:&&4;;??9+E+EMMHIrA   c                sV   V P                   '       g   R# RpRpV P                  '       dO   V P                    F>  pVP                  P                  R4      '       g   K&  VP                  pVP                  p M	  V P                    Uu. uF%  qUP                  V8w  g   K  VP                  4       NK'  	  pp. pV F  pVP                  V P                  P                  VP                  4      4       \        VP                  4      '       g   KT  VP                  \        4       P                  VP                  4      4       K  	  V'       Ed   V P                  '       d   \        P                  ! RV4        V'       d   V P                  P                  W4      pM]V P                  P                  WV4      w  rV
 UUu. uF(  qP!                  4       P#                  4        F  qNK  	  K*  	  pppW,           p V'       d   V F  pVP+                  V4       K  	  MB\        P,                  ! RV4       VP/                  ^ \1        V P2                  VRVRR/4      4       W`n        Wpn        R# u upi u uppi   \$        \&        3 d$   p\        P(                  ! RT4       Rp Rp?LRp?ii ; i)	z6Gathers necessary files before iterating through them.NzN/AzGetting files for %szGame not available: %sz7Unable to get files from service. Setting %s to manual.urlZfilenamer<   )r1   r-   rU   Z
startswithrI   copyZset_urlr&   _substituter   r   Ztransform_urlr   infoZget_patch_filesZget_installer_filesZget_dest_files_by_idZvaluesr   r   Z	exceptionrR   ZdebugZinsertr   r   r"   r2   )r6   ZextrasZpatch_versionZinstaller_file_idZinstaller_file_urlr>   r"   r2   Zinstaller_filesZcontent_filesZextra_filesZfZpathr8   r;   s   &&&            r9   prepare_game_filesZ"LutrisInstaller.prepare_game_files   s       !<<<))88&&u--(,%)-&	 *
 *.):):[):ggIZ>Z):[ DLL))55dhh?@DHH%%UW22488<= 
 KK.0AB
' &*ll&B&B4&[O151Q1QRVkq1r.M6A'pkNdNdNfNmNmNodNok$'p&3&AO
 &5NLL0 '6 VXij}T^^5FPbdnprHst 
 0K \" (q')=> '  !92>"&'sB   I)I)5I4 =I4 #I4 <.I.*I4 .I4 4J(J##J(c                sD   V P                   '       dS   \        V P                   4      \        V P                  4      8X  d&   \        P                  ! R 4       . V P
                  R&   V P                    F+  pV P
                  R,          P                  RRVRR//4       K-  	  R# )z,Installer with only extras and no game filesr'   rV   ZsrcZdstz$GAMEDIR/extrasN)r2   Zlenr"   r   warningr   rR   )r6   Z
extra_filerN   r9   install_extrasZLutrisInstaller.install_extras   s{        S)>)>%?3tzz?%RNNIJ')DKK$//JKK$++VeZPa5b,cd 0rA   c                s   / pV EF  p\        V\        4      '       g   \        \        R4      V4      hW,          p\        V4      P	                  4       R8X  d   Rp\        V4      P	                  4       R8X  d   RpVR8X  dU   V UUUu. uF?  qUP                  4        UUu/ uF   w  rgW`P                  P                  V4      bK"  	  uppNKA  	  upppW#&   K  \        V\        4      '       d0   V Uu. uF  qP                  P                  V4      NK  	  upW#&   EK  \        V\        4      '       dC   VP                  4        UUu/ uF   w  rgW`P                  P                  V4      bK"  	  uppW#&   EKo  \        V\        4      '       d   WBV&   EK  V P                  P                  V4      W#&   EK  	  V# u uppi u upppi u upi u uppi )z4Substitute values such as $GAMEDIR in a config dict.z Game config key must be a stringZtrueTZfalseFZlaunch_configs)rP   r=   r   r+   rF   r0   r&   rW   ZlistrQ   Zbool)	r6   Zscript_configconfigkeyZvalueZ_confZkZvZis	   &&       r9   _substitute_configZ"LutrisInstaller._substitute_config   su    Cc3''$Q'I%JCPP!&E5z!V+5z!W,&&mrsmrdiQ\Q\Q^_Q^v#3#3#?#?#B BQ^_mrsE4((HMN1//;;A>NE4((PUP[P[P]^P]fqq"2"2">">q"AAP]^E4((#s"..::5A# !$   `sN^s$   	F;
 &F5F;
1#G&G5F;
c                s@   V P                   '       d   \        V P                   RR7      pV'       g   \        V P                   RR7      pV'       g   \        RV P                   ,          4      h\        V P                  VR,          R7      pVP
                  pMR/ /pRV P                  9   d&   V P                  V P                  R,          4      VR&   V P                  P                  V P                  4      '       dd   V P                  V P                  V P                  ,          4      p\        V P                  4      ! 4       P                  V4       WCV P                  &   VR,          pRpRV P                  9   d$    VP                  V P                  R,          4       V FI  pWP                  9   g   K  W9  g   K  \        P                  ! RV4       V P                  V,          WX&   KK  	  V P                  V4      p\         VP                  R	R4      9   d&   \#        V P$                  P&                  RR7      VR	&   M=\(        VP                  R	R4      9   d#   \+        V P$                  P&                  4      VR	&   V F+  p	VP                  V	4      p
V
'       g   K  \-        V
4      WY&   K-  	  WSR&   V P.                  VR&   V P                  VR&   V P0                  VR&   V P2                  VR&   V P                   VR&   V P4                  VR&   V P6                  VR&   V P8                  VR&   V P:                  '       d)   V P:                  P<                  VR&   V P>                  VR&   V#   \         d.   p\        \        R
4      T P                  R,          R7      ThRp?ii ; i)zReturn the game configurationinstaller_slug)rS   r   z.No game matched '%s' on installer_slug or slug
configpath)Zrunner_slugZgame_config_idrH   ZsystemexezInvalid 'game' section)Zfaulty_dataNzAMoving entry point '%s' from script root level to the game configr<   T)Zmake_executabler   r   r!   r   r#   r   r   r-   rG   )ZisoZromZ	main_filera   ) r#   r   Z
ValueErrorr   r   Z
game_levelr   r^   r)   r   Zadjust_installer_runner_configupdater   r+   r   rZ   r	   r   r&   target_pathr
   r   r   r*   r!   r   r   r   r   r-   rI   r/   )r6   Zrequired_gameZbase_configr\   Zinstaller_runner_configrJ   Zentry_point_keysZerrZentry_point_keyr]   Zentry_points   &          r9   get_game_configZLutrisInstaller.get_game_config   s   ===-dmmCSTM  1$--v N  !QTXTaTa!abb&4;;}]iOjkK ++Fb\F t{{"#66t{{87LMF8;;??4;;''&*&=&=dkk$++>V&W#$++&(GGH_`"94;;Vn=T[[ l""4;;v#67  0O++-/2Tbdst/3{{?/K,  0
 --k:;??5"55!;D<L<L<X<Xjn!oK{ub99!=d>N>N>Z>Z![K $C%//#.K{#0#=  $
 %vv;;x"nn{ LLy!]]zv"nn{v<<< $F9#'#5#5F< I  l$Q'?%@dkkZ`Nabhkkls   ="M% %N0(NNc                s   V P                   '       d.   \        P                  ! RV P                   4       V P                  # V P                  '       dt   \        V P                  P                  4      pV'       dM   \        V P                  P                  4      p\        W4      pV P                  R,          P                  V4       \        V P                  V P                  4       4      p\        V P                   V P"                  V P$                  \'        V P"                  4      ! 4       P)                  4       V P                  P                  ^V P                  V P*                  V P,                  TV P.                  '       d   V P.                  P0                  MRV P2                  V P                  V P4                  R7      V n        V P                  # )z6Write the game configuration in the DB and config filez9This is an extension to %s, not creating a new game entryrH   N)r   r   r   ZplatformZ	directoryrM   r_   Zparent_slugr   r`   r-   rG   rI   r%   )r$   r   rX   r4   r5   r   r&   rc   r   r   r   rb   r   r   rd   r   r*   r   r   r   Zget_platformr#   r   r-   rI   r/   r%   )r6   Z
gog_configZgog_game_pathZlutris_configr`   s   &    r9   saveZLutrisInstaller.save;  s:   <<<KKK <<;;;1$2B2B2N2NOJ 1$2B2B2N2N O <Z WF#**=9&tyy$2F2F2HI
$;;"4;;/1>>@&&2299!'+|||DLLOO))||
  ||rA   )r%   r$   r2   r"   r4   r*   r   r'   r&   r5   r(   r#   r   r   r1   r-   r/   r   r!   r   r   )N)Z__name__Z
__module__Z__qualname__Z__firstlineno____doc__r:   r    r@   r,   r.   ZpropertyrL   r3   rO   rT   rY   r[   r^   rd   re   Z__static_attributes__Z__classdictcell__)Z__classdict__s   @r9   r   r      s     '6@ A A(* 1 1'  $821h	e.AF! !rA   r   )+rf   rK   Z	functoolsr    r   r+   Zpathlibr   Zlutris.configr   r   Zlutris.database.gamesr   r   Zlutris.exceptionsr   r   Zlutris.installerr	   r
   Zlutris.installer.errorsr   Zlutris.installer.installer_filer   Zlutris.runnersr   Zlutris.servicesr   Zlutris.util.game_finderr   r   Zlutris.util.gogr   r   r   Zlutris.util.logr   Zlutris.util.moddbr   r   Zlutris.util.systemr   r   ) rA   r9   <module>rg      sJ      %    9 B G 9 2 9 ( $ \ e e " 1 ,E ErA   