From 0eaef8f892ebd7fccc682554baa02443e077a39b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Eric=20M=C3=BCller?= <mueller@kip.uni-heidelberg.de>
Date: Fri, 2 Aug 2024 11:00:26 +0200
Subject: [PATCH] chore(update_build_caches): add more debug [DO-NOT-MERGE]

Change-Id: I43d641d4d8a7b7ffaedebbd9fd13bc8e7a87349c
---
 lib/yashchiki/install_spack_packages.sh          | 3 +++
 lib/yashchiki/update_build_cache.sh              | 3 +++
 lib/yashchiki/update_build_cache_in_container.sh | 5 +++++
 3 files changed, 11 insertions(+)

diff --git a/lib/yashchiki/install_spack_packages.sh b/lib/yashchiki/install_spack_packages.sh
index 8a6b5818..d0d3b0e5 100755
--- a/lib/yashchiki/install_spack_packages.sh
+++ b/lib/yashchiki/install_spack_packages.sh
@@ -11,6 +11,8 @@ source "${sourcedir}/setup_env_spack.sh"
 
 cd "$HOME"
 
+ls -lisa ${SPEC_FOLDER_IN_CONTAINER}
+
 install_from_buildcache "${spack_packages[@]+"${spack_packages[@]}"}"
 
 if [ -n "${SPACK_ENVIRONMENT:-}" ]; then
@@ -31,6 +33,7 @@ for package in "${spack_packages[@]+"${spack_packages[@]}"}"; do
         echo "ERROR: Failed to concretize ${package} for install." >&2
         exit 1
     fi
+    ls -lisa ${SPEC_FOLDER_IN_CONTAINER}
 
     echo "Installing: ${package} (parallelism factor ${SPACK_INSTALL_PARALLELISM})" >&2
     for i in `seq 1 ${SPACK_INSTALL_PARALLELISM}`; do
diff --git a/lib/yashchiki/update_build_cache.sh b/lib/yashchiki/update_build_cache.sh
index a0345e4b..a6367a41 100755
--- a/lib/yashchiki/update_build_cache.sh
+++ b/lib/yashchiki/update_build_cache.sh
@@ -44,6 +44,9 @@ proot -w / -S ${TARGET_FOLDER} \
     --bind="${BUILD_CACHE_OUTSIDE}:${BUILD_CACHE_INSIDE}" \
     /opt/spack_install_scripts/update_build_cache_in_container.sh -q || exit 0
 
+ls -l ${TARGET_FOLDER}/opt/build_cache/default
+find ${TARGET_FOLDER}/opt/spack/opt/spack/
+
 if [ -n "${CACHE_BUILD_TYPE:-}" ]; then
     if [ ${CACHE_SOURCE_TYPE} != "oci" ]; then
         echo "Unknown cache type"
diff --git a/lib/yashchiki/update_build_cache_in_container.sh b/lib/yashchiki/update_build_cache_in_container.sh
index 75875485..14d72136 100755
--- a/lib/yashchiki/update_build_cache_in_container.sh
+++ b/lib/yashchiki/update_build_cache_in_container.sh
@@ -70,11 +70,13 @@ export SPACK_SHELL="bash"
 get_hashes_in_spack() {
     # we only return hashes that are actually IN spack, i.e., that reside under /opt/spack/opt/spack
     spack find --no-groups -Lp | awk '$3 ~ /^\/opt\/spack\/opt\/spack\// { print $1 }' | sort
+    echo "DEBUG: Found $(spack find --no-groups -Lp | awk '$3 ~ /^\/opt\/spack\/opt\/spack\// { print $1 }' | sort | wc -l) installed hashes" >&2
 }
 
 
 # we store all hashes currently installed that are not already in the buildcache
 get_hashes_to_store() {
+    echo "DEBUG: Number of new packages to be added to cache: $(comm -13 <(get_hashes_in_buildcache "${base_buildcache}") <(get_hashes_in_spack))" >&2
     comm -13 <(get_hashes_in_buildcache "${base_buildcache}") <(get_hashes_in_spack)
 }
 
@@ -95,6 +97,9 @@ rm_tmpdir() {
 }
 trap rm_tmpdir EXIT
 
+
+set -x
+
 get_hashes_to_store \
     | parallel -r ${args_progress} -j${num_jobs} \
         tar Pcfz "${tmpdir_in_destination_folder}/{}.tar.gz" \"\$\(spack location -i /{}\)\"
-- 
GitLab