aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2008-04-12 21:53:11 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2008-04-12 21:53:11 +0000
commit68b4f3d25b131b53a749624778a6c6ab5e058373 (patch)
treefe276d5c0cee03c70fe1fb736c696b102969a775
parent05ccb6326bad0de2cf0fe7728cabda851f8a6e24 (diff)
downloadpaludis-68b4f3d25b131b53a749624778a6c6ab5e058373.tar.gz
paludis-68b4f3d25b131b53a749624778a6c6ab5e058373.tar.xz
Use PretendFetchAction to get download sizes. Fixes: ticket:504
-rw-r--r--paludis/action-fwd.hh1
-rw-r--r--paludis/action.cc29
-rw-r--r--paludis/action.hh35
-rw-r--r--paludis/install_task.cc6
-rw-r--r--paludis/install_task.hh1
-rw-r--r--paludis/package_id.hh14
-rw-r--r--paludis/repositories/cran/cran_installed_repository.cc4
-rw-r--r--paludis/repositories/cran/cran_package_id.cc17
-rw-r--r--paludis/repositories/cran/cran_package_id.hh2
-rw-r--r--paludis/repositories/cran/cran_repository.cc5
-rw-r--r--paludis/repositories/e/Makefile.am4
-rw-r--r--paludis/repositories/e/e_installed_repository.cc5
-rw-r--r--paludis/repositories/e/e_installed_repository_id.cc23
-rw-r--r--paludis/repositories/e/e_installed_repository_id.hh2
-rw-r--r--paludis/repositories/e/e_key.cc55
-rw-r--r--paludis/repositories/e/e_key.hh23
-rw-r--r--paludis/repositories/e/e_repository.cc5
-rw-r--r--paludis/repositories/e/e_repository_TEST.cc44
-rw-r--r--paludis/repositories/e/e_repository_entries.hh6
-rw-r--r--paludis/repositories/e/ebuild_entries.cc18
-rw-r--r--paludis/repositories/e/ebuild_entries.hh3
-rw-r--r--paludis/repositories/e/ebuild_id.cc79
-rw-r--r--paludis/repositories/e/ebuild_id.hh2
-rw-r--r--paludis/repositories/e/pretend_fetch_visitor.cc (renamed from paludis/repositories/e/distfiles_size_visitor.cc)78
-rw-r--r--paludis/repositories/e/pretend_fetch_visitor.hh (renamed from paludis/repositories/e/distfiles_size_visitor.hh)40
-rw-r--r--paludis/repositories/fake/fake_installed_repository.cc4
-rw-r--r--paludis/repositories/fake/fake_package_id.cc7
-rw-r--r--paludis/repositories/fake/fake_repository.cc4
-rw-r--r--paludis/repositories/gems/gem_specification.cc19
-rw-r--r--paludis/repositories/gems/gem_specification.hh2
-rw-r--r--paludis/repositories/gems/gems_repository.cc4
-rw-r--r--paludis/repositories/gems/installed_gems_repository.cc4
-rw-r--r--paludis/repositories/unpackaged/installed_id.cc22
-rw-r--r--paludis/repositories/unpackaged/installed_id.hh2
-rw-r--r--paludis/repositories/unpackaged/installed_repository.cc5
-rw-r--r--paludis/repositories/unpackaged/unpackaged_id.cc12
-rw-r--r--paludis/repositories/unpackaged/unpackaged_id.hh2
-rw-r--r--paludis/repositories/virtuals/installed_virtuals_repository.cc4
-rw-r--r--paludis/repositories/virtuals/package_id.cc19
-rw-r--r--paludis/repositories/virtuals/package_id.hh2
-rw-r--r--paludis/repositories/virtuals/virtuals_repository.cc4
-rw-r--r--src/output/console_install_task.cc67
-rw-r--r--src/output/console_install_task.hh9
43 files changed, 336 insertions, 357 deletions
diff --git a/paludis/action-fwd.hh b/paludis/action-fwd.hh
index dbad67d..a457b4b 100644
--- a/paludis/action-fwd.hh
+++ b/paludis/action-fwd.hh
@@ -43,6 +43,7 @@ namespace paludis
class ConfigAction;
class FetchAction;
class InfoAction;
+ class PretendFetchAction;
class SupportsActionTestBase;
template <typename A_> class SupportsActionTest;
diff --git a/paludis/action.cc b/paludis/action.cc
index 849eb39..719a927 100644
--- a/paludis/action.cc
+++ b/paludis/action.cc
@@ -158,6 +158,30 @@ PretendAction::set_failed()
_imp->failed = true;
}
+namespace paludis
+{
+ template <>
+ struct Implementation<PretendFetchAction>
+ {
+ const FetchActionOptions options;
+
+ Implementation(const FetchActionOptions & o) :
+ options(o)
+ {
+ }
+ };
+}
+
+PretendFetchAction::PretendFetchAction(const FetchActionOptions & o) :
+ PrivateImplementationPattern<PretendFetchAction>(new Implementation<PretendFetchAction>(o)),
+ options(_imp->options)
+{
+}
+
+PretendFetchAction::~PretendFetchAction()
+{
+}
+
SupportsActionTestBase::~SupportsActionTestBase()
{
}
@@ -217,6 +241,11 @@ namespace
{
s << "fetch";
}
+
+ void visit(const PretendFetchAction &)
+ {
+ s << "pretend fetch";
+ }
};
}
diff --git a/paludis/action.hh b/paludis/action.hh
index c983552..069beed 100644
--- a/paludis/action.hh
+++ b/paludis/action.hh
@@ -58,7 +58,8 @@ namespace paludis
UninstallAction,
PretendAction,
ConfigAction,
- InfoAction
+ InfoAction,
+ PretendFetchAction
>
{
};
@@ -80,7 +81,8 @@ namespace paludis
SupportsActionTest<UninstallAction>,
SupportsActionTest<PretendAction>,
SupportsActionTest<ConfigAction>,
- SupportsActionTest<InfoAction>
+ SupportsActionTest<InfoAction>,
+ SupportsActionTest<PretendFetchAction>
>
{
};
@@ -228,6 +230,35 @@ namespace paludis
};
/**
+ * A PretendFetchAction is used to get information about a fetch that will take
+ * place on a PackageID.
+ *
+ * \since 0.26
+ * \ingroup g_actions
+ * \nosubgrouping
+ */
+ class PALUDIS_VISIBLE PretendFetchAction :
+ public Action,
+ private PrivateImplementationPattern<PretendFetchAction>,
+ public AcceptInterfaceVisitsThis<ActionVisitorTypes, PretendFetchAction>
+ {
+ public:
+ ///\name Basic operations
+ ///\{
+
+ PretendFetchAction(const FetchActionOptions &);
+ ~PretendFetchAction();
+
+ ///\}
+
+ /// Options for the FetchAction we will use.
+ const FetchActionOptions & options;
+
+ /// Signal that we will fetch a particular file.
+ virtual void will_fetch(const FSEntry & destination, const unsigned long size_in_bytes) = 0;
+ };
+
+ /**
* A ConfigAction is used via PackageID::perform_action to execute
* post-install configuration (for example, via 'paludis --config')
* on a PackageID.
diff --git a/paludis/install_task.cc b/paludis/install_task.cc
index 115b99b..500ba0c 100644
--- a/paludis/install_task.cc
+++ b/paludis/install_task.cc
@@ -1654,3 +1654,9 @@ InstallTask::already_done(const DepListEntry & e) const
return v.result;
}
+FetchActionOptions &
+InstallTask::fetch_action_options()
+{
+ return _imp->fetch_options;
+}
+
diff --git a/paludis/install_task.hh b/paludis/install_task.hh
index 5e25b37..ac53716 100644
--- a/paludis/install_task.hh
+++ b/paludis/install_task.hh
@@ -81,6 +81,7 @@ namespace paludis
///\}
bool already_done(const DepListEntry &) const PALUDIS_ATTRIBUTE((warn_unused_result));
+ FetchActionOptions & fetch_action_options() PALUDIS_ATTRIBUTE((warn_unused_result));
public:
///\name Basic operations
diff --git a/paludis/package_id.hh b/paludis/package_id.hh
index 9479c8c..af4867d 100644
--- a/paludis/package_id.hh
+++ b/paludis/package_id.hh
@@ -273,20 +273,6 @@ namespace paludis
virtual const tr1::shared_ptr<const MetadataValueKey<FSEntry> > fs_location_key() const = 0;
/**
- * The size_of_download_required_key, if non-zero, contains a
- * long integer representing the size of distfiles that still need
- * to be downloaded.
- */
- virtual const tr1::shared_ptr<const MetadataValueKey<long> > size_of_download_required_key() const = 0;
-
- /**
- * The size_of_all_distfiles_key, if non-zero, contains a long
- * integer representing the size of all distfiles used by the
- * package with the current USE settings.
- */
- virtual const tr1::shared_ptr<const MetadataValueKey<long> > size_of_all_distfiles_key() const = 0;
-
- /**
* The transient_key, if non-zero, indicates whether this
* PackageID's originating repository is volatile.
*/
diff --git a/paludis/repositories/cran/cran_installed_repository.cc b/paludis/repositories/cran/cran_installed_repository.cc
index 9ea9e49..aa0c1a6 100644
--- a/paludis/repositories/cran/cran_installed_repository.cc
+++ b/paludis/repositories/cran/cran_installed_repository.cc
@@ -538,6 +538,10 @@ namespace
{
}
+ void visit(const SupportsActionTest<PretendFetchAction> &)
+ {
+ }
+
void visit(const SupportsActionTest<UninstallAction> &)
{
result = true;
diff --git a/paludis/repositories/cran/cran_package_id.cc b/paludis/repositories/cran/cran_package_id.cc
index 77d0e89..b491254 100644
--- a/paludis/repositories/cran/cran_package_id.cc
+++ b/paludis/repositories/cran/cran_package_id.cc
@@ -486,6 +486,11 @@ namespace
result = cran_repository;
}
+ void visit(const SupportsActionTest<PretendFetchAction> &)
+ {
+ result = cran_repository;
+ }
+
void visit(const SupportsActionTest<InstallAction> &)
{
result = cran_repository;
@@ -541,18 +546,6 @@ CRANPackageID::fs_location_key() const
return _imp->fs_location_key;
}
-const tr1::shared_ptr<const MetadataValueKey<long> >
-CRANPackageID::size_of_download_required_key() const
-{
- return tr1::shared_ptr<const MetadataValueKey<long> >();
-}
-
-const tr1::shared_ptr<const MetadataValueKey<long> >
-CRANPackageID::size_of_all_distfiles_key() const
-{
- return tr1::shared_ptr<const MetadataValueKey<long> >();
-}
-
const tr1::shared_ptr<const MetadataValueKey<bool> >
CRANPackageID::transient_key() const
{
diff --git a/paludis/repositories/cran/cran_package_id.hh b/paludis/repositories/cran/cran_package_id.hh
index 6f94af2..758adce 100644
--- a/paludis/repositories/cran/cran_package_id.hh
+++ b/paludis/repositories/cran/cran_package_id.hh
@@ -76,8 +76,6 @@ namespace paludis
virtual const tr1::shared_ptr<const MetadataCollectionKey<PackageIDSequence> > contains_key() const;
virtual const tr1::shared_ptr<const MetadataValueKey<tr1::shared_ptr<const PackageID> > > contained_in_key() const;
virtual const tr1::shared_ptr<const MetadataValueKey<FSEntry> > fs_location_key() const;
- virtual const tr1::shared_ptr<const MetadataValueKey<long> > size_of_download_required_key() const;
- virtual const tr1::shared_ptr<const MetadataValueKey<long> > size_of_all_distfiles_key() const;
virtual const tr1::shared_ptr<const MetadataValueKey<bool> > transient_key() const;
diff --git a/paludis/repositories/cran/cran_repository.cc b/paludis/repositories/cran/cran_repository.cc
index 12c2ff9..f586578 100644
--- a/paludis/repositories/cran/cran_repository.cc
+++ b/paludis/repositories/cran/cran_repository.cc
@@ -491,6 +491,11 @@ namespace
result = true;
}
+ void visit(const SupportsActionTest<PretendFetchAction> &)
+ {
+ result = true;
+ }
+
void visit(const SupportsActionTest<UninstallAction> &)
{
}
diff --git a/paludis/repositories/e/Makefile.am b/paludis/repositories/e/Makefile.am
index 2dfa808..68fa2f5 100644
--- a/paludis/repositories/e/Makefile.am
+++ b/paludis/repositories/e/Makefile.am
@@ -73,6 +73,7 @@ paludis_repositories_e_include_HEADERS = \
exndbam_repository.hh \
exndbam_repository-sr.hh \
fetch_visitor.hh \
+ pretend_fetch_visitor.hh \
fix_locked_dependencies.hh \
glsa-sr.hh \
glsa.hh \
@@ -80,7 +81,6 @@ paludis_repositories_e_include_HEADERS = \
make_ebuild_repository.hh \
manifest2_entry-sr.hh \
manifest2_reader.hh \
- distfiles_size_visitor.hh \
package_dep_spec.hh \
pipe_command_handler.hh \
source_uri_finder.hh \
@@ -128,12 +128,12 @@ libpaludiserepository_la_SOURCES = \
exndbam_repository.cc \
exheres_layout.cc \
fetch_visitor.cc \
+ pretend_fetch_visitor.cc \
fix_locked_dependencies.cc \
glsa.cc \
layout.cc \
make_ebuild_repository.cc \
manifest2_reader.cc \
- distfiles_size_visitor.cc \
package_dep_spec.cc \
pipe_command_handler.cc \
registration.cc \
diff --git a/paludis/repositories/e/e_installed_repository.cc b/paludis/repositories/e/e_installed_repository.cc
index 1ce7a1b..454098e 100644
--- a/paludis/repositories/e/e_installed_repository.cc
+++ b/paludis/repositories/e/e_installed_repository.cc
@@ -113,6 +113,11 @@ namespace
result = false;
}
+ void visit(const SupportsActionTest<PretendFetchAction> &)
+ {
+ result = false;
+ }
+
void visit(const SupportsActionTest<InstallAction> &)
{
result = false;
diff --git a/paludis/repositories/e/e_installed_repository_id.cc b/paludis/repositories/e/e_installed_repository_id.cc
index b158b45..31e4b33 100644
--- a/paludis/repositories/e/e_installed_repository_id.cc
+++ b/paludis/repositories/e/e_installed_repository_id.cc
@@ -640,19 +640,6 @@ EInstalledRepositoryID::fs_location_key() const
return _imp->fs_location;
}
-const tr1::shared_ptr<const MetadataValueKey<long> >
-EInstalledRepositoryID::size_of_download_required_key() const
-{
- return tr1::shared_ptr<const MetadataValueKey<long> >();
-}
-
-const tr1::shared_ptr<const MetadataValueKey<long> >
-EInstalledRepositoryID::size_of_all_distfiles_key() const
-{
- return tr1::shared_ptr<const MetadataValueKey<long> >();
-}
-
-
bool
EInstalledRepositoryID::arbitrary_less_than_comparison(const PackageID &) const
{
@@ -695,6 +682,10 @@ namespace
{
}
+ void visit(const SupportsActionTest<PretendFetchAction> &)
+ {
+ }
+
void visit(const SupportsActionTest<PretendAction> &)
{
}
@@ -754,6 +745,7 @@ namespace
void visit(const InstallAction & a) PALUDIS_ATTRIBUTE((noreturn));
void visit(const PretendAction & a) PALUDIS_ATTRIBUTE((noreturn));
void visit(const FetchAction & a) PALUDIS_ATTRIBUTE((noreturn));
+ void visit(const PretendFetchAction & a) PALUDIS_ATTRIBUTE((noreturn));
};
void PerformAction::visit(const InstallAction & a)
@@ -770,6 +762,11 @@ namespace
{
throw UnsupportedActionError(*id, a);
}
+
+ void PerformAction::visit(const PretendFetchAction & a)
+ {
+ throw UnsupportedActionError(*id, a);
+ }
}
void
diff --git a/paludis/repositories/e/e_installed_repository_id.hh b/paludis/repositories/e/e_installed_repository_id.hh
index be1ec22..db48511 100644
--- a/paludis/repositories/e/e_installed_repository_id.hh
+++ b/paludis/repositories/e/e_installed_repository_id.hh
@@ -79,8 +79,6 @@ namespace paludis
virtual const tr1::shared_ptr<const MetadataCollectionKey<PackageIDSequence> > contains_key() const;
virtual const tr1::shared_ptr<const MetadataValueKey<tr1::shared_ptr<const PackageID> > > contained_in_key() const;
virtual const tr1::shared_ptr<const MetadataValueKey<FSEntry> > fs_location_key() const;
- virtual const tr1::shared_ptr<const MetadataValueKey<long> > size_of_download_required_key() const;
- virtual const tr1::shared_ptr<const MetadataValueKey<long> > size_of_all_distfiles_key() const;
virtual const tr1::shared_ptr<const MetadataCollectionKey<UseFlagNameSet> > use_key() const;
virtual const tr1::shared_ptr<const MetadataCollectionKey<Set<std::string> > > inherited_key() const;
diff --git a/paludis/repositories/e/e_key.cc b/paludis/repositories/e/e_key.cc
index fec8432..bc3a094 100644
--- a/paludis/repositories/e/e_key.cc
+++ b/paludis/repositories/e/e_key.cc
@@ -1091,58 +1091,3 @@ EMTimeKey::value() const
return *_imp->value;
}
-namespace paludis
-{
- template <>
- struct Implementation<EDistSizeKey>
- {
- const tr1::shared_ptr<const EFetchableURIKey> src_uri;
- const tr1::shared_ptr<DistfilesSizeVisitor> dsv;
- mutable Mutex value_mutex;
- mutable tr1::shared_ptr<long> value;
-
- Implementation(const tr1::shared_ptr<const EFetchableURIKey> & s,
- const tr1::shared_ptr<DistfilesSizeVisitor> & d) :
- src_uri(s),
- dsv(d)
- {
- }
- };
-}
-
-EDistSizeKey::EDistSizeKey(const std::string & r, const std::string & h, const MetadataKeyType t,
- const tr1::shared_ptr<const EFetchableURIKey> & s,
- const tr1::shared_ptr<DistfilesSizeVisitor> & d) :
- MetadataValueKey<long> (r, h, t),
- PrivateImplementationPattern<EDistSizeKey>(new Implementation<EDistSizeKey>(s, d)),
- _imp(PrivateImplementationPattern<EDistSizeKey>::_imp)
-{
-}
-
-EDistSizeKey::~EDistSizeKey()
-{
-}
-
-const long
-EDistSizeKey::value() const
-{
- Lock l(_imp->value_mutex);
-
- if (_imp->value)
- return *_imp->value;
-
- _imp->value.reset(new long(0));
-
- if (_imp->src_uri)
- _imp->src_uri->value()->accept(*_imp->dsv);
-
- *_imp->value = _imp->dsv->size();
-
- return *_imp->value;
-}
-
-std::string
-EDistSizeKey::pretty_print() const
-{
- return pretty_print_bytes(value());
-}
diff --git a/paludis/repositories/e/e_key.hh b/paludis/repositories/e/e_key.hh
index 419a2db..da547a4 100644
--- a/paludis/repositories/e/e_key.hh
+++ b/paludis/repositories/e/e_key.hh
@@ -24,8 +24,6 @@
#include <paludis/util/fs_entry.hh>
#include <paludis/util/set.hh>
-#include <paludis/repositories/e/distfiles_size_visitor.hh>
-
namespace paludis
{
namespace erepository
@@ -318,27 +316,6 @@ namespace paludis
time_t value() const
PALUDIS_ATTRIBUTE((warn_unused_result));
};
-
- class EDistSizeKey:
- public MetadataValueKey<long>,
- private PrivateImplementationPattern<EDistSizeKey>
- {
- private:
- PrivateImplementationPattern<EDistSizeKey>::ImpPtr & _imp;
-
- public:
- EDistSizeKey(const std::string &, const std::string &, const MetadataKeyType,
- const tr1::shared_ptr<const EFetchableURIKey> &,
- const tr1::shared_ptr<DistfilesSizeVisitor> &);
-
- ~EDistSizeKey();
-
- const long value() const
- PALUDIS_ATTRIBUTE((warn_unused_result));
-
- std::string pretty_print() const
- PALUDIS_ATTRIBUTE((warn_unused_result));
- };
}
}
diff --git a/paludis/repositories/e/e_repository.cc b/paludis/repositories/e/e_repository.cc
index 80033dd..fe6c901 100644
--- a/paludis/repositories/e/e_repository.cc
+++ b/paludis/repositories/e/e_repository.cc
@@ -1276,6 +1276,11 @@ namespace
result = true;
}
+ void visit(const SupportsActionTest<PretendFetchAction> &)
+ {
+ result = true;
+ }
+
void visit(const SupportsActionTest<UninstallAction> &)
{
}
diff --git a/paludis/repositories/e/e_repository_TEST.cc b/paludis/repositories/e/e_repository_TEST.cc
index d21520d..225d37e 100644
--- a/paludis/repositories/e/e_repository_TEST.cc
+++ b/paludis/repositories/e/e_repository_TEST.cc
@@ -1628,50 +1628,6 @@ namespace test_cases
}
} test_e_repository_install_exheres_0;
- /**
- * \test Test ERepository Distfile Size querying (total needed to
- * download, and amount downloaded.
- */
- struct ERepositoryDistSizeTest : TestCase
- {
- ERepositoryDistSizeTest() : TestCase("dist_size") { }
-
- void run()
- {
- TestEnvironment env;
- env.set_paludis_command("/bin/false");
- tr1::shared_ptr<Map<std::string, std::string> > keys(
- new Map<std::string, std::string>);
- keys->insert("format", "ebuild");
- keys->insert("names_cache", "/var/empty");
- keys->insert("location", "e_repository_TEST_dir/repo16");
- keys->insert("profiles", "e_repository_TEST_dir/repo16/profiles/profile");
- tr1::shared_ptr<ERepository> repo(make_ebuild_repository(
- &env, keys));
- env.package_database()->add_repository(1, repo);
-
- const tr1::shared_ptr<const PackageID> ida(*env.package_database()->
- query(query::Matches(
- PackageDepSpec(parse_user_package_dep_spec("category/package-a",
- UserPackageDepSpecOptions()))), qo_order_by_version)->last());
- const tr1::shared_ptr<const PackageID> idb(*env.package_database()->
- query(query::Matches(
- PackageDepSpec(parse_user_package_dep_spec("category/package-b",
- UserPackageDepSpecOptions()))), qo_order_by_version)->last());
- const tr1::shared_ptr<const PackageID> idc(*env.package_database()->
- query(query::Matches(
- PackageDepSpec(parse_user_package_dep_spec("category/package-c",
- UserPackageDepSpecOptions()))), qo_order_by_version)->last());
-
- TEST_CHECK_EQUAL(ida->size_of_download_required_key()->value(), 0);
- TEST_CHECK_EQUAL(ida->size_of_all_distfiles_key()->value(), 10);
- TEST_CHECK_EQUAL(idb->size_of_download_required_key()->value(),
- idb->size_of_all_distfiles_key()->value());
- TEST_CHECK_EQUAL(idc->size_of_download_required_key()->value(), 12);
- TEST_CHECK_EQUAL(idc->size_of_all_distfiles_key()->value(), 22);
- }
- } test_e_repository_dist_size;
-
struct ERepositoryDependenciesRewriterTest : TestCase
{
ERepositoryDependenciesRewriterTest() : TestCase("dependencies_rewriter") { }
diff --git a/paludis/repositories/e/e_repository_entries.hh b/paludis/repositories/e/e_repository_entries.hh
index 1c5e9fb..5e130e4 100644
--- a/paludis/repositories/e/e_repository_entries.hh
+++ b/paludis/repositories/e/e_repository_entries.hh
@@ -93,6 +93,12 @@ namespace paludis
tr1::shared_ptr<const ERepositoryProfile>) const = 0;
/**
+ * Handle a pretend fetch.
+ */
+ virtual void pretend_fetch(const tr1::shared_ptr<const ERepositoryID> &, PretendFetchAction &,
+ tr1::shared_ptr<const ERepositoryProfile>) const = 0;
+
+ /**
* Handle a pretend.
*/
virtual bool pretend(const tr1::shared_ptr<const ERepositoryID> &,
diff --git a/paludis/repositories/e/ebuild_entries.cc b/paludis/repositories/e/ebuild_entries.cc
index b35eb54..792c3b5 100644
--- a/paludis/repositories/e/ebuild_entries.cc
+++ b/paludis/repositories/e/ebuild_entries.cc
@@ -26,6 +26,7 @@
#include <paludis/repositories/e/eapi.hh>
#include <paludis/repositories/e/dep_parser.hh>
#include <paludis/repositories/e/fetch_visitor.hh>
+#include <paludis/repositories/e/pretend_fetch_visitor.hh>
#include <paludis/repositories/e/check_fetched_files_visitor.hh>
#include <paludis/repositories/e/aa_visitor.hh>
#include <paludis/repositories/e/e_stripper.hh>
@@ -475,6 +476,23 @@ EbuildEntries::fetch(const tr1::shared_ptr<const ERepositoryID> & id,
}
void
+EbuildEntries::pretend_fetch(const tr1::shared_ptr<const ERepositoryID> & id,
+ PretendFetchAction & a, tr1::shared_ptr<const ERepositoryProfile>) const
+{
+ using namespace tr1::placeholders;
+
+ Context context("When pretending to fetch ID '" + stringify(*id) + "':");
+
+ if (id->fetches_key())
+ {
+ PretendFetchVisitor f(_imp->params.environment, id, *id->eapi(),
+ _imp->e_repository->params().distdir, a.options[k::fetch_unneeded()],
+ id->fetches_key()->initial_label(), a);
+ id->fetches_key()->value()->accept(f);
+ }
+}
+
+void
EbuildEntries::install(const tr1::shared_ptr<const ERepositoryID> & id,
const InstallActionOptions & o, tr1::shared_ptr<const ERepositoryProfile> p) const
{
diff --git a/paludis/repositories/e/ebuild_entries.hh b/paludis/repositories/e/ebuild_entries.hh
index db36fd7..d97af81 100644
--- a/paludis/repositories/e/ebuild_entries.hh
+++ b/paludis/repositories/e/ebuild_entries.hh
@@ -84,6 +84,9 @@ namespace paludis
virtual void fetch(const tr1::shared_ptr<const ERepositoryID> &, const FetchActionOptions &,
tr1::shared_ptr<const ERepositoryProfile>) const;
+ virtual void pretend_fetch(const tr1::shared_ptr<const ERepositoryID> &, PretendFetchAction &,
+ tr1::shared_ptr<const ERepositoryProfile>) const;
+
virtual void install(const tr1::shared_ptr<const ERepositoryID> &, const InstallActionOptions &,
tr1::shared_ptr<const ERepositoryProfile>) const;
diff --git a/paludis/repositories/e/ebuild_id.cc b/paludis/repositories/e/ebuild_id.cc
index 97434eb..0aa1aec 100644
--- a/paludis/repositories/e/ebuild_id.cc
+++ b/paludis/repositories/e/ebuild_id.cc
@@ -26,7 +26,6 @@
#include <paludis/repositories/e/e_key.hh>
#include <paludis/repositories/e/e_mask.hh>
#include <paludis/repositories/e/eapi.hh>
-#include <paludis/repositories/e/distfiles_size_visitor.hh>
#include <paludis/repositories/e/manifest2_reader.hh>
#include <paludis/name.hh>
@@ -77,8 +76,6 @@ namespace paludis
mutable tr1::shared_ptr<const EDependenciesKey> build_dependencies;
mutable tr1::shared_ptr<const EDependenciesKey> run_dependencies;
mutable tr1::shared_ptr<const EDependenciesKey> post_dependencies;
- mutable tr1::shared_ptr<const EDistSizeKey> size_of_download_required;
- mutable tr1::shared_ptr<const EDistSizeKey> size_of_all_distfiles;
mutable tr1::shared_ptr<const EProvideKey> provide;
mutable tr1::shared_ptr<const ERestrictKey> restrictions;
mutable tr1::shared_ptr<const EFetchableURIKey> src_uri;
@@ -264,33 +261,6 @@ EbuildID::need_keys_added() const
_imp->profile_mask = make_shared_ptr(new EMutableRepositoryMaskInfoKey(shared_from_this(), "profile_mask", "Profile masked",
tr1::static_pointer_cast<const ERepository>(repository())->profile()->profile_masked(*this), mkt_internal));
add_metadata_key(_imp->profile_mask);
-
- FSEntry m2(_imp->repository->layout()->package_directory(_imp->name) / "Manifest");
- if (_imp->src_uri && m2.exists())
- {
- tr1::shared_ptr<Manifest2Reader> m2r(new Manifest2Reader(m2));
-
- tr1::shared_ptr<DistfilesSizeVisitor> dsv(new DistfilesSizeVisitor(_imp->environment,
- shared_from_this(),
- _imp->repository->params().distdir,
- _imp->src_uri->initial_label(),
- false,
- m2r));
- tr1::shared_ptr<DistfilesSizeVisitor> dsv2(new DistfilesSizeVisitor(_imp->environment,
- shared_from_this(),
- _imp->repository->params().distdir,
- _imp->src_uri->initial_label(),
- true,
- m2r));
-
- _imp->size_of_download_required.reset(new EDistSizeKey("UNDOWNLOADEDDISTFILESIZE",
- "Undownloaded Size", mkt_normal, _imp->src_uri, dsv));
- add_metadata_key(_imp->size_of_download_required);
-
- _imp->size_of_all_distfiles.reset(new EDistSizeKey("TOTALDISTFILESIZE",
- "Total Distfiles Size", mkt_normal, _imp->src_uri, dsv2));
- add_metadata_key(_imp->size_of_all_distfiles);
- }
}
namespace
@@ -654,20 +624,6 @@ EbuildID::fs_location_key() const
return _imp->fs_location;
}
-const tr1::shared_ptr<const MetadataValueKey<long> >
-EbuildID::size_of_download_required_key() const
-{
- need_keys_added();
- return _imp->size_of_download_required;
-}
-
-const tr1::shared_ptr<const MetadataValueKey<long> >
-EbuildID::size_of_all_distfiles_key() const
-{
- need_keys_added();
- return _imp->size_of_all_distfiles;
-}
-
bool
EbuildID::arbitrary_less_than_comparison(const PackageID &) const
{
@@ -836,6 +792,11 @@ namespace
result = true;
}
+ void visit(const SupportsActionTest<PretendFetchAction> &)
+ {
+ result = true;
+ }
+
void visit(const SupportsActionTest<InstallAction> &)
{
result = true;
@@ -873,7 +834,7 @@ EbuildID::supports_action(const SupportsActionTestBase & b) const
namespace
{
struct PerformAction :
- ConstVisitor<ActionVisitorTypes>
+ Visitor<ActionVisitorTypes>
{
const tr1::shared_ptr<const PackageID> id;
@@ -882,7 +843,7 @@ namespace
{
}
- void visit(const InstallAction & a)
+ void visit(InstallAction & a)
{
tr1::static_pointer_cast<const ERepository>(id->repository())->entries()->install(
tr1::static_pointer_cast<const ERepositoryID>(id),
@@ -890,7 +851,7 @@ namespace
tr1::static_pointer_cast<const ERepository>(id->repository())->profile());
}
- void visit(const FetchAction & a)
+ void visit(FetchAction & a)
{
tr1::static_pointer_cast<const ERepository>(id->repository())->entries()->fetch(
tr1::static_pointer_cast<const ERepositoryID>(id),
@@ -898,36 +859,44 @@ namespace
tr1::static_pointer_cast<const ERepository>(id->repository())->profile());
}
- void visit(const PretendAction &)
+ void visit(PretendFetchAction & a)
+ {
+ tr1::static_pointer_cast<const ERepository>(id->repository())->entries()->pretend_fetch(
+ tr1::static_pointer_cast<const ERepositoryID>(id),
+ a,
+ tr1::static_pointer_cast<const ERepository>(id->repository())->profile());
+ }
+
+ void visit(PretendAction &)
{
tr1::static_pointer_cast<const ERepository>(id->repository())->entries()->pretend(
tr1::static_pointer_cast<const ERepositoryID>(id),
tr1::static_pointer_cast<const ERepository>(id->repository())->profile());
}
- void visit(const InfoAction &)
+ void visit(InfoAction &)
{
tr1::static_pointer_cast<const ERepository>(id->repository())->entries()->info(
tr1::static_pointer_cast<const ERepositoryID>(id),
tr1::static_pointer_cast<const ERepository>(id->repository())->profile());
}
- void visit(const InstalledAction & a) PALUDIS_ATTRIBUTE((noreturn));
- void visit(const UninstallAction & a) PALUDIS_ATTRIBUTE((noreturn));
- void visit(const ConfigAction & a) PALUDIS_ATTRIBUTE((noreturn));
+ void visit(InstalledAction & a) PALUDIS_ATTRIBUTE((noreturn));
+ void visit(UninstallAction & a) PALUDIS_ATTRIBUTE((noreturn));
+ void visit(ConfigAction & a) PALUDIS_ATTRIBUTE((noreturn));
};
- void PerformAction::visit(const InstalledAction & a)
+ void PerformAction::visit(InstalledAction & a)
{
throw UnsupportedActionError(*id, a);
}
- void PerformAction::visit(const UninstallAction & a)
+ void PerformAction::visit(UninstallAction & a)
{
throw UnsupportedActionError(*id, a);
}
- void PerformAction::visit(const ConfigAction & a)
+ void PerformAction::visit(ConfigAction & a)
{
throw UnsupportedActionError(*id, a);
}
diff --git a/paludis/repositories/e/ebuild_id.hh b/paludis/repositories/e/ebuild_id.hh
index f61d0a5..b7a1663 100644
--- a/paludis/repositories/e/ebuild_id.hh
+++ b/paludis/repositories/e/ebuild_id.hh
@@ -83,8 +83,6 @@ namespace paludis
virtual const tr1::shared_ptr<const MetadataCollectionKey<PackageIDSequence> > contains_key() const;
virtual const tr1::shared_ptr<const MetadataValueKey<tr1::shared_ptr<const PackageID> > > contained_in_key() const;
virtual const tr1::shared_ptr<const MetadataValueKey<FSEntry> > fs_location_key() const;
- virtual const tr1::shared_ptr<const MetadataValueKey<long> > size_of_download_required_key() const;
- virtual const tr1::shared_ptr<const MetadataValueKey<long> > size_of_all_distfiles_key() const;
const tr1::shared_ptr<const MetadataCollectionKey<Set<std::string> > > inherited_key() const;
const tr1::shared_ptr<const MetadataSpecTreeKey<LicenseSpecTree> > license_key() const;
diff --git a/paludis/repositories/e/distfiles_size_visitor.cc b/paludis/repositories/e/pretend_fetch_visitor.cc
index c0e2456..37340ba 100644
--- a/paludis/repositories/e/distfiles_size_visitor.cc
+++ b/paludis/repositories/e/pretend_fetch_visitor.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2007 Mike Kelly
+ * Copyright (c) 2008 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -17,27 +17,22 @@
* Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include <paludis/repositories/e/distfiles_size_visitor.hh>
-#include <paludis/repositories/e/source_uri_finder.hh>
+#include <paludis/repositories/e/pretend_fetch_visitor.hh>
#include <paludis/repositories/e/e_repository_id.hh>
-#include <paludis/repositories/e/dep_parser.hh>
#include <paludis/repositories/e/manifest2_reader.hh>
#include <paludis/dep_spec.hh>
#include <paludis/environment.hh>
#include <paludis/package_id.hh>
#include <paludis/action.hh>
-#include <paludis/repository.hh>
-#include <paludis/about.hh>
+#include <paludis/metadata_key.hh>
#include <paludis/util/visitor-impl.hh>
-#include <paludis/util/system.hh>
#include <paludis/util/private_implementation_pattern-impl.hh>
#include <paludis/util/fs_entry.hh>
#include <paludis/util/log.hh>
-#include <paludis/util/join.hh>
#include <paludis/util/stringify.hh>
#include <paludis/util/make_shared_ptr.hh>
-#include <iostream>
#include <list>
+#include <set>
using namespace paludis;
using namespace paludis::erepository;
@@ -45,59 +40,64 @@ using namespace paludis::erepository;
namespace paludis
{
template <>
- struct Implementation<DistfilesSizeVisitor>
+ struct Implementation<PretendFetchVisitor>
{
const Environment * const env;
const tr1::shared_ptr<const PackageID> id;
+ const EAPI & eapi;
const FSEntry distdir;
+ const bool fetch_unneeded;
tr1::shared_ptr<const URILabel> default_label;
- bool everything;
- const tr1::shared_ptr<Manifest2Reader> m2r;
+ PretendFetchAction & action;
+ std::set<std::string> already_done;
std::list<const URILabel *> labels;
- size_t size;
+ Manifest2Reader manifest;
Implementation(
const Environment * const e,
const tr1::shared_ptr<const PackageID> & i,
+ const EAPI & p,
const FSEntry & d,
+ const bool f,
const tr1::shared_ptr<const URILabel> & n,
- const bool ev,
- const tr1::shared_ptr<Manifest2Reader> mr) :
+ PretendFetchAction & a) :
env(e),
id(i),
+ eapi(p),
distdir(d),
+ fetch_unneeded(f),
default_label(n),
- everything(ev),
- m2r(mr),
- size(0)
+ action(a),
+ manifest(id->fs_location_key()->value().dirname() / "Manifest")
{
labels.push_front(default_label.get());
}
};
}
-DistfilesSizeVisitor::DistfilesSizeVisitor(
+PretendFetchVisitor::PretendFetchVisitor(
const Environment * const e,
const tr1::shared_ptr<const PackageID> & i,
+ const EAPI & p,
const FSEntry & d,
+ const bool f,
const tr1::shared_ptr<const URILabel> & n,
- const bool ev,
- const tr1::shared_ptr<Manifest2Reader> mr) :
- PrivateImplementationPattern<DistfilesSizeVisitor>(new Implementation<DistfilesSizeVisitor>(e, i, d, n, ev, mr))
+ PretendFetchAction & a) :
+ PrivateImplementationPattern<PretendFetchVisitor>(new Implementation<PretendFetchVisitor>(e, i, p, d, f, n, a))
{
}
-DistfilesSizeVisitor::~DistfilesSizeVisitor()
+PretendFetchVisitor::~PretendFetchVisitor()
{
}
void
-DistfilesSizeVisitor::visit_sequence(const ConditionalDepSpec & u,
+PretendFetchVisitor::visit_sequence(const ConditionalDepSpec & u,
FetchableURISpecTree::ConstSequenceIterator cur,
FetchableURISpecTree::ConstSequenceIterator end)
{
- if (u.condition_met())
+ if ((_imp->fetch_unneeded) || (u.condition_met()))
{
_imp->labels.push_front(* _imp->labels.begin());
std::for_each(cur, end, accept_visitor(*this));
@@ -106,7 +106,7 @@ DistfilesSizeVisitor::visit_sequence(const ConditionalDepSpec & u,
}
void
-DistfilesSizeVisitor::visit_sequence(const AllDepSpec &,
+PretendFetchVisitor::visit_sequence(const AllDepSpec &,
FetchableURISpecTree::ConstSequenceIterator cur,
FetchableURISpecTree::ConstSequenceIterator end)
{
@@ -116,7 +116,7 @@ DistfilesSizeVisitor::visit_sequence(const AllDepSpec &,
}
void
-DistfilesSizeVisitor::visit_leaf(const URILabelsDepSpec & l)
+PretendFetchVisitor::visit_leaf(const URILabelsDepSpec & l)
{
for (URILabelsDepSpec::ConstIterator i(l.begin()), i_end(l.end()) ;
i != i_end ; ++i)
@@ -124,25 +124,19 @@ DistfilesSizeVisitor::visit_leaf(const URILabelsDepSpec & l)
}
void
-DistfilesSizeVisitor::visit_leaf(const FetchableURIDepSpec & u)
+PretendFetchVisitor::visit_leaf(const FetchableURIDepSpec & u)
{
- Context context("When visiting URI dep spec '" + stringify(u.text()) + "':");
+ if (! _imp->already_done.insert(u.filename()).second)
+ return;
FSEntry destination(_imp->distdir / u.filename());
-
- if (destination.exists() && ! _imp->everything)
+ if (destination.exists())
return;
- Manifest2Reader::ConstIterator m(_imp->m2r->find("DIST", u.filename()));
- if (_imp->m2r->end() == m)
+
+ Manifest2Reader::ConstIterator m(_imp->manifest.find("DIST", u.filename()));
+ if (_imp->manifest.end() == m)
return;
- long s(m->size);
- Log::get_instance()->message(ll_debug, lc_context) << "Adding " << s << " to size. Was "
- << _imp->size << ", is now " << (_imp->size + s);
- _imp->size += s;
-}
-long
-DistfilesSizeVisitor::size()
-{
- return _imp->size;
+ _imp->action.will_fetch(destination, m->size);
}
+
diff --git a/paludis/repositories/e/distfiles_size_visitor.hh b/paludis/repositories/e/pretend_fetch_visitor.hh
index 1b82e7f..227667a 100644
--- a/paludis/repositories/e/distfiles_size_visitor.hh
+++ b/paludis/repositories/e/pretend_fetch_visitor.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2007 Mike Kelly
+ * Copyright (c) 2008 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -17,39 +17,36 @@
* Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#ifndef PALUDIS_GUARD_PALUDIS_REPOSITORIES_E_FETCH_VISITOR_HH
-#define PALUDIS_GUARD_PALUDIS_REPOSITORIES_E_FETCH_VISITOR_HH 1
+#ifndef PALUDIS_GUARD_PALUDIS_REPOSITORIES_E_PRETEND_FETCH_VISITOR_HH
+#define PALUDIS_GUARD_PALUDIS_REPOSITORIES_E_PRETEND_FETCH_VISITOR_HH 1
-#include <paludis/repositories/e/eapi-fwd.hh>
-#include <paludis/repositories/e/manifest2_reader.hh>
-#include <paludis/util/attributes.hh>
-#include <paludis/util/private_implementation_pattern.hh>
-#include <paludis/util/visitor-fwd.hh>
-#include <paludis/util/fs_entry-fwd.hh>
-#include <paludis/util/tr1_memory.hh>
-#include <paludis/dep_spec.hh>
+#include <paludis/action-fwd.hh>
+#include <paludis/dep_label-fwd.hh>
#include <paludis/dep_tree.hh>
#include <paludis/package_id-fwd.hh>
-#include <paludis/environment-fwd.hh>
+#include <paludis/repositories/e/eapi-fwd.hh>
+#include <paludis/util/fs_entry-fwd.hh>
+#include <paludis/util/private_implementation_pattern.hh>
namespace paludis
{
namespace erepository
{
- class PALUDIS_VISIBLE DistfilesSizeVisitor :
- private PrivateImplementationPattern<DistfilesSizeVisitor>,
+ class PALUDIS_VISIBLE PretendFetchVisitor :
+ private PrivateImplementationPattern<PretendFetchVisitor>,
public ConstVisitor<FetchableURISpecTree>
{
public:
- DistfilesSizeVisitor(
+ PretendFetchVisitor(
const Environment * const,
const tr1::shared_ptr<const PackageID> &,
- const FSEntry &,
- const tr1::shared_ptr<const URILabel> &,
- const bool,
- const tr1::shared_ptr<Manifest2Reader>);
+ const EAPI & eapi,
+ const FSEntry & distdir,
+ const bool fetch_unneeded,
+ const tr1::shared_ptr<const URILabel> & initial_label,
+ PretendFetchAction & action);
- ~DistfilesSizeVisitor();
+ ~PretendFetchVisitor();
void visit_sequence(const AllDepSpec &,
FetchableURISpecTree::ConstSequenceIterator,
@@ -62,9 +59,8 @@ namespace paludis
void visit_leaf(const URILabelsDepSpec &);
void visit_leaf(const FetchableURIDepSpec &);
-
- long size();
};
+
}
}
diff --git a/paludis/repositories/fake/fake_installed_repository.cc b/paludis/repositories/fake/fake_installed_repository.cc
index 9ec7edb..8ce9b57 100644
--- a/paludis/repositories/fake/fake_installed_repository.cc
+++ b/paludis/repositories/fake/fake_installed_repository.cc
@@ -169,6 +169,10 @@ namespace
{
}
+ void visit(const SupportsActionTest<PretendFetchAction> &)
+ {
+ }
+
void visit(const SupportsActionTest<InfoAction> &)
{
}
diff --git a/paludis/repositories/fake/fake_package_id.cc b/paludis/repositories/fake/fake_package_id.cc
index ba02001..f785e0d 100644
--- a/paludis/repositories/fake/fake_package_id.cc
+++ b/paludis/repositories/fake/fake_package_id.cc
@@ -903,6 +903,13 @@ namespace
if (! id->repository()->some_ids_might_support_action(t))
throw UnsupportedActionError(*id, a);
}
+
+ void visit(const PretendFetchAction & a)
+ {
+ SupportsActionTest<PretendFetchAction> t;
+ if (! id->repository()->some_ids_might_support_action(t))
+ throw UnsupportedActionError(*id, a);
+ }
};
}
diff --git a/paludis/repositories/fake/fake_repository.cc b/paludis/repositories/fake/fake_repository.cc
index 128e450..60b2aaf 100644
--- a/paludis/repositories/fake/fake_repository.cc
+++ b/paludis/repositories/fake/fake_repository.cc
@@ -163,6 +163,10 @@ namespace
{
}
+ void visit(const SupportsActionTest<PretendFetchAction> &)
+ {
+ }
+
void visit(const SupportsActionTest<FetchAction> &)
{
}
diff --git a/paludis/repositories/gems/gem_specification.cc b/paludis/repositories/gems/gem_specification.cc
index 781dece..d7d829c 100644
--- a/paludis/repositories/gems/gem_specification.cc
+++ b/paludis/repositories/gems/gem_specification.cc
@@ -444,18 +444,6 @@ GemSpecification::contained_in_key() const
return tr1::shared_ptr<const MetadataValueKey<tr1::shared_ptr<const PackageID> > >();
}
-const tr1::shared_ptr<const MetadataValueKey<long> >
-GemSpecification::size_of_download_required_key() const
-{
- return tr1::shared_ptr<const MetadataValueKey<long> >();
-}
-
-const tr1::shared_ptr<const MetadataValueKey<long> >
-GemSpecification::size_of_all_distfiles_key() const
-{
- return tr1::shared_ptr<const MetadataValueKey<long> >();
-}
-
const tr1::shared_ptr<const MetadataValueKey<bool> >
GemSpecification::transient_key() const
{
@@ -581,6 +569,13 @@ namespace
if (! id->repository()->some_ids_might_support_action(t))
throw UnsupportedActionError(*id, a);
}
+
+ void visit(const PretendFetchAction & a)
+ {
+ SupportsActionTest<PretendFetchAction> t;
+ if (! id->repository()->some_ids_might_support_action(t))
+ throw UnsupportedActionError(*id, a);
+ }
};
}
diff --git a/paludis/repositories/gems/gem_specification.hh b/paludis/repositories/gems/gem_specification.hh
index 0ef6fe0..cbdca80 100644
--- a/paludis/repositories/gems/gem_specification.hh
+++ b/paludis/repositories/gems/gem_specification.hh
@@ -111,8 +111,6 @@ namespace paludis
virtual const tr1::shared_ptr<const MetadataValueKey<std::string> > source_origin_key() const;
virtual const tr1::shared_ptr<const MetadataValueKey<std::string> > binary_origin_key() const;
- virtual const tr1::shared_ptr<const MetadataValueKey<long> > size_of_download_required_key() const;
- virtual const tr1::shared_ptr<const MetadataValueKey<long> > size_of_all_distfiles_key() const;
virtual const tr1::shared_ptr<const MetadataValueKey<bool> > transient_key() const;
virtual bool supports_action(const SupportsActionTestBase &) const PALUDIS_ATTRIBUTE((warn_unused_result));
diff --git a/paludis/repositories/gems/gems_repository.cc b/paludis/repositories/gems/gems_repository.cc
index 23c116e..640b39b 100644
--- a/paludis/repositories/gems/gems_repository.cc
+++ b/paludis/repositories/gems/gems_repository.cc
@@ -302,6 +302,10 @@ namespace
{
}
+ void visit(const SupportsActionTest<PretendFetchAction> &)
+ {
+ }
+
void visit(const SupportsActionTest<ConfigAction> &)
{
}
diff --git a/paludis/repositories/gems/installed_gems_repository.cc b/paludis/repositories/gems/installed_gems_repository.cc
index 151d7f8..1338bbb 100644
--- a/paludis/repositories/gems/installed_gems_repository.cc
+++ b/paludis/repositories/gems/installed_gems_repository.cc
@@ -328,6 +328,10 @@ namespace
{
}
+ void visit(const SupportsActionTest<PretendFetchAction> &)
+ {
+ }
+
void visit(const SupportsActionTest<InfoAction> &)
{
}
diff --git a/paludis/repositories/unpackaged/installed_id.cc b/paludis/repositories/unpackaged/installed_id.cc
index d2f061f..aa59f15 100644
--- a/paludis/repositories/unpackaged/installed_id.cc
+++ b/paludis/repositories/unpackaged/installed_id.cc
@@ -506,18 +506,6 @@ InstalledUnpackagedID::fs_location_key() const
return _imp->fs_location_key;
}
-const tr1::shared_ptr<const MetadataValueKey<long> >
-InstalledUnpackagedID::size_of_download_required_key() const
-{
- return tr1::shared_ptr<const MetadataValueKey<long> >();
-}
-
-const tr1::shared_ptr<const MetadataValueKey<long> >
-InstalledUnpackagedID::size_of_all_distfiles_key() const
-{
- return tr1::shared_ptr<const MetadataValueKey<long> >();
-}
-
namespace paludis
{
class InstalledUnpackagedTransientKey :
@@ -594,6 +582,11 @@ namespace
{
result = false;
}
+
+ void visit(const SupportsActionTest<PretendFetchAction> &)
+ {
+ result = false;
+ }
};
struct PerformAction :
@@ -626,6 +619,11 @@ namespace
throw UnsupportedActionError(*id, a);
}
+ void visit(PretendFetchAction & a) PALUDIS_ATTRIBUTE((noreturn))
+ {
+ throw UnsupportedActionError(*id, a);
+ }
+
void visit(InfoAction & a) PALUDIS_ATTRIBUTE((noreturn))
{
throw UnsupportedActionError(*id, a);
diff --git a/paludis/repositories/unpackaged/installed_id.hh b/paludis/repositories/unpackaged/installed_id.hh
index 9b103c2..caa4e36 100644
--- a/paludis/repositories/unpackaged/installed_id.hh
+++ b/paludis/repositories/unpackaged/installed_id.hh
@@ -76,8 +76,6 @@ namespace paludis
virtual const tr1::shared_ptr<const MetadataValueKey<std::string> > source_origin_key() const;
virtual const tr1::shared_ptr<const MetadataValueKey<std::string> > binary_origin_key() const;
virtual const tr1::shared_ptr<const MetadataValueKey<FSEntry> > fs_location_key() const;
- virtual const tr1::shared_ptr<const MetadataValueKey<long> > size_of_download_required_key() const;
- virtual const tr1::shared_ptr<const MetadataValueKey<long> > size_of_all_distfiles_key() const;
virtual const tr1::shared_ptr<const MetadataValueKey<bool> > transient_key() const;
virtual bool supports_action(const SupportsActionTestBase &) const PALUDIS_ATTRIBUTE((warn_unused_result));
diff --git a/paludis/repositories/unpackaged/installed_repository.cc b/paludis/repositories/unpackaged/installed_repository.cc
index 4725854..bf5647c 100644
--- a/paludis/repositories/unpackaged/installed_repository.cc
+++ b/paludis/repositories/unpackaged/installed_repository.cc
@@ -203,6 +203,11 @@ namespace
result = false;
}
+ void visit(const SupportsActionTest<PretendFetchAction> &)
+ {
+ result = false;
+ }
+
void visit(const SupportsActionTest<InstallAction> &)
{
result = false;
diff --git a/paludis/repositories/unpackaged/unpackaged_id.cc b/paludis/repositories/unpackaged/unpackaged_id.cc
index b3032c7..83e2cbd 100644
--- a/paludis/repositories/unpackaged/unpackaged_id.cc
+++ b/paludis/repositories/unpackaged/unpackaged_id.cc
@@ -277,18 +277,6 @@ UnpackagedID::fs_location_key() const
return _imp->fs_location_key;
}
-const tr1::shared_ptr<const MetadataValueKey<long> >
-UnpackagedID::size_of_download_required_key() const
-{
- return tr1::shared_ptr<const MetadataValueKey<long> >();
-}
-
-const tr1::shared_ptr<const MetadataValueKey<long> >
-UnpackagedID::size_of_all_distfiles_key() const
-{
- return tr1::shared_ptr<const MetadataValueKey<long> >();
-}
-
const tr1::shared_ptr<const MetadataValueKey<bool> >
UnpackagedID::transient_key() const
{
diff --git a/paludis/repositories/unpackaged/unpackaged_id.hh b/paludis/repositories/unpackaged/unpackaged_id.hh
index 5dbb323..47232da 100644
--- a/paludis/repositories/unpackaged/unpackaged_id.hh
+++ b/paludis/repositories/unpackaged/unpackaged_id.hh
@@ -74,8 +74,6 @@ namespace paludis
virtual const tr1::shared_ptr<const MetadataValueKey<std::string> > source_origin_key() const;
virtual const tr1::shared_ptr<const MetadataValueKey<std::string> > binary_origin_key() const;
virtual const tr1::shared_ptr<const MetadataValueKey<FSEntry> > fs_location_key() const;
- virtual const tr1::shared_ptr<const MetadataValueKey<long> > size_of_download_required_key() const;
- virtual const tr1::shared_ptr<const MetadataValueKey<long> > size_of_all_distfiles_key() const;
virtual const tr1::shared_ptr<const MetadataValueKey<bool> > transient_key() const;
virtual bool supports_action(const SupportsActionTestBase &) const PALUDIS_ATTRIBUTE((warn_unused_result));
diff --git a/paludis/repositories/virtuals/installed_virtuals_repository.cc b/paludis/repositories/virtuals/installed_virtuals_repository.cc
index f1c5280..5da8ea8 100644
--- a/paludis/repositories/virtuals/installed_virtuals_repository.cc
+++ b/paludis/repositories/virtuals/installed_virtuals_repository.cc
@@ -298,6 +298,10 @@ namespace
{
}
+ void visit(const SupportsActionTest<PretendFetchAction> &)
+ {
+ }
+
void visit(const SupportsActionTest<InfoAction> &)
{
}
diff --git a/paludis/repositories/virtuals/package_id.cc b/paludis/repositories/virtuals/package_id.cc
index 451fd7f..eef070c 100644
--- a/paludis/repositories/virtuals/package_id.cc
+++ b/paludis/repositories/virtuals/package_id.cc
@@ -418,6 +418,13 @@ namespace
if (! id->repository()->some_ids_might_support_action(t))
throw UnsupportedActionError(*id, a);
}
+
+ void visit(const PretendFetchAction & a)
+ {
+ SupportsActionTest<PretendFetchAction> t;
+ if (! id->repository()->some_ids_might_support_action(t))
+ throw UnsupportedActionError(*id, a);
+ }
};
}
@@ -515,18 +522,6 @@ VirtualsPackageID::fs_location_key() const
return tr1::shared_ptr<const MetadataValueKey<FSEntry> >();
}
-const tr1::shared_ptr<const MetadataValueKey<long> >
-VirtualsPackageID::size_of_download_required_key() const
-{
- return tr1::shared_ptr<const MetadataValueKey<long> >();
-}
-
-const tr1::shared_ptr<const MetadataValueKey<long> >
-VirtualsPackageID::size_of_all_distfiles_key() const
-{
- return tr1::shared_ptr<const MetadataValueKey<long> >();
-}
-
const tr1::shared_ptr<const MetadataValueKey<bool> >
VirtualsPackageID::transient_key() const
{
diff --git a/paludis/repositories/virtuals/package_id.hh b/paludis/repositories/virtuals/package_id.hh
index b840335..b3b101b 100644
--- a/paludis/repositories/virtuals/package_id.hh
+++ b/paludis/repositories/virtuals/package_id.hh
@@ -102,8 +102,6 @@ namespace paludis
virtual const tr1::shared_ptr<const MetadataCollectionKey<PackageIDSequence> > contains_key() const;
virtual const tr1::shared_ptr<const MetadataValueKey<tr1::shared_ptr<const PackageID> > > contained_in_key() const;
virtual const tr1::shared_ptr<const MetadataValueKey<FSEntry> > fs_location_key() const;
- virtual const tr1::shared_ptr<const MetadataValueKey<long> > size_of_download_required_key() const;
- virtual const tr1::shared_ptr<const MetadataValueKey<long> > size_of_all_distfiles_key() const;
virtual const tr1::shared_ptr<const MetadataValueKey<bool> > transient_key() const;
virtual bool supports_action(const SupportsActionTestBase &) const PALUDIS_ATTRIBUTE((warn_unused_result));
diff --git a/paludis/repositories/virtuals/virtuals_repository.cc b/paludis/repositories/virtuals/virtuals_repository.cc
index bb582a4..3a73350 100644
--- a/paludis/repositories/virtuals/virtuals_repository.cc
+++ b/paludis/repositories/virtuals/virtuals_repository.cc
@@ -394,6 +394,10 @@ namespace
void visit(const SupportsActionTest<UninstallAction> &)
{
}
+
+ void visit(const SupportsActionTest<PretendFetchAction> &)
+ {
+ }
};
}
diff --git a/src/output/console_install_task.cc b/src/output/console_install_task.cc
index 2eb1174..7ba91f1 100644
--- a/src/output/console_install_task.cc
+++ b/src/output/console_install_task.cc
@@ -38,6 +38,7 @@
#include <paludis/util/visitor_cast.hh>
#include <paludis/util/kc.hh>
#include <paludis/util/make_shared_ptr.hh>
+#include <paludis/util/pretty_print.hh>
#include <paludis/query.hh>
#include <paludis/action.hh>
#include <paludis/repository.hh>
@@ -127,9 +128,11 @@ ConsoleInstallTask::ConsoleInstallTask(Environment * const env,
tr1::shared_ptr<const DestinationsSet> d) :
InstallTask(env, options, d),
_download_size(0),
+ _download_size_overflow(false),
_all_tags(new Set<DepTagEntry>),
_all_use_descriptions(new Set<UseDescription, UseDescriptionComparator>),
_all_expand_prefixes(new UseFlagNameSet),
+ _already_downloaded(new Set<FSEntry>),
_resolution_finished(false)
{
std::fill_n(_counts, static_cast<int>(last_count), 0);
@@ -625,7 +628,10 @@ ConsoleInstallTask::display_merge_list_post_counts()
if (get_download_size())
{
- s << ", at most " << pretty_print_bytes(get_download_size()) << " to download";
+ if (_download_size_overflow)
+ s << ", more than " << pretty_print_bytes(std::numeric_limits<unsigned long>::max()) << " to download";
+ else
+ s << ", at most " << pretty_print_bytes(get_download_size()) << " to download";
}
}
@@ -1229,6 +1235,37 @@ ConsoleInstallTask::display_merge_list_entry_use(const DepListEntry & d,
_all_expand_prefixes->inserter());
}
+namespace
+{
+ struct FindDistfilesSize :
+ PretendFetchAction
+ {
+ tr1::shared_ptr<Set<FSEntry> > already_downloaded;
+ unsigned long size;
+ bool overflow;
+
+ FindDistfilesSize(const FetchActionOptions & o, const tr1::shared_ptr<Set<FSEntry> > & a) :
+ PretendFetchAction(o),
+ already_downloaded(a),
+ size(0),
+ overflow(false)
+ {
+ }
+
+ void will_fetch(const FSEntry & destination, const unsigned long size_in_bytes)
+ {
+ if (already_downloaded->end() != already_downloaded->find(destination))
+ return;
+ already_downloaded->insert(destination);
+ unsigned long new_size(size + size_in_bytes);
+ if (new_size < size)
+ overflow = true;
+ else
+ size = new_size;
+ }
+ };
+}
+
void
ConsoleInstallTask::display_merge_list_entry_distsize(const DepListEntry & d,
const DisplayMode m)
@@ -1236,7 +1273,14 @@ ConsoleInstallTask::display_merge_list_entry_distsize(const DepListEntry & d,
if (normal_entry != m && suggested_entry != m)
return;
- if (! d.package_id->size_of_download_required_key() || d.package_id->size_of_download_required_key()->value() == 0)
+ SupportsActionTest<PretendFetchAction> action_test;
+ if (! d.package_id->supports_action(action_test))
+ return;
+
+ FindDistfilesSize action(fetch_action_options(), _already_downloaded);
+ d.package_id->perform_action(action);
+
+ if (! action.size)
return;
if (want_compact())
@@ -1247,9 +1291,22 @@ ConsoleInstallTask::display_merge_list_entry_distsize(const DepListEntry & d,
output_no_endl(" ");
}
- output_stream() << d.package_id->size_of_download_required_key()->pretty_print()
- << " to download";
- set_download_size(get_download_size() + d.package_id->size_of_download_required_key()->value());
+ if (action.overflow)
+ output_stream() << "more than " << pretty_print_bytes(std::numeric_limits<unsigned long>::max())
+ << " to download";
+ else
+ output_stream() << pretty_print_bytes(action.size) << " to download";
+
+ if (action.overflow)
+ _download_size_overflow = true;
+ else
+ {
+ unsigned long new_size(_download_size + action.size);
+ if (new_size < _download_size)
+ _download_size_overflow = true;
+ else
+ _download_size = new_size;
+ }
}
void
diff --git a/src/output/console_install_task.hh b/src/output/console_install_task.hh
index 3651de6..46bf2eb 100644
--- a/src/output/console_install_task.hh
+++ b/src/output/console_install_task.hh
@@ -113,10 +113,12 @@ namespace paludis
private:
int _counts[last_count];
- long _download_size;
+ unsigned long _download_size;
+ bool _download_size_overflow;
tr1::shared_ptr<Set<DepTagEntry> > _all_tags;
tr1::shared_ptr<Set<UseDescription, UseDescriptionComparator> > _all_use_descriptions;
tr1::shared_ptr<UseFlagNameSet> _all_expand_prefixes;
+ tr1::shared_ptr<Set<FSEntry> > _already_downloaded;
void _add_descriptions(tr1::shared_ptr<const UseFlagNameSet>,
const tr1::shared_ptr<const PackageID> &, UseDescriptionState);
@@ -284,11 +286,6 @@ namespace paludis
return _download_size;
}
- void set_download_size(const long value)
- {
- _download_size = value;
- }
-
tr1::shared_ptr<Set<DepTagEntry> > all_tags()
{
return _all_tags;