Skip to content

Commit

Permalink
feat(tofs): lookup files directory in “tpldir” hierarchy
Browse files Browse the repository at this point in the history
Without user configuration, the “libtofs.jinja” lookup the “files”
directory under “tplroot” with is the base directory of the current
formula unless the “v1_path_prefix” is set.

Now, we lookup the directory in each sub-directory from the
sub-directory of the current SLS (“tpldir”) to the top level directory
of the formula (“tplroot”).

This permit to support formula with different components, each one
providing its own “files” directory like “systemd-formula”.
  • Loading branch information
baby-gnu committed Jul 30, 2019
1 parent c4440d7 commit 5c495fb
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion template/libtofs.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,15 @@
{%- set path_prefix_exts = [''] %}
{%- if v1_path_prefix != '' %}
{%- do path_prefix_exts.append(v1_path_prefix) %}
{%- elif tplroot != tpldir %}
{#- Walk directory tree to find {{ files_dir }} #}
{%- set subpath_parts = tpldir.lstrip(tplroot).lstrip('/').split('/') %}
{%- for path in subpath_parts %}
{%- set subpath = subpath_parts[0:loop.index] | join('/') %}
{%- do path_prefix_exts.append('/' ~ subpath) %}
{%- endfor %}
{%- endif %}
{%- for path_prefix_ext in path_prefix_exts %}
{%- for path_prefix_ext in path_prefix_exts|reverse %}
{%- set path_prefix_inc_ext = path_prefix ~ path_prefix_ext %}
{#- For older TOFS implementation, use `files_switch` from the config #}
{#- Use the default, new method otherwise #}
Expand Down

0 comments on commit 5c495fb

Please sign in to comment.