@ -760,6 +760,7 @@ class Dependency(gclient_utils.WorkItem, DependencySettings):
bucket = dep_value [ ' bucket ' ] ,
bucket = dep_value [ ' bucket ' ] ,
object_name = dep_value [ ' object_name ' ] ,
object_name = dep_value [ ' object_name ' ] ,
sha256sum = dep_value [ ' sha256sum ' ] ,
sha256sum = dep_value [ ' sha256sum ' ] ,
output_file = dep_value . get ( ' output_file ' ) ,
custom_vars = self . custom_vars ,
custom_vars = self . custom_vars ,
should_process = should_process ,
should_process = should_process ,
relative = use_relative_paths ,
relative = use_relative_paths ,
@ -2503,10 +2504,11 @@ class GcsDependency(Dependency):
""" A Dependency object that represents a single GCS bucket and object """
""" A Dependency object that represents a single GCS bucket and object """
def __init__ ( self , parent , name , bucket , object_name , sha256sum ,
def __init__ ( self , parent , name , bucket , object_name , sha256sum ,
custom_vars, should_process , relative , condition ) :
output_file, custom_vars, should_process , relative , condition ) :
self . bucket = bucket
self . bucket = bucket
self . object_name = object_name
self . object_name = object_name
self . sha256sum = sha256sum
self . sha256sum = sha256sum
self . output_file = output_file
url = ' gs:// {bucket} / {object_name} ' . format (
url = ' gs:// {bucket} / {object_name} ' . format (
bucket = self . bucket ,
bucket = self . bucket ,
object_name = self . object_name ,
object_name = self . object_name ,
@ -2581,7 +2583,8 @@ class GcsDependency(Dependency):
# Directory of the extracted tarfile contents
# Directory of the extracted tarfile contents
output_dir = os . path . join ( root_dir , self . name )
output_dir = os . path . join ( root_dir , self . name )
output_file = os . path . join ( output_dir , gcs_file_name )
output_file = os . path . join ( output_dir , self . output_file
or gcs_file_name )
if not self . IsDownloadNeeded ( output_dir , output_file ) :
if not self . IsDownloadNeeded ( output_dir , output_file ) :
return
return
@ -2601,16 +2604,20 @@ class GcsDependency(Dependency):
os . makedirs ( output_dir )
os . makedirs ( output_dir )
if os . getenv ( ' GCLIENT_TEST ' ) == ' 1 ' :
if os . getenv ( ' GCLIENT_TEST ' ) == ' 1 ' :
# Create fake tar file and extracted tar contents
if ' no-extract ' in output_file :
tmpdir = tempfile . mkdtemp ( )
with open ( output_file , ' w+ ' ) as f :
copy_dir = os . path . join ( tmpdir , self . name , ' extracted_dir ' )
f . write ( ' non-extractable file ' )
if os . path . exists ( copy_dir ) :
else :
shutil . rmtree ( copy_dir )
# Create fake tar file and extracted tar contents
os . makedirs ( copy_dir )
tmpdir = tempfile . mkdtemp ( )
with open ( os . path . join ( copy_dir , ' extracted_file ' ) , ' w+ ' ) as f :
copy_dir = os . path . join ( tmpdir , self . name , ' extracted_dir ' )
f . write ( ' extracted text ' )
if os . path . exists ( copy_dir ) :
with tarfile . open ( output_file , " w:gz " ) as tar :
shutil . rmtree ( copy_dir )
tar . add ( copy_dir , arcname = os . path . basename ( copy_dir ) )
os . makedirs ( copy_dir )
with open ( os . path . join ( copy_dir , ' extracted_file ' ) , ' w+ ' ) as f :
f . write ( ' extracted text ' )
with tarfile . open ( output_file , " w:gz " ) as tar :
tar . add ( copy_dir , arcname = os . path . basename ( copy_dir ) )
else :
else :
gcs_url = ' gs:// %s / %s ' % ( self . bucket , self . object_name )
gcs_url = ' gs:// %s / %s ' % ( self . bucket , self . object_name )
gsutil = download_from_google_storage . Gsutil (
gsutil = download_from_google_storage . Gsutil (