aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-10-01 08:09:41 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-10-01 08:09:41 +0000
commit99969bc86fb0a831e7984adc481ee5af44edde7a (patch)
tree53a9262a4603df78fc325e434fe043f7dda508e0
parent31a6b81915e32bd38db09b380aafbac4a35df917 (diff)
downloadpaludis-99969bc86fb0a831e7984adc481ee5af44edde7a.tar.gz
paludis-99969bc86fb0a831e7984adc481ee5af44edde7a.tar.xz
Split up PortageRepository some more
-rw-r--r--paludis/package_database.hh16
-rw-r--r--paludis/repositories/portage/Makefile.am2
-rw-r--r--paludis/repositories/portage/portage_repository_profile.cc248
-rw-r--r--paludis/repositories/portage/portage_repository_profile_file.cc81
-rw-r--r--paludis/repositories/portage/portage_repository_profile_file.hh45
5 files changed, 242 insertions, 150 deletions
diff --git a/paludis/package_database.hh b/paludis/package_database.hh
index de10721..b9991e1 100644
--- a/paludis/package_database.hh
+++ b/paludis/package_database.hh
@@ -57,7 +57,7 @@ namespace paludis
* \ingroup grpexceptions
* \ingroup grppackagedatabase
*/
- class PackageDatabaseError : public Exception
+ class PALUDIS_VISIBLE PackageDatabaseError : public Exception
{
protected:
/**
@@ -73,7 +73,7 @@ namespace paludis
* \ingroup grpexceptions
* \ingroup grppackagedatabase
*/
- class PackageDatabaseLookupError : public PackageDatabaseError
+ class PALUDIS_VISIBLE PackageDatabaseLookupError : public PackageDatabaseError
{
protected:
/**
@@ -89,7 +89,7 @@ namespace paludis
* \ingroup grpexceptions
* \ingroup grppackagedatabase
*/
- class AmbiguousPackageNameError :
+ class PALUDIS_VISIBLE AmbiguousPackageNameError :
public PackageDatabaseLookupError
{
private:
@@ -136,7 +136,7 @@ namespace paludis
* \ingroup grpexceptions
* \ingroup grppackagedatabase
*/
- class DuplicateRepositoryError : public PackageDatabaseError
+ class PALUDIS_VISIBLE DuplicateRepositoryError : public PackageDatabaseError
{
public:
/**
@@ -152,7 +152,7 @@ namespace paludis
* \ingroup grpexceptions
* \ingroup grppackagedatabase
*/
- class NoSuchPackageError : public PackageDatabaseLookupError
+ class PALUDIS_VISIBLE NoSuchPackageError : public PackageDatabaseLookupError
{
private:
std::string _name;
@@ -186,7 +186,7 @@ namespace paludis
* \ingroup grpexceptions
* \ingroup grppackagedatabase
*/
- class NoSuchRepositoryError : public PackageDatabaseLookupError
+ class PALUDIS_VISIBLE NoSuchRepositoryError : public PackageDatabaseLookupError
{
public:
/**
@@ -213,7 +213,7 @@ namespace paludis
*
* \ingroup grppackagedatabase
*/
- class PackageDatabase :
+ class PALUDIS_VISIBLE PackageDatabase :
private PrivateImplementationPattern<PackageDatabase>,
private InstantiationPolicy<PackageDatabase, instantiation_method::NonCopyableTag>,
public InternalCounted<PackageDatabase>
@@ -294,7 +294,7 @@ namespace paludis
};
std::ostream &
- operator<< (std::ostream &, const InstallState &);
+ operator<< (std::ostream &, const InstallState &) PALUDIS_VISIBLE;
}
#endif
diff --git a/paludis/repositories/portage/Makefile.am b/paludis/repositories/portage/Makefile.am
index 2083e58..16444b1 100644
--- a/paludis/repositories/portage/Makefile.am
+++ b/paludis/repositories/portage/Makefile.am
@@ -16,6 +16,7 @@ libpaludisportagerepository_la_LDFLAGS = -version-info @VERSION_LIB_CURRENT@:@VE
paludis_repositories_portage_include_HEADERS = \
portage_repository.hh \
+ portage_repository_profile_file.hh \
portage_repository_profile.hh \
portage_repository_exceptions.hh \
portage_repository_news.hh \
@@ -30,6 +31,7 @@ paludis_repositories_portage_include_HEADERS = \
libpaludisportagerepository_la_SOURCES = \
portage_repository.cc \
+ portage_repository_profile_file.cc \
portage_repository_profile.cc \
portage_repository_exceptions.cc \
portage_repository_news.cc \
diff --git a/paludis/repositories/portage/portage_repository_profile.cc b/paludis/repositories/portage/portage_repository_profile.cc
index 021062e..0197873 100644
--- a/paludis/repositories/portage/portage_repository_profile.cc
+++ b/paludis/repositories/portage/portage_repository_profile.cc
@@ -18,6 +18,7 @@
*/
#include <paludis/repositories/portage/portage_repository_profile.hh>
+#include <paludis/repositories/portage/portage_repository_profile_file.hh>
#include <paludis/repositories/portage/portage_repository_exceptions.hh>
#include <paludis/util/log.hh>
@@ -69,21 +70,18 @@ namespace paludis
void load_profile_directory_recursively(const FSEntry & dir);
void load_profile_parent(const FSEntry & dir);
void load_profile_make_defaults(const FSEntry & dir);
- void load_profile_use_mask_or_force(const FSEntry & dir,
- const std::string & mask_or_force, UseFlagSet & set);
- void load_profile_package_use_mask_or_force(const FSEntry & dir,
- const std::string & mask_or_force, PackageUseMaskMap & set);
- void load_profile_packages(const FSEntry & dir);
- void load_profile_virtuals(const FSEntry & dir);
- void load_profile_package_mask(const FSEntry & dir);
void add_use_expand_to_use();
- void load_system_packages();
- void load_package_mask();
+ void make_vars_from_file_vars();
void handle_profile_arch_var();
- std::set<std::string> system_lines;
- std::set<std::string> package_mask_lines;
+ ProfileFile use_mask_file;
+ ProfileFile package_use_mask_file;
+ ProfileFile use_force_file;
+ ProfileFile package_use_force_file;
+ ProfileFile packages_file;
+ ProfileFile virtuals_file;
+ ProfileFile package_mask_file;
public:
///\name General variables
@@ -157,8 +155,7 @@ namespace paludis
load_profile_directory_recursively(*d);
add_use_expand_to_use();
- load_package_mask();
- load_system_packages();
+ make_vars_from_file_vars();
handle_profile_arch_var();
}
@@ -185,13 +182,14 @@ Implementation<PortageRepositoryProfile>::load_profile_directory_recursively(con
load_profile_parent(dir);
load_profile_make_defaults(dir);
- load_profile_use_mask_or_force(dir, "mask", use_mask);
- load_profile_use_mask_or_force(dir, "force", use_force);
- load_profile_package_use_mask_or_force(dir, "mask", package_use_mask);
- load_profile_package_use_mask_or_force(dir, "force", package_use_force);
- load_profile_packages(dir);
- load_profile_virtuals(dir);
- load_profile_package_mask(dir);
+
+ use_mask_file.add_file(dir / "use.mask");
+ package_use_mask_file.add_file(dir / "package.use.mask");
+ use_force_file.add_file(dir / "use.force");
+ package_use_force_file.add_file(dir / "package.use.force");
+ packages_file.add_file(dir / "packages");
+ virtuals_file.add_file(dir / "virtuals");
+ package_mask_file.add_file(dir / "package.mask");
}
void
@@ -292,48 +290,68 @@ Implementation<PortageRepositoryProfile>::load_profile_make_defaults(const FSEnt
}
void
-Implementation<PortageRepositoryProfile>::load_profile_use_mask_or_force(const FSEntry & dir,
- const std::string & mask_or_force, UseFlagSet & set)
+Implementation<PortageRepositoryProfile>::make_vars_from_file_vars()
{
- Context context("When handling use." + mask_or_force + " file for profile directory '" +
- stringify(dir) + ":");
+ try
+ {
+ Context context("When parsing use.mask:");
+ std::copy(use_mask_file.begin(), use_mask_file.end(), create_inserter<UseFlagName>(
+ std::inserter(use_mask, use_mask.begin())));
+ }
+ catch (const NameError & e)
+ {
+ Log::get_instance()->message(ll_warning, lc_context, "Loading use.mask "
+ " failed due to exception: " + stringify(e.message()) + " (" + e.what() + ")");
+ }
- if (! (dir / ("use." + mask_or_force)).exists())
- return;
+ try
+ {
+ Context context("When parsing use.force:");
+ std::copy(use_force_file.begin(), use_force_file.end(), create_inserter<UseFlagName>(
+ std::inserter(use_force, use_force.begin())));
+ }
+ catch (const NameError & e)
+ {
+ Log::get_instance()->message(ll_warning, lc_context, "Loading use.force "
+ " failed due to exception: " + stringify(e.message()) + " (" + e.what() + ")");
+ }
- LineConfigFile file(dir / ("use." + mask_or_force));
try
{
- for (LineConfigFile::Iterator line(file.begin()), line_end(file.end()) ;
+ Context context("When parsing package.use.mask:");
+
+ for (ProfileFile::Iterator line(package_use_mask_file.begin()), line_end(package_use_mask_file.end()) ;
line != line_end ; ++line)
{
- if ('-' == line->at(0))
- set.erase(UseFlagName(line->substr(1)));
- else
- set.insert(UseFlagName(*line));
+ std::list<std::string> tokens;
+ WhitespaceTokeniser::get_instance()->tokenise(*line, std::back_inserter(tokens));
+ if (tokens.size() < 2)
+ continue;
+
+ std::list<std::string>::const_iterator t(tokens.begin()), t_end(tokens.end());
+ PackageDepAtom::ConstPointer d(new PackageDepAtom(*t++));
+ QualifiedPackageName p(d->package());
+
+ PackageUseMaskMap::iterator i(package_use_mask.find(p));
+ if (package_use_mask.end() == i)
+ i = package_use_mask.insert(std::make_pair(p, std::list<std::pair<PackageDepAtom::ConstPointer,
+ UseFlagName> >())).first;
+
+ for ( ; t != t_end ; ++t)
+ i->second.push_back(std::make_pair(d, UseFlagName(*t)));
}
}
catch (const NameError & e)
{
- Log::get_instance()->message(ll_warning, lc_context, "Loading use." + mask_or_force +
- " failed due to exception: " + e.message() + " (" + e.what() + ")");
+ Log::get_instance()->message(ll_warning, lc_context, "Loading package.use.mask "
+ " failed due to exception: " + stringify(e.message()) + " (" + e.what() + ")");
}
-}
-void
-Implementation<PortageRepositoryProfile>::load_profile_package_use_mask_or_force(const FSEntry & dir,
- const std::string & mask_or_force, PackageUseMaskMap & set)
-{
- Context context("When handling package.use." + mask_or_force + " file for profile directory '" +
- stringify(dir) + ":");
-
- if (! (dir / ("package.use." + mask_or_force)).exists())
- return;
-
- LineConfigFile file(dir / ("package.use." + mask_or_force));
try
{
- for (LineConfigFile::Iterator line(file.begin()), line_end(file.end()) ;
+ Context context("When parsing package.use.force:");
+
+ for (ProfileFile::Iterator line(package_use_force_file.begin()), line_end(package_use_force_file.end()) ;
line != line_end ; ++line)
{
std::list<std::string> tokens;
@@ -345,9 +363,9 @@ Implementation<PortageRepositoryProfile>::load_profile_package_use_mask_or_force
PackageDepAtom::ConstPointer d(new PackageDepAtom(*t++));
QualifiedPackageName p(d->package());
- PackageUseMaskMap::iterator i(set.find(p));
- if (set.end() == i)
- i = set.insert(std::make_pair(p, std::list<std::pair<PackageDepAtom::ConstPointer,
+ PackageUseMaskMap::iterator i(package_use_force.find(p));
+ if (package_use_force.end() == i)
+ i = package_use_force.insert(std::make_pair(p, std::list<std::pair<PackageDepAtom::ConstPointer,
UseFlagName> >())).first;
for ( ; t != t_end ; ++t)
@@ -356,105 +374,66 @@ Implementation<PortageRepositoryProfile>::load_profile_package_use_mask_or_force
}
catch (const NameError & e)
{
- Log::get_instance()->message(ll_warning, lc_context, "Loading package.use." + mask_or_force +
+ Log::get_instance()->message(ll_warning, lc_context, "Loading package.use.mask "
" failed due to exception: " + e.message() + " (" + e.what() + ")");
}
-}
-
-void
-Implementation<PortageRepositoryProfile>::load_profile_packages(const FSEntry & dir)
-{
- Context context("When loading packages file in '" + stringify(dir) + "':");
-
- if (! (dir / "packages").exists())
- return;
- LineConfigFile file(dir / "packages");
- for (LineConfigFile::Iterator line(file.begin()), line_end(file.end()) ;
- line != line_end ; ++line)
+ try
{
- if (line->empty())
- continue;
-
- Context context_line("When reading line '" + *line + "':");
+ for (ProfileFile::Iterator i(packages_file.begin()), i_end(packages_file.end()) ; i != i_end ; ++i)
+ {
+ if (0 != i->compare(0, 1, "*", 0, 1))
+ continue;
- if ('*' == line->at(0))
- system_lines.insert(line->substr(1));
- else if (0 == line->compare(0, 2, "-*"))
- if (0 == system_lines.erase(line->substr(2)))
- Log::get_instance()->message(ll_qa, lc_context,
- "Trying to remove packages line '" + line->substr(2) +
- "' that doesn't exist");
+ Context context_atom("When parsing '" + *i + "':");
+ PackageDepAtom::Pointer atom(new PackageDepAtom(i->substr(1)));
+ atom->set_tag(system_tag);
+ system_packages->add_child(atom);
+ }
}
-}
-
-void
-Implementation<PortageRepositoryProfile>::load_profile_virtuals(const FSEntry & dir)
-{
- Context context("When loading virtuals file in '" + stringify(dir) + "':");
-
- if (! (dir / "virtuals").exists())
- return;
-
- LineConfigFile file(dir / "virtuals");
- for (LineConfigFile::Iterator line(file.begin()), line_end(file.end()) ;
- line != line_end ; ++line)
+ catch (const NameError & e)
{
- std::vector<std::string> tokens;
- WhitespaceTokeniser::get_instance()->tokenise(*line, std::back_inserter(tokens));
- if (tokens.size() < 2)
- continue;
-
- QualifiedPackageName v(tokens[0]);
- virtuals.erase(v);
- virtuals.insert(std::make_pair(v, PackageDepAtom::Pointer(new PackageDepAtom(tokens[1]))));
+ Log::get_instance()->message(ll_warning, lc_context, "Loading packages "
+ " failed due to exception: " + e.message() + " (" + e.what() + ")");
}
-}
-void
-Implementation<PortageRepositoryProfile>::load_profile_package_mask(const FSEntry & dir)
-{
- Context context("When loading package.mask file in '" + stringify(dir) + "':");
+ try
+ {
+ for (ProfileFile::Iterator line(virtuals_file.begin()), line_end(virtuals_file.end()) ;
+ line != line_end ; ++line)
+ {
+ std::vector<std::string> tokens;
+ WhitespaceTokeniser::get_instance()->tokenise(*line, std::back_inserter(tokens));
+ if (tokens.size() < 2)
+ continue;
- if (! (dir / "package.mask").exists())
- return;
+ QualifiedPackageName v(tokens[0]);
+ virtuals.erase(v);
+ virtuals.insert(std::make_pair(v, PackageDepAtom::Pointer(new PackageDepAtom(tokens[1]))));
+ }
+ }
+ catch (const NameError & e)
+ {
+ Log::get_instance()->message(ll_warning, lc_context, "Loading virtuals "
+ " failed due to exception: " + e.message() + " (" + e.what() + ")");
+ }
- LineConfigFile file(dir / "package.mask");
- for (LineConfigFile::Iterator line(file.begin()), line_end(file.end()) ;
+ for (ProfileFile::Iterator line(package_mask_file.begin()), line_end(package_mask_file.end()) ;
line != line_end ; ++line)
{
if (line->empty())
continue;
- if ('-' == line->at(0))
- {
- if (0 == package_mask_lines.erase(line->substr(1)))
- Log::get_instance()->message(ll_qa, lc_context,
- "Trying to remove package.mask line '" + line->substr(1) +
- "' that doesn't exist");
- }
- else
- package_mask_lines.insert(*line);
- }
-}
-
-void
-Implementation<PortageRepositoryProfile>::load_package_mask()
-{
- Context context("When building package.mask set:");
-
- for (std::set<std::string>::const_iterator i(package_mask_lines.begin()),
- i_end(package_mask_lines.end()) ; i != i_end ; ++i)
- {
try
{
- PackageDepAtom::ConstPointer a(new PackageDepAtom(*i));
+ PackageDepAtom::ConstPointer a(new PackageDepAtom(*line));
package_mask[a->package()].push_back(a);
}
catch (const NameError & e)
{
- Log::get_instance()->message(ll_warning, lc_context, "Skipping package.mask entry '"
- + *i + "' due to exception '" + e.message() + "' (" + e.what() + ")");
+ Log::get_instance()->message(ll_warning, lc_context, "Loading package.mask atom '"
+ + stringify(*line) + "' failed due to exception '" + e.message() + "' ("
+ + e.what() + ")");
}
}
}
@@ -524,21 +503,6 @@ Implementation<PortageRepositoryProfile>::add_use_expand_to_use()
}
void
-Implementation<PortageRepositoryProfile>::load_system_packages()
-{
- Context context("When loading system packages:");
-
- for (std::set<std::string>::const_iterator i(system_lines.begin()),
- i_end(system_lines.end()) ; i != i_end ; ++i)
- {
- Context context_atom("When parsing package '" + *i + "':");
- PackageDepAtom::Pointer atom(new PackageDepAtom(*i));
- atom->set_tag(system_tag);
- system_packages->add_child(atom);
- }
-}
-
-void
Implementation<PortageRepositoryProfile>::handle_profile_arch_var()
{
Context context("When handling profile ARCH variable:");
diff --git a/paludis/repositories/portage/portage_repository_profile_file.cc b/paludis/repositories/portage/portage_repository_profile_file.cc
new file mode 100644
index 0000000..1ad991c
--- /dev/null
+++ b/paludis/repositories/portage/portage_repository_profile_file.cc
@@ -0,0 +1,81 @@
+/* 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 "portage_repository_profile_file.hh"
+#include <paludis/util/log.hh>
+#include <paludis/config_file.hh>
+#include <set>
+
+using namespace paludis;
+
+namespace paludis
+{
+ template <>
+ struct Implementation<ProfileFile> :
+ InternalCounted<Implementation<ProfileFile> >
+ {
+ std::set<std::string> lines;
+ };
+}
+
+void
+ProfileFile::add_file(const FSEntry & f)
+{
+ Context context("When adding profile configuration file '" + stringify(f) + "':");
+
+ if (! f.exists())
+ return;
+
+ LineConfigFile file(f);
+ for (LineConfigFile::Iterator line(file.begin()), line_end(file.end()) ; line != line_end ; ++line)
+ {
+ if (0 == line->compare(0, 1, "-", 0, 1))
+ {
+ std::set<std::string>::iterator i(_imp->lines.find(line->substr(1)));
+ if (_imp->lines.end() == i)
+ Log::get_instance()->message(ll_qa, lc_context, "No match for '" + *line + "'");
+ else
+ _imp->lines.erase(i);
+ }
+ else
+ _imp->lines.insert(*line);
+ }
+}
+
+ProfileFile::ProfileFile() :
+ PrivateImplementationPattern<ProfileFile>(new Implementation<ProfileFile>)
+{
+}
+
+ProfileFile::~ProfileFile()
+{
+}
+
+ProfileFile::Iterator
+ProfileFile::begin() const
+{
+ return Iterator(_imp->lines.begin());
+}
+
+ProfileFile::Iterator
+ProfileFile::end() const
+{
+ return Iterator(_imp->lines.end());
+}
+
diff --git a/paludis/repositories/portage/portage_repository_profile_file.hh b/paludis/repositories/portage/portage_repository_profile_file.hh
new file mode 100644
index 0000000..c06aa13
--- /dev/null
+++ b/paludis/repositories/portage/portage_repository_profile_file.hh
@@ -0,0 +1,45 @@
+/* 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_PROFILE_FILE_HH
+#define PALUDIS_GUARD_PALUDIS_REPOSITORIES_PORTAGE_PORTAGE_REPOSITORY_PROFILE_FILE_HH 1
+
+#include <paludis/util/private_implementation_pattern.hh>
+#include <paludis/util/attributes.hh>
+#include <paludis/util/fs_entry.hh>
+#include <libwrapiter/libwrapiter_forward_iterator.hh>
+
+namespace paludis
+{
+ class ProfileFile :
+ private PrivateImplementationPattern<ProfileFile>
+ {
+ public:
+ ProfileFile();
+ ~ProfileFile();
+
+ void add_file(const FSEntry &);
+
+ typedef libwrapiter::ForwardIterator<ProfileFile, const std::string> Iterator;
+ Iterator begin() const;
+ Iterator end() const;
+ };
+}
+
+#endif