Skip to content
Snippets Groups Projects
Commit 1b2f5225 authored by Nat Goodspeed's avatar Nat Goodspeed
Browse files

DRTVWR-447: Streamline some of the logic around extra packages.

parent 0869e86f
No related branches found
No related tags found
No related merge requests found
...@@ -232,16 +232,12 @@ def main(): ...@@ -232,16 +232,12 @@ def main():
print "Option:", opt, "=", args[opt] print "Option:", opt, "=", args[opt]
# pass in sourceid as an argument now instead of an environment variable # pass in sourceid as an argument now instead of an environment variable
try: args['sourceid'] = os.environ.get("sourceid", "")
args['sourceid'] = os.environ["sourceid"]
except KeyError:
args['sourceid'] = ""
# Build base package. # Build base package.
touch = args.get('touch') touch = args.get('touch')
if touch: if touch:
print 'Creating base package' print 'Creating base package'
args['package_id'] = "" # base package has no package ID
wm = LLManifest.for_platform(args['platform'], args.get('arch'))(args) wm = LLManifest.for_platform(args['platform'], args.get('arch'))(args)
wm.do(*args['actions']) wm.do(*args['actions'])
# Store package file for later if making touched file. # Store package file for later if making touched file.
...@@ -251,64 +247,25 @@ def main(): ...@@ -251,64 +247,25 @@ def main():
base_package_file = "" + wm.package_file base_package_file = "" + wm.package_file
# handle multiple packages if set # handle multiple packages if set
try: # ''.split() produces empty list
additional_packages = os.environ["additional_packages"] additional_packages = os.environ.get("additional_packages", "").split()
except KeyError:
additional_packages = ""
if additional_packages: if additional_packages:
# Determine destination prefix / suffix for additional packages. # Determine destination prefix / suffix for additional packages.
base_dest_postfix = args['dest']
base_dest_prefix = ""
base_dest_parts = args['dest'].split(os.sep) base_dest_parts = args['dest'].split(os.sep)
if len(base_dest_parts) > 1: base_dest_parts.insert(-1, "{}")
base_dest_postfix = base_dest_parts[len(base_dest_parts) - 1] base_dest_template = os.sep.join(base_dest_parts)
base_dest_prefix = base_dest_parts[0]
i = 1
while i < len(base_dest_parts) - 1:
base_dest_prefix = base_dest_prefix + os.sep + base_dest_parts[i]
i = i + 1
# Determine touched prefix / suffix for additional packages. # Determine touched prefix / suffix for additional packages.
base_touch_postfix = ""
base_touch_prefix = ""
if touch: if touch:
base_touch_postfix = touch base_touch_parts = touch.split(os.sep)
base_touch_parts = touch.split('/')
if "arwin" in args['platform']: if "arwin" in args['platform']:
if len(base_touch_parts) > 1: base_touch_parts.insert(-1, "{}")
base_touch_postfix = base_touch_parts[len(base_touch_parts) - 1]
base_touch_prefix = base_touch_parts[0]
i = 1
while i < len(base_touch_parts) - 1:
base_touch_prefix = base_touch_prefix + '/' + base_touch_parts[i]
i = i + 1
else: else:
if len(base_touch_parts) > 2: base_touch_parts.insert(-2, "{}")
base_touch_postfix = base_touch_parts[len(base_touch_parts) - 2] + '/' + base_touch_parts[len(base_touch_parts) - 1] base_touch_template = os.sep.join(base_touch_parts)
base_touch_prefix = base_touch_parts[0] for package_id in additional_packages:
i = 1 args['channel_suffix'] = os.environ.get(package_id + "_viewer_channel_suffix")
while i < len(base_touch_parts) - 2: args['sourceid'] = os.environ.get(package_id + "_sourceid")
base_touch_prefix = base_touch_prefix + '/' + base_touch_parts[i] args['dest'] = base_dest_template.format(package_id)
i = i + 1
# Store base channel name.
base_channel_name = args['channel']
# Build each additional package.
package_id_list = additional_packages.split(" ")
args['channel'] = base_channel_name
for package_id in package_id_list:
try:
if package_id + "_viewer_channel_suffix" in os.environ:
args['channel_suffix'] = os.environ[package_id + "_viewer_channel_suffix"]
else:
args['channel_suffix'] = None
if package_id + "_sourceid" in os.environ:
args['sourceid'] = os.environ[package_id + "_sourceid"]
else:
args['sourceid'] = None
args['dest'] = base_dest_prefix + os.sep + package_id + os.sep + base_dest_postfix
except KeyError:
sys.stderr.write("Failed to create package for package_id: %s" % package_id)
sys.stderr.flush()
continue
if touch: if touch:
print 'Creating additional package for "', package_id, '" in ', args['dest'] print 'Creating additional package for "', package_id, '" in ', args['dest']
try: try:
...@@ -318,18 +275,14 @@ def main(): ...@@ -318,18 +275,14 @@ def main():
sys.exit(str(err)) sys.exit(str(err))
if touch: if touch:
print 'Created additional package ', wm.package_file, ' for ', package_id print 'Created additional package ', wm.package_file, ' for ', package_id
faketouch = base_touch_prefix + '/' + package_id + '/' + base_touch_postfix with open(base_touch_template.format(package_id), 'w') as fp:
fp = open(faketouch, 'w') fp.write('set package_file=%s\n' % wm.package_file)
fp.write('set package_file=%s\n' % wm.package_file)
fp.close()
# Write out the package file in this format, so that it can easily be called # Write out the package file in this format, so that it can easily be called
# and used in a .bat file - yeah, it sucks, but this is the simplest... # and used in a .bat file - yeah, it sucks, but this is the simplest...
touch = args.get('touch')
if touch: if touch:
fp = open(touch, 'w') with open(touch, 'w') as fp:
fp.write('set package_file=%s\n' % base_package_file) fp.write('set package_file=%s\n' % base_package_file)
fp.close()
print 'touched', touch print 'touched', touch
return 0 return 0
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment