aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Stephen P. Bennett <spb@exherbo.org> 2006-04-15 17:21:29 +0000
committerAvatar Stephen P. Bennett <spb@exherbo.org> 2006-04-15 17:21:29 +0000
commit2b223ef16cb52f52c8cceac58dc5aefabb437079 (patch)
tree9062b7a08458b90ce3dc21ed21bbae20453d2b4b
parenta21a84d887b6e33275546348c58a756e71c28ca3 (diff)
downloadpaludis-2b223ef16cb52f52c8cceac58dc5aefabb437079.tar.gz
paludis-2b223ef16cb52f52c8cceac58dc5aefabb437079.tar.xz
Add SyncOptions, and use it for sync_exclude support. Currently only for portage repositories with rsync.
-rw-r--r--paludis/portage_repository.cc25
-rw-r--r--paludis/portage_repository.hh2
-rw-r--r--paludis/syncer.cc15
-rw-r--r--paludis/syncer.hh26
4 files changed, 55 insertions, 13 deletions
diff --git a/paludis/portage_repository.cc b/paludis/portage_repository.cc
index 1419d65..da48138 100644
--- a/paludis/portage_repository.cc
+++ b/paludis/portage_repository.cc
@@ -109,6 +109,9 @@ namespace paludis
/// Sync URL
std::string sync;
+ /// Sync exclude file
+ std::string sync_exclude;
+
/// Root location
FSEntry root;
@@ -175,7 +178,7 @@ namespace paludis
Implementation(const Environment * const,
const PackageDatabase * const d, const FSEntry & l, const FSEntry & p,
const FSEntry & c, const FSEntry &, const FSEntry &, const std::string &,
- const FSEntry &);
+ const std::string &, const FSEntry &);
/// Destructor.
~Implementation();
@@ -198,7 +201,7 @@ Implementation<PortageRepository>::Implementation(const Environment * const env,
const PackageDatabase * const d,
const FSEntry & l, const FSEntry & p, const FSEntry & c,
const FSEntry & e, const FSEntry & dd, const std::string & syn,
- const FSEntry & r) :
+ const std::string & se, const FSEntry & r) :
db(d),
env(env),
location(l),
@@ -207,6 +210,7 @@ Implementation<PortageRepository>::Implementation(const Environment * const env,
eclassdir(e),
distdir(dd),
sync(syn),
+ sync_exclude(se),
root(r),
has_category_names(false),
has_repo_mask(false),
@@ -382,10 +386,10 @@ PortageRepository::PortageRepository(
const FSEntry & location, const FSEntry & profile,
const FSEntry & cache, const FSEntry & eclassdir,
const FSEntry & distdir, const std::string & sync,
- const FSEntry & root) :
+ const std::string & sync_exclude, const FSEntry & root) :
Repository(PortageRepository::fetch_repo_name(location)),
PrivateImplementationPattern<PortageRepository>(new Implementation<PortageRepository>(e,
- d, location, profile, cache, eclassdir, distdir, sync, root))
+ d, location, profile, cache, eclassdir, distdir, sync, sync_exclude, root))
{
_info.insert(std::make_pair(std::string("location"), location));
_info.insert(std::make_pair(std::string("profile"), profile));
@@ -396,6 +400,9 @@ PortageRepository::PortageRepository(
_info.insert(std::make_pair(std::string("root"), stringify(root)));
if (! sync.empty())
_info.insert(std::make_pair(std::string("sync"), sync));
+ if (! sync_exclude.empty())
+ _info.insert(std::make_pair(std::string("sync_exclude"), sync_exclude));
+
}
PortageRepository::~PortageRepository()
@@ -983,12 +990,16 @@ PortageRepository::make_portage_repository(
if (m.end() == m.find("sync") || ((sync = m.find("sync")->second)).empty())
; // nothing
+ std::string sync_exclude;
+ if (m.end() == m.find("sync_exclude") || ((sync_exclude = m.find("sync_exclude")->second)).empty())
+ ; // nothing
+
std::string root;
if (m.end() == m.find("root") || ((root = m.find("root")->second)).empty())
root = "/";
return CountedPtr<Repository>(new PortageRepository(env, db, location, profile, cache,
- eclassdir, distdir, sync, root));
+ eclassdir, distdir, sync, sync_exclude, root));
}
PortageRepositoryConfigurationError::PortageRepositoryConfigurationError(
@@ -1307,8 +1318,10 @@ PortageRepository::do_sync() const
if (std::string::npos == p)
throw NoSuchSyncerError(_imp->sync);
+ SyncOptions opts(_imp->sync_exclude);
+
SyncerMaker::get_instance()->find_maker(_imp->sync.substr(0, std::min(p, q)))(
- _imp->location, _imp->sync.substr(q < p ? q + 1 : 0))->sync();
+ _imp->location, _imp->sync.substr(q < p ? q + 1 : 0))->sync(opts);
return true;
}
diff --git a/paludis/portage_repository.hh b/paludis/portage_repository.hh
index c59c42c..e067d5d 100644
--- a/paludis/portage_repository.hh
+++ b/paludis/portage_repository.hh
@@ -109,7 +109,7 @@ namespace paludis
const FSEntry & location, const FSEntry & profile,
const FSEntry & cache, const FSEntry & distdir,
const FSEntry & eclassdir, const std::string & sync,
- const FSEntry & root);
+ const std::string & sync_exclude, const FSEntry & root);
/**
* Virtual constructor.
diff --git a/paludis/syncer.cc b/paludis/syncer.cc
index 14235ae..1536b10 100644
--- a/paludis/syncer.cc
+++ b/paludis/syncer.cc
@@ -43,7 +43,7 @@ namespace
}
public:
- virtual void sync() const;
+ virtual void sync(const SyncOptions &) const;
static Syncer::Pointer make(const std::string & local, const std::string & remote)
{
@@ -66,7 +66,7 @@ namespace
}
public:
- virtual void sync() const;
+ virtual void sync(const SyncOptions &) const;
static Syncer::Pointer make(const std::string & local, const std::string & remote)
{
return Syncer::Pointer(new SvnSyncer(local, remote));
@@ -79,22 +79,27 @@ namespace
}
void
-RsyncSyncer::sync() const
+RsyncSyncer::sync(const SyncOptions & opts) const
{
Context context("When performing sync via rsync from '" + _remote + "' to '"
+ _local + "':");
+ std::string exclude;
+ if (! opts.get<so_excludefrom>().empty())
+ exclude = "--exclude-from " + std::string(opts.get<so_excludefrom>()) + " ";
+
+
std::string cmd("rsync --recursive --links --safe-links --perms --times "
"--compress --force --whole-file --delete --delete-after --stats "
"--timeout=180 --exclude=/distfiles --exclude=/packages --progress "
- "'" + _remote + "' '" + _local + "/'");
+ + exclude + "'" + _remote + "' '" + _local + "/'");
if (0 != run_command(cmd))
throw SyncFailedError(_local, _remote);
}
void
-SvnSyncer::sync() const
+SvnSyncer::sync(const SyncOptions &) const
{
Context context("When performing sync via subversion from '" + _remote + "' to '"
+ _local + "':");
diff --git a/paludis/syncer.hh b/paludis/syncer.hh
index b244e31..9d29f1c 100644
--- a/paludis/syncer.hh
+++ b/paludis/syncer.hh
@@ -29,6 +29,30 @@ using namespace paludis;
namespace paludis
{
+ /**
+ * Keys for SyncOptions
+ */
+ enum SyncOptionsKeys
+ {
+ so_excludefrom, ///< Filename from which to take a list of excluded files
+ so_last ///< Number of keys.
+ };
+
+ /**
+ * Tag for SyncOptions.
+ */
+ struct SyncOptionsTag :
+ SmartRecordTag<comparison_mode::NoComparisonTag, void>,
+ SmartRecordKeys<SyncOptionsKeys, so_last>,
+ SmartRecordKey<so_excludefrom, std::string>
+ {
+ };
+
+ /**
+ * Defines options to be passed to the syncer.
+ */
+ typedef MakeSmartRecord<SyncOptionsTag>::Type SyncOptions;
+
class Syncer :
private InstantiationPolicy<Syncer, instantiation_method::NonCopyableTag>,
public InternalCounted<Syncer>
@@ -43,7 +67,7 @@ namespace paludis
{
}
- virtual void sync() const = 0;
+ virtual void sync(const SyncOptions &) const = 0;
};
/**