aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar David Leverton <levertond@googlemail.com> 2007-08-01 14:30:36 +0000
committerAvatar David Leverton <levertond@googlemail.com> 2007-08-01 14:30:36 +0000
commit1daa45d087b135979f1c7ef68dd9d03ebfeaa601 (patch)
tree03d7ae74b65f215d281fc94b23b26ffc1428574d
parent5205c6647034f685b7347604c36745b398084c8e (diff)
downloadpaludis-1daa45d087b135979f1c7ef68dd9d03ebfeaa601.tar.gz
paludis-1daa45d087b135979f1c7ef68dd9d03ebfeaa601.tar.xz
Add mask comment to RepositoryMaskInfo.
-rw-r--r--paludis/mask.hh1
-rwxr-xr-xpaludis/mask.sr1
-rw-r--r--paludis/repositories/e/Makefile.am2
-rw-r--r--paludis/repositories/e/e_repository.cc13
-rw-r--r--paludis/repositories/e/e_repository_mask_file.cc97
-rw-r--r--paludis/repositories/e/e_repository_mask_file.hh67
-rw-r--r--paludis/repositories/e/e_repository_profile.cc21
-rw-r--r--paludis/repositories/e/e_repository_profile_file.cc74
-rw-r--r--paludis/repositories/e/e_repository_profile_file.hh56
-rw-r--r--src/output/console_query_task.cc10
10 files changed, 280 insertions, 62 deletions
diff --git a/paludis/mask.hh b/paludis/mask.hh
index 96c15b8..29b660c 100644
--- a/paludis/mask.hh
+++ b/paludis/mask.hh
@@ -26,6 +26,7 @@
#include <paludis/util/visitor.hh>
#include <paludis/util/attributes.hh>
#include <paludis/util/fs_entry.hh>
+#include <paludis/util/sequence-fwd.hh>
#include <string>
namespace paludis
diff --git a/paludis/mask.sr b/paludis/mask.sr
index da4754f..c7d73a9 100755
--- a/paludis/mask.sr
+++ b/paludis/mask.sr
@@ -6,6 +6,7 @@ make_class_RepositoryMaskInfo()
visible
key mask_file "FSEntry"
+ key comment "tr1::shared_ptr<const Sequence<std::string> >"
doxygen_comment << "END"
/**
diff --git a/paludis/repositories/e/Makefile.am b/paludis/repositories/e/Makefile.am
index 2f16d3f..3b354fb 100644
--- a/paludis/repositories/e/Makefile.am
+++ b/paludis/repositories/e/Makefile.am
@@ -46,6 +46,7 @@ paludis_repositories_e_include_HEADERS = \
e_repository_entries.hh \
e_repository_exceptions.hh \
e_repository_id.hh \
+ e_repository_mask_file.hh \
e_repository_news.hh \
e_repository_params-sr.hh \
e_repository_params.hh \
@@ -96,6 +97,7 @@ libpaludiserepository_la_SOURCES = \
e_repository_entries.cc \
e_repository_exceptions.cc \
e_repository_id.cc \
+ e_repository_mask_file.cc \
e_repository_news.cc \
e_repository_params.cc \
e_repository_profile.cc \
diff --git a/paludis/repositories/e/e_repository.cc b/paludis/repositories/e/e_repository.cc
index 5b039a7..9a9906d 100644
--- a/paludis/repositories/e/e_repository.cc
+++ b/paludis/repositories/e/e_repository.cc
@@ -23,6 +23,7 @@
#include <paludis/repositories/e/aa_visitor.hh>
#include <paludis/repositories/e/e_key.hh>
#include <paludis/repositories/e/e_repository.hh>
+#include <paludis/repositories/e/e_repository_mask_file.hh>
#include <paludis/repositories/e/e_repository_profile.hh>
#include <paludis/repositories/e/e_repository_news.hh>
#include <paludis/repositories/e/e_repository_sets.hh>
@@ -390,24 +391,24 @@ ERepository::repository_masked(const PackageID & id) const
if (p->exists())
{
- LineConfigFile ff(*p, LineConfigFileOptions());
- for (LineConfigFile::Iterator line(ff.begin()), line_end(ff.end()) ;
+ erepository::MaskFile ff(*p, LineConfigFileOptions());
+ for (erepository::MaskFile::Iterator line(ff.begin()), line_end(ff.end()) ;
line != line_end ; ++line)
{
try
{
- tr1::shared_ptr<const PackageDepSpec> a(new PackageDepSpec(*line, pds_pm_eapi_0));
+ tr1::shared_ptr<const PackageDepSpec> a(new PackageDepSpec(line->first, pds_pm_eapi_0));
if (a->package_ptr())
- _imp->repo_mask[*a->package_ptr()].push_back(std::make_pair(a, tr1::shared_ptr<const RepositoryMaskInfo>(new RepositoryMaskInfo(*p))));
+ _imp->repo_mask[*a->package_ptr()].push_back(std::make_pair(a, line->second));
else
Log::get_instance()->message(ll_warning, lc_context, "Loading package mask spec '"
- + stringify(*line) + "' failed because specification does not restrict to a "
+ + stringify(line->first) + "' failed because specification does not restrict to a "
"unique package");
}
catch (const Exception & e)
{
Log::get_instance()->message(ll_warning, lc_context, "Loading package mask spec '"
- + stringify(*line) + "' failed due to exception '" + e.message() + "' ("
+ + stringify(line->first) + "' failed due to exception '" + e.message() + "' ("
+ e.what() + ")");
}
}
diff --git a/paludis/repositories/e/e_repository_mask_file.cc b/paludis/repositories/e/e_repository_mask_file.cc
new file mode 100644
index 0000000..1ecf793
--- /dev/null
+++ b/paludis/repositories/e/e_repository_mask_file.cc
@@ -0,0 +1,97 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2007 David Leverton <levertond@googlemail.com>
+ *
+ * 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 "e_repository_mask_file.hh"
+#include <paludis/util/private_implementation_pattern-impl.hh>
+#include <paludis/util/options.hh>
+#include <paludis/util/sequence.hh>
+#include <paludis/util/strip.hh>
+#include <paludis/config_file.hh>
+#include <paludis/mask.hh>
+
+#include <libwrapiter/libwrapiter_forward_iterator-impl.hh>
+#include <libwrapiter/libwrapiter_output_iterator-impl.hh>
+
+#include <list>
+
+using namespace paludis;
+using namespace paludis::erepository;
+
+namespace paludis
+{
+ template <>
+ struct Implementation<MaskFile>
+ {
+ std::list<std::pair<const std::string, tr1::shared_ptr<const RepositoryMaskInfo> > > lines;
+ };
+}
+
+MaskFile::MaskFile(const FSEntry & f, const LineConfigFileOptions & opts) :
+ PrivateImplementationPattern<MaskFile>(new Implementation<MaskFile>)
+{
+ LineConfigFileOptions myopts(opts);
+ myopts += lcfo_disallow_comments;
+ myopts += lcfo_no_skip_blank_lines;
+
+ LineConfigFile file(f, myopts);
+ tr1::shared_ptr<Sequence<std::string> > comment(new Sequence<std::string>);
+ bool comment_used(false);
+ for (LineConfigFile::Iterator it(file.begin()), it_end(file.end()); it_end != it; ++it)
+ {
+ if (it->empty())
+ {
+ comment.reset(new Sequence<std::string>);
+ comment_used = false;
+ continue;
+ }
+
+ if ('#' == it->at(0))
+ {
+ if (comment_used)
+ {
+ tr1::shared_ptr<Sequence<std::string> > cpy(new Sequence<std::string>);
+ std::copy(comment->begin(), comment->end(), cpy->back_inserter());
+ comment = cpy;
+ comment_used = false;
+ }
+ comment->push_back(strip_leading(it->substr(1), " \t\r\n"));
+ continue;
+ }
+
+ _imp->lines.push_back(std::make_pair(*it, tr1::shared_ptr<RepositoryMaskInfo>(new RepositoryMaskInfo(f, comment))));
+ comment_used = true;
+ }
+}
+
+MaskFile::Iterator
+MaskFile::begin() const
+{
+ return Iterator(_imp->lines.begin());
+}
+
+MaskFile::Iterator
+MaskFile::end() const
+{
+ return Iterator(_imp->lines.end());
+}
+
+MaskFile::~MaskFile()
+{
+}
+
diff --git a/paludis/repositories/e/e_repository_mask_file.hh b/paludis/repositories/e/e_repository_mask_file.hh
new file mode 100644
index 0000000..b6dff82
--- /dev/null
+++ b/paludis/repositories/e/e_repository_mask_file.hh
@@ -0,0 +1,67 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2007 David Leverton <levertond@googlemail.com>
+ *
+ * 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_E_E_REPOSITORY_MASK_FILE_HH
+#define PALUDIS_GUARD_PALUDIS_REPOSITORIES_E_E_REPOSITORY_MASK_FILE_HH 1
+
+#include <paludis/util/private_implementation_pattern.hh>
+#include <paludis/util/attributes.hh>
+#include <paludis/util/fs_entry.hh>
+#include <paludis/config_file.hh>
+#include <paludis/mask-fwd.hh>
+
+#include <libwrapiter/libwrapiter_forward_iterator-fwd.hh>
+
+namespace paludis
+{
+ namespace erepository
+ {
+ /**
+ * A file listing masks in an ERepository.
+ *
+ * Handles parsing mask reasons from the comments.
+ *
+ * \ingroup grperepository
+ */
+ class PALUDIS_VISIBLE MaskFile :
+ private PrivateImplementationPattern<MaskFile>
+ {
+ public:
+ ///\name Basic operations
+ ///\{
+
+ MaskFile(const FSEntry &, const LineConfigFileOptions &);
+ ~MaskFile();
+
+ ///\}
+
+ ///\name Iterate over our mask lines.
+ ///\{
+
+ typedef libwrapiter::ForwardIterator<MaskFile, const std::pair<const std::string, tr1::shared_ptr<const RepositoryMaskInfo> > > Iterator;
+ Iterator begin() const;
+ Iterator end() const;
+
+ ///\}
+ };
+ }
+}
+
+#endif
+
diff --git a/paludis/repositories/e/e_repository_profile.cc b/paludis/repositories/e/e_repository_profile.cc
index c318d23..57800ec 100644
--- a/paludis/repositories/e/e_repository_profile.cc
+++ b/paludis/repositories/e/e_repository_profile.cc
@@ -19,6 +19,7 @@
#include <paludis/repositories/e/e_repository_profile.hh>
#include <paludis/repositories/e/e_repository_profile_file.hh>
+#include <paludis/repositories/e/e_repository_mask_file.hh>
#include <paludis/repositories/e/e_repository_exceptions.hh>
#include <paludis/repositories/e/e_repository.hh>
#include <paludis/repositories/e/eapi.hh>
@@ -108,9 +109,9 @@ namespace paludis
void handle_profile_arch_var(const std::string &);
void load_special_make_defaults_vars();
- ProfileFile packages_file;
- ProfileFile virtuals_file;
- ProfileFile package_mask_file;
+ erepository::ProfileFile<LineConfigFile> packages_file;
+ erepository::ProfileFile<LineConfigFile> virtuals_file;
+ erepository::ProfileFile<erepository::MaskFile> package_mask_file;
bool is_incremental(const std::string & s) const;
@@ -425,13 +426,13 @@ Implementation<ERepositoryProfile>::make_vars_from_file_vars()
{
try
{
- for (ProfileFile::Iterator i(packages_file.begin()), i_end(packages_file.end()) ; i != i_end ; ++i)
+ for (erepository::ProfileFile<LineConfigFile>::Iterator i(packages_file.begin()), i_end(packages_file.end()) ; i != i_end ; ++i)
{
- if (0 != i->first.compare(0, 1, "*", 0, 1))
+ if (0 != i->compare(0, 1, "*", 0, 1))
continue;
- Context context_spec("When parsing '" + i->first + "':");
- tr1::shared_ptr<PackageDepSpec> spec(new PackageDepSpec(i->first.substr(1), pds_pm_eapi_0));
+ Context context_spec("When parsing '" + *i + "':");
+ tr1::shared_ptr<PackageDepSpec> spec(new PackageDepSpec(i->substr(1), pds_pm_eapi_0));
spec->set_tag(system_tag);
system_packages->add(tr1::shared_ptr<SetSpecTree::ConstItem>(new TreeLeaf<SetSpecTree, PackageDepSpec>(spec)));
}
@@ -446,11 +447,11 @@ Implementation<ERepositoryProfile>::make_vars_from_file_vars()
env->default_distribution())->support_old_style_virtuals)
try
{
- for (ProfileFile::Iterator line(virtuals_file.begin()), line_end(virtuals_file.end()) ;
+ for (erepository::ProfileFile<LineConfigFile>::Iterator line(virtuals_file.begin()), line_end(virtuals_file.end()) ;
line != line_end ; ++line)
{
std::vector<std::string> tokens;
- WhitespaceTokeniser::get_instance()->tokenise(line->first, std::back_inserter(tokens));
+ WhitespaceTokeniser::get_instance()->tokenise(*line, std::back_inserter(tokens));
if (tokens.size() < 2)
continue;
@@ -466,7 +467,7 @@ Implementation<ERepositoryProfile>::make_vars_from_file_vars()
" failed due to exception: " + e.message() + " (" + e.what() + ")");
}
- for (ProfileFile::Iterator line(package_mask_file.begin()), line_end(package_mask_file.end()) ;
+ for (erepository::ProfileFile<erepository::MaskFile>::Iterator line(package_mask_file.begin()), line_end(package_mask_file.end()) ;
line != line_end ; ++line)
{
if (line->first.empty())
diff --git a/paludis/repositories/e/e_repository_profile_file.cc b/paludis/repositories/e/e_repository_profile_file.cc
index fac86ed..093d806 100644
--- a/paludis/repositories/e/e_repository_profile_file.cc
+++ b/paludis/repositories/e/e_repository_profile_file.cc
@@ -18,6 +18,8 @@
*/
#include "e_repository_profile_file.hh"
+#include "e_repository_mask_file.hh"
+#include <paludis/util/tr1_type_traits.hh>
#include <paludis/util/log.hh>
#include <paludis/util/stringify.hh>
#include <paludis/config_file.hh>
@@ -27,59 +29,93 @@
#include <libwrapiter/libwrapiter_forward_iterator.hh>
#include <libwrapiter/libwrapiter_output_iterator.hh>
#include <map>
+#include <set>
#include <algorithm>
using namespace paludis;
+using namespace paludis::erepository;
+
+namespace
+{
+ template <typename T_>
+ struct FileEntryTraits
+ {
+ typedef std::multiset<typename tr1::remove_const<T_>::type> Storage;
+ static T_ & extract_key(const T_ & k)
+ {
+ return k;
+ }
+ };
+
+ template <typename F_, typename S_>
+ struct FileEntryTraits<const std::pair<F_, S_> >
+ {
+ typedef std::multimap<F_, S_> Storage;
+ static const F_ & extract_key(const std::pair<F_, S_> & p)
+ {
+ return p.first;
+ }
+ };
+}
namespace paludis
{
- template <>
- struct Implementation<ProfileFile>
+ template <typename F_>
+ struct Implementation<ProfileFile<F_> >
{
- std::multimap<std::string, tr1::shared_ptr<const RepositoryMaskInfo> > lines;
+ typename FileEntryTraits<typename F_::Iterator::value_type>::Storage lines;
};
}
+template <typename F_>
void
-ProfileFile::add_file(const FSEntry & f)
+ProfileFile<F_>::add_file(const FSEntry & f)
{
Context context("When adding profile configuration file '" + stringify(f) + "':");
if (! f.exists())
return;
- LineConfigFile file(f, LineConfigFileOptions());
- for (LineConfigFile::Iterator line(file.begin()), line_end(file.end()) ; line != line_end ; ++line)
+ F_ file(f, LineConfigFileOptions());
+ for (typename F_::Iterator line(file.begin()), line_end(file.end()) ; line != line_end ; ++line)
{
- if (0 == line->compare(0, 1, "-", 0, 1))
+ const std::string & key(FileEntryTraits<typename F_::Iterator::value_type>::extract_key(*line));
+ if (0 == key.compare(0, 1, "-", 0, 1))
{
- int erased(_imp->lines.erase(line->substr(1)));
+ int erased(this->_imp->lines.erase(key.substr(1)));
if (0 == erased)
- Log::get_instance()->message(ll_qa, lc_context, "No match for '" + *line + "'");
+ Log::get_instance()->message(ll_qa, lc_context, "No match for '" + key + "'");
}
else
- _imp->lines.insert(std::make_pair(*line, tr1::shared_ptr<const RepositoryMaskInfo>(new RepositoryMaskInfo(f))));
+ this->_imp->lines.insert(*line);
}
}
-ProfileFile::ProfileFile() :
- PrivateImplementationPattern<ProfileFile>(new Implementation<ProfileFile>)
+template <typename F_>
+ProfileFile<F_>::ProfileFile() :
+ PrivateImplementationPattern<ProfileFile>(new Implementation<ProfileFile<F_> >)
{
}
-ProfileFile::~ProfileFile()
+template <typename F_>
+ProfileFile<F_>::~ProfileFile()
{
}
-ProfileFile::Iterator
-ProfileFile::begin() const
+template <typename F_>
+typename ProfileFile<F_>::Iterator
+ProfileFile<F_>::begin() const
{
- return Iterator(_imp->lines.begin());
+ return Iterator(this->_imp->lines.begin());
}
-ProfileFile::Iterator
-ProfileFile::end() const
+template <typename F_>
+typename ProfileFile<F_>::Iterator
+ProfileFile<F_>::end() const
{
- return Iterator(_imp->lines.end());
+ return Iterator(this->_imp->lines.end());
}
+template class ProfileFile<LineConfigFile>;
+template class ProfileFile<MaskFile>;
+
diff --git a/paludis/repositories/e/e_repository_profile_file.hh b/paludis/repositories/e/e_repository_profile_file.hh
index f0f127a..64a3e10 100644
--- a/paludis/repositories/e/e_repository_profile_file.hh
+++ b/paludis/repositories/e/e_repository_profile_file.hh
@@ -28,39 +28,43 @@
namespace paludis
{
- /**
- * A file in a ERepository profile.
- *
- * Handles -lines, comments, inherits automatically.
- *
- * \ingroup grperepository
- */
- class PALUDIS_VISIBLE ProfileFile :
- private PrivateImplementationPattern<ProfileFile>
+ namespace erepository
{
- public:
- ///\name Basic operations
- ///\{
+ /**
+ * A file in a ERepository profile.
+ *
+ * Handles -lines, comments, inherits automatically.
+ *
+ * \ingroup grperepository
+ */
+ template <typename F_>
+ class PALUDIS_VISIBLE ProfileFile :
+ private PrivateImplementationPattern<ProfileFile<F_> >
+ {
+ public:
+ ///\name Basic operations
+ ///\{
- ProfileFile();
- ~ProfileFile();
+ ProfileFile();
+ ~ProfileFile();
- ///\}
+ ///\}
- /**
- * Add a file.
- */
- void add_file(const FSEntry &);
+ /**
+ * Add a file.
+ */
+ void add_file(const FSEntry &);
- ///\name Iterate over our profile lines.
- ///\{
+ ///\name Iterate over our profile lines.
+ ///\{
- typedef libwrapiter::ForwardIterator<ProfileFile, const std::pair<const std::string, tr1::shared_ptr<const RepositoryMaskInfo> > > Iterator;
- Iterator begin() const;
- Iterator end() const;
+ typedef libwrapiter::ForwardIterator<ProfileFile, typename F_::Iterator::value_type> Iterator;
+ Iterator begin() const;
+ Iterator end() const;
- ///\}
- };
+ ///\}
+ };
+ }
}
#endif
diff --git a/src/output/console_query_task.cc b/src/output/console_query_task.cc
index 0616722..488ec09 100644
--- a/src/output/console_query_task.cc
+++ b/src/output/console_query_task.cc
@@ -27,6 +27,7 @@
#include <paludis/util/set.hh>
#include <paludis/util/map.hh>
#include <paludis/util/map-impl.hh>
+#include <paludis/util/join.hh>
#include <libwrapiter/libwrapiter_forward_iterator.hh>
#include <libwrapiter/libwrapiter_output_iterator.hh>
#include <paludis/query.hh>
@@ -498,12 +499,19 @@ ConsoleQueryTask::display_metadata_repository_mask_info(const std::string & k, c
if (want_raw())
{
output_left_column(kk + ":");
+ output_right_column(stringify(i->mask_file) + ": " + join(i->comment->begin(), i->comment->end(), " "));
}
else
{
output_left_column(k + ":");
+ output_right_column(stringify(i->mask_file) + ":");
+ for (Sequence<std::string>::Iterator it(i->comment->begin()),
+ it_end(i->comment->end()); it_end != it; ++it)
+ {
+ output_left_column("");
+ output_right_column(*it);
+ }
}
- output_right_column(stringify(i->mask_file));
}
void