aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-11-17 04:43:40 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-11-17 04:43:40 +0000
commita7c0e279090afdb14dbc80510bd68a406bbbe5ab (patch)
tree6188eb08c95b1dcff274b73a90a332e53cce0397
parent7546ef4845d1597d2d8819f3fdeba154c1108c8f (diff)
downloadpaludis-a7c0e279090afdb14dbc80510bd68a406bbbe5ab.tar.gz
paludis-a7c0e279090afdb14dbc80510bd68a406bbbe5ab.tar.xz
Split up PortageRepository some more.
-rw-r--r--paludis/repositories/portage/Makefile.am14
-rw-r--r--paludis/repositories/portage/ebuild_entries.cc (renamed from paludis/repositories/portage/portage_repository_ebuild_entries.cc)112
-rw-r--r--paludis/repositories/portage/ebuild_entries.hh (renamed from paludis/repositories/portage/portage_repository_ebuild_entries.hh)14
-rw-r--r--paludis/repositories/portage/ebuild_flat_metadata_cache.cc96
-rw-r--r--paludis/repositories/portage/ebuild_flat_metadata_cache.hh44
-rw-r--r--paludis/repositories/portage/eclass_mtimes.cc69
-rw-r--r--paludis/repositories/portage/eclass_mtimes.hh (renamed from paludis/repositories/portage/make_ebin_repository.hh)22
-rw-r--r--paludis/repositories/portage/make_ebin_repository.cc114
-rw-r--r--paludis/repositories/portage/make_ebuild_repository.cc5
-rw-r--r--paludis/repositories/portage/portage_repository_ebin_entries.cc379
-rw-r--r--paludis/repositories/portage/portage_repository_ebin_entries.hh71
-rw-r--r--paludis/repositories/portage/portage_repository_params.sr1
12 files changed, 277 insertions, 664 deletions
diff --git a/paludis/repositories/portage/Makefile.am b/paludis/repositories/portage/Makefile.am
index 98b6cbd..5caa7b9 100644
--- a/paludis/repositories/portage/Makefile.am
+++ b/paludis/repositories/portage/Makefile.am
@@ -26,10 +26,10 @@ paludis_repositories_portage_include_HEADERS = \
portage_repository_params-sr.hh \
portage_repository_sets.hh \
portage_repository_entries.hh \
- portage_repository_ebuild_entries.hh \
- portage_repository_ebin_entries.hh \
- make_ebuild_repository.hh \
- make_ebin_repository.hh
+ ebuild_entries.hh \
+ ebuild_flat_metadata_cache.hh \
+ eclass_mtimes.hh \
+ make_ebuild_repository.hh
libpaludisportagerepository_la_SOURCES = \
glsa.cc \
@@ -40,11 +40,11 @@ libpaludisportagerepository_la_SOURCES = \
portage_repository_news.cc \
portage_repository_sets.cc \
portage_repository_entries.cc \
- portage_repository_ebuild_entries.cc \
- portage_repository_ebin_entries.cc \
+ ebuild_entries.cc \
+ ebuild_flat_metadata_cache.cc \
+ eclass_mtimes.cc \
portage_repository_params.cc \
make_ebuild_repository.cc \
- make_ebin_repository.cc \
$(paludis_repositories_portage_include_HEADERS)
libpaludisportagerepository_la_LIBADD = \
diff --git a/paludis/repositories/portage/portage_repository_ebuild_entries.cc b/paludis/repositories/portage/ebuild_entries.cc
index 562e93c..d1c77c9 100644
--- a/paludis/repositories/portage/portage_repository_ebuild_entries.cc
+++ b/paludis/repositories/portage/ebuild_entries.cc
@@ -17,7 +17,8 @@
* Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include <paludis/repositories/portage/portage_repository_ebuild_entries.hh>
+#include <paludis/repositories/portage/ebuild_entries.hh>
+#include <paludis/repositories/portage/ebuild_flat_metadata_cache.hh>
#include <paludis/repositories/portage/portage_repository.hh>
#include <paludis/dep_atom_flattener.hh>
@@ -40,112 +41,68 @@ using namespace paludis;
namespace paludis
{
/**
- * Implementation data for PortageRepositoryEbuildEntries.
+ * Implementation data for EbuildEntries.
*
* \ingroup grpportagerepository
*/
template<>
- struct Implementation<PortageRepositoryEbuildEntries> :
- InternalCounted<Implementation<PortageRepositoryEbuildEntries> >
+ struct Implementation<EbuildEntries> :
+ InternalCounted<Implementation<EbuildEntries> >
{
const Environment * const environment;
PortageRepository * const portage_repository;
const PortageRepositoryParams params;
+ EclassMtimes::Pointer eclass_mtimes;
+ time_t master_mtime;
+
Implementation(const Environment * const e, PortageRepository * const p,
const PortageRepositoryParams & k) :
environment(e),
portage_repository(p),
- params(k)
+ params(k),
+ eclass_mtimes(new EclassMtimes(k.eclassdirs)),
+ master_mtime(0)
{
+ FSEntry m(k.location / "metadata" / "timestamp");
+ if (m.exists())
+ master_mtime = m.mtime();
}
};
}
-PortageRepositoryEbuildEntries::PortageRepositoryEbuildEntries(
+EbuildEntries::EbuildEntries(
const Environment * const e, PortageRepository * const p, const PortageRepositoryParams & k) :
PortageRepositoryEntries(".ebuild"),
- PrivateImplementationPattern<PortageRepositoryEbuildEntries>(new
- Implementation<PortageRepositoryEbuildEntries>(e, p, k))
+ PrivateImplementationPattern<EbuildEntries>(new
+ Implementation<EbuildEntries>(e, p, k))
{
}
-PortageRepositoryEbuildEntries::~PortageRepositoryEbuildEntries()
+EbuildEntries::~EbuildEntries()
{
}
VersionMetadata::Pointer
-PortageRepositoryEbuildEntries::generate_version_metadata(const QualifiedPackageName & q,
+EbuildEntries::generate_version_metadata(const QualifiedPackageName & q,
const VersionSpec & v) const
{
VersionMetadata::Pointer result(new VersionMetadata::Ebuild(PortageDepParser::parse_depend));
- FSEntry cache_file(_imp->params.cache);
- cache_file /= stringify(q.category);
- cache_file /= stringify(q.package) + "-" + stringify(v);
+ FSEntry ebuild_file(_imp->params.location / stringify(q.category) /
+ stringify(q.package) / (stringify(q.package) + "-" + stringify(v) + ".ebuild"));
bool ok(false);
- if (cache_file.is_regular_file())
+ if (_imp->params.cache.basename() != "empty")
{
- std::ifstream cache(stringify(cache_file).c_str());
- std::string line;
+ FSEntry cache_file(_imp->params.cache);
+ cache_file /= stringify(q.category);
+ cache_file /= stringify(q.package) + "-" + stringify(v);
- if (cache)
- {
- std::getline(cache, line); result->deps.build_depend_string = line;
- std::getline(cache, line); result->deps.run_depend_string = line;
- std::getline(cache, line); result->slot = SlotName(line);
- std::getline(cache, line); result->get_ebuild_interface()->src_uri = line;
- std::getline(cache, line); result->get_ebuild_interface()->restrict_string = line;
- std::getline(cache, line); result->homepage = line;
- std::getline(cache, line); result->license_string = line;
- std::getline(cache, line); result->description = line;
- std::getline(cache, line); result->get_ebuild_interface()->keywords = line;
- std::getline(cache, line); result->get_ebuild_interface()->inherited = line;
- std::getline(cache, line); result->get_ebuild_interface()->iuse = line;
- std::getline(cache, line);
- std::getline(cache, line); result->deps.post_depend_string = line;
- std::getline(cache, line); result->get_ebuild_interface()->provide_string = line;
- std::getline(cache, line); result->eapi = line;
-
- // check mtimes
- time_t cache_time(cache_file.mtime());
+ EbuildFlatMetadataCache metadata_cache(cache_file, ebuild_file, _imp->master_mtime,
+ _imp->eclass_mtimes);
+ if (metadata_cache.load(result))
ok = true;
-
- if ((_imp->params.location / stringify(q.category) /
- stringify(q.package) /
- (stringify(q.package) + "-" + stringify(v)
- + ".ebuild")).mtime() > cache_time)
- ok = false;
- else
- {
- FSEntry timestamp(_imp->params.location / "metadata" / "timestamp");
- if (timestamp.exists())
- cache_time = timestamp.mtime();
-
- std::list<std::string> inherits;
- WhitespaceTokeniser::get_instance()->tokenise(
- stringify(result->get_ebuild_interface()->inherited),
- std::back_inserter(inherits));
- for (FSEntryCollection::Iterator e(_imp->params.eclassdirs->begin()),
- e_end(_imp->params.eclassdirs->end()) ; e != e_end ; ++e)
- for (std::list<std::string>::const_iterator i(inherits.begin()),
- i_end(inherits.end()) ; i != i_end ; ++i)
- {
- if ((*e / (*i + ".eclass")).exists())
- if (((*e / (*i + ".eclass"))).mtime() > cache_time)
- ok = false;
- }
- }
-
- if (! ok)
- Log::get_instance()->message(ll_warning, lc_no_context, "Stale cache file at '"
- + stringify(cache_file) + "'");
- }
- else
- Log::get_instance()->message(ll_warning, lc_no_context,
- "Couldn't read the cache file at '"
- + stringify(cache_file) + "'");
}
if (! ok)
@@ -178,7 +135,6 @@ PortageRepositoryEbuildEntries::generate_version_metadata(const QualifiedPackage
}
return result;
-
}
namespace
@@ -245,7 +201,7 @@ namespace
}
void
-PortageRepositoryEbuildEntries::install(const QualifiedPackageName & q, const VersionSpec & v,
+EbuildEntries::install(const QualifiedPackageName & q, const VersionSpec & v,
const InstallOptions & o, PortageRepositoryProfile::ConstPointer p) const
{
if (! _imp->portage_repository->has_version(q, v))
@@ -508,7 +464,7 @@ PortageRepositoryEbuildEntries::install(const QualifiedPackageName & q, const Ve
}
std::string
-PortageRepositoryEbuildEntries::get_environment_variable(const QualifiedPackageName & q,
+EbuildEntries::get_environment_variable(const QualifiedPackageName & q,
const VersionSpec & v, const std::string & var,
PortageRepositoryProfile::ConstPointer) const
{
@@ -535,11 +491,11 @@ PortageRepositoryEbuildEntries::get_environment_variable(const QualifiedPackageN
return cmd.result();
}
-PortageRepositoryEbuildEntries::Pointer
-PortageRepositoryEbuildEntries::make_portage_repository_ebuild_entries(
+EbuildEntries::Pointer
+EbuildEntries::make_ebuild_entries(
const Environment * const e, PortageRepository * const r, const PortageRepositoryParams & p)
{
- return Pointer(new PortageRepositoryEbuildEntries(e, r, p));
+ return Pointer(new EbuildEntries(e, r, p));
}
#ifdef PALUDIS_ENABLE_VISIBILITY
@@ -548,7 +504,7 @@ PortageRepositoryEbuildEntries::make_portage_repository_ebuild_entries(
namespace
{
const PortageRepositoryEntriesMaker::RegisterMaker register_portage_repository_ebuild_entries PALUDIS_ATTRIBUTE((used)) (
- "ebuild", &PortageRepositoryEbuildEntries::make_portage_repository_ebuild_entries);
+ "ebuild", &EbuildEntries::make_ebuild_entries);
}
#ifdef PALUDIS_ENABLE_VISIBILITY
# pragma GCC visibility pop
diff --git a/paludis/repositories/portage/portage_repository_ebuild_entries.hh b/paludis/repositories/portage/ebuild_entries.hh
index a3fb2f8..24cbad2 100644
--- a/paludis/repositories/portage/portage_repository_ebuild_entries.hh
+++ b/paludis/repositories/portage/ebuild_entries.hh
@@ -25,7 +25,7 @@
#include <paludis/util/private_implementation_pattern.hh>
/** \file
- * Declaration for the PortageRepositoryEbuildEntries class.
+ * Declaration for the EbuildEntries class.
*
* \ingroup grpportagerepository
*/
@@ -40,20 +40,20 @@ namespace paludis
*
* \ingroup grpportagerepository
*/
- class PALUDIS_VISIBLE PortageRepositoryEbuildEntries :
+ class PALUDIS_VISIBLE EbuildEntries :
public PortageRepositoryEntries,
- private PrivateImplementationPattern<PortageRepositoryEbuildEntries>
+ private PrivateImplementationPattern<EbuildEntries>
{
public:
- static PortageRepositoryEbuildEntries::Pointer
- make_portage_repository_ebuild_entries(const Environment * const,
+ static EbuildEntries::Pointer
+ make_ebuild_entries(const Environment * const,
PortageRepository * const, const PortageRepositoryParams &);
- PortageRepositoryEbuildEntries(const Environment * const,
+ EbuildEntries(const Environment * const,
PortageRepository * const portage_repository,
const PortageRepositoryParams &);
- virtual ~PortageRepositoryEbuildEntries();
+ virtual ~EbuildEntries();
virtual VersionMetadata::Pointer generate_version_metadata(const QualifiedPackageName &,
const VersionSpec &) const;
diff --git a/paludis/repositories/portage/ebuild_flat_metadata_cache.cc b/paludis/repositories/portage/ebuild_flat_metadata_cache.cc
new file mode 100644
index 0000000..b09c9ca
--- /dev/null
+++ b/paludis/repositories/portage/ebuild_flat_metadata_cache.cc
@@ -0,0 +1,96 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaranm@ciaranm.org>
+ *
+ * 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
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include "ebuild_flat_metadata_cache.hh"
+#include <paludis/util/log.hh>
+#include <paludis/util/tokeniser.hh>
+#include <fstream>
+#include <set>
+
+using namespace paludis;
+
+EbuildFlatMetadataCache::EbuildFlatMetadataCache(const FSEntry & f,
+ const FSEntry & e, time_t t, EclassMtimes::ConstPointer m) :
+ _filename(f),
+ _ebuild(e),
+ _master_mtime(t),
+ _eclass_mtimes(m)
+{
+}
+
+bool
+EbuildFlatMetadataCache::load(VersionMetadata::Pointer result)
+{
+ std::ifstream cache(stringify(_filename).c_str());
+ std::string line;
+
+ if (cache)
+ {
+ std::getline(cache, line); result->deps.build_depend_string = line;
+ std::getline(cache, line); result->deps.run_depend_string = line;
+ std::getline(cache, line); result->slot = SlotName(line);
+ std::getline(cache, line); result->get_ebuild_interface()->src_uri = line;
+ std::getline(cache, line); result->get_ebuild_interface()->restrict_string = line;
+ std::getline(cache, line); result->homepage = line;
+ std::getline(cache, line); result->license_string = line;
+ std::getline(cache, line); result->description = line;
+ std::getline(cache, line); result->get_ebuild_interface()->keywords = line;
+ std::getline(cache, line); result->get_ebuild_interface()->inherited = line;
+ std::getline(cache, line); result->get_ebuild_interface()->iuse = line;
+ std::getline(cache, line);
+ std::getline(cache, line); result->deps.post_depend_string = line;
+ std::getline(cache, line); result->get_ebuild_interface()->provide_string = line;
+ std::getline(cache, line); result->eapi = line;
+
+ // check mtimes
+ time_t cache_time(std::max(_master_mtime, _filename.mtime()));
+ bool ok = true;
+
+ if (_ebuild.mtime() > cache_time)
+ ok = false;
+ else
+ {
+ std::set<std::string> inherits;
+ WhitespaceTokeniser::get_instance()->tokenise(
+ stringify(result->get_ebuild_interface()->inherited),
+ std::inserter(inherits, inherits.end()));
+
+ for (std::set<std::string>::const_iterator i(inherits.begin()),
+ i_end(inherits.end()) ; i != i_end ; ++i)
+ if (_eclass_mtimes->mtime(*i) > cache_time)
+ {
+ ok = false;
+ break;
+ }
+ }
+
+ if (! ok)
+ Log::get_instance()->message(ll_warning, lc_no_context, "Stale cache file at '"
+ + stringify(_filename) + "'");
+
+ return ok;
+ }
+ else
+ {
+ Log::get_instance()->message(ll_warning, lc_no_context,
+ "Couldn't use the cache file at '" + stringify(_filename) + "'");
+ return false;
+ }
+}
+
diff --git a/paludis/repositories/portage/ebuild_flat_metadata_cache.hh b/paludis/repositories/portage/ebuild_flat_metadata_cache.hh
new file mode 100644
index 0000000..b5107a7
--- /dev/null
+++ b/paludis/repositories/portage/ebuild_flat_metadata_cache.hh
@@ -0,0 +1,44 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaranm@ciaranm.org>
+ *
+ * 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
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef PALUDIS_GUARD_PALUDIS_REPOSITORIES_PORTAGE_EBUILD_FLAT_METADATA_CACHE_HH
+#define PALUDIS_GUARD_PALUDIS_REPOSITORIES_PORTAGE_EBUILD_FLAT_METADATA_CACHE_HH 1
+
+#include <paludis/util/fs_entry.hh>
+#include <paludis/version_metadata.hh>
+#include <paludis/repositories/portage/eclass_mtimes.hh>
+
+namespace paludis
+{
+ class EbuildFlatMetadataCache
+ {
+ private:
+ const FSEntry & _filename;
+ const FSEntry & _ebuild;
+ time_t _master_mtime;
+ EclassMtimes::ConstPointer _eclass_mtimes;
+
+ public:
+ EbuildFlatMetadataCache(const FSEntry &, const FSEntry &,
+ time_t, EclassMtimes::ConstPointer);
+ bool load(VersionMetadata::Pointer);
+ };
+}
+
+#endif
diff --git a/paludis/repositories/portage/eclass_mtimes.cc b/paludis/repositories/portage/eclass_mtimes.cc
new file mode 100644
index 0000000..c4ac0c8
--- /dev/null
+++ b/paludis/repositories/portage/eclass_mtimes.cc
@@ -0,0 +1,69 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaranm@ciaranm.org>
+ *
+ * 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
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include "eclass_mtimes.hh"
+#include <paludis/hashed_containers.hh>
+
+using namespace paludis;
+
+namespace paludis
+{
+ template<>
+ struct Implementation<EclassMtimes> :
+ public InternalCounted<Implementation<EclassMtimes> >
+ {
+ FSEntryCollection::ConstPointer eclass_dirs;
+ mutable MakeHashedMap<std::string, time_t>::Type eclass_mtimes;
+
+ Implementation(FSEntryCollection::ConstPointer d) :
+ eclass_dirs(d)
+ {
+ }
+ };
+}
+
+EclassMtimes::EclassMtimes(FSEntryCollection::ConstPointer d) :
+ PrivateImplementationPattern<EclassMtimes>(new Implementation<EclassMtimes>(d))
+{
+}
+
+EclassMtimes::~EclassMtimes()
+{
+}
+
+time_t
+EclassMtimes::mtime(const std::string & e) const
+{
+ MakeHashedMap<std::string, time_t>::Type::const_iterator i(_imp->eclass_mtimes.find(e));
+ if (_imp->eclass_mtimes.end() != i)
+ return i->second;
+
+ time_t r(0);
+ for (FSEntryCollection::Iterator d(_imp->eclass_dirs->begin()),
+ d_end(_imp->eclass_dirs->end()) ; d != d_end ; ++d)
+ {
+ FSEntry f(*d / (e + ".eclass"));
+ if (f.exists())
+ r = std::max(r, f.mtime());
+ }
+
+ _imp->eclass_mtimes.insert(std::make_pair(e, r));
+ return r;
+}
+
diff --git a/paludis/repositories/portage/make_ebin_repository.hh b/paludis/repositories/portage/eclass_mtimes.hh
index efcf2ce..84b3616 100644
--- a/paludis/repositories/portage/make_ebin_repository.hh
+++ b/paludis/repositories/portage/eclass_mtimes.hh
@@ -17,19 +17,25 @@
* Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#ifndef PALUDIS_GUARD_PALUDIS_REPOSITORIES_PORTAGE_MAKE_EBIN_REPOSITORY_HH
-#define PALUDIS_GUARD_PALUDIS_REPOSITORIES_PORTAGE_MAKE_EBIN_REPOSITORY_HH 1
+#ifndef PALUDIS_GUARD_PALUDIS_REPOSITORIES_PORTAGE_ECLASS_MTIMES_HH
+#define PALUDIS_GUARD_PALUDIS_REPOSITORIES_PORTAGE_ECLASS_MTIMES_HH 1
-#include <paludis/repositories/portage/portage_repository.hh>
+#include <paludis/util/private_implementation_pattern.hh>
+#include <paludis/util/fs_entry.hh>
+#include <paludis/util/collection.hh>
namespace paludis
{
- CountedPtr<Repository>
- make_ebin_repository(const Environment * const,
- const PackageDatabase * const,
- AssociativeCollection<std::string, std::string>::ConstPointer) PALUDIS_VISIBLE;
+ class EclassMtimes :
+ private PrivateImplementationPattern<EclassMtimes>,
+ public InternalCounted<EclassMtimes>
+ {
+ public:
+ EclassMtimes(FSEntryCollection::ConstPointer);
+ ~EclassMtimes();
+ time_t mtime(const std::string &) const;
+ };
}
-
#endif
diff --git a/paludis/repositories/portage/make_ebin_repository.cc b/paludis/repositories/portage/make_ebin_repository.cc
deleted file mode 100644
index bd94cc3..0000000
--- a/paludis/repositories/portage/make_ebin_repository.cc
+++ /dev/null
@@ -1,114 +0,0 @@
-/* vim: set sw=4 sts=4 et foldmethod=syntax : */
-
-/*
- * Copyright (c) 2006 Ciaran McCreesh <ciaranm@ciaranm.org>
- *
- * 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
- * Public License version 2, as published by the Free Software Foundation.
- *
- * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- * details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#include "make_ebin_repository.hh"
-#include <paludis/util/log.hh>
-#include <paludis/util/collection_concrete.hh>
-#include <paludis/util/tokeniser.hh>
-#include <paludis/repositories/portage/portage_repository_exceptions.hh>
-
-using namespace paludis;
-
-CountedPtr<Repository>
-paludis::make_ebin_repository(
- const Environment * const env,
- const PackageDatabase * const db,
- AssociativeCollection<std::string, std::string>::ConstPointer m)
-{
- std::string repo_file(m->end() == m->find("repo_file") ? std::string("?") :
- m->find("repo_file")->second);
-
- Context context("When making ebin repository from repo_file '" + repo_file + "':");
-
- std::string location;
- if (m->end() == m->find("location") || ((location = m->find("location")->second)).empty())
- throw PortageRepositoryConfigurationError("Key 'location' not specified or empty");
-
- FSEntryCollection::Pointer profiles(new FSEntryCollection::Concrete);
- if (m->end() != m->find("profiles"))
- WhitespaceTokeniser::get_instance()->tokenise(m->find("profiles")->second,
- create_inserter<FSEntry>(std::back_inserter(*profiles)));
- if (profiles->empty())
- throw PortageRepositoryConfigurationError("No profiles have been specified");
-
- FSEntryCollection::Pointer eclassdirs(new FSEntryCollection::Concrete);
-
- std::string pkgdir;
- if (m->end() == m->find("pkgdir") || ((pkgdir = m->find("pkgdir")->second)).empty())
- pkgdir = location + "/packages";
-
- std::string setsdir;
- if (m->end() == m->find("setsdir") || ((setsdir = m->find("setsdir")->second)).empty())
- setsdir = location + "/sets";
-
- std::string securitydir;
- if (m->end() == m->find("securitydir") || ((securitydir = m->find("securitydir")->second)).empty())
- securitydir = location + "/metadata/glsa";
-
- std::string newsdir;
- if (m->end() == m->find("newsdir") || ((newsdir = m->find("newsdir")->second)).empty())
- newsdir = location + "/metadata/news";
-
- std::string sync;
- if (m->end() == m->find("sync"))
- sync = m->find("sync")->second;
-
- std::string sync_exclude;
- if (m->end() == m->find("sync_exclude"))
- sync_exclude = m->find("sync_exclude")->second;
-
- std::string root;
- if (m->end() == m->find("root") || ((root = m->find("root")->second)).empty())
- root = "/";
-
- std::string buildroot;
- if (m->end() == m->find("buildroot") || ((buildroot = m->find("buildroot")->second)).empty())
- buildroot = "/var/tmp/paludis";
-
- return CountedPtr<Repository>(new PortageRepository(PortageRepositoryParams::create()
- .entry_format("ebin")
- .environment(env)
- .package_database(db)
- .location(location)
- .profiles(profiles)
- .cache(FSEntry("/var/empty"))
- .eclassdirs(eclassdirs)
- .distdir(FSEntry("/var/empty"))
- .pkgdir(pkgdir)
- .securitydir(securitydir)
- .setsdir(setsdir)
- .newsdir(newsdir)
- .sync(sync)
- .sync_exclude(sync_exclude)
- .root(root)
- .buildroot(buildroot)));
-}
-
-#ifdef PALUDIS_ENABLE_VISIBILITY
-# pragma GCC visibility push(default)
-#endif
-namespace
-{
- const RepositoryMaker::RegisterMaker register_portage_ebin_repository PALUDIS_ATTRIBUTE((used)) (
- "ebin", &make_ebin_repository);
-}
-#ifdef PALUDIS_ENABLE_VISIBILITY
-# pragma GCC visibility pop
-#endif
-
diff --git a/paludis/repositories/portage/make_ebuild_repository.cc b/paludis/repositories/portage/make_ebuild_repository.cc
index 744b332..efae0e1 100644
--- a/paludis/repositories/portage/make_ebuild_repository.cc
+++ b/paludis/repositories/portage/make_ebuild_repository.cc
@@ -98,6 +98,10 @@ paludis::make_ebuild_repository(
cache = "/var/empty";
}
+ std::string write_cache;
+ if (m->end() == m->find("write_cache") || ((write_cache = m->find("write_cache")->second)).empty())
+ write_cache = "/var/empty";
+
std::string sync;
if (m->end() != m->find("sync"))
sync = m->find("sync")->second;
@@ -121,6 +125,7 @@ paludis::make_ebuild_repository(
.location(location)
.profiles(profiles)
.cache(cache)
+ .write_cache(write_cache)
.eclassdirs(eclassdirs)
.distdir(distdir)
.pkgdir(FSEntry("/var/empty"))
diff --git a/paludis/repositories/portage/portage_repository_ebin_entries.cc b/paludis/repositories/portage/portage_repository_ebin_entries.cc
deleted file mode 100644
index de948c6..0000000
--- a/paludis/repositories/portage/portage_repository_ebin_entries.cc
+++ /dev/null
@@ -1,379 +0,0 @@
-/* vim: set sw=4 sts=4 et foldmethod=syntax : */
-
-/*
- * Copyright (c) 2005, 2006 Ciaran McCreesh <ciaranm@ciaranm.org>
- *
- * 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
- * Public License version 2, as published by the Free Software Foundation.
- *
- * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- * details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#include <paludis/repositories/portage/portage_repository_ebin_entries.hh>
-#include <paludis/repositories/portage/portage_repository.hh>
-
-#include <paludis/config_file.hh>
-#include <paludis/dep_atom_flattener.hh>
-#include <paludis/ebin.hh>
-#include <paludis/environment.hh>
-#include <paludis/portage_dep_parser.hh>
-#include <paludis/version_metadata.hh>
-#include <paludis/util/collection_concrete.hh>
-#include <paludis/util/fs_entry.hh>
-#include <paludis/util/log.hh>
-#include <paludis/util/strip.hh>
-#include <paludis/util/tokeniser.hh>
-
-#include <fstream>
-#include <list>
-#include <set>
-
-using namespace paludis;
-
-namespace paludis
-{
- /**
- * Implementation data for PortageRepositoryEbinEntries.
- *
- * \ingroup grpportagerepository
- */
- template<>
- struct Implementation<PortageRepositoryEbinEntries> :
- InternalCounted<Implementation<PortageRepositoryEbinEntries> >
- {
- const Environment * const environment;
- PortageRepository * const portage_repository;
- const PortageRepositoryParams params;
-
- Implementation(const Environment * const e, PortageRepository * const p,
- const PortageRepositoryParams & k) :
- environment(e),
- portage_repository(p),
- params(k)
- {
- }
- };
-}
-
-PortageRepositoryEbinEntries::PortageRepositoryEbinEntries(
- const Environment * const e, PortageRepository * const p, const PortageRepositoryParams & k) :
- PortageRepositoryEntries(".ebin"),
- PrivateImplementationPattern<PortageRepositoryEbinEntries>(new
- Implementation<PortageRepositoryEbinEntries>(e, p, k))
-{
-}
-
-PortageRepositoryEbinEntries::~PortageRepositoryEbinEntries()
-{
-}
-
-VersionMetadata::Pointer
-PortageRepositoryEbinEntries::generate_version_metadata(const QualifiedPackageName & q,
- const VersionSpec & v) const
-{
- VersionMetadata::Pointer result(new VersionMetadata::Ebin(PortageDepParser::parse_depend));
-
- FSEntry ebin_file(_imp->params.location);
- ebin_file /= stringify(q.category);
- ebin_file /= stringify(q.package);
- ebin_file /= (stringify(q.package) + "-" + stringify(v) + ".ebin");
-
- if (ebin_file.is_regular_file())
- {
- KeyValueConfigFile f(ebin_file);
- result->deps.build_depend_string = f.get("depend");
- result->deps.run_depend_string = f.get("rdepend");
- result->deps.post_depend_string = f.get("pdepend");
- result->slot = SlotName(f.get("slot"));
- result->license_string = f.get("license");
- result->eapi = f.get("eapi");
- result->homepage = f.get("homepage");
- result->description = f.get("description");
- result->get_ebuild_interface()->provide_string = f.get("provide");
- result->get_ebuild_interface()->restrict_string = f.get("restrict");
- result->get_ebuild_interface()->keywords = f.get("keywords");
- result->get_ebuild_interface()->iuse = f.get("iuse");
- result->get_ebuild_interface()->inherited = f.get("inherited");
- result->get_ebin_interface()->bin_uri = f.get("bin_uri");
- result->get_ebin_interface()->src_repository = RepositoryName(f.get("src_repository"));
- }
- else
- throw NoSuchPackageError(stringify(PackageDatabaseEntry(q, v, _imp->portage_repository->name())));
-
- return result;
-
-}
-
-void
-PortageRepositoryEbinEntries::install(const QualifiedPackageName & q, const VersionSpec & v,
- const InstallOptions & o, PortageRepositoryProfile::ConstPointer p) const
-{
- VersionMetadata::ConstPointer metadata(_imp->portage_repository->version_metadata(q, v));
-
- if (! _imp->portage_repository->has_version(q, v))
- throw PackageInstallActionError("Can't install '" + stringify(q) + "-"
- + stringify(v) + "' since has_version failed");
-
- PackageDatabaseEntry e(q, v, _imp->portage_repository->name());
-
- std::string binaries, flat_bin_uri;
- {
- std::set<std::string> already_in_binaries;
-
- /* make B */
- DepAtom::ConstPointer f_atom(PortageDepParser::parse(metadata->get_ebin_interface()->bin_uri,
- PortageDepParserPolicy<PlainTextDepAtom, false>::get_instance()));
- DepAtomFlattener f(_imp->params.environment, &e, f_atom);
-
- for (DepAtomFlattener::Iterator ff(f.begin()), ff_end(f.end()) ; ff != ff_end ; ++ff)
- {
- std::string::size_type pos((*ff)->text().rfind('/'));
- if (std::string::npos == pos)
- {
- if (already_in_binaries.end() == already_in_binaries.find((*ff)->text()))
- {
- binaries.append((*ff)->text());
- already_in_binaries.insert((*ff)->text());
- }
- }
- else
- {
- if (already_in_binaries.end() == already_in_binaries.find((*ff)->text().substr(pos + 1)))
- {
- binaries.append((*ff)->text().substr(pos + 1));
- already_in_binaries.insert((*ff)->text().substr(pos + 1));
- }
- }
- binaries.append(" ");
-
- /* add * mirror entries */
- for (Environment::MirrorIterator
- m(_imp->params.environment->begin_mirrors("*")),
- m_end(_imp->params.environment->end_mirrors("*")) ;
- m != m_end ; ++m)
- flat_bin_uri.append(m->second + "/" + (*ff)->text().substr(pos + 1) + " ");
-
- if (0 == (*ff)->text().compare(0, 9, "mirror://"))
- {
- std::string mirror((*ff)->text().substr(9));
- std::string::size_type s_pos(mirror.find('/'));
-
- if (std::string::npos == s_pos)
- throw PackageInstallActionError("Can't install '" + stringify(q) + "-"
- + stringify(v) + "' since SRC_URI is broken");
-
- if (! _imp->portage_repository->is_mirror(mirror.substr(0, s_pos)))
- throw PackageInstallActionError("Can't install '" + stringify(s_pos) + "-"
- + stringify(v) + "' since SRC_URI references unknown mirror:// '" +
- mirror.substr(0, s_pos) + "'");
-
- for (Environment::MirrorIterator
- m(_imp->params.environment->begin_mirrors(mirror.substr(0, s_pos))),
- m_end(_imp->params.environment->end_mirrors(mirror.substr(0, s_pos))) ;
- m != m_end ; ++m)
- flat_bin_uri.append(m->second + "/" + mirror.substr(s_pos + 1) + " ");
-
- for (RepositoryMirrorsInterface::MirrorsIterator
- m(_imp->portage_repository->begin_mirrors(mirror.substr(0, s_pos))),
- m_end(_imp->portage_repository->end_mirrors(mirror.substr(0, s_pos))) ;
- m != m_end ; ++m)
- flat_bin_uri.append(m->second + "/" + mirror.substr(s_pos + 1) + " ");
- }
- else
- flat_bin_uri.append((*ff)->text());
- flat_bin_uri.append(" ");
-
- /* add mirror://gentoo/ entries */
- std::string master_mirror(strip_trailing_string(stringify(_imp->portage_repository->name()), "x-"));
- if (_imp->portage_repository->is_mirror(master_mirror))
- {
- for (Environment::MirrorIterator
- m(_imp->params.environment->begin_mirrors(master_mirror)),
- m_end(_imp->params.environment->end_mirrors(master_mirror)) ;
- m != m_end ; ++m)
- flat_bin_uri.append(m->second + "/" + (*ff)->text().substr(pos + 1) + " ");
-
- for (RepositoryMirrorsInterface::MirrorsIterator
- m(_imp->portage_repository->begin_mirrors(master_mirror)),
- m_end(_imp->portage_repository->end_mirrors(master_mirror)) ;
- m != m_end ; ++m)
- flat_bin_uri.append(m->second + "/" + (*ff)->text().substr(pos + 1) + " ");
- }
- }
- }
-
- std::string use;
- {
- std::set<UseFlagName> iuse;
- WhitespaceTokeniser::get_instance()->tokenise(metadata->get_ebuild_interface()->
- iuse, create_inserter<UseFlagName>(std::inserter(iuse, iuse.begin())));
- for (std::set<UseFlagName>::const_iterator iuse_it(iuse.begin()), iuse_end(iuse.end()) ;
- iuse_it != iuse_end; ++iuse_it)
- if (_imp->params.environment->query_use(*iuse_it, &e))
- use += (*iuse_it).data() + " ";
- }
-
- use += p->environment_variable("ARCH") + " ";
-
- /* add expand to use (iuse isn't reliable for use_expand things), and make the expand
- * environment variables */
- AssociativeCollection<std::string, std::string>::Pointer expand_vars(
- new AssociativeCollection<std::string, std::string>::Concrete);
- for (PortageRepositoryProfile::UseExpandIterator x(p->begin_use_expand()),
- x_end(p->end_use_expand()) ; x != x_end ; ++x)
- {
- std::string lower_x;
- std::transform(x->data().begin(), x->data().end(), std::back_inserter(lower_x), &::tolower);
-
- /* possible values from profile */
- std::set<UseFlagName> possible_values;
- WhitespaceTokeniser::get_instance()->tokenise(p->environment_variable(stringify(*x)),
- create_inserter<UseFlagName>(std::inserter(possible_values, possible_values.end())));
-
- /* possible values from environment */
- UseFlagNameCollection::ConstPointer possible_values_from_env(_imp->params.environment->
- known_use_expand_names(*x, &e));
- std::copy(possible_values_from_env->begin(), possible_values_from_env->end(),
- std::inserter(possible_values, possible_values.end()));
-
- for (std::set<UseFlagName>::const_iterator u(possible_values.begin()), u_end(possible_values.end()) ;
- u != u_end ; ++u)
- {
- if (! _imp->params.environment->query_use(UseFlagName(lower_x + "_" + stringify(*u)), &e))
- continue;
-
- use.append(lower_x + "_" + stringify(*u) + " ");
-
- std::string value;
- AssociativeCollection<std::string, std::string>::Iterator i(expand_vars->find(stringify(*x)));
- if (expand_vars->end() != i)
- {
- value = i->second + " ";
- expand_vars->erase(i);
- }
- value.append(stringify(*u));
- expand_vars->insert(stringify(*x), value);
- }
- }
-
- binaries = strip_trailing(binaries, " ");
-
- EbinFetchCommand fetch_cmd(EbinCommandParams::create()
- .environment(_imp->params.environment)
- .db_entry(&e)
- .src_repository(metadata->get_ebin_interface()->src_repository)
- .ebin_dir(_imp->params.location / stringify(q.category) /
- stringify(q.package))
- .pkgdir(_imp->params.pkgdir)
- .buildroot(_imp->params.buildroot),
-
- EbinFetchCommandParams::create()
- .b(binaries)
- .flat_bin_uri(flat_bin_uri)
- .root(stringify(_imp->params.root) + "/")
- .profiles(_imp->params.profiles));
-
- fetch_cmd();
-
- if (o.fetch_only)
- return;
-
- EbinInstallCommand install_cmd(EbinCommandParams::create()
- .environment(_imp->params.environment)
- .db_entry(&e)
- .src_repository(metadata->get_ebin_interface()->src_repository)
- .ebin_dir(_imp->params.location / stringify(q.category) /
- stringify(q.package))
- .pkgdir(_imp->params.pkgdir)
- .buildroot(_imp->params.buildroot),
-
- EbinInstallCommandParams::create()
- .b(binaries)
- .use(use)
- .use_expand(join(
- p->begin_use_expand(),
- p->end_use_expand(), " "))
- .expand_vars(expand_vars)
- .root(stringify(_imp->params.root) + "/")
- .profiles(_imp->params.profiles)
- .disable_cfgpro(o.no_config_protect)
- .slot(SlotName(metadata->slot)));
-
- install_cmd();
-}
-
-std::string
-PortageRepositoryEbinEntries::get_environment_variable(const QualifiedPackageName & q,
- const VersionSpec & v, const std::string & s,
- PortageRepositoryProfile::ConstPointer) const
-{
- VersionMetadata::ConstPointer metadata(_imp->portage_repository->version_metadata(q, v));
-
- if (s == "DEPEND")
- return metadata->deps.build_depend_string;
- if (s == "RDEPEND")
- return metadata->deps.run_depend_string;
- if (s == "PDEPEND")
- return metadata->deps.post_depend_string;
-
- if (s == "SLOT")
- return stringify(metadata->slot);
- if (s == "LICENSE")
- return metadata->license_string;
- if (s == "EAPI")
- return metadata->eapi;
- if (s == "HOMEPAGE")
- return metadata->homepage;
- if (s == "DESCRIPTION")
- return metadata->description;
-
- if (s == "PROVIDE")
- return metadata->get_ebuild_interface()->provide_string;
- if (s == "SRC_URI")
- return metadata->get_ebuild_interface()->src_uri;
- if (s == "RESTRICT")
- return metadata->get_ebuild_interface()->restrict_string;
- if (s == "KEYWORDS")
- return metadata->get_ebuild_interface()->keywords;
- if (s == "IUSE")
- return metadata->get_ebuild_interface()->iuse;
- if (s == "VIRTUAL")
- return metadata->get_ebuild_interface()->inherited;
-
- if (s == "BIN_URI")
- return metadata->get_ebin_interface()->bin_uri;
- if (s == "SRC_REPOSITORY")
- return stringify(metadata->get_ebin_interface()->src_repository);
-
- PackageDatabaseEntry for_package(q, v, _imp->portage_repository->name());
- throw EnvironmentVariableActionError("Couldn't get environment variable '" +
- stringify(s) + "' for package '" + stringify(for_package) + "'");
-}
-
-PortageRepositoryEbinEntries::Pointer
-PortageRepositoryEbinEntries::make_portage_repository_ebin_entries(
- const Environment * const e, PortageRepository * const r, const PortageRepositoryParams & p)
-{
- return Pointer(new PortageRepositoryEbinEntries(e, r, p));
-}
-
-#ifdef PALUDIS_ENABLE_VISIBILITY
-# pragma GCC visibility push(default)
-#endif
-namespace
-{
- const PortageRepositoryEntriesMaker::RegisterMaker register_portage_repository_ebin_entries PALUDIS_ATTRIBUTE((used)) (
- "ebin", &PortageRepositoryEbinEntries::make_portage_repository_ebin_entries);
-}
-#ifdef PALUDIS_ENABLE_VISIBILITY
-# pragma GCC visibility pop
-#endif
-
diff --git a/paludis/repositories/portage/portage_repository_ebin_entries.hh b/paludis/repositories/portage/portage_repository_ebin_entries.hh
deleted file mode 100644
index bc7eda7..0000000
--- a/paludis/repositories/portage/portage_repository_ebin_entries.hh
+++ /dev/null
@@ -1,71 +0,0 @@
-/* vim: set sw=4 sts=4 et foldmethod=syntax : */
-
-/*
- * Copyright (c) 2006 Ciaran McCreesh <ciaranm@ciaranm.org>
- *
- * 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
- * Public License version 2, as published by the Free Software Foundation.
- *
- * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- * details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#ifndef PALUDIS_GUARD_PALUDIS_REPOSITORIES_PORTAGE_PORTAGE_REPOSITORY_EBIN_METADATA_HH
-#define PALUDIS_GUARD_PALUDIS_REPOSITORIES_PORTAGE_PORTAGE_REPOSITORY_EBIN_METADATA_HH 1
-
-#include <paludis/repositories/portage/portage_repository_entries.hh>
-#include <paludis/repositories/portage/portage_repository_params.hh>
-#include <paludis/util/private_implementation_pattern.hh>
-
-/** \file
- * Declaration for the PortageRepositoryEbinEntries class.
- *
- * \ingroup grpportagerepository
- */
-
-namespace paludis
-{
- class FSEntry;
- class PortageRepository;
-
- /**
- * PortageRepositoryEntries handler for ebins.
- *
- * \ingroup grpportagerepository
- */
- class PALUDIS_VISIBLE PortageRepositoryEbinEntries :
- public PortageRepositoryEntries,
- private PrivateImplementationPattern<PortageRepositoryEbinEntries>
- {
- public:
- static PortageRepositoryEbinEntries::Pointer
- make_portage_repository_ebin_entries(const Environment * const,
- PortageRepository * const, const PortageRepositoryParams &);
-
- PortageRepositoryEbinEntries(const Environment * const,
- PortageRepository * const portage_repository,
- const PortageRepositoryParams &);
-
- virtual ~PortageRepositoryEbinEntries();
-
- virtual VersionMetadata::Pointer generate_version_metadata(const QualifiedPackageName &,
- const VersionSpec &) const;
-
- virtual std::string get_environment_variable(const QualifiedPackageName &,
- const VersionSpec &, const std::string & var,
- PortageRepositoryProfile::ConstPointer) const;
-
- virtual void install(const QualifiedPackageName &, const VersionSpec &,
- const InstallOptions &, PortageRepositoryProfile::ConstPointer) const;
- };
-}
-
-#endif
-
diff --git a/paludis/repositories/portage/portage_repository_params.sr b/paludis/repositories/portage/portage_repository_params.sr
index 4babebd..75ca948 100644
--- a/paludis/repositories/portage/portage_repository_params.sr
+++ b/paludis/repositories/portage/portage_repository_params.sr
@@ -9,6 +9,7 @@ make_class_PortageRepositoryParams()
key location FSEntry
key profiles FSEntryCollection::ConstPointer
key cache FSEntry
+ key write_cache FSEntry
key distdir FSEntry
key pkgdir FSEntry
key eclassdirs FSEntryCollection::ConstPointer