+
    & i}5  c                   s   ^ RI t ^ RIHtHt ^ RIHt ^ RIHt ^ RIH	t	H
t
HtHt ^ RIHt ^ RIHt ^ RIHt ^ R	IHt ^ R
IHt ]! ]4      ;_uu_ 4        ^ RIHtHtHt ^ RIHt RRR4        ! R R]4      t ! R R]4      t ! R R]4      t ! R R]4      t  ! R R]4      t!Rt"^
t#^t$ ! R R4      t%R#   + '       g   i     LY; i)i    N)FutureThreadPoolExecutor)suppress)Enum)ACCESS_READACCESS_WRITEMADV_DONTNEEDmmap)Path)rmtree)	TypedDict)log)	memfdfile)
DParameterZstdDict
decompress)xxh3_64_intdigestc                   s6    ] tR t^tRtRtRtRtRtRt	Rt
RtR	tR
# )FileTypezRepresents an file type.fileZblockZcharZdirZfifoZlinkZsocket N)__name__
__module____qualname____firstlineno____doc__FileZBlockZCharDirZFifoLinkZSocket__static_attributes__r       4/usr/lib/python3.14/site-packages/umu/umu_bspatch.pyr   r      s*    " DED
CDDFr   r   c                   s0   a  ] tR t^t o RtV 3R ltRtV tR# )Entryz;Represents an entry within a patch section of a patch file.c                sn   < V ^8  d   Qh/ S[ ;R&   S[;R&   S[;R&   S[;R&   S[;R&   S[;R&   S[;R&   # )   datamodenametypexxhashtimesize)bytesintstrr   floatZformat__classdict__   "r   __annotate__ZEntry.__annotate__   sY      K	  I  I  N  K  K " I# r   r   Nr   r   r   r   r   Z__annotate_func__r   __classdictcell__r-      @r   r   r      s     E  r   r   c                   s0   a  ] tR t^3t o RtV 3R ltRtV tR# )ManifestEntryz>Represents an entry within a manifest section of a patch file.c                sV   < V ^8  d   Qh/ S[ ;R&   S[;R&   S[ ;R&   S[ ;R&   S[;R&   # )r    r"   r#   r%   r'   r&   )r)   r*   r+   r,   r.   r   r/   ZManifestEntry.__annotate__3   sA      I	  I  K  I  K r   r   Nr0   r2   r3   r   r4   r4   3   s     H  r   r4   c                   s0   a  ] tR t^Ct o RtV 3R ltRtV tR# )ContentzQRepresent a child of the root section, containing patch sections of a patch file.c                s   < V ^8  d   Qh/ S[ S[,          ;R&   S[ S[,          ;R&   S[ S[,          ;R&   S[ S[,          ;R&   S[;R&   S[;R&   # )r    manifestaddupdatedeleteZsourceZtarget)listr4   r   r*   r,   r.   r   r/   ZContent.__annotate__C   sb      =!! 
 
e  K  K  K  K r   r   Nr0   r2   r3   r   r5   r5   C   s     [  r   r5   c                   s0   a  ] tR t^Qt o RtV 3R ltRtV tR# )ContentContainerz+Represent the root section of a patch file.c                sz   < V ^8  d   Qh/ S[ S[,          ;R&   S[S[S[3,          ;R&   S[S[S[3,          ;R&   # )r    ZcontentsZ	signatureZ
public_key)r:   r5   tupler(   r,   r.   r   r/   ZContentContainer.__annotate__Q   sB      7m 
 UE\""  eUl## r   r   Nr0   r2   r3   r   r;   r;   Q   s     5  r   r;   c                   s   a  ] tR t^bt o RtV 3R lR ltV 3R lR ltV 3R lR ltV 3R lR	 ltV 3R
 lR lt	V 3R lR lt
V 3R lR ltV 3R lR ltV 3R lR ltRtV tR# )CustomPatchera  Class for updating the contents within a compatibility tool directory.

Intended to update supported tools like Proton and the Steam Linux Runtime within
$XDG_DATA_HOME/umu.

Given a patch file and two directories, 'a' and 'b', that have similar structure
and where 'a' is already present on the system, will update all the contents within
'a' to recreate 'b'. The patch file format will drive behavior and will contain all
the necessary data and metadata to create 'b'.
c                s0   < V ^8  d   QhRS[ RS[RS[RR/# )r    contentcompat_toolthread_poolreturnN)r5   r   r   r,   r.   r   r/   CustomPatcher.__annotate__n   s3     ( (( ( (	(
 
(r   c                s    Wn         V P                   R ,          V n        W n        W0n        . V n        . V n        . V n        R# )r6   N)_arc_contents_arc_manifest_compat_tool_thread_pool_add_update_verify)selfr>   r?   r@   s   &&&&r   __init__ZCustomPatcher.__init__n   s>     '.262D2DZ2P''"$	%'%'r   c                   < V ^8  d   QhRR/# r    rA   Nr   r,   r.   r   r/   rB      s      d r   c                s   V P                   R,           EF7  pV P                  P                  VR,          4      pVR,          \        P                  P
                  8X  dB   V P                  P                  V P                  P                  V P                  W!4      4       K  VR,          \        P                  P
                  8X  d   VP                  VR,          4       K  VR,          \        P                  P
                  8X  d   VP                  VR,          RRR7       EK  \        P                   ! RVR,          VR,          4       EK:  	  R	# )
a3  Add binaries within a compatibility tool.

Handles the case where the subdirectory contents in 'b' are not in 'a'.

Will only operate on files, links and directories. Files will be recreated by
decompressing the data in the patch item. Links will be symlinked to its target
and directories will be created.
r7   r#   r$   r!   r"   T)r"   Zexist_okZparentsz6Found file '%s' with type '%s', skipping its inclusionN)rC   rE   joinpathr   r   valuerG   appendrF   submit_write_proton_filer   
symlink_tor   Zmkdirr   warningrJ   item
build_file   &  r   add_binariesZCustomPatcher.add_binaries   s     &&u--D#0099$v,GJF|x}}222		  %%,,T-D-DjW F|x}}222%%d6l3F|x||111  d6lT4 PKKHVV .r   c                rL   rM   r   r,   r.   r   r/   rB      s       r   c                s   V P                   R,           EFK  pV P                  P                  VR,          4      pVR,          \        P                  P
                  8X  dB   V P                  P                  V P                  P                  V P                  W!4      4       K  VR,          \        P                  P
                  8X  d"   \        P                  ! W!R,          RR7       K  VR,          \        P                  P
                  8X  d,   VP                  4        VP!                  VR,          4       EK%  \"        P$                  ! RVR,          VR,          4       EKN  	  R	# )
a  Update binaries within a compatibility tool.

Handles the case where the subdirectory contents between 'a' and 'b' differ,
where 'b' is the new version.

Will apply a binary patch for files that need to be updated. Directories will
have its permissions changed. Links will be deleted.
r8   r#   r$   r"   FZfollow_symlinksr!   3Found file '%s' with type '%s', skipping its updateN)rC   rE   rN   r   r   rO   rH   rP   rF   rQ   _patch_proton_filer   oschmodr   unlinkrS   r   rT   rU   rX   r   update_binariesZCustomPatcher.update_binaries   s     &&x00D#0099$v,GJF|x}}222##%%,,T-D-DjW F|x||111&\5IF|x}}222!!#%%d6l3KKEVV# 1r   c                rL   rM   r   r,   r.   r   r/   rB      s       r   c           
     sl   V P                   R,           EF  pVR,          \        P                  P                  8X  g'   VR,          \        P                  P                  8X  d5   V P
                  P                  VR,          4      P                  RR7       K  VR,          \        P                  P                  8X  dL   V P                  P                  \        \        V P
                  P                  VR,          4      4      4       K  \        P                  ! RVR,          VR,          4       EK  	  R# )zDelete obsolete binaries within a compatibility tool.

Handles the case where the subdirectory contents of 'a' are not in 'b',
where 'b' is the new version.

Will only operate on links, normal files, and directories while skipping
everything else.
r9   r$   r#   TZ
missing_okr[   N)rC   r   r   rO   r   rE   rN   r_   r   rF   rQ   r	   r*   r   rT   rJ   rV      & r   delete_binariesZCustomPatcher.delete_binaries   s     &&x00DV 3 33<8==#6#66!!**4<8??4?PF|x||111!!((C 1 1 : :4< HI KKEVV 1r   c                rL   rM   r   r,   r.   r   r/   rB      s      $ r   c                s    V P                    FM  pV P                  P                  V P                  P	                  V P
                  V P                  V4      4       KO  	  R# )zJVerify the expected mode, size, file and digest of the compatibility tool.N)rD   rI   rP   rF   rQ   _check_binariesrE   rb   rc   r   verify_integrityZCustomPatcher.verify_integrity   sI    &&DLL!!(()=)=t?P?PRVW 'r   c                sj   < V ^8  d   QhRS[ S[S[,          S[S[,          S[S[,          3,          /# )r    rA   )r<   r:   r    r,   r.   r   r/   rB      s,     7 7d6lDL$v,FG 7r   c                sH    V P                   V P                  V P                  3# )z)Return all the currently submitted tasks.)rI   rG   rH   )rJ   s   &r   resultZCustomPatcher.result   s    dii66r   c                s,   < V ^8  d   QhRS[ RS[RS[/# )r    protonrV   rA   )r   r4   r,   r.   r   r/   rB      s"      d - M r   c           	     s   VP                  VR ,          4      p VP                  R4      ;_uu_ 4       p\        P                  ! VP	                  4       4      p^ pVR,          VP
                  8w  d%   RVR,           RVP
                   2p\        V4      hVR,          VP                  8w  d%   RVR,           RVP                   2p\        V4      hVP
                  \        8  d_   \        VP	                  4       ^ \        R7      ;_uu_ 4       p\        V4      pVP                  \        ^ VP
                  4       RRR4       M\        VP                  4       4      pVR	,          V8w  d   R
VR	,           RV 2p\        V4      h RRR4       V#   + '       g   i     LC; i  + '       g   i     T# ; i  \         d    \         P"                  ! RT4       h i ; i)r#   Zrbr'   zExpected size , received r"   zExpected mode ZlengthZaccessNr%   Expected xxhash z+Aborting partial update, file not found: %s)rN   openr]   Zfstatfilenost_size
ValueErrorZst_modeMMAP_MINr   r   r   madviser   readZFileNotFoundErrorr   Zdebug)	rJ   rh   rV   Zrpathfpstatsr%   errmms	   &&&      r   re   ZCustomPatcher._check_binaries   s   ood6l3	D!!R(*(=<5==0!/V~[XC$S/)<5==0!/V~[XC$S/)==8+biik!KHHB "32!6

=!U]]C	 IH /rwwy9F>V+!1$x.1AVHUC$S/) ,# "0  IH "!0 	 ! 	IICUK	sB   F8 CF$-F	<A
F$F8 F!F$$F5	/F8 5F8 8$Gc                *   < V ^8  d   QhRS[ RS[RR/# r    pathrV   rA   Nr   r   r,   r.   r   r/   rB     s'     M Mt M5 MT Mr   c                s    VR ,          pVR,          pVR,          pVR,          pVR,          \         P                  P                  8X  d^   VP                  4       '       dH   V P                  P                  VR,          4      pVP                  RR7       V P                  Wr4       R#  \        P                  ! VR	R
R7       VP                  R4      ;_uu_ 4       p\        P                  ! VP                  4       4      p	^ p
\        V	P                  V4      P                  4       \         8  d   VP#                  V4       VP%                  V4       \        P&                  ! VP                  4       ^ \        P(                  4       \+        VP-                  4       4      p
W8w  d'   RV RV
 RV RV	P                   RV 2
p\/        V4      h\        P0                  ! VP                  4       V4        RRR4       R# \3        VP                  4       ^ \4        R7      ;_uu_ 4       p\7        VRR7      p\8        P:                  \<        /pV	P                  V8  d   VP?                  V4       \A        W=PB                  VR7      VRV% WiP                  8  d   VP?                  V4       \+        V4      p
W8w  d'   RV RV
 RV RV	P                   RV 2
p\/        V4      hVPE                  \F        ^ V4       RRR4       \        P0                  ! VP                  4       V4       RRR4       R#   + '       g   i     L?; i  + '       g   i     R# ; i  \H         d4   p\J        PL                  ! T4       \J        PN                  ! RT4       h Rp?ii ; i)r!   r%   r"   r'   r$   r#   Tra   Ni  FrZ   zrb+rk   ri   z for file 'z' truncating from size z -> rj   )Zis_raw)Z	zstd_dictZoptionz0File '%s' may be corrupt and has mode bits 0o700)(r   r   rO   Z
is_symlinkrE   rN   r_   rR   r]   r^   rl   Zstatrm   Zmaxrn   Z
bit_lengthZSTD_WINDOW_LOG_MINZwritetruncateZlseekZSEEK_SETr   rr   ro   fchmodr   r   r   r   ZwindowLogMaxZSTD_WINDOW_LOG_MAXZresizer   Z	as_prefixrq   r   ZBaseExceptionr   Z	exceptionrT   )rJ   ry   rV   Zbdiffdigestr"   r'   rW   rs   rt   r%   ru   rv   Zzst_dictZzst_optZes   &&&             r   r\   Z CustomPatcher._patch_proton_file  s   F|8nLLLHMM///T__5F5F#0099$v,GJKK4K(##J5A	 HHT5%8 5!!R(*		(< u}}d+668;NNHHUOKK%HHRYY[!R[[9.rwwy9F'.vhk& J  $v%<U]]O4PTvW  )o-IIbiik40) "!. "))+aEE'48H)668KLG }}t+		$ !+););G!BuI
 mm+		$ /r2F'.vhk& J%%)F*A%--PTUYTZ\  )o-JJ}a69 F> 		"))+t,m "!. FE/ "!!n  	MM!KKJDQ	s\   )2M DL;0M :(L;"CL(	1-L;M (L83L;;M	M M N.NNc                rw   rx   rz   r,   r.   r   r/   rB   P  s"     3 3t 35 3T 3r   c                sH   VR ,          pVR,          pVR,          pVR,          p\        VP                  4      ;_uu_ 4       p^ pVP                  V4       \        VP	                  4       ^ \
        R7      ;_uu_ 4       p	\        V4      V	R&   \        V	4      pW8w  d(   RV RV RVP	                  4        R	V 2p
\        V
4      hVP                  R
4      ;_uu_ 4       p\        P                  ! VP	                  4       VP	                  4       ^ V4       \        P                  ! VP	                  4       V4       RRR4       V	P                  \        ^ V4       RRR4       RRR4       R#   + '       g   i     L9; i  + '       g   i     L-; i  + '       g   i     R# ; i)r!   r%   r"   r'   rj   :NNNrk   ri   z for fd z from source ZwbN)r   r#   r|   r   rm   r   r   r   ro   rl   r]   Zsendfiler}   rq   r   )rJ   ry   rV   r!   r   r"   r'   rs   r%   rv   ru   r   s   &&&         r   rR   Z CustomPatcher._write_proton_fileP  s9   6l8nLLtyy!!RFKK biik!LAAR"4(1*2.#*6(+fXX99;-}TF<  %S/)YYt__KKryy{AtDIIdkkmT2 % 

=!T2! B "!$ %_ BA "!!s>   <F>A E=	AE*9E=	F*E:5E=	=FFF!	)rG   rC   rD   rE   rF   rH   rI   N)r   r   r   r   r   rK   rY   r`   rd   rf   rg   re   r\   rR   r   r1   r2   r3   r   r=   r=   b   sh     	( (" < @ 6 7 7 <M M^3 3r   r=   i @  )&r]   Zconcurrent.futuresr    r   Z
contextlibr   Zenumr   r   r   r   r   Zpathlibr   Zshutilr	   Ztypingr
   Zumu.umu_logr   Zumu.umu_utilr   ZModuleNotFoundErrorZpyzstdr   r   r   r%   r   r   r   r4   r5   r;   rp   r{   r~   r=   r   r   r   <module>r      s    	 9   ? ?     "!""77( #

t 
I (I  i $y $   J3 J3k #"s   B55C	