particle-os-cli/template/templates/modules/modules.j2
2025-01-31 22:29:31 -05:00

71 lines
3.1 KiB
Django/Jinja

{% macro main_modules_run(modules_ext, os_version) %}
# Module RUNs
{%- for module in modules_ext.modules %}
{%- if let Some(module) = module.required_fields %}
{%- if module.no_cache %}
ARG CACHEBUST="{{ build_id }}"
{%- endif %}
{%- if module.module_type.typ() == "containerfile" %}
{%- include "modules/containerfile/containerfile.j2" %}
{%- else if module.module_type.typ() == "copy" %}
{%- include "modules/copy/copy.j2" %}
{%- else %}
RUN \
{%- if self::files_dir_exists() %}
--mount=type=bind,from=stage-files,src=/files,dst=/tmp/files,rw \
{%- else if self::config_dir_exists() %}
--mount=type=bind,from=stage-config,src=/config,dst=/tmp/config,rw \
{%- endif %}
{%- if let Some(source) = module.get_non_local_source() %}
--mount=type=bind,from={{ source }},src=/modules,dst=/tmp/modules,rw \
{%- else if module.is_local_source() %}
--mount=type=bind,from=stage-modules,src=/modules,dst=/tmp/modules,rw \
{%- else %}
--mount=type=bind,from={{ module.get_module_image() }},src=/modules,dst=/tmp/modules,rw \
{%- endif %}
{%- if module.module_type.typ() == "akmods" %}
--mount=type=bind,from=stage-akmods-{{ module.generate_akmods_info(os_version).stage_name }},src=/rpms,dst=/tmp/rpms,rw \
{%- endif %}
--mount=type=bind,from={{ build_scripts_image }},src=/scripts/,dst=/tmp/scripts/ \
--mount=type=cache,dst=/var/cache/rpm-ostree,id=rpm-ostree-cache-{{ recipe.name }}-{{ recipe.image_version }},sharing=locked \
--mount=type=cache,dst=/var/cache/libdnf5,id=dnf-cache-{{ recipe.name }}-{{ recipe.image_version }},sharing=locked \
/tmp/scripts/run_module.sh '{{ module.module_type.typ() }}' '{{ module|json|safe }}'
{%- endif %}
{%- endif %}
{%- endfor %}
{% endmacro %}
{% macro stage_modules_run(modules_ext, os_version) %}
# Module RUNs
{%- for module in modules_ext.modules %}
{%- if let Some(module) = module.required_fields %}
{%- if module.no_cache %}
ARG CACHEBUST="{{ build_id }}"
{%- endif %}
{%- if module.module_type.typ() == "containerfile" %}
{%- include "modules/containerfile/containerfile.j2" %}
{%- else if module.module_type.typ() == "copy" %}
{%- include "modules/copy/copy.j2" %}
{%- else %}
RUN \
{%- if self::files_dir_exists() %}
--mount=type=bind,from=stage-files,src=/files,dst=/tmp/files,rw \
{%- else if self::config_dir_exists() %}
--mount=type=bind,from=stage-config,src=/config,dst=/tmp/config,rw \
{%- endif %}
{%- if let Some(source) = module.get_non_local_source() %}
--mount=type=bind,from={{ source }},src=/modules,dst=/tmp/modules,rw \
{%- else if module.is_local_source() %}
--mount=type=bind,from=stage-modules,src=/modules,dst=/tmp/modules,rw \
{%- else %}
--mount=type=bind,from={{ module.get_module_image() }},src=/modules,dst=/tmp/modules,rw \
{%- endif %}
--mount=type=bind,from={{ build_scripts_image }},src=/scripts/,dst=/tmp/scripts/ \
/tmp/scripts/run_module.sh '{{ module.module_type.typ() }}' '{{ module|json|safe }}'
{%- endif %}
{%- endif %}
{%- endfor %}
{% endmacro %}