@ -290,14 +290,8 @@ class ZipArchive(object):
self . excludes = module . params [ ' exclude ' ]
self . includes = [ ]
self . include_files = self . module . params [ ' include ' ]
try :
self . cmd_path = get_bin_path ( ' unzip ' )
except ValueError :
self . module . fail_json ( msg = " Unable to find required ' unzip ' binary in the path " )
try :
self . zipinfocmd_path = get_bin_path ( ' zipinfo ' )
except ValueError :
self . module . fail_json ( msg = " Unable to find required ' zipinfo ' binary in the path " )
self . cmd_path = None
self . zipinfo_cmd_path = None
self . _files_in_archive = [ ]
self . _infodict = dict ( )
@ -387,7 +381,7 @@ class ZipArchive(object):
def is_unarchived ( self ) :
# BSD unzip doesn't support zipinfo listings with timestamp.
cmd = [ self . zipinfo cmd_path, ' -T ' , ' -s ' , self . src ]
cmd = [ self . zipinfo _ cmd_path, ' -T ' , ' -s ' , self . src ]
if self . excludes :
cmd . extend ( [ ' -x ' , ] + self . excludes )
@ -708,8 +702,20 @@ class ZipArchive(object):
return dict ( cmd = cmd , rc = rc , out = out , err = err )
def can_handle_archive ( self ) :
if not self . cmd_path :
return False , ' Command " unzip " not found. '
binaries = (
( ' unzip ' , ' cmd_path ' ) ,
( ' zipinfo ' , ' zipinfo_cmd_path ' ) ,
)
missing = [ ]
for b in binaries :
try :
setattr ( self , b [ 1 ] , get_bin_path ( b [ 0 ] ) )
except ValueError :
missing . append ( b [ 0 ] )
if missing :
return False , " Unable to find required ' {missing} ' binary in the path. " . format ( missing = " ' or ' " . join ( missing ) )
cmd = [ self . cmd_path , ' -l ' , self . src ]
rc , out , err = self . module . run_command ( cmd )
if rc == 0 :
@ -729,23 +735,11 @@ class TgzArchive(object):
self . module . exit_json ( skipped = True , msg = " remote module ( %s ) does not support check mode when using gtar " % self . module . _name )
self . excludes = [ path . rstrip ( ' / ' ) for path in self . module . params [ ' exclude ' ] ]
self . include_files = self . module . params [ ' include ' ]
# Prefer gtar (GNU tar) as it supports the compression options -z, -j and -J
try :
self . cmd_path = get_bin_path ( ' gtar ' )
except ValueError :
# Fallback to tar
try :
self . cmd_path = get_bin_path ( ' tar ' )
except ValueError :
self . module . fail_json ( msg = " Unable to find required ' gtar ' or ' tar ' binary in the path " )
self . cmd_path = None
self . tar_type = None
self . zipflag = ' -z '
self . _files_in_archive = [ ]
if self . cmd_path :
self . tar_type = self . _get_tar_type ( )
else :
self . tar_type = None
def _get_tar_type ( self ) :
cmd = [ self . cmd_path , ' --version ' ]
( rc , out , err ) = self . module . run_command ( cmd )
@ -873,6 +867,18 @@ class TgzArchive(object):
return dict ( cmd = cmd , rc = rc , out = out , err = err )
def can_handle_archive ( self ) :
# Prefer gtar (GNU tar) as it supports the compression options -z, -j and -J
try :
self . cmd_path = get_bin_path ( ' gtar ' )
except ValueError :
# Fallback to tar
try :
self . cmd_path = get_bin_path ( ' tar ' )
except ValueError :
return False , " Unable to find required ' gtar ' or ' tar ' binary in the path "
self . tar_type = self . _get_tar_type ( )
if self . tar_type != ' gnu ' :
return False , ' Command " %s " detected as tar type %s . GNU tar required. ' % ( self . cmd_path , self . tar_type )