From 0668db5edea56a0d57575db127b793f59b489e7b Mon Sep 17 00:00:00 2001 From: naturedamends <120284608+naturedamends@users.noreply.github.com> Date: Sat, 26 Aug 2023 00:39:32 +0100 Subject: Commonutils: chown: cannot access '/home/vscode/.zshrc': No such file or directory (#662) * Update main.sh * Update devcontainer-feature.json * Test install as non root user. --------- Co-authored-by: Samruddhi Khandale --- src/common-utils/devcontainer-feature.json | 2 +- src/common-utils/main.sh | 2 +- test/common-utils/configure_zsh_no_template.sh | 15 --------------- .../common-utils/configure_zsh_no_template_first_step.sh | 12 ++++++++++++ .../configure_zsh_no_template_second_step.sh | 14 ++++++++++++++ test/common-utils/scenarios.json | 16 +++++++++++++--- 6 files changed, 41 insertions(+), 20 deletions(-) delete mode 100644 test/common-utils/configure_zsh_no_template.sh create mode 100644 test/common-utils/configure_zsh_no_template_first_step.sh create mode 100644 test/common-utils/configure_zsh_no_template_second_step.sh diff --git a/src/common-utils/devcontainer-feature.json b/src/common-utils/devcontainer-feature.json index 4eaef21..747be30 100644 --- a/src/common-utils/devcontainer-feature.json +++ b/src/common-utils/devcontainer-feature.json @@ -1,6 +1,6 @@ { "id": "common-utils", - "version": "2.1.1", + "version": "2.1.2", "name": "Common Utilities", "documentationURL": "https://github.com/devcontainers/features/tree/main/src/common-utils", "description": "Installs a set of common command line utilities, Oh My Zsh!, and sets up a non-root user.", diff --git a/src/common-utils/main.sh b/src/common-utils/main.sh index 3731994..902f9e6 100644 --- a/src/common-utils/main.sh +++ b/src/common-utils/main.sh @@ -500,7 +500,7 @@ if [ "${INSTALL_ZSH}" = "true" ]; then copy_to_user_files=("${oh_my_install_dir}") [ -f "$user_rc_file" ] && copy_to_user_files+=("$user_rc_file") cp -rf "${copy_to_user_files[@]}" /root - chown -R ${USERNAME}:${group_name} "${oh_my_install_dir}" "${user_rc_file}" + chown -R ${USERNAME}:${group_name} "${copy_to_user_files[@]}" fi fi fi diff --git a/test/common-utils/configure_zsh_no_template.sh b/test/common-utils/configure_zsh_no_template.sh deleted file mode 100644 index c62cae9..0000000 --- a/test/common-utils/configure_zsh_no_template.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/bash - -set -e - -# Optional: Import test library -source dev-container-features-test-lib - -# Definition specific tests -function file_not_overridden() { - cat ~/.zshrc | grep 'alias fnomockalias=' | grep testingmock -} -check "default-zsh-with-no-zshrc" file_not_overridden - -# Report result -reportResults diff --git a/test/common-utils/configure_zsh_no_template_first_step.sh b/test/common-utils/configure_zsh_no_template_first_step.sh new file mode 100644 index 0000000..d26874d --- /dev/null +++ b/test/common-utils/configure_zsh_no_template_first_step.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +set -e + +# Optional: Import test library +source dev-container-features-test-lib + +# Definition specific tests +check "default-zsh-with-no-zshrc" bash -c "[ ! -e ~/.zshrc ]" + +# Report result +reportResults diff --git a/test/common-utils/configure_zsh_no_template_second_step.sh b/test/common-utils/configure_zsh_no_template_second_step.sh new file mode 100644 index 0000000..734fa66 --- /dev/null +++ b/test/common-utils/configure_zsh_no_template_second_step.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +set -e + +# Optional: Import test library +source dev-container-features-test-lib +# Definition specific tests +function file_not_overridden() { + cat $1 | grep 'alias fnomockalias=' | grep testingmock +} +check "default-zsh-with-no-zshrc" file_not_overridden /home/devcontainer/.zshrc + +# Report result +reportResults diff --git a/test/common-utils/scenarios.json b/test/common-utils/scenarios.json index 904a47b..d7b296d 100644 --- a/test/common-utils/scenarios.json +++ b/test/common-utils/scenarios.json @@ -115,10 +115,20 @@ } } }, - "configure_zsh_no_template": { + "configure_zsh_no_template_second_step": { "image": "mcr.microsoft.com/devcontainers/base:ubuntu", - "postCreateCommand": "echo alias fnomockalias=testingmock >> /root/.zshrc", - "remoteUser": "root", + "postCreateCommand": "echo alias fnomockalias=testingmock >> /home/devcontainer/.zshrc", + "remoteUser": "devcontainer", + "features": { + "common-utils": { + "installZsh": true, + "installOhMyZshConfig": false + } + } + }, + "configure_zsh_no_template_first_step": { + "image": "debian:bullseye", + "remoteUser": "devcontainer", "features": { "common-utils": { "installZsh": true, -- cgit v1.2.3