aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-07-29 18:34:10 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-07-31 11:36:05 +0100
commitf8058cf3d2faad1df09e1a0d1af51a99f3401004 (patch)
treecd7793dddb3b7bfe82a87717af8c0dc9c1847ef9
parent7c45cd17c44ad61b76b51c18144692ccca04390d (diff)
downloadpaludis-f8058cf3d2faad1df09e1a0d1af51a99f3401004.tar.gz
paludis-f8058cf3d2faad1df09e1a0d1af51a99f3401004.tar.xz
Use GNU tar format, and support compression
-rw-r--r--paludis/files.m42
-rw-r--r--paludis/tar_extras.cc11
-rw-r--r--paludis/tar_extras.hh2
-rw-r--r--paludis/tar_merger-fwd.hh6
-rw-r--r--paludis/tar_merger.cc29
-rw-r--r--paludis/tar_merger.hh2
-rw-r--r--paludis/tar_merger.se20
-rw-r--r--paludis/tar_merger_TEST.cc1
8 files changed, 66 insertions, 7 deletions
diff --git a/paludis/files.m4 b/paludis/files.m4
index 10f32e0..d152924 100644
--- a/paludis/files.m4
+++ b/paludis/files.m4
@@ -99,7 +99,7 @@ add(`stringify_formatter', `hh', `cc', `fwd', `impl', `test')
add(`stripper', `hh', `cc', `fwd', `test', `testscript')
add(`syncer', `hh', `cc')
add(`sync_task', `hh', `cc')
-add(`tar_merger', `hh', `cc', `fwd', `test', `testscript')
+add(`tar_merger', `hh', `cc', `fwd', `test', `testscript', `se')
add(`tasks_exceptions', `hh', `cc')
add(`tee_output_manager', `hh', `cc', `fwd')
add(`unchoices_key', `hh', `cc', `fwd')
diff --git a/paludis/tar_extras.cc b/paludis/tar_extras.cc
index 76f27fd..88f5b70 100644
--- a/paludis/tar_extras.cc
+++ b/paludis/tar_extras.cc
@@ -31,12 +31,17 @@ struct PaludisTarExtras
extern "C"
PaludisTarExtras *
-paludis_tar_extras_init(const std::string & f)
+paludis_tar_extras_init(const std::string & f, const std::string & compress)
{
auto extras(new PaludisTarExtras);
extras->archive = archive_write_new();
- archive_write_set_compression_none(extras->archive);
- archive_write_set_format_pax(extras->archive);
+
+ if (compress == "bz2")
+ archive_write_set_compression_bzip2(extras->archive);
+ else
+ archive_write_set_compression_none(extras->archive);
+
+ archive_write_set_format_gnutar(extras->archive);
archive_write_open_filename(extras->archive, f.c_str());
return extras;
}
diff --git a/paludis/tar_extras.hh b/paludis/tar_extras.hh
index 64ad05c..09523a0 100644
--- a/paludis/tar_extras.hh
+++ b/paludis/tar_extras.hh
@@ -25,7 +25,7 @@
struct PaludisTarExtras;
-extern "C" PaludisTarExtras * paludis_tar_extras_init(const std::string &) PALUDIS_VISIBLE PALUDIS_ATTRIBUTE((warn_unused_result));
+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_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-fwd.hh b/paludis/tar_merger-fwd.hh
index 66605a1..e29ac42 100644
--- a/paludis/tar_merger-fwd.hh
+++ b/paludis/tar_merger-fwd.hh
@@ -20,9 +20,15 @@
#ifndef PALUDIS_GUARD_PALUDIS_TAR_MERGER_FWD_HH
#define PALUDIS_GUARD_PALUDIS_TAR_MERGER_FWD_HH 1
+#include <paludis/util/attributes.hh>
+#include <iosfwd>
+
namespace paludis
{
class TarMerger;
+
+#include <paludis/tar_merger-se.hh>
+
}
#endif
diff --git a/paludis/tar_merger.cc b/paludis/tar_merger.cc
index cfa5898..9f73eb2 100644
--- a/paludis/tar_merger.cc
+++ b/paludis/tar_merger.cc
@@ -23,8 +23,12 @@
#include <paludis/util/make_named_values.hh>
#include <paludis/util/singleton-impl.hh>
#include <paludis/util/strip.hh>
+#include <paludis/util/exception.hh>
+#include <paludis/util/stringify.hh>
#include <paludis/about.hh>
+#include <ostream>
+
#include <dlfcn.h>
#include <stdint.h>
@@ -32,12 +36,14 @@
using namespace paludis;
+#include <paludis/tar_merger-se.cc>
+
namespace
{
struct TarMergerHandle :
Singleton<TarMergerHandle>
{
- typedef PaludisTarExtras * (* InitPtr) (const std::string &);
+ typedef PaludisTarExtras * (* InitPtr) (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);
@@ -141,7 +147,26 @@ TarMerger::prepare_install_under()
void
TarMerger::merge()
{
- _imp->tar = (*TarMergerHandle::get_instance()->init)(stringify(_imp->params.tar_file()));
+ std::string compress;
+
+ switch (_imp->params.compression())
+ {
+ case tmc_none:
+ compress = "none";
+ break;
+
+ case tmc_bz2:
+ compress = "bz2";
+ break;
+
+ case last_tmc:
+ break;
+ };
+
+ if (compress.empty())
+ throw InternalError(PALUDIS_HERE, "unknown compress");
+
+ _imp->tar = (*TarMergerHandle::get_instance()->init)(stringify(_imp->params.tar_file()), compress);
try
{
diff --git a/paludis/tar_merger.hh b/paludis/tar_merger.hh
index 4e89867..ddb3e8d 100644
--- a/paludis/tar_merger.hh
+++ b/paludis/tar_merger.hh
@@ -28,6 +28,7 @@ namespace paludis
{
namespace n
{
+ typedef Name<struct compression_name> compression;
typedef Name<struct environment_name> environment;
typedef Name<struct fix_mtimes_before_name> fix_mtimes_before;
typedef Name<struct get_new_ids_or_minus_one_name> get_new_ids_or_minus_one;
@@ -50,6 +51,7 @@ namespace paludis
*/
struct TarMergerParams
{
+ NamedValue<n::compression, TarMergerCompression> compression;
NamedValue<n::environment, Environment *> environment;
NamedValue<n::fix_mtimes_before, Timestamp> fix_mtimes_before;
NamedValue<n::get_new_ids_or_minus_one, std::function<std::pair<uid_t, gid_t> (const FSEntry &)> > get_new_ids_or_minus_one;
diff --git a/paludis/tar_merger.se b/paludis/tar_merger.se
new file mode 100644
index 0000000..915ab5e
--- /dev/null
+++ b/paludis/tar_merger.se
@@ -0,0 +1,20 @@
+#!/usr/bin/env bash
+# vim: set sw=4 sts=4 et ft=sh :
+
+make_enum_TarMergerCompression()
+{
+ prefix tmc
+
+ key tmc_none "No compression"
+ key tmc_bz2 "Compress using bz2"
+
+ doxygen_comment << "END"
+ /**
+ * Compression for TarMerger
+ *
+ * \see TarMerger
+ * \ingroup g_repository
+ */
+END
+}
+
diff --git a/paludis/tar_merger_TEST.cc b/paludis/tar_merger_TEST.cc
index 42b9d2f..69dad97 100644
--- a/paludis/tar_merger_TEST.cc
+++ b/paludis/tar_merger_TEST.cc
@@ -87,6 +87,7 @@ namespace test_cases
TestEnvironment env;
TestTarMerger merger(make_named_values<TarMergerParams>(
+ n::compression() = tmc_none,
n::environment() = &env,
n::fix_mtimes_before() = Timestamp(0, 0),
n::get_new_ids_or_minus_one() = &get_new_ids_or_minus_one,