include('/etc/mock/{{ chroot }}.cfg')
config_opts['rpmbuild_networking'] = True
config_opts['use_host_resolv'] = True

{# See https://github.com/fedora-copr/copr/issues/3140 #}
{%- if not chroot.startswith("fedora-40-") %}
# We don't do 'dnf builddep' for the custom method, so we don't need to install
# python3-dnf-plugins core or dnf5-plugins at all.
config_opts["bootstrap_image_ready"] = True
{% endif %}

# Don't mixup caches with the normal mock build.
config_opts["root"] = "copr-custom-" + config_opts["root"]

# Important e.g. to keep '/script' file available across several
# /bin/mock calls (when tmpfs_enable is on).
config_opts['plugin_conf']['tmpfs_opts']['keep_mounted'] = True

# Custom mock snippets configured in copr-crpmbuild config file - can be empty
{{ mock_snippet }}

{%- for key, value in macros.items() %}
config_opts['macros']['{{ key }}'] = '{{ value }}'
{%- endfor %}

{% if repos %}
config_opts["dnf.conf"] += """
{% for repo in repos %}
[{{ repo["id"] }}]
name='{{ repo["name"] }}'
baseurl={{ repo["baseurl"] }}
gpgcheck=0
{%- if repo.get("repo_gpgcheck") is not none %}
repo_gpgcheck={{ repo["repo_gpgcheck"]|int }}
{%- endif %}
enabled=1
skip_if_unavailable=0
metadata_expire=0
cost=1
best=1

{%- if "priority" in repo and priority is not none %}
priority={{ repo["priority"] }}
{%- endif %}

{%- if "module_hotfixes" in repo %}
module_hotfixes={{ repo["module_hotfixes"] }}
{% endif -%}

{% endfor %}
"""
{% endif %}
