+
    h  c                   sX    ^ RI t ^ RIt^ RIt^ RIt^RIHt R tRR ltR tR t	RR lt
R# )	i    N)logc                 s   \         P                  ! R 4       \        P                  ! . RO\        P                  \        P                  VR7      p\        P                  ! . ROVP
                  \        P                  \        P                  VR7      p\        V R4      p\        P                  ! R.VP
                  V\        P                  R7      pVP                  4        VP                  4        VP                  4        VP                  4        VP                  P                  4       pVP                  P                  4       pVP                  P                  4       pV'       d   \         P                  ! RV4       V'       d   \         P                  ! RV4       V'       d   \         P                  ! RV4       VP                  ^ 8w  g#   VP                  ^ 8w  g   VP                  ^ 8w  d   \        R	4      hR
# )zAppending to the initrd.)stdoutstderrcwd)stdinr   r   r   ZabZgzip)r   r   r   zfind stderr=%szcpio stderr=%szgzip stderr=%sz"Failed to inject files into initrdN)ZfindZ.z-print0)Zcpioz--createz--nullz--quietz--format=newcz--owner=0:0)r    debug
subprocessZPopenZPIPEr   ZopenZwaitZcloser   ZreadZ
returncodeZRuntimeError)	initrdtempdirZ	find_procZ	cpio_procZfZ	gzip_procZfinderrZcpioerrZgziperrs	   &&       ;/usr/share/virt-manager/virtinst/install/installerinject.py_run_initrd_commandsr
      sj   II()   V]I   QI 	VTA  &1A1A!T^TcTcdINNNNNNGGI##%G##%G##%G		"G,		"G,		"G, 	!Y%9%9Q%>)BVBVZ[B[?@@ C\    c                 sn   . ROpV F!  p\         P                  ! V4      '       g   K!   M	  XRV RRRR.pV'       d   VP                  RR.4       VP                  V4       \        P
                  ! RV4       \        P                  ! V\        P                  R	7      p\        P
                  ! R
V4       R# )	xorrisofsz-oz-Jz-input-charsetZutf8z-rational-rockz-VZcidatazRunning iso build command: %s)r   zcmd output: %sN)r   ZgenisoimageZmkisofs)	shutilZwhichZextendZappendr    r   r   Zcheck_outputZSTDOUT)isor   	cloudinitZprogramsZprogramZcmdZoutputs   &&&    r	   _run_iso_commandsr   3   s     7H<<    D#t%5v?O
PC

D(#$JJwII-s3$$S1B1BCFII'r   c                 s    V '       g   R # \         P                  ! VR7      p \        P                  ! VR4       V  F  p\	        V4      \
        J d   Vw  rgM\        P                  P                  V4      p\        P                  ! RWgV4       \        P                  ! V\        P                  P                  WW4      4       K  	  V! W%3/ VB \        P                  ! V4       #   \        P                  ! T4       i ; i)N)diri  z%Injecting src=%s dst=%s into media=%s)tempfileZmkdtemposZchmodZtypeZtupleZpathZbasenamer    r   r   ZcopyZjoinZrmtree)
injections
scratchdirZmediaZcbZkwargsr   ZfilenameZdsts   &&&&,   r	   _perform_generic_injectionsr   G   s    :.G
% "HH~& (#gg&&x0II=xeTKK"'',,w"<= # %+F+ggs   B+C% %C=c                s(    \        WV \        4       R# )z>
Insert files into the root directory of the initial ram disk
N)r   r
   )r   r   r   s   &&&r	   perform_initrd_injectionsr   ]   s      
@TUr   c                s    V'       d   RpMRp\         P                  ! RW1RR7      pVP                  p \        WV\        VR7       V#   \
         d    \        P                  ! T4       h i ; i)z;
Insert files into the root directory of a generated cdrom
z-cloudinit.isoz-unattended.isoz	virtinst-F)ZprefixZsuffixr   Zdelete)r   )r   ZNamedTemporaryFileZnamer   r   Z	Exceptionr   Zunlink)r   r   r   Z
iso_suffixZfileobjr   s   &&&   r	   perform_cdrom_injectionsr   d   sp     %
&
)):eG ,,C#C):i	
 J	  
		#s   A	 	#A,)F)r   r   r   r   Zloggerr    r
   r   r   r   r   ) r   r	   <module>r      s2    
    !AH((,Vr   