aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-07-29 10:55:45 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-07-31 11:36:04 +0100
commit6ef97b0bd5fa6462bbd27ab28b753814518e1f2b (patch)
tree0b06670cec1d4cd5555f793ca0610602e7451599
parent07adeeb6f48bab15107e2e92c9dd37c9168789a5 (diff)
downloadpaludis-6ef97b0bd5fa6462bbd27ab28b753814518e1f2b.tar.gz
paludis-6ef97b0bd5fa6462bbd27ab28b753814518e1f2b.tar.xz
Support merging subdirectories
-rw-r--r--paludis/fs_merger.cc15
-rw-r--r--paludis/fs_merger.hh4
-rw-r--r--paludis/merger.cc6
-rw-r--r--paludis/merger.hh2
-rw-r--r--paludis/tar_merger.cc6
-rw-r--r--paludis/tar_merger.hh3
-rw-r--r--paludis/tar_merger_TEST.cc5
-rwxr-xr-xpaludis/tar_merger_TEST_setup.sh11
8 files changed, 47 insertions, 5 deletions
diff --git a/paludis/fs_merger.cc b/paludis/fs_merger.cc
index 58c0320..7d5d85a 100644
--- a/paludis/fs_merger.cc
+++ b/paludis/fs_merger.cc
@@ -978,3 +978,18 @@ FSMerger::on_sym_main(bool is_check, const FSEntry & src, const FSEntry & dst)
} while (false);
}
+FSEntry
+FSMerger::canonicalise_root_path(const FSEntry & f)
+{
+ return f.realpath();
+}
+
+void
+FSMerger::do_dir_recursive(bool is_check, const FSEntry & src, const FSEntry & dst)
+{
+ if ((! is_check) && (! dst.is_directory()))
+ throw MergerError("Destination directory '" + stringify(dst) + "' is not a directory");
+
+ Merger::do_dir_recursive(is_check, src, dst);
+}
+
diff --git a/paludis/fs_merger.hh b/paludis/fs_merger.hh
index 36420a1..ba58f52 100644
--- a/paludis/fs_merger.hh
+++ b/paludis/fs_merger.hh
@@ -197,6 +197,10 @@ namespace paludis
virtual void prepare_install_under();
+ virtual FSEntry canonicalise_root_path(const FSEntry & f);
+
+ virtual void do_dir_recursive(bool is_check, const FSEntry &, const FSEntry &);
+
///\}
///\name Configuration protection
diff --git a/paludis/merger.cc b/paludis/merger.cc
index 6a79c48..984c228 100644
--- a/paludis/merger.cc
+++ b/paludis/merger.cc
@@ -112,7 +112,7 @@ Merger::merge()
if (! _imp->params.no_chown())
do_ownership_fixes_recursive(_imp->params.image());
- do_dir_recursive(false, _imp->params.image(), (_imp->params.root() / _imp->params.install_under()).realpath());
+ do_dir_recursive(false, _imp->params.image(), canonicalise_root_path(_imp->params.root() / _imp->params.install_under()));
if (0 != _imp->params.environment()->perform_hook(extend_hook(
Hook("merger_install_post")
@@ -137,8 +137,6 @@ 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(dst) + "' is not a directory");
on_enter_dir(is_check, src);
@@ -172,7 +170,7 @@ Merger::do_dir_recursive(bool is_check, const FSEntry & src, const FSEntry & dst
{
if (! _imp->skip_dir)
do_dir_recursive(is_check, *d,
- is_check ? (dst / d->basename()) : (dst / d->basename()).realpath());
+ is_check ? (dst / d->basename()) : canonicalise_root_path(dst / d->basename()));
else
_imp->skip_dir = false;
}
diff --git a/paludis/merger.hh b/paludis/merger.hh
index 826e083..456e298 100644
--- a/paludis/merger.hh
+++ b/paludis/merger.hh
@@ -131,6 +131,8 @@ namespace paludis
virtual void prepare_install_under() = 0;
+ virtual FSEntry canonicalise_root_path(const FSEntry &) = 0;
+
public:
explicit Merger(const MergerParams &);
~Merger();
diff --git a/paludis/tar_merger.cc b/paludis/tar_merger.cc
index 9fd30d6..5a79d7c 100644
--- a/paludis/tar_merger.cc
+++ b/paludis/tar_merger.cc
@@ -148,3 +148,9 @@ TarMerger::merge()
}
}
+FSEntry
+TarMerger::canonicalise_root_path(const FSEntry & f)
+{
+ return f;
+}
+
diff --git a/paludis/tar_merger.hh b/paludis/tar_merger.hh
index 09716ea..4e89867 100644
--- a/paludis/tar_merger.hh
+++ b/paludis/tar_merger.hh
@@ -69,6 +69,9 @@ namespace paludis
private:
Pimp<TarMerger>::ImpPtr & _imp;
+ protected:
+ virtual FSEntry canonicalise_root_path(const FSEntry & f);
+
public:
TarMerger(const TarMergerParams &);
~TarMerger();
diff --git a/paludis/tar_merger_TEST.cc b/paludis/tar_merger_TEST.cc
index 65660c5..5ed583a 100644
--- a/paludis/tar_merger_TEST.cc
+++ b/paludis/tar_merger_TEST.cc
@@ -114,6 +114,11 @@ namespace test_cases
TEST_CHECK((FSEntry("tar_merger_TEST_dir") / "simple_extract" / "file").is_regular_file());
TEST_CHECK_EQUAL((FSEntry("tar_merger_TEST_dir") / "simple_extract" / "file").file_size(),
(FSEntry("tar_merger_TEST_dir") / "simple" / "file").file_size());
+
+ TEST_CHECK((FSEntry("tar_merger_TEST_dir") / "simple_extract" / "subdir" / "another").is_regular_file());
+
+ TEST_CHECK((FSEntry("tar_merger_TEST_dir") / "simple_extract" / "subdir" / "subsubdir" / "script").is_regular_file());
+ TEST_CHECK((FSEntry("tar_merger_TEST_dir") / "simple_extract" / "subdir" / "subsubdir" / "script").has_permission(fs_ug_owner, fs_perm_execute));
}
} test_simple_tar_merger;
}
diff --git a/paludis/tar_merger_TEST_setup.sh b/paludis/tar_merger_TEST_setup.sh
index ae4d3ca..19619ec 100755
--- a/paludis/tar_merger_TEST_setup.sh
+++ b/paludis/tar_merger_TEST_setup.sh
@@ -4,8 +4,17 @@
mkdir tar_merger_TEST_dir || exit 2
cd tar_merger_TEST_dir || exit 3
-mkdir -p simple simple_extract
+mkdir -p simple/subdir/subsubdir simple_extract
cat <<END > simple/file
This is the file.
END
+cat <<END > simple/subdir/another
+Another file
+END
+
+cat <<END > simple/subdir/subsubdir/script
+Woohoo
+END
+chmod +x simple/subdir/subsubdir/script
+