From 2f10596d28f339673f578affc152b46cb5772348 Mon Sep 17 00:00:00 2001 From: "Gerber, Mike" <mike.gerber@sbb.spk-berlin.de> Date: Thu, 13 Feb 2020 19:02:57 +0100 Subject: [PATCH] =?UTF-8?q?=E2=AC=86=20Update=20qurator=5Fdata=5Flib.sh=20?= =?UTF-8?q?(Fixes=20GH-5)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- qurator_data_lib.sh | 64 ++++++++++++++++++++++++++++++++++++++------- 1 file changed, 54 insertions(+), 10 deletions(-) diff --git a/qurator_data_lib.sh b/qurator_data_lib.sh index d170f1d..4170f32 100644 --- a/qurator_data_lib.sh +++ b/qurator_data_lib.sh @@ -1,3 +1,14 @@ +# ______________________________________ +#/ always copy the file from \ +#| mono-repo/qurator_data_lib.sh, never | +#\ edit the copy in the project / +# -------------------------------------- +# \ ^__^ +# \ (oo)\_______ +# (__)\ )\/\ +# ||----w | +# || || + if [ -z "$BASH" ]; then echo "qurator_data_lib.sh uses bash features, please make sure to run $0 in bash" exit 1 @@ -23,14 +34,31 @@ check_data_subdir() { } annex_get() { + if [[ "$1" = '--allow_symlinks' ]]; then + allow_symlinks=1 + shift + else + allow_symlinks=0 + fi file_pattern="$1" ( cd $DATA_SUBDIR git annex get $file_pattern - # fsck seems to be necessary to fix the files if we're in a submodule + # fsck seems to be necessary to fix the files if we are in a submodule git annex fsck $file_pattern + + # Check that there are no symlinks = only unlocked files. This is needed for + # Docker builds, as we cannot dereference symlinks in a Dockerfile COPY. + if [[ $allow_symlinks = 0 ]]; then + git ls-files $file_pattern | while read f; do + if ! [[ -f "$f" ]]; then + echo "$DATA_SUBDIR/$f is not a regular file – Is an unlock needed?" + exit + fi + done + fi ) } @@ -58,18 +86,34 @@ suggest_commands() { } handle_data() { + if [[ "$1" = '--no-download' ]]; then + no_download=1 + shift + else + no_download=0 + fi + if [ -n "$FORCE_DOWNLOAD" ]; then get_from_web elif ! check_data_subdir; then - select choice in "Abort to manually fix $DATA_SUBDIR submodule" "Download data files from the web"; do - if [ $REPLY = 1 ]; then - suggest_commands - exit - else - get_from_web - break - fi - done + if [[ $no_download = 1 ]]; then + select choice in "Abort to manually fix $DATA_SUBDIR submodule"; do + if [ $REPLY = 1 ]; then + suggest_commands + exit + fi + done + else + select choice in "Abort to manually fix $DATA_SUBDIR submodule" "Download data files from the web"; do + if [ $REPLY = 1 ]; then + suggest_commands + exit + else + get_from_web + break + fi + done + fi else get_from_annex fi