aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-05-15 15:01:40 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-05-15 15:01:40 +0100
commit2c52f6407e676802fd936072ec650487ca366221 (patch)
tree5d246972d435d21283109402b4e716e90ee483c5
parentf28437f74b29a7a382be8c78983950f5b821e4aa (diff)
downloadpaludis-2c52f6407e676802fd936072ec650487ca366221.tar.gz
paludis-2c52f6407e676802fd936072ec650487ca366221.tar.xz
Don't remove used packages
-rw-r--r--paludis/uninstall_list.cc24
-rw-r--r--paludis/uninstall_list.hh4
2 files changed, 25 insertions, 3 deletions
diff --git a/paludis/uninstall_list.cc b/paludis/uninstall_list.cc
index 16c4bee..d8c87a8 100644
--- a/paludis/uninstall_list.cc
+++ b/paludis/uninstall_list.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2006, 2007, 2008, 2009 Ciaran McCreesh
+ * Copyright (c) 2006, 2007, 2008, 2009, 2010 Ciaran McCreesh
*
* 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
@@ -207,13 +207,14 @@ UninstallList::add_unused()
Context context("When finding unused packages:");
std::tr1::shared_ptr<const PackageIDSet> world(collect_world()),
- everything(collect_all_installed());
+ everything(collect_all_installed()), used(collect_used());
std::tr1::shared_ptr<PackageIDSet>
world_plus_deps(new PackageIDSet),
unused(new PackageIDSet);
std::copy(world->begin(), world->end(), world_plus_deps->inserter());
+ std::copy(used->begin(), used->end(), world_plus_deps->inserter());
std::size_t old_size(0);
while (old_size != world_plus_deps->size())
@@ -558,6 +559,25 @@ UninstallList::collect_world() const
return result;
}
+std::tr1::shared_ptr<const PackageIDSet>
+UninstallList::collect_used() const
+{
+ Context local_context("When collecting used packages:");
+
+ std::tr1::shared_ptr<PackageIDSet> result(new PackageIDSet);
+ std::tr1::shared_ptr<const PackageIDSet> everything(collect_all_installed());
+
+ for (PackageIDSet::ConstIterator i(everything->begin()),
+ i_end(everything->end()) ; i != i_end ; ++i)
+ {
+ if ((*i)->behaviours_key() && (*i)->behaviours_key()->value()->end() !=
+ (*i)->behaviours_key()->value()->find("used"))
+ result->insert(*i);
+ }
+
+ return result;
+}
+
namespace
{
struct IsError
diff --git a/paludis/uninstall_list.hh b/paludis/uninstall_list.hh
index 0f993ee..fd746ac 100644
--- a/paludis/uninstall_list.hh
+++ b/paludis/uninstall_list.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2006, 2007, 2008, 2009 Ciaran McCreesh
+ * Copyright (c) 2006, 2007, 2008, 2009, 2010 Ciaran McCreesh
*
* 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
@@ -107,6 +107,8 @@ namespace paludis
std::tr1::shared_ptr<const PackageIDSet> collect_world() const;
+ std::tr1::shared_ptr<const PackageIDSet> collect_used() const;
+
public:
///\name Basic operations
///\{