Skip to content

Commit

Permalink
Merge pull request #859 from rhc54/topic/subdir
Browse files Browse the repository at this point in the history
Support specifying subdir of interest in FetchTarball
  • Loading branch information
rhc54 authored Aug 22, 2019
2 parents 8d95068 + b40dadc commit 8a5fbd2
Showing 1 changed file with 34 additions and 1 deletion.
35 changes: 34 additions & 1 deletion pylib/Tools/Fetch/FetchTarball.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
# Plugin for fetching and unpacking tarballs from the Web
# @param url URL for the tarball
# @param cmd Command line to use to fetch the tarball (e.g., "curl -o")
# @param subdir Subdirectory of interest in package
# @}
class FetchTarball(FetchMTTTool):

Expand All @@ -40,6 +41,7 @@ def __init__(self):
self.options = {}
self.options['url'] = (None, "URL to tarball")
self.options['cmd'] = ("wget", "Command to use to fetch the tarball")
self.options['subdir'] = (None, "Subdirectory of interest in package")
return

def activate(self):
Expand Down Expand Up @@ -86,6 +88,21 @@ def execute(self, log, keyvals, testDef):
if self.done[tarball] is not None:
log['status'] = self.done[repo][0]
log['location'] = self.done[repo][1]
# if they specified a subdirectory of interest,
# check to see if it exists
if cmds['subdir'] is not None:
# check that this subdirectory actually exists
ckdir = os.path.join(log['location'], cmds['subdir'])
if not os.path.exists(ckdir):
log['status'] = 1
log['stderr'] = "Subdirectory " + cmds['subdir'] + " was not found"
return
if not os.path.isdir(ckdir):
log['status'] = 1
log['stderr'] = "Subdirectory " + cmds['subdir'] + " is not a directory"
return
# adjust the location so later stages can find it
log['location'] = ckdir
return
except KeyError:
pass
Expand Down Expand Up @@ -189,13 +206,29 @@ def execute(self, log, keyvals, testDef):
log['status'] = results['status']
log['stdout'] = results['stdout']
log['stderr'] = results['stderr']
testDef.logger.verbose_print("setting location to " + package)

# log our absolute location so others can find it
log['location'] = os.getcwd()
# track that we serviced this one
self.done[tarball] = (results['status'], log['location'])

# if they specified a subdirectory of interest,
# check to see if it exists
if cmds['subdir'] is not None:
# check that this subdirectory actually exists
ckdir = os.path.join(log['location'], cmds['subdir'])
if not os.path.exists(ckdir):
log['status'] = 1
log['stderr'] = "Subdirectory " + cmds['subdir'] + " was not found"
return
if not os.path.isdir(ckdir):
log['status'] = 1
log['stderr'] = "Subdirectory " + cmds['subdir'] + " is not a directory"
return
# adjust our location so later stages can find it
log['location'] = ckdir

testDef.logger.verbose_print("setting location to " + log['location'])
# change back to the original directory
os.chdir(cwd)

Expand Down

0 comments on commit 8a5fbd2

Please sign in to comment.