aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2009-08-27 22:21:14 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2009-08-27 22:21:14 +0100
commit61abcbce1f0ed5a91eb3046f29847a33a090c846 (patch)
treeac0a86d2cd1e9588e49364048b9f54eec813280f
parent1001f085f000b67c75e9e687546b8287beec0cdc (diff)
downloadpaludis-61abcbce1f0ed5a91eb3046f29847a33a090c846.tar.gz
paludis-61abcbce1f0ed5a91eb3046f29847a33a090c846.tar.xz
Mask rather than hide installed accounts
Fixes: ticket:744
-rw-r--r--paludis/repositories/accounts/Makefile.am2
-rw-r--r--paludis/repositories/accounts/accounts_id.cc11
-rw-r--r--paludis/repositories/accounts/accounts_id.hh2
-rw-r--r--paludis/repositories/accounts/accounts_installed_mask.cc42
-rw-r--r--paludis/repositories/accounts/accounts_installed_mask.hh40
-rw-r--r--paludis/repositories/accounts/accounts_repository_store.cc12
6 files changed, 101 insertions, 8 deletions
diff --git a/paludis/repositories/accounts/Makefile.am b/paludis/repositories/accounts/Makefile.am
index ff0bde6..9dba7f9 100644
--- a/paludis/repositories/accounts/Makefile.am
+++ b/paludis/repositories/accounts/Makefile.am
@@ -26,6 +26,7 @@ paludis_repositories_accounts_include_HEADERS = \
passwd_accounts_handler.hh \
accounts_id.hh \
accounts_dep_key.hh \
+ accounts_installed_mask.hh \
installed_accounts_id.hh
libpaludisaccountsrepository_@PALUDIS_PC_SLOT@_la_SOURCES = \
@@ -35,6 +36,7 @@ libpaludisaccountsrepository_@PALUDIS_PC_SLOT@_la_SOURCES = \
accounts_repository_store.cc \
accounts_id.cc \
accounts_dep_key.cc \
+ accounts_installed_mask.cc \
installed_accounts_id.cc \
dummy_accounts_handler.cc \
passwd_accounts_handler.cc \
diff --git a/paludis/repositories/accounts/accounts_id.cc b/paludis/repositories/accounts/accounts_id.cc
index a07f270..c31c88c 100644
--- a/paludis/repositories/accounts/accounts_id.cc
+++ b/paludis/repositories/accounts/accounts_id.cc
@@ -19,6 +19,7 @@
#include <paludis/repositories/accounts/accounts_id.hh>
#include <paludis/repositories/accounts/accounts_dep_key.hh>
+#include <paludis/repositories/accounts/accounts_installed_mask.hh>
#include <paludis/util/private_implementation_pattern-impl.hh>
#include <paludis/util/make_shared_ptr.hh>
#include <paludis/util/config_file.hh>
@@ -54,6 +55,7 @@ namespace paludis
const std::tr1::shared_ptr<const LiteralMetadataValueKey<FSEntry> > fs_location_key;
const std::tr1::shared_ptr<const MetadataCollectionKey<Set<std::string> > > from_repositories_key;
+ const std::tr1::shared_ptr<const AccountsInstalledMask> mask;
const bool is_user;
@@ -76,13 +78,14 @@ namespace paludis
Implementation(const Environment * const e,
const QualifiedPackageName & q, const std::tr1::shared_ptr<const Repository> & r,
const std::tr1::shared_ptr<const MetadataCollectionKey<Set<std::string> > > & f,
- const FSEntry & l, const bool u) :
+ const FSEntry & l, const bool u, const bool m) :
env(e),
name(q),
version("0", VersionSpecOptions()),
repository(r),
fs_location_key(new LiteralMetadataValueKey<FSEntry>("location", "Location", mkt_internal, l)),
from_repositories_key(f),
+ mask(m ? make_shared_ptr(new AccountsInstalledMask) : make_null_shared_ptr()),
is_user(u),
has_file_keys(false),
has_metadata_keys(false)
@@ -94,10 +97,12 @@ namespace paludis
AccountsID::AccountsID(const Environment * const e,
const QualifiedPackageName & q, const std::tr1::shared_ptr<const Repository> & r,
const std::tr1::shared_ptr<const MetadataCollectionKey<Set<std::string> > > & f, const FSEntry & l,
- const bool u) :
- PrivateImplementationPattern<AccountsID>(new Implementation<AccountsID>(e, q, r, f, l, u)),
+ const bool u, const bool m) :
+ PrivateImplementationPattern<AccountsID>(new Implementation<AccountsID>(e, q, r, f, l, u, m)),
_imp(PrivateImplementationPattern<AccountsID>::_imp)
{
+ if (_imp->mask)
+ add_mask(_imp->mask);
}
AccountsID::~AccountsID()
diff --git a/paludis/repositories/accounts/accounts_id.hh b/paludis/repositories/accounts/accounts_id.hh
index aaf6494..93264f3 100644
--- a/paludis/repositories/accounts/accounts_id.hh
+++ b/paludis/repositories/accounts/accounts_id.hh
@@ -49,7 +49,7 @@ namespace paludis
AccountsID(const Environment * const,
const QualifiedPackageName &, const std::tr1::shared_ptr<const Repository> &,
const std::tr1::shared_ptr<const MetadataCollectionKey<Set<std::string> > > &,
- const FSEntry &, const bool is_user);
+ const FSEntry &, const bool is_user, const bool masked);
~AccountsID();
virtual const std::string canonical_form(const PackageIDCanonicalForm) const;
diff --git a/paludis/repositories/accounts/accounts_installed_mask.cc b/paludis/repositories/accounts/accounts_installed_mask.cc
new file mode 100644
index 0000000..89d3837
--- /dev/null
+++ b/paludis/repositories/accounts/accounts_installed_mask.cc
@@ -0,0 +1,42 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2009 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
+ * 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 <paludis/repositories/accounts/accounts_installed_mask.hh>
+
+using namespace paludis;
+using namespace paludis::accounts_repository;
+
+char
+AccountsInstalledMask::key() const
+{
+ return 'I';
+}
+
+const std::string
+AccountsInstalledMask::description() const
+{
+ return "already installed";
+}
+
+const std::string
+AccountsInstalledMask::explanation() const
+{
+ return "Manipulating accounts that are already present is not supported";
+}
+
diff --git a/paludis/repositories/accounts/accounts_installed_mask.hh b/paludis/repositories/accounts/accounts_installed_mask.hh
new file mode 100644
index 0000000..1aa5e85
--- /dev/null
+++ b/paludis/repositories/accounts/accounts_installed_mask.hh
@@ -0,0 +1,40 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2009 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
+ * 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_ACCOUNTS_ACCOUNTS_INSTALLED_MASK_HH
+#define PALUDIS_GUARD_PALUDIS_REPOSITORIES_ACCOUNTS_ACCOUNTS_INSTALLED_MASK_HH 1
+
+#include <paludis/mask.hh>
+
+namespace paludis
+{
+ namespace accounts_repository
+ {
+ class AccountsInstalledMask :
+ public UnsupportedMask
+ {
+ public:
+ virtual char key() const;
+ virtual const std::string description() const;
+ virtual const std::string explanation() const;
+ };
+ }
+}
+
+#endif
diff --git a/paludis/repositories/accounts/accounts_repository_store.cc b/paludis/repositories/accounts/accounts_repository_store.cc
index 6f34a97..2fab281 100644
--- a/paludis/repositories/accounts/accounts_repository_store.cc
+++ b/paludis/repositories/accounts/accounts_repository_store.cc
@@ -186,6 +186,8 @@ AccountsRepositoryStore::_load_one_user(
QualifiedPackageName qpn(cat + pkg);
std::string username(stringify(pkg));
+ bool masked(false);
+
if (_imp->installed)
{
if (! getpwnam(username.c_str()))
@@ -194,7 +196,7 @@ AccountsRepositoryStore::_load_one_user(
else
{
if (getpwnam(username.c_str()))
- return;
+ masked = true;
}
PackageNames::iterator p(_imp->package_names.find(cat));
@@ -212,7 +214,7 @@ AccountsRepositoryStore::_load_one_user(
if (_imp->installed)
q->second->push_back(make_shared_ptr(new InstalledAccountsID(_imp->env, qpn, repo, true)));
else
- q->second->push_back(make_shared_ptr(new AccountsID(_imp->env, qpn, repo, from_repo, filename, true)));
+ q->second->push_back(make_shared_ptr(new AccountsID(_imp->env, qpn, repo, from_repo, filename, true, masked)));
}
void
@@ -240,6 +242,8 @@ AccountsRepositoryStore::_load_one_group(
QualifiedPackageName qpn(cat + pkg);
std::string groupname(stringify(pkg));
+ bool masked(false);
+
if (_imp->installed)
{
if (! getgrnam(groupname.c_str()))
@@ -248,7 +252,7 @@ AccountsRepositoryStore::_load_one_group(
else
{
if (getgrnam(groupname.c_str()))
- return;
+ masked = true;
}
PackageNames::iterator p(_imp->package_names.find(cat));
@@ -266,7 +270,7 @@ AccountsRepositoryStore::_load_one_group(
if (_imp->installed)
q->second->push_back(make_shared_ptr(new InstalledAccountsID(_imp->env, qpn, repo, false)));
else
- q->second->push_back(make_shared_ptr(new AccountsID(_imp->env, qpn, repo, from_repo, filename, false)));
+ q->second->push_back(make_shared_ptr(new AccountsID(_imp->env, qpn, repo, from_repo, filename, false, masked)));
}
bool