aboutsummaryrefslogtreecommitdiff
path: root/paludis/tar_merger.cc
diff options
context:
space:
mode:
authorAvatar Marvin Schmidt <marv@exherbo.org> 2016-05-04 18:25:16 +0200
committerAvatar Marvin Schmidt <marv@exherbo.org> 2021-09-17 16:43:16 +0200
commit017154e9ed5ea544296d3d564a62c9b1300005f4 (patch)
tree9f2d628395da2b4e83ef1f96167d89e5c06f9567 /paludis/tar_merger.cc
parent8c7509d414075e3741fb0c5213463a9badaec264 (diff)
downloadpaludis-017154e9ed5ea544296d3d564a62c9b1300005f4.tar.gz
paludis-017154e9ed5ea544296d3d564a62c9b1300005f4.tar.xz
Make TarMerger handle directories correctly
The TarMerger has to handle directories explicitly in order to preserve the permissions and ownerships they were given
Diffstat (limited to 'paludis/tar_merger.cc')
-rw-r--r--paludis/tar_merger.cc21
1 files changed, 16 insertions, 5 deletions
diff --git a/paludis/tar_merger.cc b/paludis/tar_merger.cc
index bb508fcbe..6a742b7ed 100644
--- a/paludis/tar_merger.cc
+++ b/paludis/tar_merger.cc
@@ -46,12 +46,14 @@ namespace
Singleton<TarMergerHandle>
{
typedef PaludisTarExtras * (* InitPtr) (const std::string &, const std::string &);
+ typedef void (* AddDirPtr) (PaludisTarExtras * const, const std::string &, const std::string &);
typedef void (* AddFilePtr) (PaludisTarExtras * const, const std::string &, const std::string &);
typedef void (* AddSymPtr) (PaludisTarExtras * const, const std::string &, const std::string &, const std::string &);
typedef void (* CleanupPtr) (PaludisTarExtras * const);
void * handle;
InitPtr init;
+ AddDirPtr add_dir;
AddFilePtr add_file;
AddSymPtr add_sym;
CleanupPtr cleanup;
@@ -72,6 +74,10 @@ namespace
if (! init)
throw MergerError("Unable to init from libpaludistarextras due to error '" + stringify(::dlerror()) + "' from dlsym");
+ add_dir = STUPID_CAST(AddDirPtr, ::dlsym(handle, "paludis_tar_extras_add_dir"));
+ if (! add_dir)
+ throw MergerError("Unable to add_dir from libpaludistarextras due to error '" + stringify(::dlerror()) + "' from dlsym");
+
add_file = STUPID_CAST(AddFilePtr, ::dlsym(handle, "paludis_tar_extras_add_file"));
if (! add_file)
throw MergerError("Unable to add_file from libpaludistarextras due to error '" + stringify(::dlerror()) + "' from dlsym");
@@ -130,6 +136,16 @@ TarMerger::TarMerger(const TarMergerParams & p) :
TarMerger::~TarMerger() = default;
void
+TarMerger::on_dir_main(bool is_check, const FSPath & src, const FSPath & dst)
+{
+ if (is_check)
+ return;
+
+ track_install_dir(src, dst / src.basename());
+ (*TarMergerHandle::get_instance()->add_dir)(_imp->tar, stringify(src), strip_leading(stringify(dst / src.basename()), "/"));
+}
+
+void
TarMerger::on_file_main(bool is_check, const FSPath & src, const FSPath & dst)
{
if (is_check)
@@ -146,11 +162,6 @@ TarMerger::add_file(const FSPath & src, const FSPath & dst)
}
void
-TarMerger::on_dir_main(bool, const FSPath &, const FSPath &)
-{
-}
-
-void
TarMerger::on_sym_main(bool is_check, const FSPath & src, const FSPath & dst)
{
if (is_check)