+
    oFj-3                         R t ^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RI	t^ RI
Ht R tR tR
R ltR R ltRR R	 lltR# )zFunctions to manage sandboxes.N)implc                   / pV P                  RR4       RV P                  RR4       2P                  4        F9  pVP                  4       '       g   K   VP                  4       R,          w  r4YAT&   K;  	  \        VP                  4       4      #   \         d%    \
        P                  P                  RT4        K  i ; i)zDetermine necessary packages for given report.

Return list of (pkgname, version) pairs. version might be None for unknown
package versions.
Package 
DependenciesN   N%invalid Package/Dependencies line: %s)
get
splitlinesstripsplit
ValueErrorapportloggingwarninglistitems)reportpkgslinepkgversions   &    5/usr/lib/python3/dist-packages/apport/sandboxutils.pyneeded_packagesr      s     D ::i$
%R

>2(F'GHjl zz||	::<+LC
 S	 

  	NN""#JDQ	s   B+B=<B=c                R   / pV P                  RR4       RV P                  RR4       2P                  4        F9  pVP                  4       '       g   K   VP                  4       R,          w  r4YAT&   K;  	  V#   \         d%    \
        P                  P                  RT4        Km  i ; i)z1Return package -> version dictionary from report.r   r   r   r   r   r
   )r   r   r   r   r   r   r   r   )r   pkg_versr   r   r   s   &    r   report_package_versionsr   2   s    H::i$
%R

>2(F'GHjl zz||	::<+LC
   O  	NN""#JDQ	s   A77+B&%B&c           
     
   \        4       p\        4       pRV 9   d   V R,          P                  4        F  pVP                  4       '       g   K  VP                  4       p\	        V4      R9   g   K=  RV^,          9   g   KM  RV^,          9   g   K]  \
        P                  P                  V^,          4      pVP                  V4       K  	  M4\        P                  P                  V R,          4      P                  4       p\
        P                  P                  V4      '       g   \
        P                  ! V4       V F  p\        P                   ! VRVV R,          V P#                  R4      R7      p	V	'       dB   V'       d'   \        P$                  P'                  R	V R
V	 R24       VP                  V	4       K}  \        P$                  P)                  RV4       K  	  V U
u. uF  qVP#                  V
4      3NK  	  up
# u up
i )a  Determine necessary runtime packages for given report.

This determines libraries dynamically loaded at runtime in two cases:
1. The executable has already run: /proc/pid/maps is used, from the report
2. The executable has not already run: shared_libraries() is used

The libraries are resolved to the packages that installed them.

Return list of (pkgname, None) pairs.

When pkgmap_cache_dir is specified, it is used as a cache for
get_file_package().
ProcMapsxz.soExecutablePathTDistroReleaseArchitecturereleasearchzdynamically loaded z needs package z
, queueingz/%s is needed, but cannot be mapped to a package>         )setr   r   r   lenospathrealpathaddr   	fileutilsshared_librariesvaluesexistsmakedirs	packagingget_file_packager   r   logr   )r   pkgmap_cache_dirpkg_versionsverboser   libsr   colslibr   ps   &&&&       r   needed_runtime_packagesr?   E   s     5D5DV:&113D::<<::<D4yF"sd1g~%47:Jgg&&tAw/ 4 008H1IJQQS77>>*++
$% ((?+N+
 "")$se:N HHSMNN""A4 & /33d  #$d333s   "H c                n    V ^8  d   QhR\         \        \        R\        ,          3,          ,          RR/# )r	   r   Nreturn)r   tuplestr)formats   "r   __annotate__rE   |   s,      eCO&<!= $     c                z    \        V 4       F+  w  pw  r#VR8X  g   K  V P                  V4       RV3.V R&    R# 	  R# )z2Move base-files to the front or add it if missing.z
base-files:N    NN)	enumeratepop)r   ir   r   s   &   r   _move_base_files_firstrL   |   s>    &t_>C,HHQK%w/0DH	 -rF   c                &   V ^8  d   QhR\         P                  P                  R\        R,          R\        R,          R\        R,          R\        \        ,          R,          R\
        R\
        R	\
        R
\        \        \        \        3,          /	# )r	   r   
config_dirN	cache_dirsandbox_dirextra_packagesr:   log_timestampsdynamic_originsrA   )r   r   ReportrC   r   boolrB   )rD   s   "r   rE   rE      s     Z0 Z0MM  Z0d
Z0 TzZ0 t	Z0
 I$Z0 Z0 Z0 Z0 3S=Z0rF   c                   V'       d^   \         P                  P                  V4      p\         P                  P                  V4      '       g   \         P                  ! V4       RpM>\
        P                  ! RR7      p\        P                  ! \        P                  V4       RpV'       d!   \         P                  P                  V4      pM<\
        P                  ! RR7      p\        P                  ! \        P                  V4       \         P                  P                  W R,          4      p	. p
RV 9  g/   RV P                  R	R
4      V P                  RR
4      ,           9   d   \        V 4      p
VR8X  d   RpRpV'       d   V P                  R	R
4       RV P                  RR
4       2p\        P                  ! R4      p\!        VP#                  V4      4      pV'       d#   \$        P&                  P)                  RV 24       \+        V
4        \,        P.                  ! VVV R,          V
VVVV P                  R4      VR7	      pV'       dR    X\,        P.                  ! TTV R,          V Uu. uF  pVR3NK	  	  upVVVV P                  R4      VRRR7      ,          p\7        V 4      p\9        W	VV4      p
R# F  pVV 9   g   K  \,        P:                  ! V V,          RV	V R,          V P                  R4      R7      pVR8X  d   V R,          R8X  d   RV R&   RpV'       dK   \$        P&                  P)                  RV RV 2V4       V
P=                  VVP                  V4      34       K  \$        P&                  P3                  RVV V,          4       K  	  V
'       d>    X\,        P.                  ! VVV R,          V
VVVV P                  R4      VR7	      ,          pR	V 9   Ed#   R# EF  pVV 9   g   K  \         P                  P?                  W0V,          ,           4      '       d   KA  V V,          PA                  R4      '       d   \         P                  P?                  W0V,          R,          ,           4      '       d   V V,          R,          V V&   K  \$        P&                  P3                  R VW0V,          ,           V R	,          4       K  \$        P&                  P3                  R VW0V,          ,           V R	,          4       EK  	  X'       d   WR!&   \$        P&                  PC                  R"4       W2V3#   \0         d5   p\$        P&                  P3                  R\5        T4      4        Rp?EL)Rp?ii ; iu upi   \0         d5   p\$        P&                  P3                  R\5        T4      4        Rp?ELRp?ii ; i  \0         d5   p\$        P&                  P3                  R\5        T4      4        Rp?ELRp?ii ; i)$a  Build a sandbox with the packages that belong to a particular report.

This downloads and unpacks all packages from the report's Package and
Dependencies fields, plus all packages that ship the files from ProcMaps
(often, runtime plugins do not appear in Dependencies), plus optionally
some extra ones, for the distro release and architecture of the report.

For unpackaged executables, there are no Dependencies. Packages for shared
libraries are unpacked.

report is an apport.report.Report object to build a sandbox for. Presence
of the Package field determines whether to determine dependencies through
packaging (via the optional report['Dependencies'] field), or through ldd
via needed_runtime_packages() -> shared_libraries().  Usually
report['Architecture'] and report['Uname'] are present.

config_dir points to a directory with by-release configuration files for
the packaging system, or "system"; this is passed to
apport.packaging.install_packages(), see that method for details.

cache_dir points to a directory where the downloaded packages and debug
symbols are kept, which is useful if you create sandboxes very often. If
not given, the downloaded packages get deleted at program exit.

sandbox_dir points to a directory with a permanently unpacked sandbox with
the already unpacked packages. This speeds up operations even further if
you need to create sandboxes for different reports very often; but the
sandboxes can become very big over time, and you must ensure that an
already existing sandbox matches the DistroRelease: and Architecture: of
report. If not given, a temporary directory will be created which gets
deleted at program exit.

extra_packages can specify a list of additional packages to install which
are not derived from the report and will be installed along with their
dependencies.

If verbose is True (False by default), this will write some additional
logging to stdout.

If log_timestamps is True, these log messages will be prefixed with the
current time.

If dynamic_origins is True (False by default), the sandbox will be built
with packages from foreign origins that appear in the report's
Packages:/Dependencies:.

Return a tuple (sandbox_dir, cache_dir, outdated_msg).
Tapport_sandbox_)prefixFapport_cache_r#   r    z[originr   r   r   systemNr   z+\[origin: ([a-zA-Z0-9][a-zA-Z0-9\+\.\-]+)\]z	Origins: r$   )architectureoriginsz%s)r[   r\   install_dbginstall_depsr"   r%   	systemctlSourcePackagesystemdz/bin/systemctlzInstalling extra package z to get z%Cannot find package which ships %s %sz/usr:   NNz2%s %s does not exist (report specified package %s)RetraceOutdatedPackageszbuilt sandbox)InterpreterPathr"   )"r,   r-   abspathisdirr4   tempfilemkdtempatexitregistershutilrmtreejoinr   r   recompiler*   findallr   r   r7   rL   r5   install_packagesSystemErrorfatalrC   r   r?   r6   appendr3   
startswithmemdbg)r   rN   rO   rP   rQ   r:   rR   rS   permanent_rootdirr8   r   r\   pkg_listmatchoutdated_msgerrorr>   r9   r-   r   s   &&&&&&&&            r   make_sandboxr|      s   z ggook2ww}}[))KK$ &&.?@{3! GGOOI.	$$O<	y1ww||Io/FGD
 9

9b!FJJ~r$BB$ v&X
GjjB/06::nb3Q2RS

IJemmH-.NN7)45 4 / 11?#N3

 	3I66'$23Nq!TN3!#ZZ7!! L  +62L"6\7SD 66>,,t /ZZ/C k!/*i7/?F+,#C""/uHTFC^ S,"2"23"789$$;T6$</ 68 	3I66'!#ZZ7
 
L$ F9Dv~bggnn[$<5O&P&P$<**622ww~~k4L4D&DEE'-d|B'7t,,P ',6"9-	 NN((L#Tl2y)	 :( ,8()
NN/*<//K  /T3u:../ 4  	3NN  s5z22	3b  	3NN  s5z22	3sZ   5T4 U; -U6:$U; <V= 4U3?)U..U36U; ;V:)V55V:=W<)W77W<)F)NNNFFF)__doc__ri   r,   rn   rk   rg   apport.fileutilsr   apport.loggingapport.reportapport.packaging_implr   r5   r   r   r?   rL   r|    rF   r   <module>r      sF    $  	 	      32&44nZ0 Z0rF   