aboutsummaryrefslogtreecommitdiff
path: root/paludis
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-04-06 09:55:00 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-04-06 09:55:00 +0000
commitf724e50fda7c74babe105a5d45de4cc0a072978b (patch)
tree9fd7d3d41aa3183951c890884f975e3bc97799bc /paludis
parent2c46b4449c7bbef5be5c75a4ca1e67aa8e31783a (diff)
downloadpaludis-f724e50fda7c74babe105a5d45de4cc0a072978b.tar.gz
paludis-f724e50fda7c74babe105a5d45de4cc0a072978b.tar.xz
Initial uninstall support
Diffstat (limited to 'paludis')
-rw-r--r--paludis/fake_repository.cc5
-rw-r--r--paludis/fake_repository.hh2
-rw-r--r--paludis/portage_repository.cc36
-rw-r--r--paludis/portage_repository.hh2
-rw-r--r--paludis/repository.hh13
-rw-r--r--paludis/util/log.cc24
-rw-r--r--paludis/util/log.hh5
-rw-r--r--paludis/vdb_repository.cc72
-rw-r--r--paludis/vdb_repository.hh5
9 files changed, 128 insertions, 36 deletions
diff --git a/paludis/fake_repository.cc b/paludis/fake_repository.cc
index f1749e6..03d8edc 100644
--- a/paludis/fake_repository.cc
+++ b/paludis/fake_repository.cc
@@ -216,6 +216,11 @@ FakeRepository::do_install(const QualifiedPackageName &, const VersionSpec &) co
{
}
+void
+FakeRepository::do_uninstall(const QualifiedPackageName &, const VersionSpec &) const
+{
+}
+
DepAtom::Pointer
FakeRepository::do_system_packages() const
{
diff --git a/paludis/fake_repository.hh b/paludis/fake_repository.hh
index 47e95ea..edc3cef 100644
--- a/paludis/fake_repository.hh
+++ b/paludis/fake_repository.hh
@@ -81,6 +81,8 @@ namespace paludis
virtual void do_install(const QualifiedPackageName &, const VersionSpec &) const;
+ virtual void do_uninstall(const QualifiedPackageName &, const VersionSpec &) const;
+
virtual DepAtom::Pointer do_system_packages() const;
virtual bool do_sync() const;
diff --git a/paludis/portage_repository.cc b/paludis/portage_repository.cc
index 7b775e4..16c25b5 100644
--- a/paludis/portage_repository.cc
+++ b/paludis/portage_repository.cc
@@ -632,33 +632,6 @@ PortageRepository::fetch_repo_name(const std::string & location)
return RepositoryName("x-" + modified_location);
}
-namespace
-{
- std::string
- log_level_string()
- {
- switch (Log::get_instance()->log_level())
- {
- case ll_qa:
- return "qa";
-
- case ll_warning:
- return "warning";
-
- case ll_debug:
- return "debug";
-
- case ll_silent:
- return "silent";
-
- case last_ll:
- ;
- };
-
- throw InternalError(PALUDIS_HERE, "Bad log level");
- }
-}
-
VersionMetadata::ConstPointer
PortageRepository::do_version_metadata(
const CategoryNamePart & c, const PackageNamePart & p, const VersionSpec & v) const
@@ -759,7 +732,7 @@ PortageRepository::do_version_metadata(
("PALUDIS_BASHRC_FILES", _imp->env->bashrc_files())
("PALUDIS_COMMAND", _imp->env->paludis_command())
("KV", kernel_version())
- ("PALUDIS_EBUILD_LOG_LEVEL", log_level_string())
+ ("PALUDIS_EBUILD_LOG_LEVEL", Log::get_instance()->log_level_string())
("PALUDIS_EBUILD_DIR", getenv_with_default("PALUDIS_EBUILD_DIR", LIBEXECDIR "/paludis")));
@@ -1188,7 +1161,7 @@ PortageRepository::do_install(const QualifiedPackageName & q, const VersionSpec
("PALUDIS_BASHRC_FILES", _imp->env->bashrc_files())
("PALUDIS_COMMAND", _imp->env->paludis_command())
("KV", kernel_version())
- ("PALUDIS_EBUILD_LOG_LEVEL", log_level_string())
+ ("PALUDIS_EBUILD_LOG_LEVEL", Log::get_instance()->log_level_string())
("PALUDIS_EBUILD_DIR", getenv_with_default("PALUDIS_EBUILD_DIR", LIBEXECDIR "/paludis")));
if (0 != run_command(cmd))
@@ -1226,3 +1199,8 @@ PortageRepository::do_sync() const
return true;
}
+void
+PortageRepository::do_uninstall(const QualifiedPackageName &, const VersionSpec &) const
+{
+ throw InternalError(PALUDIS_HERE, "TODO: PortageRepository doesn't support do_uninstall");
+}
diff --git a/paludis/portage_repository.hh b/paludis/portage_repository.hh
index 2eb96a4..448b7eb 100644
--- a/paludis/portage_repository.hh
+++ b/paludis/portage_repository.hh
@@ -92,6 +92,8 @@ namespace paludis
virtual void do_install(const QualifiedPackageName &, const VersionSpec &) const;
+ virtual void do_uninstall(const QualifiedPackageName &, const VersionSpec &) const;
+
virtual DepAtom::Pointer do_system_packages() const;
virtual bool do_sync() const;
diff --git a/paludis/repository.hh b/paludis/repository.hh
index 7fa40ec..8cf5ada 100644
--- a/paludis/repository.hh
+++ b/paludis/repository.hh
@@ -154,6 +154,11 @@ namespace paludis
virtual void do_install(const QualifiedPackageName &, const VersionSpec &) const = 0;
/**
+ * Override in descendents: uninstall.
+ */
+ virtual void do_uninstall(const QualifiedPackageName &, const VersionSpec &) const = 0;
+
+ /**
* Override in descendents: system package list.
*/
virtual DepAtom::Pointer do_system_packages() const = 0;
@@ -387,6 +392,14 @@ namespace paludis
}
/**
+ * Uninstall a package.
+ */
+ void uninstall(const QualifiedPackageName & q, const VersionSpec & v) const
+ {
+ do_uninstall(q, v);
+ }
+
+ /**
* Return whether we are an 'installed' repo.
*
* No NVI indirection here, it's not worth it.
diff --git a/paludis/util/log.cc b/paludis/util/log.cc
index 2cdedc2..d867b01 100644
--- a/paludis/util/log.cc
+++ b/paludis/util/log.cc
@@ -103,3 +103,27 @@ Log::set_log_stream(std::ostream * const s)
{
_imp->stream = s;
}
+
+std::string
+Log::log_level_string() const
+{
+ switch (Log::get_instance()->log_level())
+ {
+ case ll_qa:
+ return "qa";
+
+ case ll_warning:
+ return "warning";
+
+ case ll_debug:
+ return "debug";
+
+ case ll_silent:
+ return "silent";
+
+ case last_ll:
+ ;
+ };
+
+ throw InternalError(PALUDIS_HERE, "Bad log level");
+}
diff --git a/paludis/util/log.hh b/paludis/util/log.hh
index 2386822..5784e64 100644
--- a/paludis/util/log.hh
+++ b/paludis/util/log.hh
@@ -83,6 +83,11 @@ namespace paludis
* Change the log stream.
*/
void set_log_stream(std::ostream * const);
+
+ /**
+ * Log level, as a string.
+ */
+ std::string log_level_string() const;
};
}
diff --git a/paludis/vdb_repository.cc b/paludis/vdb_repository.cc
index 107c719..75f9a2c 100644
--- a/paludis/vdb_repository.cc
+++ b/paludis/vdb_repository.cc
@@ -141,6 +141,9 @@ namespace paludis
/// Our base location.
FSEntry location;
+ /// Root location
+ FSEntry root;
+
/// Do we have entries loaded?
mutable bool entries_valid;
@@ -155,7 +158,8 @@ namespace paludis
/// Constructor.
Implementation(const Environment * const,
- const PackageDatabase * const d, const FSEntry & l);
+ const PackageDatabase * const d, const FSEntry & l,
+ const FSEntry & r);
/// Destructor.
~Implementation();
@@ -164,10 +168,11 @@ namespace paludis
Implementation<VDBRepository>::Implementation(const Environment * const env,
const PackageDatabase * const d,
- const FSEntry & l) :
+ const FSEntry & l, const FSEntry & r) :
db(d),
env(env),
location(l),
+ root(r),
entries_valid(false)
{
}
@@ -245,12 +250,13 @@ Implementation<VDBRepository>::load_entry(std::vector<VDBEntry>::iterator p) con
VDBRepository::VDBRepository(
const Environment * const e, const PackageDatabase * const d,
- const FSEntry & location) :
+ const FSEntry & location, const FSEntry & root) :
Repository(RepositoryName("installed")),
PrivateImplementationPattern<VDBRepository>(new Implementation<VDBRepository>(e,
- d, location))
+ d, location, root))
{
_info.insert(std::make_pair(std::string("location"), location));
+ _info.insert(std::make_pair(std::string("root"), root));
_info.insert(std::make_pair(std::string("format"), std::string("vdb")));
}
@@ -422,7 +428,11 @@ VDBRepository::make_vdb_repository(
if (m.end() == m.find("location") || ((location = m.find("location")->second)).empty())
throw VDBRepositoryConfigurationError("Key 'location' not specified or empty");
- return CountedPtr<Repository>(new VDBRepository(env, db, location));
+ std::string root;
+ if (m.end() == m.find("root") || ((root = m.find("root")->second)).empty())
+ root = "/";
+
+ return CountedPtr<Repository>(new VDBRepository(env, db, location, root));
}
VDBRepositoryConfigurationError::VDBRepositoryConfigurationError(
@@ -458,7 +468,57 @@ VDBRepository::do_is_mirror(const std::string &) const
void
VDBRepository::do_install(const QualifiedPackageName &, const VersionSpec &) const
{
- throw InternalError(PALUDIS_HERE, "TODO");
+ throw InternalError(PALUDIS_HERE, "TODO: VDBRepository doesn't support do_install");
+}
+
+void
+VDBRepository::do_uninstall(const QualifiedPackageName & q, const VersionSpec & v) const
+{
+ if (! _imp->root.is_directory())
+ throw InternalError(PALUDIS_HERE, "todo: root not a directory");
+
+ VersionMetadata::ConstPointer metadata(0);
+ if (! has_version(q, v))
+ throw InternalError(PALUDIS_HERE, "Can't install '" + stringify(q) + "-"
+ + stringify(v) + "' since has_version failed"); /// \todo fixme
+ else
+ metadata = version_metadata(q, v);
+
+ PackageDatabaseEntry e(q, v, name());
+ std::string actions;
+ if (metadata->get(vmk_virtual).empty())
+ actions = "prerm unmerge postrm";
+ else
+ actions = "unmerge";
+
+ std::string cmd(make_env_command(
+ getenv_with_default("PALUDIS_EBUILD_DIR", LIBEXECDIR "/paludis") +
+ "/ebuild.bash '" +
+ stringify(_imp->location) + "/" +
+ stringify(q.get<qpn_category>()) + "/" +
+ stringify(q.get<qpn_package>()) + "-" + stringify(v) + "/" +
+ stringify(q.get<qpn_package>()) + "-" + stringify(v) + ".ebuild' " + actions)
+ ("P", stringify(q.get<qpn_package>()) + "-" + stringify(v.remove_revision()))
+ ("PV", stringify(v.remove_revision()))
+ ("PR", v.revision_only())
+ ("PN", stringify(q.get<qpn_package>()))
+ ("PVR", stringify(v.remove_revision()) + "-" + v.revision_only())
+ ("PF", stringify(q.get<qpn_package>()) + "-" + stringify(v))
+ ("CATEGORY", stringify(q.get<qpn_category>()))
+ ("ECLASSDIR", stringify(_imp->location) + "/" +
+ stringify(q.get<qpn_category>()) + "/" +
+ stringify(q.get<qpn_package>()) + "-" + stringify(v) + "/")
+ ("ROOT", stringify(_imp->root) + "/")
+ ("PALUDIS_TMPDIR", BIGTEMPDIR "/paludis/")
+ ("PALUDIS_CONFIG_DIR", SYSCONFDIR "/paludis/")
+ ("PALUDIS_BASHRC_FILES", _imp->env->bashrc_files())
+ ("PALUDIS_COMMAND", _imp->env->paludis_command())
+ ("KV", kernel_version())
+ ("PALUDIS_EBUILD_LOG_LEVEL", Log::get_instance()->log_level_string())
+ ("PALUDIS_EBUILD_DIR", getenv_with_default("PALUDIS_EBUILD_DIR", LIBEXECDIR "/paludis")));
+
+ if (0 != run_command(cmd))
+ throw InternalError(PALUDIS_HERE, "todo"); /// \todo fixme
}
DepAtom::Pointer
diff --git a/paludis/vdb_repository.hh b/paludis/vdb_repository.hh
index d05be0a..8570d05 100644
--- a/paludis/vdb_repository.hh
+++ b/paludis/vdb_repository.hh
@@ -72,6 +72,8 @@ namespace paludis
virtual void do_install(const QualifiedPackageName &,
const VersionSpec &) const PALUDIS_ATTRIBUTE((noreturn));
+ virtual void do_uninstall(const QualifiedPackageName &, const VersionSpec &) const;
+
virtual DepAtom::Pointer do_system_packages() const;
virtual bool do_sync() const;
@@ -82,7 +84,8 @@ namespace paludis
*/
VDBRepository(const Environment * const env,
const PackageDatabase * const db,
- const FSEntry & location);
+ const FSEntry & location,
+ const FSEntry & root);
/**
* Virtual constructor.