From 27893836c89a0e7e0fda30cdd34e900bfe1b9cf3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bob=20Dr=C3=B6ge?= Date: Tue, 6 Feb 2024 16:03:26 +0100 Subject: [PATCH 1/2] add code for moving existing compat layer --- scripts/ingest-tarball.sh | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/scripts/ingest-tarball.sh b/scripts/ingest-tarball.sh index d71ff733..399765cc 100755 --- a/scripts/ingest-tarball.sh +++ b/scripts/ingest-tarball.sh @@ -193,11 +193,15 @@ function ingest_compat_tarball() { if [ -f "/cvmfs/${repo}/${basedir}/${version}/compat/${os}/${arch}/startprefix" ]; then echo_yellow "Compatibility layer for version ${version}, OS ${os}, and architecture ${arch} already exists!" - echo_yellow "Removing the existing layer, and adding the new one from the tarball..." + old_layer_path="/cvmfs/${repo}/${basedir}/${version}/compat/${os}/${arch}" ${cvmfs_server} transaction "${repo}" - rm -rf "/cvmfs/${repo}/${basedir}/${version}/compat/${os}/${arch}/" + last_suffix=$((ls -1d ${old_layer_path}-* | tail -n 1 | xargs basename | cut -d- -f2) 2> /dev/null) + new_suffix=$(printf '%03d\n' $((${last_suffix:-0} + 1))) + old_layer_suffixed_path="${old_layer_path}-${new_suffix}" + echo_yellow "Moving the existing compat layer from ${old_layer_path} to ${old_layer_suffixed_path}..." + mv ${old_layer_path} ${old_layer_suffixed_path} tar -C "/cvmfs/${repo}/${basedir}/" -xzf "${tar_file}" - ${cvmfs_server} publish -m "update compat layer for ${version}, ${os}, ${arch}" "${repo}" + ${cvmfs_server} publish -m "updated compat layer for ${version}, ${os}, ${arch}" "${repo}" ec=$? if [ $ec -eq 0 ] then From bc2a3aaecddbc5533108a44933c4b2989ef05d49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bob=20Dr=C3=B6ge?= Date: Tue, 6 Feb 2024 16:25:09 +0100 Subject: [PATCH 2/2] use variable for path to compat layer dir --- scripts/ingest-tarball.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/scripts/ingest-tarball.sh b/scripts/ingest-tarball.sh index 399765cc..808f45d7 100755 --- a/scripts/ingest-tarball.sh +++ b/scripts/ingest-tarball.sh @@ -189,17 +189,17 @@ function ingest_compat_tarball() { # Handle the ingestion of tarballs containing a compatibility layer check_arch check_os + compat_layer_path="/cvmfs/${repo}/${basedir}/${version}/compat/${os}/${arch}" # Assume that we already had a compat layer in place if there is a startprefix script in the corresponding CVMFS directory - if [ -f "/cvmfs/${repo}/${basedir}/${version}/compat/${os}/${arch}/startprefix" ]; + if [ -f "${compat_layer_path}/startprefix" ]; then echo_yellow "Compatibility layer for version ${version}, OS ${os}, and architecture ${arch} already exists!" - old_layer_path="/cvmfs/${repo}/${basedir}/${version}/compat/${os}/${arch}" ${cvmfs_server} transaction "${repo}" - last_suffix=$((ls -1d ${old_layer_path}-* | tail -n 1 | xargs basename | cut -d- -f2) 2> /dev/null) + last_suffix=$((ls -1d ${compat_layer_path}-* | tail -n 1 | xargs basename | cut -d- -f2) 2> /dev/null) new_suffix=$(printf '%03d\n' $((${last_suffix:-0} + 1))) - old_layer_suffixed_path="${old_layer_path}-${new_suffix}" - echo_yellow "Moving the existing compat layer from ${old_layer_path} to ${old_layer_suffixed_path}..." - mv ${old_layer_path} ${old_layer_suffixed_path} + old_layer_suffixed_path="${compat_layer_path}-${new_suffix}" + echo_yellow "Moving the existing compat layer from ${compat_layer_path} to ${old_layer_suffixed_path}..." + mv ${compat_layer_path} ${old_layer_suffixed_path} tar -C "/cvmfs/${repo}/${basedir}/" -xzf "${tar_file}" ${cvmfs_server} publish -m "updated compat layer for ${version}, ${os}, ${arch}" "${repo}" ec=$?