From d0a7011b160e4a14c9131866c2f63c597ba66499 Mon Sep 17 00:00:00 2001 From: David Kwon Date: Thu, 10 Jul 2025 16:40:40 -0400 Subject: [PATCH 1/3] fix: create links in entrypoint for files under /home/tooling/.config Files under /home/tooling/.config are not stowed in the entrypoint because it is in the .stow-local-ignore file. Stow ignores everything in the .config folder because the /home/user/.config folder should be created in the entrypoint in order to have proper user permissions required for Podman 5.x. Signed-off-by: David Kwon --- base/ubi9/.copy-files | 22 ++++++++++++++++++++++ base/ubi9/entrypoint.sh | 24 +++++++++++++++++++----- base/ubi9/foo/bar | 0 base/ubi9/foo/fff | 0 base/ubi9/foo/test/foobar | 0 5 files changed, 41 insertions(+), 5 deletions(-) create mode 100644 base/ubi9/.copy-files create mode 100644 base/ubi9/foo/bar create mode 100644 base/ubi9/foo/fff create mode 100644 base/ubi9/foo/test/foobar diff --git a/base/ubi9/.copy-files b/base/ubi9/.copy-files new file mode 100644 index 00000000..ae8a50f7 --- /dev/null +++ b/base/ubi9/.copy-files @@ -0,0 +1,22 @@ +# This file contains a list directories or files to copy over from /home/tooling to /home/user in entrypoint.sh. +# +# For example, the follwing will copy /home/tooling/testfile to /home/user/testfile: +# ./testfile +# +# The goal of this file is to copy over files that cannot be used as symbolic links created by stow. +# For example, Vim does not permit .viminfo to be a symbolic link for security reasons, therefore it is copied +# over to /home/user manually without stow. +# +# When copying over directories or files from /home/tooling to /home/user using this file, remember to add the +# directory or file to .stow-local-ignore so that a symbolic link is not created. + + +# Vim does not permit .viminfo to be a symbolic link for security reasons, so manually copy it +.viminfo + +# We have to restore bash-related files back onto /home/user/ (since they will have been overwritten by the PVC) +# but we don't want them to be symbolic links (so that they persist on the PVC) +.bashrc +.bash_profile + +./foo \ No newline at end of file diff --git a/base/ubi9/entrypoint.sh b/base/ubi9/entrypoint.sh index 0e2920f3..45dc9389 100644 --- a/base/ubi9/entrypoint.sh +++ b/base/ubi9/entrypoint.sh @@ -1,5 +1,10 @@ #!/bin/bash +# Replace /home/tooling/* path to /home/user/* path +replace_user_home() { + echo "$1" | sed "s|^/home/tooling|$HOME|" +} + # Ensure $HOME exists when starting if [ ! -d "${HOME}" ]; then mkdir -p "${HOME}" @@ -15,11 +20,20 @@ if [ ! -d "${HOME}/.config/containers" ]; then fi fi -# Create Sym Link for Composer Keys in /home/tooling/.config -if [ -d /home/tooling/.config/composer ] && [ ! -d "${HOME}/.config/composer" ]; then - mkdir -p ${HOME}/.config/composer - ln -s /home/tooling/.config/composer/keys.dev.pub ${HOME}/.config/composer/keys.dev.pub - ln -s /home/tooling/.config/composer/keys.tags.pub ${HOME}/.config/composer/keys.tags.pub +# Find files under /home/tooling/.config and create symlinks. The /home/tooling/.config folder +# is ignored by stow with the .stow-local-ignore file +if [ -d /home/tooling/.config ]; then + for file in $(find /home/tooling/.config -type f); do + tooling_dir=$(dirname "$file") + + # Create dir in /home/user if it does not exist already + mkdir -p $(replace_user_home "$tooling_dir") + + # Create symbolic link if it does not exist already + if [ ! -f $(replace_user_home $file) ]; then + ln -s $file $(replace_user_home $file) + fi + done fi # Setup $PS1 for a consistent and reasonable prompt diff --git a/base/ubi9/foo/bar b/base/ubi9/foo/bar new file mode 100644 index 00000000..e69de29b diff --git a/base/ubi9/foo/fff b/base/ubi9/foo/fff new file mode 100644 index 00000000..e69de29b diff --git a/base/ubi9/foo/test/foobar b/base/ubi9/foo/test/foobar new file mode 100644 index 00000000..e69de29b From e40343ddf0c1a103179974b5b975ab80d3bed07b Mon Sep 17 00:00:00 2001 From: David Kwon Date: Fri, 11 Jul 2025 11:07:47 -0400 Subject: [PATCH 2/3] Remove uneccesary folder, added by mistake Signed-off-by: David Kwon --- base/ubi9/foo/bar | 0 base/ubi9/foo/fff | 0 base/ubi9/foo/test/foobar | 0 3 files changed, 0 insertions(+), 0 deletions(-) delete mode 100644 base/ubi9/foo/bar delete mode 100644 base/ubi9/foo/fff delete mode 100644 base/ubi9/foo/test/foobar diff --git a/base/ubi9/foo/bar b/base/ubi9/foo/bar deleted file mode 100644 index e69de29b..00000000 diff --git a/base/ubi9/foo/fff b/base/ubi9/foo/fff deleted file mode 100644 index e69de29b..00000000 diff --git a/base/ubi9/foo/test/foobar b/base/ubi9/foo/test/foobar deleted file mode 100644 index e69de29b..00000000 From 3f00bc3f7f0157fd94ccdbbf39b8ffa7299ddbe6 Mon Sep 17 00:00:00 2001 From: David Kwon Date: Wed, 16 Jul 2025 17:40:22 -0400 Subject: [PATCH 3/3] Address PR feedback Signed-off-by: David Kwon --- base/ubi9/.copy-files | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/base/ubi9/.copy-files b/base/ubi9/.copy-files index ae8a50f7..f59b35e5 100644 --- a/base/ubi9/.copy-files +++ b/base/ubi9/.copy-files @@ -1,6 +1,6 @@ # This file contains a list directories or files to copy over from /home/tooling to /home/user in entrypoint.sh. # -# For example, the follwing will copy /home/tooling/testfile to /home/user/testfile: +# For example, the following will copy /home/tooling/testfile to /home/user/testfile: # ./testfile # # The goal of this file is to copy over files that cannot be used as symbolic links created by stow. @@ -18,5 +18,3 @@ # but we don't want them to be symbolic links (so that they persist on the PVC) .bashrc .bash_profile - -./foo \ No newline at end of file