build-extensions-container: support `yumrepos` setups
In RHCOS, we use `--yumrepos` to pull in the yum repo definition files
from a separate git repo. Add support for this flow when building the
extensions container.
@@ -11,11 +11,25 @@ workdir=$PWD
builddir="${workdir}/builds/latest/${arch}"
ostree_ociarchive=$(ls "${builddir}"/*-ostree*.ociarchive)
+if [ ! -d "${workdir}/src/yumrepos" ]; then
+ ctx_dir=${workdir}/src/config
+else
+ ctx_dir="${workdir}/tmp/build-extensions-container"
+ rm -rf "${ctx_dir}"
+ cp -a "${workdir}/src/config" "${ctx_dir}"
+ find "${workdir}/src/yumrepos/" -maxdepth 1 -type f -name '*.repo' -exec cp -t "${ctx_dir}" {} +
+ cleanup_ctx_dir=1
+fi
+
# Build the image, replacing the FROM directive with the local image we have
img=localhost/extensions-container
(set -x; podman build --from oci-archive:"$ostree_ociarchive" --network=host \
--build-arg COSA=true --label version="$buildid" \
- -t "${img}" -f extensions/Dockerfile "${workdir}/src/config")
+ -t "${img}" -f extensions/Dockerfile "${ctx_dir}")
+
+if [ -n "${cleanup_ctx_dir:-}" ]; then
+ rm -rf "${ctx_dir}"
+fi
# Call skopeo to export it from the container storage to an oci-archive.
(set -x; skopeo copy "containers-storage:${img}" oci-archive:"$filename")
