From e5017b5f9222a2d704d3311c7fabde699d5c6f90 Mon Sep 17 00:00:00 2001
From: Marcel Bargull <marcel.bargull@udo.edu>
Date: Mon, 15 Apr 2024 17:10:28 +0200
Subject: [PATCH] fix: Workaround conda-mambabuild needs local channel

prepopulated if referenced via "-c local" for newer conda/conda-build
versions (not sure why, TBH).

Signed-off-by: Marcel Bargull <marcel.bargull@udo.edu>
---
 bioconda_utils/docker_utils.py | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/bioconda_utils/docker_utils.py b/bioconda_utils/docker_utils.py
index a5792bc3a5..482eedb128 100644
--- a/bioconda_utils/docker_utils.py
+++ b/bioconda_utils/docker_utils.py
@@ -94,10 +94,13 @@
 # will exist in the container but will be empty.  Channels expect at least
 # a linux-64/linux-aarch64 and noarch directory within that directory, so we
 # make sure it exists before adding the channel.
-mkdir -p {self.container_staging}/linux-64
-mkdir -p {self.container_staging}/linux-aarch64
-mkdir -p {self.container_staging}/noarch
-conda index {self.container_staging}
+# Also ensure conda-build's local channel directory exists the same way.
+for local_channel in '/opt/conda/conda-bld' '{self.container_staging}'; do
+  mkdir -p "${{local_channel}}"/linux-64
+  mkdir -p "${{local_channel}}"/linux-aarch64
+  mkdir -p "${{local_channel}}"/noarch
+  conda index "${{local_channel}}"
+done
 conda config --add channels file://{self.container_staging} 2> >(
     grep -vF "Warning: 'file://{self.container_staging}' already in 'channels' list, moving to the top" >&2
 )