+
    AiO)                        ^ 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	t	Rt
Rt] P                  P                  R4      tRtRtR	tR
t] P&                  ! ]RR7       ] P&                  ! ]
RR7       R tR tR tR tR tR tR tR tR tR R lt]! RR4       ]! RR4       R$R ltR%R ltR&R lt R'R lt!R t"R  t#R! t$R" t%R# t&R# )(    N)urlparse)tqdmz/tmp/fempkgbuildz/var/lib/fempkg/pkgsz/var/lib/fempkg/repoz/var/lib/fempkg/manifestsz!/var/lib/fempkg/manifest-versionsz/var/lib/fempkg/local-manifestsz/var/lib/fempkg/binpkgTexist_okc                      \         P                  ! V R R7       R#   \         d,   pTP                  \        P                  8w  d   h  Rp?R# Rp?ii ; i)Tr   N)osmakedirsOSErrorerrnoEEXIST)pathes   & /usr/bin/utils.py_ensure_dirr   (   s=    
D4( 77ell" #s    A AAc                 *    R  pV! V 4      V! V4      8  # )c                     V P                  R R4      P                  R4      p. pV F5  pTP                  VP                  4       '       d   \	        V4      MT4       K7  	  V# )-.)replacesplitappendisdigitint)vpartsparsedps   &   r   parse version_satisfies.<locals>.parse0   sM    		#s#))#.AMMAIIKK#a&Q7      )	installedlatestr   s   && r   version_satisfiesr$   /   s     uV},,r    c                 l   \         P                  P                  R4      R8X  d   \        P                  ! 4       p RV n        \        P                  V n        \        P                  P                  \        P                  P                  V R7      4      p\        P                  P                  V4       R# R# )z2Sets up insecure SSL handling if FEMPKG_INSECURE=1FEMPKG_INSECURE1F)contextN)r   environgetsslcreate_default_contextcheck_hostname	CERT_NONEverify_modeurllibrequestbuild_openerHTTPSHandlerinstall_opener)ctxopeners     r   %_install_insecure_opener_if_requestedr7   8   sw    	zz~~'(C/((*"--,,V^^-H-HQT-H-UV%%f- 0r    c                     \        V 4      p\        P                  P                  VP                  4      pT;'       g    R # )zdownloaded.file)r   r   r   basename)urlr   names   &  r   _safe_basename_from_urlr<   A   s2    c]F77FKK(D$$$$r    c                     R F+  pV P                  V4      '       g   K  V R\        V4      )  u # 	  \        P                  P	                  V 4      ^ ,          # ).tar.gzN)r>   z.tar.bz2z.tar.xzz.tgzz.tar)endswithlenr   r   splitext)r;   exts   & r   _strip_archive_extrC   F   sK    A==
#c(## B 77D!!$$r    c                   \         P                  P                  \         P                  P                  V 4      4      ^ ,          p\         P                  P	                  \
        V4      p\         P                  P                  V4      '       d   \        P                  ! V4       \         P                  ! \
        RR7       \        P                  ! RRW.4       V# )z%Clone a git repository into BUILD_DIRTr   gitclone)r   r   rA   r9   join	BUILD_DIRexistsshutilrmtreer	   
subprocess
check_call)r:   	repo_namedests   &  r   _clone_git_reporP   L   s      !1!1#!67:I77<<	9-D	ww~~ddKK	D)5'356Kr    c                 \   \        4        \        P                  ! \        P                  P	                  V4      R R7       \        P
                  P                  R4      R8g  pRR/p\        P                  ! WR VR7      ;_uu_ 4       pVP                  4        \        VP                  P                  R^ 4      4      pRp\        VR4      ;_uu_ 4       p\        VR	R R
\        P                  P                  V4       2R7      ;_uu_ 4       pVP                  VR7       F8  p	V	'       g   K  VP                  V	4       VP!                  \#        V	4      4       K:  	  RRR4       RRR4       RRR4       R#   + '       g   i     L"; i  + '       g   i     L-; i  + '       g   i     R# ; i)Tr   r&   r'   z
User-AgentzeMozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.0.0 Safari/537.36)headersstreamverifyzcontent-lengthwbBzDownloading )totalunit
unit_scaledesc)
chunk_sizeNi   )r7   r   r	   r   dirnamer)   r*   requestsraise_for_statusr   rR   openr   r9   iter_contentwriteupdater@   )
r:   rO   
verify_sslrR   r
total_sizer[   fpbarchunks
   &&        r   download_tori   W   s6   )+KK%5  12c9J 	}G 
c4
	K	Kq	'7;<
 
$D 0 0 678	%
 %

 :>5GGENKKE
+ ?%
 
L	K
%
 %
 
L	K	KsC   AF8F	E4+/E4F	"F4F?F	FFF+	c                    \        4        VR 8X  d   \        V 4      # \        V 4      p\        P                  P                  \        V4      p\        P                  P                  V4      '       g   \        W4       \        P                  P                  \        \        V4      4      p\        P                  P                  V4      '       d   \        P                  ! V4       \        P                  ! V4       V# )rE   )r7   rP   r<   r   r   rG   PKG_DIRrI   ri   rH   rC   rJ   rK   r	   )r:   source_typer9   tarball_pathdest_dirs   &&   r   download_extractro   s   s    )+es##&s+H77<<2L77>>,''C&ww||I'9('CDH	ww~~hhKKOr    c                   \         P                  P                  V 4      '       du   \         P                  P                  V 4      p\         P                  P	                  V4      '       d   \
        P                  ! VRR7       \         P                  ! V 4       R# \         P                  P	                  V 4      '       d   \
        P                  ! V RR7       R# R# )z*Remove path recursively or symlink target.Tignore_errorsN)r   r   islinkrealpathrI   rJ   rK   unlink)r   	real_paths   & r   safe_rmtreerw      s{    	ww~~dGG$$T*	77>>)$$MM)48
		$			d$/ 
r    c                0    V ^8  d   QhR\         R\         /# )   srctarget)str)formats   "r   __annotate__r~      s     	 	 	c 	r    c                    \         P                  P                  V 4      '       d5   \         P                  ! V 4      V8X  d   R # \         P                  ! V 4       M=\         P                  P                  V 4      '       d   \        P                  ! V RR7       \         P                  ! VRR7       \         P                  ! W4       R # )NTrq   r   )
r   r   rs   readlinkru   rI   rJ   rK   r	   symlink)rz   r{   s   &&r   _ensure_symlinkr      so    	ww~~c;;sv%IIcN			c.KK&JJvr    z/tmp/fempkgz/var/tmp/fempkgz/var/tmp/fempkgbuildc           
         V  R 2p\        RV 24        \        P                  ! 4       ;_uu_ 4       pVP                  V4      pVP	                  4        VP
                  P                  4        Uu. uF  qDP                  R4      '       g   K  VNK  	  pp\        VRRR7       F  pV  RV 2p\        P                  P                  \        V4      pVP                  V4      p	V	P	                  4        \        VR4      ;_uu_ 4       p
V
P                  V	P                  4       RRR4       K  	  RRR4       R# u upi   + '       g   i     K  ; i  + '       g   i     R# ; i  \          d   p\        R	T 24        Rp?R# Rp?ii ; i)

/index.txtzFetching recipe index from z
.recipe.pyRecipesfilerZ   rX   /rU   NzError fetching index/recipes: )printr]   Sessionr*   r^   text
splitlinesr?   r   r   r   rG   RECIPE_CACHE_DIRr_   ra   content	Exceptionrepo_url	index_urlsessionrespr   entriesentryr:   	dest_pathrd   rf   s   &          r   fetch_all_recipesr      s@   *J'I	'	{
3447;;y)D!!#"&))"6"6"8U"8QJJ|<Tqq"8GUgIFC!
!E7+GGLL)95A	KK$""$)T**aGGAII& +* D   V +**    4.qc2334e   E% >E0D8D8A3ED="E.E% 8E=E	EE"	E% "E% %F	0FF	c           
         V  R 2p\        RV 24        \        P                  ! 4       ;_uu_ 4       pVP                  V4      pVP	                  4        VP
                  P                  4        Uu. uF  qDP                  R4      '       g   K  VNK  	  pp\        VRRR7       F  pV  RV 2p\        P                  P                  \        V4      pVP                  V4      p	V	P	                  4        \        VR4      ;_uu_ 4       p
V
P                  V	P                  4       RRR4       K  	  RRR4       R# u upi   + '       g   i     K  ; i  + '       g   i     R# ; i  \          d   p\        R	T 24        Rp?R# Rp?ii ; i)
r   zFetching manifest index from .txt	Manifestsr   r   r   rU   Nz Error fetching index/manifests: )r   r]   r   r*   r^   r   r   r?   r   r   r   rG   MANIFEST_CACHE_DIRr_   ra   r   r   r   s   &          r   fetch_all_manifestsr      s@   *J'I	))
5667;;y)D!!#"&))"6"6"8O"8QJJv<Nqq"8GOgKfE!
!E7+GGLL);UC	KK$""$)T**aGGAII& +* F   P +**    604556r   c           	      h   V  R 2p\        RV 24        \        P                  ! 4       ;_uu_ 4       pVP                  V4      pVP	                  4        \
        P                  P                  \        R4      pVP                  V4      pVP	                  4        \        VR4      ;_uu_ 4       pVP                  VP                  4       RRR4       \        R4       RRR4       R#   + '       g   i     L%; i  + '       g   i     R# ; i  \         d   p\        RT 24        Rp?R# Rp?ii ; i)r   zFetching binpkg index from z	index.txtrU   Nz%Binpkg index downloaded successfully.zError fetching binpkg index: )r   r]   r   r*   r^   r   r   rG   BINPKG_CACHE_DIRr_   ra   r   r   )r   r   r   r   r   rd   rf   r   s   &       r   fetch_binpkg_indexr      s    *J'I	'	{
3437;;y)D!!#%5{CII&A i&&!		" '9:   '&    3-aS1223sM   D A;C9-C&		C9D &C61C99D
	D 
D D1D,,D1c                     \         P                  ! R \         R24       \        T ;'       g    R4       \	        T;'       g    R4       \        T;'       g    R4       \        R4       R# )zrm -rf z/*-https://rocketleaguechatp.duckdns.org/recipes/https://rocketleaguechatp.duckdns.org/manifests,https://rocketleaguechatp.duckdns.org/binpkgzKAll recipes, manifests and the binpkg index have been fetched successfully.N)r   systemr   r   r   r   r   )repo_url_recipesrepo_url_manifestsrepo_url_binpkgs   &&&r   	fetch_allr      sW    II(),-&YY*YZ*__._`XX*XY	
WXr    c                    \         P                  ! \        RR7       \         P                  P	                  \        V  RV R24      p\
        P                  ! W#4       V# )zVCopy the current manifest to local-manifests/<pkg>-<version>.txt (temporary snapshot).Tr   r   r   )r   r	   LOCAL_MANIFESTS_DIRr   rG   rJ   copy)pkgnameversionsrc_manifest_pathrO   s   &&& r   save_local_manifest_snapshotr      sE    KK#d377<<+y'$-GHD
KK!(Kr    c                   \         P                  P                  \        V  RV R24      p\         P                  P	                  V4      '       g   R# \         P
                  ! \        RR7       \         P                  P                  \        V  RV R24      p\        P                  ! W#4       \         P                  P                  \        V  R24      p\        P                  ! W44       V# )zOMove local snapshot to the versioned directory and update the current manifest.r   r   NTr   )r   r   rG   r   rI   r	   VERSIONED_MANIFEST_DIRrJ   mover   r   )r   r   local	versionedcurrents   &&   r   promote_local_to_versionedr      s    GGLL,	7)4.HIE77>>%  KK&63y'$5OPI
KK!ggll-'$/?@G
KK	#r    c                     \         P                  P                  \        V  R V R24      p\         P                  P	                  V4      '       d   \         P
                  ! V4       R# R# )r   r   N)r   r   rG   r   rI   remove)r   r   r   s   && r   remove_versioned_manifestr      sG    
+y'$-GHA	ww~~a
		! r    c                ,   \         P                  P                  V 4      '       g   . # \        V 4      ;_uu_ 4       pV Uu. uF*  q"P	                  4       '       g   K  VP	                  4       NK,  	  upuuRRR4       # u upi   + '       g   i     R# ; i)z8Return a list of absolute paths listed in manifest_path.N)r   r   rI   r_   strip)manifest_pathrf   lines   &  r   read_manifest_pathsr      s^    77>>-((		m		)*;jjl

; 
	; 
		s#   B A=A=0B=BB	c                    \         P                  P                  V 4      '       g&   \         P                  P                  V 4      '       d   \         P                  ! V 4       M<\         P                  P                  V 4      '       d    \         P                  ! V 4       \         P                  P                  V 4      pV'       dK   VR8w  dB   VR8w  d9    \         P                  ! V4       \         P                  P                  T4      pKN  R# R# R#   \         d     R# i ; i  \         d     R# i ; i  \         d   p\        RT  RT 24        Rp?R# Rp?ii ; i)zERemove a file and try to prune empty parents up to / (but stop at /).Nr    z#[fempkg] Warning: failed to remove z: )r   r   rs   isfiler   isdirrmdirr
   r\   r   r   )r   parentr   s   &  r   delete_file_and_prune_dirsr     s    A77>>$277>>$#7#7IIdOWW]]4  
 &36R<  WW__V,F ,8f      A3D6A3?@@Asp   $D6 $D6 ;D6 	D &D6 D6 D$ +!D6 D!D6  D!!D6 $D3/D6 2D33D6 6EEE)r   )r   )r   )NNN)'r   rJ   r+   rL   r   r0   urllib.parser   r   r]   rH   rk   r   
expanduserr   r   r   r   r   r	   r   r$   r7   r<   rC   rP   ri   ro   rw   r   r   r   r   r   r   r   r   r   r   r!   r    r   <module>r      s   " 
  
    !   	
 77%%&<= 0 < 7 +  Gd # I %-.%
%,8(0	 0 1 "$: ;4(6(3"Y
<Ar    