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

{# Hotfix for https://github.com/fedora-copr/copr/issues/3140 #}
{%- if not chroot.startswith("fedora-rawhide-") and not "fedora-40" in chroot %}
# 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

{%- 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
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 %}
