aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-07-14 18:03:13 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-07-14 18:03:13 +0000
commit4abff4bad730342758d2c60b447ba6020ad60bf5 (patch)
tree0fc735fcbf3bd5d793d5262eb61920b1c35b327e
parent00ccfb539b5cb6bfc617af6ce4597a2230b60b99 (diff)
downloadpaludis-4abff4bad730342758d2c60b447ba6020ad60bf5.tar.gz
paludis-4abff4bad730342758d2c60b447ba6020ad60bf5.tar.xz
Make CONFIG_PROTECT work as expected when ROOT=/. Add tests for CONFIG_PROTECT behaviour. Fixes: Berlios#8113, Berlios#FR2377.
-rw-r--r--ebuild/utils/merge_TEST.bash93
-rwxr-xr-xebuild/utils/merge_TEST_setup.sh30
-rw-r--r--ebuild/utils/merge_common.cc2
3 files changed, 125 insertions, 0 deletions
diff --git a/ebuild/utils/merge_TEST.bash b/ebuild/utils/merge_TEST.bash
index ac1cb4d..98165a7 100644
--- a/ebuild/utils/merge_TEST.bash
+++ b/ebuild/utils/merge_TEST.bash
@@ -119,6 +119,7 @@ merge_links_over_TEST()
[[ -L "merge_TEST_dir/links_over_dst/link_to_three" ]] ; test_return_code
test_equality "$(< merge_TEST_dir/links_over_dst/link_to_three)" "contents of three"
}
+
merge_links_over_dir_TEST()
{
! ${TOP_BUILD_DIR}/ebuild/utils/merge "merge_TEST_dir/links_over_dir_src" \
@@ -127,4 +128,96 @@ merge_links_over_dir_TEST()
test_return_code
}
+merge_config_protect_TEST()
+{
+ export CONFIG_PROTECT=/dir
+
+ ${TOP_BUILD_DIR}/ebuild/utils/merge "merge_TEST_dir/config_pro_src" \
+ "merge_TEST_dir/config_pro_dst" \
+ "merge_TEST_dir/config_pro_contents" 1>/dev/null
+ test_return_code
+
+ echo -n "[one]"
+
+ [[ -f merge_TEST_dir/config_pro_dst/dir/one ]] ; test_return_code
+ [[ -f merge_TEST_dir/config_pro_dst/dir/._cfg0000_one ]] ; test_return_code
+ ! [[ -f merge_TEST_dir/config_pro_dst/dir/._cfg0001_one ]] ; test_return_code
+ test_equality "$(< merge_TEST_dir/config_pro_dst/dir/one)" "i am a fish"
+ test_equality "$(< merge_TEST_dir/config_pro_dst/dir/._cfg0000_one)" "contents of one"
+
+ echo -n "[two]"
+
+ [[ -f merge_TEST_dir/config_pro_dst/dir/two ]] ; test_return_code
+ ! [[ -f merge_TEST_dir/config_pro_dst/dir/._cfg0000_two ]] ; test_return_code
+ test_equality "$(< merge_TEST_dir/config_pro_dst/dir/two)" "contents of two"
+
+ echo -n "[three]"
+
+ [[ -f merge_TEST_dir/config_pro_dst/dir/three ]] ; test_return_code
+ [[ -f merge_TEST_dir/config_pro_dst/dir/._cfg0000_three ]] ; test_return_code
+ [[ -f merge_TEST_dir/config_pro_dst/dir/._cfg0001_three ]] ; test_return_code
+ [[ -f merge_TEST_dir/config_pro_dst/dir/._cfg0002_three ]] ; test_return_code
+ ! [[ -f merge_TEST_dir/config_pro_dst/dir/._cfg0003_three ]] ; test_return_code
+ test_equality "$(< merge_TEST_dir/config_pro_dst/dir/three)" "i am a fish"
+ test_equality "$(< merge_TEST_dir/config_pro_dst/dir/._cfg0000_three)" "i am a dish"
+ test_equality "$(< merge_TEST_dir/config_pro_dst/dir/._cfg0001_three)" "i am a fist"
+ test_equality "$(< merge_TEST_dir/config_pro_dst/dir/._cfg0002_three)" "contents of three"
+
+ echo -n "[four]"
+
+ [[ -f merge_TEST_dir/config_pro_dst/dir/four ]] ; test_return_code
+ [[ -f merge_TEST_dir/config_pro_dst/dir/._cfg0000_four ]] ; test_return_code
+ [[ -f merge_TEST_dir/config_pro_dst/dir/._cfg0001_four ]] ; test_return_code
+ ! [[ -f merge_TEST_dir/config_pro_dst/dir/._cfg0002_four ]] ; test_return_code
+ test_equality "$(< merge_TEST_dir/config_pro_dst/dir/four)" "i am a fish"
+ test_equality "$(< merge_TEST_dir/config_pro_dst/dir/._cfg0000_four)" "contents of four"
+ test_equality "$(< merge_TEST_dir/config_pro_dst/dir/._cfg0001_four)" "i am a fist"
+}
+
+merge_config_protect_noroot_TEST()
+{
+ export CONFIG_PROTECT=$(${PALUDIS_EBUILD_DIR}/utils/canonicalise `pwd` )/merge_TEST_dir/noroot_dst/dir
+
+ ${TOP_BUILD_DIR}/ebuild/utils/merge "merge_TEST_dir/config_pro_noroot_src" \
+ "/" \
+ "merge_TEST_dir/config_pro_slash_root_contents" 1>/dev/null
+ test_return_code
+
+ echo -n "[one]"
+
+ [[ -f merge_TEST_dir/noroot_dst/dir/one ]] ; test_return_code
+ [[ -f merge_TEST_dir/noroot_dst/dir/._cfg0000_one ]] ; test_return_code
+ ! [[ -f merge_TEST_dir/noroot_dst/dir/._cfg0001_one ]] ; test_return_code
+ test_equality "$(< merge_TEST_dir/noroot_dst/dir/one)" "i am a fish"
+ test_equality "$(< merge_TEST_dir/noroot_dst/dir/._cfg0000_one)" "contents of one"
+
+ echo -n "[two]"
+
+ [[ -f merge_TEST_dir/noroot_dst/dir/two ]] ; test_return_code
+ ! [[ -f merge_TEST_dir/noroot_dst/dir/._cfg0000_two ]] ; test_return_code
+ test_equality "$(< merge_TEST_dir/noroot_dst/dir/two)" "contents of two"
+
+ echo -n "[three]"
+
+ [[ -f merge_TEST_dir/noroot_dst/dir/three ]] ; test_return_code
+ [[ -f merge_TEST_dir/noroot_dst/dir/._cfg0000_three ]] ; test_return_code
+ [[ -f merge_TEST_dir/noroot_dst/dir/._cfg0001_three ]] ; test_return_code
+ [[ -f merge_TEST_dir/noroot_dst/dir/._cfg0002_three ]] ; test_return_code
+ ! [[ -f merge_TEST_dir/noroot_dst/dir/._cfg0003_three ]] ; test_return_code
+ test_equality "$(< merge_TEST_dir/noroot_dst/dir/three)" "i am a fish"
+ test_equality "$(< merge_TEST_dir/noroot_dst/dir/._cfg0000_three)" "i am a dish"
+ test_equality "$(< merge_TEST_dir/noroot_dst/dir/._cfg0001_three)" "i am a fist"
+ test_equality "$(< merge_TEST_dir/noroot_dst/dir/._cfg0002_three)" "contents of three"
+
+ echo -n "[four]"
+
+ [[ -f merge_TEST_dir/noroot_dst/dir/four ]] ; test_return_code
+ [[ -f merge_TEST_dir/noroot_dst/dir/._cfg0000_four ]] ; test_return_code
+ [[ -f merge_TEST_dir/noroot_dst/dir/._cfg0001_four ]] ; test_return_code
+ ! [[ -f merge_TEST_dir/noroot_dst/dir/._cfg0002_four ]] ; test_return_code
+ test_equality "$(< merge_TEST_dir/noroot_dst/dir/four)" "i am a fish"
+ test_equality "$(< merge_TEST_dir/noroot_dst/dir/._cfg0000_four)" "contents of four"
+ test_equality "$(< merge_TEST_dir/noroot_dst/dir/._cfg0001_four)" "i am a fist"
+
+}
diff --git a/ebuild/utils/merge_TEST_setup.sh b/ebuild/utils/merge_TEST_setup.sh
index 33b23e7..4af857d 100755
--- a/ebuild/utils/merge_TEST_setup.sh
+++ b/ebuild/utils/merge_TEST_setup.sh
@@ -42,3 +42,33 @@ ln -s three merge_TEST_dir/links_over_dir_src/link_to_three
mkdir merge_TEST_dir/links_over_dir_dst/link_to_two
echo "existing file" > merge_TEST_dir/links_over_dir_dst/link_to_three
+mkdir -p merge_TEST_dir/{config_pro_src/dir,config_pro_dst/dir} || exit 6
+echo "contents of one" > merge_TEST_dir/config_pro_src/dir/one
+echo "contents of two" > merge_TEST_dir/config_pro_src/dir/two
+echo "contents of three" > merge_TEST_dir/config_pro_src/dir/three
+echo "contents of four" > merge_TEST_dir/config_pro_src/dir/four
+echo "i am a fish" > merge_TEST_dir/config_pro_dst/dir/one
+echo "contents of two" > merge_TEST_dir/config_pro_dst/dir/two
+echo "i am a fish" > merge_TEST_dir/config_pro_dst/dir/three
+echo "i am a dish" > merge_TEST_dir/config_pro_dst/dir/._cfg0000_three
+echo "i am a fist" > merge_TEST_dir/config_pro_dst/dir/._cfg0001_three
+echo "i am a fish" > merge_TEST_dir/config_pro_dst/dir/four
+echo "contents of four" > merge_TEST_dir/config_pro_dst/dir/._cfg0000_four
+echo "i am a fist" > merge_TEST_dir/config_pro_dst/dir/._cfg0001_four
+
+d=merge_TEST_dir/config_pro_noroot_src/$(${PALUDIS_EBUILD_DIR}/utils/canonicalise `pwd` )/merge_TEST_dir/noroot_dst/dir
+mkdir -p "${d}" || exit 7
+mkdir -p merge_TEST_dir/noroot_dst/dir || exit 7
+echo "contents of one" > ${d}/one
+echo "contents of two" > ${d}/two
+echo "contents of three" > ${d}/three
+echo "contents of four" > ${d}/four
+echo "i am a fish" > merge_TEST_dir/noroot_dst/dir/one
+echo "contents of two" > merge_TEST_dir/noroot_dst/dir/two
+echo "i am a fish" > merge_TEST_dir/noroot_dst/dir/three
+echo "i am a dish" > merge_TEST_dir/noroot_dst/dir/._cfg0000_three
+echo "i am a fist" > merge_TEST_dir/noroot_dst/dir/._cfg0001_three
+echo "i am a fish" > merge_TEST_dir/noroot_dst/dir/four
+echo "contents of four" > merge_TEST_dir/noroot_dst/dir/._cfg0000_four
+echo "i am a fist" > merge_TEST_dir/noroot_dst/dir/._cfg0001_four
+
diff --git a/ebuild/utils/merge_common.cc b/ebuild/utils/merge_common.cc
index abb42a2..d6e9693 100644
--- a/ebuild/utils/merge_common.cc
+++ b/ebuild/utils/merge_common.cc
@@ -66,6 +66,8 @@ merge::is_config_protected(const FSEntry & root, const FSEntry & file)
file_str.erase(0, root_str.length());
if (file_str.empty())
file_str = "/";
+ if ('/' != file_str.at(0))
+ file_str = "/" + file_str;
bool result(false);
for (std::vector<std::string>::const_iterator c(cfg_pro.begin()),