aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar David Leverton <levertond@googlemail.com> 2007-09-19 08:57:12 +0000
committerAvatar David Leverton <levertond@googlemail.com> 2007-09-19 08:57:12 +0000
commit4c2f7daf3adfe934985383f1700c9b9c2bf71351 (patch)
tree2feabf12190bcbbd1d3c3379d4fd27de653935da
parent318ea9e78ab6af81d38f4b864b35ffb1f24b4f5b (diff)
downloadpaludis-4c2f7daf3adfe934985383f1700c9b9c2bf71351.tar.gz
paludis-4c2f7daf3adfe934985383f1700c9b9c2bf71351.tar.xz
Make mergers work when ${ROOT} contains symlinks. Fixes: ticket:313
-rw-r--r--paludis/merger/merger.cc10
-rw-r--r--paludis/merger/merger_TEST.cc12
-rwxr-xr-xpaludis/merger/merger_TEST_setup.sh151
-rw-r--r--paludis/repositories/e/vdb_merger.cc16
-rwxr-xr-xpaludis/repositories/e/vdb_merger_TEST_setup.sh10
-rwxr-xr-xpython/mask_TEST.py6
6 files changed, 111 insertions, 94 deletions
diff --git a/paludis/merger/merger.cc b/paludis/merger/merger.cc
index bd66601..30aee78 100644
--- a/paludis/merger/merger.cc
+++ b/paludis/merger/merger.cc
@@ -107,7 +107,7 @@ Merger::merge()
Log::get_instance()->message(ll_warning, lc_context,
"Merge of '" + stringify(_options.image) + "' to '" + stringify(_options.root) + "' pre hooks returned non-zero");
- do_dir_recursive(false, _options.image, _options.root);
+ do_dir_recursive(false, _options.image, _options.root.realpath());
if (0 != _options.environment->perform_hook(extend_hook(
Hook("merger_install_post")
@@ -146,7 +146,7 @@ Merger::do_dir_recursive(bool is_check, const FSEntry & src, const FSEntry & dst
if (! src.is_directory())
throw MergerError("Source directory '" + stringify(src) + "' is not a directory");
if ((! is_check) && (! dst.is_directory()))
- throw MergerError("Destination directory '" + stringify(src) + "' is not a directory");
+ throw MergerError("Destination directory '" + stringify(dst) + "' is not a directory");
on_enter_dir(is_check, src);
@@ -217,7 +217,7 @@ Merger::on_file(bool is_check, const FSEntry & src, const FSEntry & dst)
<< stringify(src) << "' to '" << stringify(dst) << "' skip hooks returned non-zero";
else if (hr.output == "skip")
{
- std::string tidy(stringify((dst / src.basename()).strip_leading(_options.root)));
+ std::string tidy(stringify((dst / src.basename()).strip_leading(_options.root.realpath())));
display_override("--- [skp] " + tidy);
return;
}
@@ -289,7 +289,7 @@ Merger::on_dir(bool is_check, const FSEntry & src, const FSEntry & dst)
<< stringify(src) << "' to '" << stringify(dst) << "' skip hooks returned non-zero";
else if (hr.output == "skip")
{
- std::string tidy(stringify((dst / src.basename()).strip_leading(_options.root)));
+ std::string tidy(stringify((dst / src.basename()).strip_leading(_options.root.realpath())));
display_override("--- [skp] " + tidy);
_skip_dir = true;
return;
@@ -363,7 +363,7 @@ Merger::on_sym(bool is_check, const FSEntry & src, const FSEntry & dst)
<< stringify(src) << "' to '" << stringify(dst) << "' skip hooks returned non-zero";
else if (hr.output == "skip")
{
- std::string tidy(stringify((dst / src.basename()).strip_leading(_options.root)));
+ std::string tidy(stringify((dst / src.basename()).strip_leading(_options.root.realpath())));
display_override("--- [skp] " + tidy);
return;
}
diff --git a/paludis/merger/merger_TEST.cc b/paludis/merger/merger_TEST.cc
index c92c725..3f8c2fc 100644
--- a/paludis/merger/merger_TEST.cc
+++ b/paludis/merger/merger_TEST.cc
@@ -141,10 +141,10 @@ namespace
MergerTest(EntryType src_type, EntryType dst_type, int n = 0) :
TestCase("merge " + stringify(src_type) + " over " + stringify(dst_type) + (0 == n ? "" : " "
+ stringify(n))),
- image_dir("merger_TEST_dir/image_" + stringify(src_type) + "_over_" + stringify(dst_type)
- + (0 == n ? "" : "_" + stringify(n))),
- root_dir("merger_TEST_dir/root_" + stringify(src_type) + "_over_" + stringify(dst_type)
- + (0 == n ? "" : "_" + stringify(n))),
+ image_dir("merger_TEST_dir/" + stringify(src_type) + "_over_" + stringify(dst_type)
+ + (0 == n ? "" : "_" + stringify(n)) + "/image"),
+ root_dir("merger_TEST_dir/" + stringify(src_type) + "_over_" + stringify(dst_type)
+ + (0 == n ? "" : "_" + stringify(n)) + "/root"),
env(FSEntry("merger_TEST_dir/hooks")),
merger(MergerOptions::create()
.image(image_dir)
@@ -156,8 +156,8 @@ namespace
MergerTest(const std::string & custom_test) :
TestCase("merge " + custom_test + " test"),
- image_dir("merger_TEST_dir/image_" + custom_test),
- root_dir("merger_TEST_dir/root_" + custom_test),
+ image_dir("merger_TEST_dir/" + custom_test + "/image"),
+ root_dir("merger_TEST_dir/" + custom_test + "/root"),
env(FSEntry("merger_TEST_dir/hooks")),
merger(MergerOptions::create()
.image(image_dir)
diff --git a/paludis/merger/merger_TEST_setup.sh b/paludis/merger/merger_TEST_setup.sh
index 12fb678..9d9dd18 100755
--- a/paludis/merger/merger_TEST_setup.sh
+++ b/paludis/merger/merger_TEST_setup.sh
@@ -5,79 +5,84 @@ mkdir merger_TEST_dir || exit 2
cd merger_TEST_dir || exit 3
-mkdir image_sym_over_nothing root_sym_over_nothing
-ln -s image_dst image_sym_over_nothing/sym
-
-mkdir image_sym_over_sym root_sym_over_sym
-ln -s image_dst image_sym_over_sym/sym
-ln -s root_dst root_sym_over_sym/sym
-
-mkdir image_sym_over_file root_sym_over_file
-ln -s image_dst image_sym_over_file/sym
-> root_sym_over_file/sym
-
-mkdir image_sym_over_dir root_sym_over_dir
-ln -s image_dst image_sym_over_dir/sym
-mkdir root_sym_over_dir/sym
-
-
-mkdir image_dir_over_nothing root_dir_over_nothing
-mkdir image_dir_over_nothing/dir
-
-mkdir image_dir_over_dir root_dir_over_dir
-mkdir image_dir_over_dir/dir
-mkdir root_dir_over_dir/dir
-
-mkdir image_dir_over_file root_dir_over_file
-mkdir image_dir_over_file/dir
-> root_dir_over_file/dir
-
-mkdir image_dir_over_sym_1 root_dir_over_sym_1
-mkdir image_dir_over_sym_1/dir
-> image_dir_over_sym_1/dir/file
-mkdir root_dir_over_sym_1/realdir
-ln -s realdir root_dir_over_sym_1/dir
-
-mkdir image_dir_over_sym_2 root_dir_over_sym_2
-mkdir image_dir_over_sym_2/dir
-> image_dir_over_sym_2/dir/file
-> root_dir_over_sym_2/file
-ln -s file root_dir_over_sym_2/dir
-
-mkdir image_dir_over_sym_3 root_dir_over_sym_3
-mkdir image_dir_over_sym_3/dir
-> image_dir_over_sym_3/dir/file
-ln -s nowhere root_dir_over_sym_3/dir
-
-
-mkdir image_file_over_nothing root_file_over_nothing
-echo "image contents" > image_file_over_nothing/file
-
-mkdir image_file_over_file root_file_over_file
-echo "image contents" > image_file_over_file/file
-echo "root contents" > root_file_over_file/file
-
-mkdir image_file_over_sym root_file_over_sym
-echo "image 1 contents" > image_file_over_sym/file1
-echo "image 2 contents" > image_file_over_sym/file2
-echo "image 3 contents" > image_file_over_sym/file3
-ln -s nowhere root_file_over_sym/file1
-ln -s file root_file_over_sym/file2
-ln -s dir root_file_over_sym/file3
-> root_file_over_sym/file
-mkdir root_file_over_sym/dir
-
-mkdir image_file_over_dir root_file_over_dir
-> image_file_over_dir/file
-mkdir root_file_over_dir/file
-
-mkdir image_override root_override
-mkdir image_override/dir_skip_me/
-mkdir image_override/dir_install_me/
-> image_override/file_skip_me
-> image_override/file_install_me
-ln -s image_override/file_skip_me image_override/sym_skip_me
-ln -s image_override/file_install_me image_override/sym_install_me
+mkdir -p sym_over_nothing_dir/{image,root}
+ln -s image_dst sym_over_nothing_dir/image/sym
+
+mkdir -p sym_over_sym_dir/{image,root}
+ln -s image_dst sym_over_sym_dir/image/sym
+ln -s root_dst sym_over_sym_dir/root/sym
+
+mkdir -p sym_over_file_dir/{image,root}
+ln -s image_dst sym_over_file_dir/image/sym
+> sym_over_file_dir/root/sym
+
+mkdir -p sym_over_dir_dir/{image,root}
+ln -s image_dst sym_over_dir_dir/image/sym
+mkdir sym_over_dir_dir/root/sym
+
+
+mkdir -p dir_over_nothing_dir/{image,root}
+mkdir dir_over_nothing_dir/image/dir
+
+mkdir -p dir_over_dir_dir/{image,root}
+mkdir dir_over_dir_dir/image/dir
+mkdir dir_over_dir_dir/root/dir
+
+mkdir -p dir_over_file_dir/{image,root}
+mkdir dir_over_file_dir/image/dir
+> dir_over_file_dir/root/dir
+
+mkdir -p dir_over_sym_1_dir/{image,root}
+mkdir dir_over_sym_1_dir/image/dir
+> dir_over_sym_1_dir/image/dir/file
+mkdir dir_over_sym_1_dir/root/realdir
+ln -s realdir dir_over_sym_1_dir/root/dir
+
+mkdir -p dir_over_sym_2_dir/{image,root}
+mkdir dir_over_sym_2_dir/image/dir
+> dir_over_sym_2_dir/image/dir/file
+> dir_over_sym_2_dir/root/file
+ln -s file dir_over_sym_2_dir/root/dir
+
+mkdir -p dir_over_sym_3_dir/{image,root}
+mkdir dir_over_sym_3_dir/image/dir
+> dir_over_sym_3_dir/image/dir/file
+ln -s nowhere dir_over_sym_3_dir/root/dir
+
+
+mkdir -p file_over_nothing_dir/{image,root}
+echo "image contents" > file_over_nothing_dir/image/file
+
+mkdir -p file_over_file_dir/{image,root}
+echo "image contents" > file_over_file_dir/image/file
+echo "root contents" > file_over_file_dir/root/file
+
+mkdir -p file_over_sym_dir/{image,root}
+echo "image 1 contents" > file_over_sym_dir/image/file1
+echo "image 2 contents" > file_over_sym_dir/image/file2
+echo "image 3 contents" > file_over_sym_dir/image/file3
+ln -s nowhere file_over_sym_dir/root/file1
+ln -s file file_over_sym_dir/root/file2
+ln -s dir file_over_sym_dir/root/file3
+> file_over_sym_dir/root/file
+mkdir file_over_sym_dir/root/dir
+
+mkdir -p file_over_dir_dir/{image,root}
+> file_over_dir_dir/image/file
+mkdir file_over_dir_dir/root/file
+
+mkdir -p override_dir/{image,root}
+mkdir override_dir/image/dir_skip_me/
+mkdir override_dir/image/dir_install_me/
+> override_dir/image/file_skip_me
+> override_dir/image/file_install_me
+ln -s override_dir/image/file_skip_me override_dir/image/sym_skip_me
+ln -s override_dir/image/file_install_me override_dir/image/sym_install_me
+
+
+for d in *_dir; do
+ ln -s ${d} ${d%_dir}
+done
mkdir hooks
diff --git a/paludis/repositories/e/vdb_merger.cc b/paludis/repositories/e/vdb_merger.cc
index 57a9f84..20d1453 100644
--- a/paludis/repositories/e/vdb_merger.cc
+++ b/paludis/repositories/e/vdb_merger.cc
@@ -48,13 +48,15 @@ namespace paludis
struct Implementation<VDBMerger>
{
VDBMergerOptions options;
+ FSEntry realroot;
tr1::shared_ptr<std::ofstream> contents_file;
std::list<std::string> config_protect;
std::list<std::string> config_protect_mask;
Implementation(const VDBMergerOptions & o) :
- options(o)
+ options(o),
+ realroot(options.root.realpath())
{
WhitespaceTokeniser::get_instance()->tokenise(o.config_protect,
std::back_inserter(config_protect));
@@ -114,8 +116,8 @@ VDBMerger::extend_hook(const Hook & h)
void
VDBMerger::record_install_file(const FSEntry & src, const FSEntry & dst_dir, const std::string & dst_name)
{
- std::string tidy(stringify((dst_dir / dst_name).strip_leading(_imp->options.root))),
- tidy_real(stringify((dst_dir / src.basename()).strip_leading(_imp->options.root)));
+ std::string tidy(stringify((dst_dir / dst_name).strip_leading(_imp->realroot))),
+ tidy_real(stringify((dst_dir / src.basename()).strip_leading(_imp->realroot)));
time_t timestamp((dst_dir / dst_name).mtime());
std::ifstream infile(stringify(FSEntry(dst_dir / dst_name)).c_str());
@@ -135,7 +137,7 @@ VDBMerger::record_install_file(const FSEntry & src, const FSEntry & dst_dir, con
void
VDBMerger::record_install_dir(const FSEntry & src, const FSEntry & dst_dir)
{
- std::string tidy(stringify((dst_dir / src.basename()).strip_leading(_imp->options.root)));
+ std::string tidy(stringify((dst_dir / src.basename()).strip_leading(_imp->realroot)));
display_override(">>> [dir] " + tidy);
*_imp->contents_file << "dir " << tidy << std::endl;
@@ -144,7 +146,7 @@ VDBMerger::record_install_dir(const FSEntry & src, const FSEntry & dst_dir)
void
VDBMerger::record_install_sym(const FSEntry & src, const FSEntry & dst_dir)
{
- std::string tidy(stringify((dst_dir / src.basename()).strip_leading(_imp->options.root)));
+ std::string tidy(stringify((dst_dir / src.basename()).strip_leading(_imp->realroot)));
std::string target((dst_dir / src.basename()).readlink());
time_t timestamp((dst_dir / src.basename()).mtime());
@@ -174,7 +176,7 @@ VDBMerger::on_warn(bool is_check, const std::string & s)
bool
VDBMerger::config_protected(const FSEntry & src, const FSEntry & dst_dir)
{
- std::string tidy(stringify((dst_dir / src.basename()).strip_leading(_imp->options.root)));
+ std::string tidy(stringify((dst_dir / src.basename()).strip_leading(_imp->realroot)));
bool result(false);
for (std::list<std::string>::const_iterator c(_imp->config_protect.begin()),
@@ -204,7 +206,7 @@ VDBMerger::make_config_protect_name(const FSEntry & src, const FSEntry & dst)
std::ifstream our_md5_file(stringify(src).c_str());
if (! our_md5_file)
- throw MergerError("Could not get md5 for '" + stringify((dst / src.basename()).strip_leading(_imp->options.root)) + "'");
+ throw MergerError("Could not get md5 for '" + stringify((dst / src.basename()).strip_leading(_imp->realroot)) + "'");
MD5 our_md5(our_md5_file);
while (true)
diff --git a/paludis/repositories/e/vdb_merger_TEST_setup.sh b/paludis/repositories/e/vdb_merger_TEST_setup.sh
index f110faf..1cd9693 100755
--- a/paludis/repositories/e/vdb_merger_TEST_setup.sh
+++ b/paludis/repositories/e/vdb_merger_TEST_setup.sh
@@ -4,9 +4,10 @@
mkdir vdb_merger_TEST_dir || exit 2
cd vdb_merger_TEST_dir || exit 3
-mkdir -p config_protect/{image,root,CONTENTS} || exit 4
-cd config_protect/image
+mkdir -p config_protect_dir/{image,root,CONTENTS} || exit 4
+
+cd config_protect_dir/image
echo foo >protected_file
echo foo >unprotected_file
@@ -58,3 +59,8 @@ echo bar >protected_dir_not_really/unprotected_file
cd ../..
+
+for d in *_dir; do
+ ln -s ${d} ${d%_dir}
+done
+
diff --git a/python/mask_TEST.py b/python/mask_TEST.py
index 54106e8..6cddddf 100755
--- a/python/mask_TEST.py
+++ b/python/mask_TEST.py
@@ -68,7 +68,11 @@ class TestCase_01_Masks(unittest.TestCase):
self.assertEquals(m.key(), "R")
self.assertEquals(m.description(), "repository")
- package_mask_path = os.path.join(os.getcwd(), "mask_TEST_dir/testrepo/profiles/package.mask")
+ for section in self.db.fetch_repository("testrepo").info(False).sections:
+ for k, v in section.kvs:
+ if k == "location":
+ location = v
+ package_mask_path = os.path.join(location, "profiles/package.mask")
self.assertEquals(m.mask_key().value().mask_file, package_mask_path)
self.assert_(isinstance(m.mask_key().value().comment, StringIterable))