From 74af9a280eb835c2f6f68c5b6946ec461d007c6c Mon Sep 17 00:00:00 2001 From: Ivan Suftin Date: Fri, 13 Dec 2024 13:49:11 -0600 Subject: [PATCH] fix: Update .stow-local-ignore with files in /home/user that would break running stow (#196) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Update JDK patch versions to latest from sdkman (#193) Signed-off-by: Aurélien Pupier Signed-off-by: Ivan Suftin * fix: Update .stow-local-ignore with files in /home/user that would break running stow Signed-off-by: Ivan Suftin --------- Signed-off-by: Aurélien Pupier Signed-off-by: Ivan Suftin Co-authored-by: Aurélien Pupier --- universal/ubi9/entrypoint.sh | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/universal/ubi9/entrypoint.sh b/universal/ubi9/entrypoint.sh index aeb28436..1a22938e 100755 --- a/universal/ubi9/entrypoint.sh +++ b/universal/ubi9/entrypoint.sh @@ -12,6 +12,32 @@ mountpoint -q /home/user/; HOME_USER_MOUNTED=$? STOW_COMPLETE=/home/user/.stow_completed if [ $HOME_USER_MOUNTED -eq 0 ] && [ ! -f $STOW_COMPLETE ]; then + # There may be regular, non-symlink files in /home/user that match the + # pathing of files in /home/tooling. Stow will error out when it tries to + # stow on top of that. Instead, we can append to the current + # /home/tooling/.stow-local-ignore file to ignore pre-existing, + # non-symlinked files in /home/user that match those in /home/tooling before + # we run stow. + # + # Create two text files containing a sorted path-based list of files in + # /home/tooling and /home/user. Cut off "/home/user" and "/home/tooling" and + # only get the sub-paths so we can do a proper comparison + # + # In the case of /home/user, we want regular file types and not symbolic + # links. + find /home/user -type f -xtype f -print | sort | sed 's|/home/user||g' > /tmp/user.txt + find /home/tooling -print | sort | sed 's|/home/tooling||g' > /tmp/tooling.txt + # We compare the two files, trying to find files that exist in /home/user + # and /home/tooling. Being that the files that get flagged here are not + # already synlinks, we will want to ignore them. + IGNORE_FILES="$(comm -12 /tmp/user.txt /tmp/tooling.txt)" + # We no longer require the file lists, so remove them + rm /tmp/user.txt /tmp/tooling.txt + # For each file we need to ignore, append them to + # /home/tooling/.stow-local-ignore. + for f in $IGNORE_FILES; do echo "${f}" >> /home/tooling/.stow-local-ignore;done + # We are now ready to run stow + # # Create symbolic links from /home/tooling/ -> /home/user/ stow . -t /home/user/ -d /home/tooling/ --no-folding -v 2 > /tmp/stow.log 2>&1 # Vim does not permit .viminfo to be a symbolic link for security reasons, so manually copy it