aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-10-11 19:39:35 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-10-11 19:39:35 +0000
commit353f8a5fd0414a4026e9584e158f02f8120f8b32 (patch)
treef4c208eb677ce44719689330212c5c1df13e19a6
parent89eb9efed2ba392eb08dabab9aaa8a8c18d0393d (diff)
downloadpaludis-353f8a5fd0414a4026e9584e158f02f8120f8b32.tar.gz
paludis-353f8a5fd0414a4026e9584e158f02f8120f8b32.tar.xz
Implement --dl-reinstall if-use-changed. Show USE flag changes visually.
-rw-r--r--paludis/dep_list.cc23
-rw-r--r--src/paludis/command_line.cc5
-rw-r--r--src/paludis/install.cc5
-rw-r--r--src/paludis/use.cc10
-rw-r--r--src/paludis/use.hh3
5 files changed, 40 insertions, 6 deletions
diff --git a/paludis/dep_list.cc b/paludis/dep_list.cc
index 8b0c6ab..37a32f7 100644
--- a/paludis/dep_list.cc
+++ b/paludis/dep_list.cc
@@ -27,6 +27,7 @@
#include <paludis/util/log.hh>
#include <paludis/util/save.hh>
#include <paludis/util/stringify.hh>
+#include <paludis/util/tokeniser.hh>
#include <algorithm>
#include <functional>
@@ -783,7 +784,27 @@ DepList::prefer_installed_over_uninstalled(const PackageDatabaseEntry & installe
if (uninstalled.version != installed.version)
return false;
- /* todo: check dl_reinstall_if_use_changed */
+ if (dl_reinstall_if_use_changed == _imp->opts.reinstall)
+ {
+ const EbuildVersionMetadata * const evm_i(_imp->env->package_database()->fetch_repository(
+ installed.repository)->version_metadata(installed.name, installed.version)->get_ebuild_interface());
+ const EbuildVersionMetadata * const evm_u(_imp->env->package_database()->fetch_repository(
+ uninstalled.repository)->version_metadata(uninstalled.name, uninstalled.version)->get_ebuild_interface());
+
+ std::set<std::string> use_i, use_u, use_common;
+ if (evm_i)
+ WhitespaceTokeniser::get_instance()->tokenise(evm_i->iuse, std::inserter(use_i, use_i.end()));
+ if (evm_u)
+ WhitespaceTokeniser::get_instance()->tokenise(evm_u->iuse, std::inserter(use_u, use_u.end()));
+
+ std::set_intersection(use_i.begin(), use_i.end(), use_u.begin(), use_u.end(),
+ std::inserter(use_common, use_common.end()));
+
+ for (std::set<std::string>::const_iterator f(use_common.begin()), f_end(use_common.end()) ;
+ f != f_end ; ++f)
+ if (_imp->env->query_use(UseFlagName(*f), &installed) != _imp->env->query_use(UseFlagName(*f), &uninstalled))
+ return false;
+ }
return true;
}
diff --git a/src/paludis/command_line.cc b/src/paludis/command_line.cc
index de63493..a3b10c0 100644
--- a/src/paludis/command_line.cc
+++ b/src/paludis/command_line.cc
@@ -89,8 +89,9 @@ CommandLine::CommandLine() :
dl_reinstall(&dl_args, "dl-reinstall", '\0', "When to reinstall packages",
paludis::args::EnumArg::EnumArgOptions
- ("never", "Never")
- ("always", "Always"),
+ ("never", "Never")
+ ("always", "Always")
+ ("if-use-changed", "If USE flags have changed"),
"never"),
dl_upgrade(&dl_args, "dl-upgrade", '\0', "When to upgrade packages",
paludis::args::EnumArg::EnumArgOptions
diff --git a/src/paludis/install.cc b/src/paludis/install.cc
index 6db94f5..5de8260 100644
--- a/src/paludis/install.cc
+++ b/src/paludis/install.cc
@@ -503,7 +503,8 @@ namespace
/* display USE flags */
if (! d.already_installed)
- std::cout << make_pretty_use_flags_string(DefaultEnvironment::get_instance(), p, d.metadata);
+ std::cout << make_pretty_use_flags_string(DefaultEnvironment::get_instance(), p, d.metadata,
+ (existing->empty() ? 0 : &*existing->last()));
/* display tag, add tag to our post display list */
if (! d.tags->empty())
@@ -666,6 +667,8 @@ do_install()
options.reinstall = dl_reinstall_never;
else if (CommandLine::get_instance()->dl_reinstall.argument() == "always")
options.reinstall = dl_reinstall_always;
+ else if (CommandLine::get_instance()->dl_reinstall.argument() == "if-use-changed")
+ options.reinstall = dl_reinstall_if_use_changed;
else
throw DoHelp("bad value for --dl-reinstall");
}
diff --git a/src/paludis/use.cc b/src/paludis/use.cc
index 3e41179..f598e48 100644
--- a/src/paludis/use.cc
+++ b/src/paludis/use.cc
@@ -39,7 +39,7 @@ namespace
std::string
make_pretty_use_flags_string(const Environment * const env, const PackageDatabaseEntry & p,
- VersionMetadata::ConstPointer metadata)
+ VersionMetadata::ConstPointer metadata, const PackageDatabaseEntry * const other_p)
{
std::ostringstream c;
@@ -74,6 +74,10 @@ make_pretty_use_flags_string(const Environment * const env, const PackageDatabas
else
c << " " << colour(cl_flag_off, "-" + stringify(*i));
}
+
+ if (other_p)
+ if (env->query_use(*i, &p) != env->query_use(*i, other_p))
+ c << "*";
}
/* now display expand flags */
@@ -109,6 +113,10 @@ make_pretty_use_flags_string(const Environment * const env, const PackageDatabas
else
c << " " << colour(cl_flag_off, "-" + stringify(expand_value));
}
+
+ if (other_p)
+ if (env->query_use(*i, &p) != env->query_use(*i, other_p))
+ c << "*";
}
}
diff --git a/src/paludis/use.hh b/src/paludis/use.hh
index fcd19cf..ed7e846 100644
--- a/src/paludis/use.hh
+++ b/src/paludis/use.hh
@@ -30,6 +30,7 @@
*/
std::string
make_pretty_use_flags_string(const paludis::Environment * const env, const paludis::PackageDatabaseEntry & p,
- paludis::VersionMetadata::ConstPointer metadata) PALUDIS_ATTRIBUTE((nonnull(1)));
+ paludis::VersionMetadata::ConstPointer metadata, const paludis::PackageDatabaseEntry * const other_p = 0)
+ PALUDIS_ATTRIBUTE((nonnull(1)));
#endif