aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-07-06 22:13:11 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-07-06 22:13:11 +0000
commitfde7e099b854342189efdf7aa0a06e18b77254a6 (patch)
treeb1352e35f97811648b277b5bb6f32fb752b6080f
parent76a110f31951af7d9accbbb025ce6f5ef43dae42 (diff)
downloadpaludis-fde7e099b854342189efdf7aa0a06e18b77254a6.tar.gz
paludis-fde7e099b854342189efdf7aa0a06e18b77254a6.tar.xz
Make --pretend --install output for USE_EXPAND things much cleaner
-rw-r--r--paludis/fake_repository.cc13
-rw-r--r--paludis/fake_repository.hh2
-rw-r--r--paludis/portage_repository.cc41
-rw-r--r--paludis/portage_repository.hh4
-rw-r--r--paludis/repository.cc10
-rw-r--r--paludis/repository.hh37
-rw-r--r--paludis/vdb_repository.cc12
-rw-r--r--paludis/vdb_repository.hh2
-rw-r--r--src/install.cc40
9 files changed, 161 insertions, 0 deletions
diff --git a/paludis/fake_repository.cc b/paludis/fake_repository.cc
index 59d4365..208ebd9 100644
--- a/paludis/fake_repository.cc
+++ b/paludis/fake_repository.cc
@@ -229,6 +229,19 @@ FakeRepository::do_is_expand_flag(const UseFlagName &) const
return false;
}
+
+bool
+FakeRepository::do_is_expand_hidden_flag(const UseFlagName &) const
+{
+ return false;
+}
+
+std::string::size_type
+FakeRepository::do_expand_flag_delim_pos(const UseFlagName &) const
+{
+ return 0;
+}
+
bool
FakeRepository::do_is_licence(const std::string &) const
{
diff --git a/paludis/fake_repository.hh b/paludis/fake_repository.hh
index b798fe8..ce94dfa 100644
--- a/paludis/fake_repository.hh
+++ b/paludis/fake_repository.hh
@@ -78,6 +78,8 @@ namespace paludis
virtual bool do_is_arch_flag(const UseFlagName &) const;
virtual bool do_is_expand_flag(const UseFlagName &) const;
+ virtual bool do_is_expand_hidden_flag(const UseFlagName &) const;
+ virtual std::string::size_type do_expand_flag_delim_pos(const UseFlagName &) const;
virtual bool do_is_licence(const std::string &) const;
diff --git a/paludis/portage_repository.cc b/paludis/portage_repository.cc
index fd838b0..c1ac03c 100644
--- a/paludis/portage_repository.cc
+++ b/paludis/portage_repository.cc
@@ -205,6 +205,9 @@ namespace paludis
/// Expand flags
mutable UseFlagSet expand_list;
+ /// Expand hidden flags
+ mutable UseFlagSet expand_hidden_list;
+
/// Do we have arch_list?
mutable bool has_arch_list;
@@ -372,6 +375,10 @@ Implementation<PortageRepository>::add_profile_r(const FSEntry & f) const
make_defaults_f.get("USE_EXPAND"), create_inserter<UseFlagName>(
std::inserter(expand_list, expand_list.begin())));
+ WhitespaceTokeniser::get_instance()->tokenise(
+ make_defaults_f.get("USE_EXPAND_HIDDEN"), create_inserter<UseFlagName>(
+ std::inserter(expand_hidden_list, expand_hidden_list.begin())));
+
for (KeyValueConfigFile::Iterator k(make_defaults_f.begin()),
k_end(make_defaults_f.end()) ; k != k_end ; ++k)
profile_env[k->first] = k->second;
@@ -536,6 +543,7 @@ Implementation<PortageRepository>::invalidate() const
has_profile = false;
arch_list.clear();
expand_list.clear();
+ expand_hidden_list.clear();
has_arch_list = false;
has_mirrors = false;
mirrors.clear();
@@ -1309,6 +1317,39 @@ PortageRepository::do_is_expand_flag(const UseFlagName & u) const
}
bool
+PortageRepository::do_is_expand_hidden_flag(const UseFlagName & u) const
+{
+ _imp->need_profiles();
+
+ for (UseFlagSet::const_iterator i(_imp->expand_hidden_list.begin()),
+ i_end(_imp->expand_hidden_list.end()) ; i != i_end ; ++i)
+ if (0 == strncasecmp(
+ stringify(u).c_str(),
+ (stringify(*i) + "_").c_str(),
+ stringify(*i).length() + 1))
+ return true;
+
+ return false;
+}
+
+std::string::size_type
+PortageRepository::do_expand_flag_delim_pos(const UseFlagName & u) const
+{
+ _imp->need_profiles();
+
+ for (UseFlagSet::const_iterator i(_imp->expand_list.begin()),
+ i_end(_imp->expand_list.end()) ; i != i_end ; ++i)
+ if (0 == strncasecmp(
+ stringify(u).c_str(),
+ (stringify(*i) + "_").c_str(),
+ stringify(*i).length() + 1))
+ return stringify(*i).length();
+
+ throw InternalError(PALUDIS_HERE, "Use flag '" +
+ stringify(u) + "' not an expand flag?");
+}
+
+bool
PortageRepository::do_is_licence(const std::string & s) const
{
FSEntry l(_imp->location);
diff --git a/paludis/portage_repository.hh b/paludis/portage_repository.hh
index 63d4544..c3d4941 100644
--- a/paludis/portage_repository.hh
+++ b/paludis/portage_repository.hh
@@ -161,6 +161,10 @@ namespace paludis
virtual bool do_is_expand_flag(const UseFlagName &) const;
+ virtual bool do_is_expand_hidden_flag(const UseFlagName &) const;
+
+ virtual std::string::size_type do_expand_flag_delim_pos(const UseFlagName &) const;
+
virtual bool do_is_licence(const std::string &) const;
virtual bool do_is_mirror(const std::string &) const;
diff --git a/paludis/repository.cc b/paludis/repository.cc
index 284249e..abd8e66 100644
--- a/paludis/repository.cc
+++ b/paludis/repository.cc
@@ -18,6 +18,7 @@
*/
#include <paludis/repository.hh>
+#include <ctype.h>
/** \file
* Implementation of Repository.
@@ -101,3 +102,12 @@ Repository::info(bool) const
return _info;
}
+UseFlagName
+Repository::UseInterface::expand_flag_name(const UseFlagName & u) const
+{
+ std::string upper_u;
+ std::transform(u.data().begin(), u.data().end(), std::back_inserter(upper_u),
+ &::toupper);
+ return UseFlagName(upper_u.substr(0, do_expand_flag_delim_pos(u)));
+}
+
diff --git a/paludis/repository.hh b/paludis/repository.hh
index f418405..34cc951 100644
--- a/paludis/repository.hh
+++ b/paludis/repository.hh
@@ -535,6 +535,19 @@ namespace paludis
*/
virtual bool do_is_expand_flag(const UseFlagName &) const = 0;
+ /**
+ * Override in descendents: is this an expand flag that should be
+ * ignored?
+ */
+ virtual bool do_is_expand_hidden_flag(const UseFlagName &) const = 0;
+
+ /**
+ * Override in descendents: for a UseFlagName where is_expand_flag
+ * is true, return the position of the delimiting underscore that
+ * splits name and value.
+ */
+ virtual std::string::size_type do_expand_flag_delim_pos(const UseFlagName &) const = 0;
+
public:
/**
* Query the state of the specified use flag.
@@ -581,6 +594,30 @@ namespace paludis
return do_is_expand_flag(u);
}
+ /**
+ * Query whether the specified use flag is an expand flag that
+ * is ignored in visible output.
+ */
+ bool is_expand_hidden_flag(const UseFlagName & u) const
+ {
+ return do_is_expand_hidden_flag(u);
+ }
+
+ /**
+ * Fetch the expand flag name for a given use flag where
+ * is_expand_flag returns true.
+ */
+ UseFlagName expand_flag_name(const UseFlagName & u) const;
+
+ /**
+ * Fetch the expand flag value for a given use flag where
+ * is_expand_flag returns true.
+ */
+ UseFlagName expand_flag_value(const UseFlagName & u) const
+ {
+ return UseFlagName(stringify(u).substr(do_expand_flag_delim_pos(u) + 1));
+ }
+
virtual ~UseInterface() { }
};
diff --git a/paludis/vdb_repository.cc b/paludis/vdb_repository.cc
index 396d5d1..833f220 100644
--- a/paludis/vdb_repository.cc
+++ b/paludis/vdb_repository.cc
@@ -728,6 +728,18 @@ VDBRepository::do_is_expand_flag(const UseFlagName &) const
}
bool
+VDBRepository::do_is_expand_hidden_flag(const UseFlagName &) const
+{
+ return false;
+}
+
+std::string::size_type
+VDBRepository::do_expand_flag_delim_pos(const UseFlagName &) const
+{
+ return 0;
+}
+
+bool
VDBRepository::do_is_licence(const std::string &) const
{
return false;
diff --git a/paludis/vdb_repository.hh b/paludis/vdb_repository.hh
index 8980204..4600bbb 100644
--- a/paludis/vdb_repository.hh
+++ b/paludis/vdb_repository.hh
@@ -127,6 +127,8 @@ namespace paludis
virtual bool do_is_arch_flag(const UseFlagName &) const;
virtual bool do_is_expand_flag(const UseFlagName &) const;
+ virtual bool do_is_expand_hidden_flag(const UseFlagName &) const;
+ virtual std::string::size_type do_expand_flag_delim_pos(const UseFlagName &) const;
virtual bool do_is_licence(const std::string &) const;
diff --git a/src/install.cc b/src/install.cc
index 17942be..08eb6c4 100644
--- a/src/install.cc
+++ b/src/install.cc
@@ -256,9 +256,15 @@ do_install()
p::WhitespaceTokeniser::get_instance()->tokenise(
dep->get<p::dle_metadata>()->get_ebuild_interface()->get<p::evm_iuse>(),
p::create_inserter<p::UseFlagName>(std::inserter(iuse, iuse.end())));
+
+
+ /* display normal use flags first */
for (std::set<p::UseFlagName>::const_iterator i(iuse.begin()), i_end(iuse.end()) ;
i != i_end ; ++i)
{
+ if (use_interface->is_expand_flag(*i))
+ continue;
+
if (env->query_use(*i, &p))
{
if (use_interface && use_interface->query_use_force(*i, &p))
@@ -274,6 +280,40 @@ do_install()
cout << " " << colour(cl_flag_off, "-" + p::stringify(*i));
}
}
+
+ /* now display expand flags */
+ p::UseFlagName old_expand_name("OFTEN_NOT_BEEN_ON_BOATS");
+ for (std::set<p::UseFlagName>::const_iterator i(iuse.begin()), i_end(iuse.end()) ;
+ i != i_end ; ++i)
+ {
+ if ((! use_interface->is_expand_flag(*i)) ||
+ (use_interface->is_expand_hidden_flag(*i)))
+ continue;
+
+ p::UseFlagName expand_name(use_interface->expand_flag_name(*i)),
+ expand_value(use_interface->expand_flag_value(*i));
+
+ if (expand_name != old_expand_name)
+ {
+ cout << " " << expand_name << ":";
+ old_expand_name = expand_name;
+ }
+
+ if (env->query_use(*i, &p))
+ {
+ if (use_interface && use_interface->query_use_force(*i, &p))
+ cout << " " << colour(cl_flag_on, "(" + p::stringify(expand_value) + ")");
+ else
+ cout << " " << colour(cl_flag_on, expand_value);
+ }
+ else
+ {
+ if (use_interface && use_interface->query_use_mask(*i, &p))
+ cout << " " << colour(cl_flag_off, "(-" + p::stringify(expand_value) + ")");
+ else
+ cout << " " << colour(cl_flag_off, "-" + p::stringify(expand_value));
+ }
+ }
}
/* display tag, add tag to our post display list */