In process-templates script write output files to provided dir when using base path

When running the process-templates script with both the -o OUTPUT_DIR and
-p BASE_PATH options the output files were not being written to the output
directory.  This fix splits out the file path from the base path to properly
write the files.

Change-Id: I845e8a2cbd2b12a4a1552b2cfa3ac013466da6bd
Closes-Bug: #1794769
(cherry picked from commit 47f47c1dea)
This commit is contained in:
Bob Fournier 2018-09-27 09:57:29 -04:00 committed by Harald Jensås
parent e3b140e010
commit c46632b851
1 changed files with 5 additions and 1 deletions

View File

@ -158,7 +158,11 @@ def process_templates(template_path, role_data_path, output_dir,
# the command multiple times with the same output_dir.
out_dir = subdir
if output_dir:
out_dir = os.path.join(output_dir, subdir)
if template_path != '.':
# strip out base path if not default
temp = out_dir.split(template_path)[1]
out_dir = temp[1:] if temp.startswith('/') else temp
out_dir = os.path.join(output_dir, out_dir)
if not os.path.exists(out_dir):
os.mkdir(out_dir)