
                            d Z ddlmZ ddlmZ ddlZddlZddlZddlmZ	 ddl
mZ ddlmZ  ej                  d	      Zej!                  d
dd       ej!                  ddd       ej!                  ddd       ej!                  ddd       ej!                  ddd       ej!                  ddd       ej!                  ddd       ej!                  ddd       d Zedk(  r e        yy)z;This package flattens image metadata into a single tarball.    )absolute_import)print_functionN)docker_image)logging_setup)zipzFlatten container images.)descriptionz	--tarballstorez&An optional legacy base image tarball.)actionhelpz--configz.The path to the file storing the image config.z--digestappendz,The list of layer digest filenames in order.z--layerz0The list of compressed layer filenames in order.z--uncompressed_layerz2The list of uncompressed layer filenames in order.z	--diff_idzThe list of diff_ids in order.z--filesystemz2The name of where to write the filesystem tarball.z
--metadataz:The name of where to write the container startup metadata.c                     t        j                  t               t        j                         } t        j                  |        | j
                  rPt        j                  d| j
                         t        | j
                  d      5 }|j                         }d d d        nq| j                  rYt        j                  d| j                         t        j                  | j                        5 }|j                         }d d d        n| j
                  }t        t        | j                   xs g | j"                  xs g             }t        t        | j$                  xs g | j&                  xs g             }t        j                  d       t        j(                  ||| j                        5 }t+        j                  | j,                  dd	      5 }t        j.                  ||       d d d        t        | j0                  d
      5 }|j3                  |j                                d d d        d d d        y # 1 sw Y   -xY w# 1 sw Y   :xY w# 1 sw Y   jxY w# 1 sw Y   8xY w# 1 sw Y   y xY w)N)argszReading config from %rrzReading config from tarball %rz Loading v2.2 image From Disk ...)config_filelayersuncompressed_layerslegacy_basezw:zutf-8)encodingw)r   DefineCommandLineArgsparser
parse_argsInitconfiglogginginfoopenreadtarball
v2_2_imageFromTarballr   listr   digestlayerdiff_iduncompressed_layerFromDisktarfile
filesystemextractmetadatawrite)	r   readerr   baser   r   v2_2_imgtarfs	            8lib/third_party/containerregistry/tools/fast_flatten_.pymainr3   E   s   %%f-				$$ 
[[LL)4;;7	dkk3	6{{}f 
 	||LL14<<@				-!f 
.	- [[FDKK%2tzz'7R89&	$,,
"d55;<>	,,12-,,	  $,	dootg	>#3' 
? 
dmmS	!Qggh""$% 
"    
 	 
.	- 
?	> 
"	!   sT   H4+I+#I&I%I& I#I&4H>II	I&I#	I&&I/__main__)__doc__
__future__r   r   argparser   r(   containerregistry.client.v2_2r   r    containerregistry.toolsr   	six.movesr   ArgumentParserr   add_argumentr3   __name__     r2   <module>r@      sB   B & %    D 1 	 	 	 -H	I   &N  P   	9  ;
   	7  9
   	;  =
   	=  ?
   'G  I   	=  ?
      &D z& r?   