aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--paludis/repositories/e/pbin_merger.cc6
-rw-r--r--paludis/repositories/e/pbin_merger.hh1
-rw-r--r--paludis/tar_extras.cc23
-rw-r--r--paludis/tar_extras.hh1
-rw-r--r--paludis/tar_merger.cc21
-rw-r--r--paludis/tar_merger.hh3
-rw-r--r--paludis/tar_merger_TEST.cc4
7 files changed, 53 insertions, 6 deletions
diff --git a/paludis/repositories/e/pbin_merger.cc b/paludis/repositories/e/pbin_merger.cc
index 64eff3a82..4e4684aab 100644
--- a/paludis/repositories/e/pbin_merger.cc
+++ b/paludis/repositories/e/pbin_merger.cc
@@ -174,6 +174,12 @@ PbinMerger::on_done_merge()
}
void
+PbinMerger::track_install_dir(const FSPath &, const FSPath & dst)
+{
+ display_override(">>> [dir] " + stringify(dst));
+}
+
+void
PbinMerger::track_install_file(const FSPath &, const FSPath & dst)
{
display_override(">>> [obj] " + stringify(dst));
diff --git a/paludis/repositories/e/pbin_merger.hh b/paludis/repositories/e/pbin_merger.hh
index 358b8f36e..f8a92be5e 100644
--- a/paludis/repositories/e/pbin_merger.hh
+++ b/paludis/repositories/e/pbin_merger.hh
@@ -77,6 +77,7 @@ namespace paludis
void on_done_merge() override;
+ void track_install_dir(const FSPath &, const FSPath &) override;
void track_install_file(const FSPath &, const FSPath &) override;
void track_install_sym(const FSPath &, const FSPath &) override;
diff --git a/paludis/tar_extras.cc b/paludis/tar_extras.cc
index 6e459d63e..85080c997 100644
--- a/paludis/tar_extras.cc
+++ b/paludis/tar_extras.cc
@@ -67,6 +67,29 @@ paludis_tar_extras_init(const std::string & f, const std::string & compress)
extern "C"
void
+paludis_tar_extras_add_dir(PaludisTarExtras * const extras, const std::string & from, const std::string & path)
+{
+ struct archive_entry * entry(archive_entry_new());
+ if (! entry)
+ throw MergerError("archive_entry_new returned null");
+
+ struct stat st;
+ if (0 != lstat(from.c_str(), &st))
+ throw MergerError("lstat failed");
+
+ archive_entry_copy_pathname(entry, path.c_str());
+ archive_entry_copy_stat(entry, &st);
+ if (ARCHIVE_OK != archive_write_header(extras->archive, entry))
+ throw MergerError("archive_write_header failed");
+
+ if (ARCHIVE_OK != archive_write_finish_entry(extras->archive))
+ throw MergerError("archive_write_finish_entry failed");
+
+ archive_entry_free(entry);
+}
+
+extern "C"
+void
paludis_tar_extras_add_file(PaludisTarExtras * const extras, const std::string & from, const std::string & path)
{
struct archive * disk_archive(archive_read_disk_new());
diff --git a/paludis/tar_extras.hh b/paludis/tar_extras.hh
index 09523a0f3..029260c57 100644
--- a/paludis/tar_extras.hh
+++ b/paludis/tar_extras.hh
@@ -26,6 +26,7 @@
struct PaludisTarExtras;
extern "C" PaludisTarExtras * paludis_tar_extras_init(const std::string &, const std::string &) PALUDIS_VISIBLE PALUDIS_ATTRIBUTE((warn_unused_result));
+extern "C" void paludis_tar_extras_add_dir(PaludisTarExtras * const, const std::string &, const std::string &) PALUDIS_VISIBLE;
extern "C" void paludis_tar_extras_add_file(PaludisTarExtras * const, const std::string &, const std::string &) PALUDIS_VISIBLE;
extern "C" void paludis_tar_extras_add_sym(PaludisTarExtras * const, const std::string &, const std::string &, const std::string &) PALUDIS_VISIBLE;
extern "C" void paludis_tar_extras_cleanup(PaludisTarExtras * const) PALUDIS_VISIBLE;
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)
diff --git a/paludis/tar_merger.hh b/paludis/tar_merger.hh
index ea6e5e1b8..009e2f4b6 100644
--- a/paludis/tar_merger.hh
+++ b/paludis/tar_merger.hh
@@ -79,6 +79,7 @@ namespace paludis
virtual void add_file(const FSPath &, const FSPath &);
+ virtual void track_install_dir(const FSPath &, const FSPath &) = 0;
virtual void track_install_file(const FSPath &, const FSPath &) = 0;
virtual void track_install_sym(const FSPath &, const FSPath &) = 0;
@@ -86,8 +87,8 @@ namespace paludis
TarMerger(const TarMergerParams &);
~TarMerger();
- void on_file_main(bool is_check, const FSPath &, const FSPath &) override;
void on_dir_main(bool is_check, const FSPath &, const FSPath &) override;
+ void on_file_main(bool is_check, const FSPath &, const FSPath &) override;
void on_sym_main(bool is_check, const FSPath &, const FSPath &) override;
void prepare_install_under() override;
diff --git a/paludis/tar_merger_TEST.cc b/paludis/tar_merger_TEST.cc
index 6a047d5c9..c01842b7c 100644
--- a/paludis/tar_merger_TEST.cc
+++ b/paludis/tar_merger_TEST.cc
@@ -72,6 +72,10 @@ namespace
{
}
+ void track_install_dir(const FSPath &, const FSPath &) override
+ {
+ }
+
void track_install_file(const FSPath &, const FSPath &) override
{
}