aboutsummaryrefslogtreecommitdiff
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
parent2c46b4449c7bbef5be5c75a4ca1e67aa8e31783a (diff)
downloadpaludis-f724e50fda7c74babe105a5d45de4cc0a072978b.tar.gz
paludis-f724e50fda7c74babe105a5d45de4cc0a072978b.tar.xz
Initial uninstall support
-rw-r--r--ebuild/Makefile.am1
-rw-r--r--ebuild/builtin_merge.bash7
-rw-r--r--ebuild/builtin_unmerge.bash122
-rwxr-xr-xebuild/ebuild.bash35
-rw-r--r--ebuild/pkg_postrm.bash15
-rw-r--r--ebuild/pkg_prerm.bash14
-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
-rw-r--r--src/Makefile.am1
-rw-r--r--src/command_line.cc9
-rw-r--r--src/command_line.hh5
-rw-r--r--src/paludis.cc10
-rw-r--r--src/uninstall.hh33
20 files changed, 360 insertions, 56 deletions
diff --git a/ebuild/Makefile.am b/ebuild/Makefile.am
index b03ae2b..423ca71 100644
--- a/ebuild/Makefile.am
+++ b/ebuild/Makefile.am
@@ -26,6 +26,7 @@ libexecprog_SCRIPTS = \
src_compile.bash \
builtin_fetch.bash \
builtin_merge.bash \
+ builtin_unmerge.bash \
builtin_tidyup.bash \
builtin_strip.bash \
src_install.bash \
diff --git a/ebuild/builtin_merge.bash b/ebuild/builtin_merge.bash
index f7751c7..19104fd 100644
--- a/ebuild/builtin_merge.bash
+++ b/ebuild/builtin_merge.bash
@@ -54,9 +54,14 @@ builtin_merge()
done
[[ -f "${EBUILD}" ]] && cp "${EBUILD}" ${dbdir}/
+ local x
+ for i in ${INHERITED} ; do
+ cp "${ECLASSDIR}/${i}".eclass "${dbdir}/" || die "save eclass ${i} failed"
+ done
+
env | bzip2 > ${dbdir}/environment.bz2
- touch ${dbdir}/CONTENTS || die "pkg db write CONTENTS failed"
+ > ${dbdir}/CONTENTS || die "pkg db write CONTENTS failed"
if [[ -n "${D}" ]] && [[ -d "${D}" ]] ; then
local f ff
find "${D}/" | \
diff --git a/ebuild/builtin_unmerge.bash b/ebuild/builtin_unmerge.bash
new file mode 100644
index 0000000..5d2ffa4
--- /dev/null
+++ b/ebuild/builtin_unmerge.bash
@@ -0,0 +1,122 @@
+#!/bin/bash
+# vim: set sw=4 sts=4 et :
+
+# Copyright (c) 2006 Ciaran McCreesh <ciaranm@gentoo.org>
+#
+# 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 as published by the Free Software Foundation; either version
+# 2 of the License, or (at your option) any later version.
+#
+# 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
+
+builtin_unmerge()
+{
+ local dbdir="${ROOT}"/var/db/pkg/"${CATEGORY}/${PF}" entry
+ [[ -d "${dbdir}" ]] || die "couldn't find pkg db directory (\"${dbdir}\")"
+
+ for v in CATEGORY CBUILD CFLAGS CHOST CXXFLAGS DEPEND DESCRIPTION EAPI \
+ FEATURES HOMEPAGE INHERITED IUSE KEYWORDS LICENSE PDEPEND PF \
+ PROVIDE RDEPEND SLOT SRC_URI USE ; do
+ eval "${v}='$(< ${dbdir}/${v} )' || die \"Load key ${v} failed\""
+ done
+
+ sort -r -t ' ' -k 2 < "${dbdir}/CONTENTS" | \
+ while read entry ; do
+ local items=( ${entry} )
+ case ${items[0]} in
+ dir)
+ ;;
+
+ sym)
+ if ! [[ -L "${ROOT}/${items[1]}" ]] ; then
+ echo "skip !type ${items[1]}"
+ elif [[ $(readlink "${ROOT}/${items[1]}" ) != "${items[3]}" ]] ; then
+ echo "skip !dest ${items[1]}"
+ elif [[ $(stat -c '%Y' "${ROOT}/${items[1]}" ) != "${items[4]}" ]] ; then
+ echo "skip !time ${items[1]}"
+ else
+ echo "remove ${items[1]}"
+ rm -f "${ROOT}/${items[1]}"
+ fi
+ ;;
+
+ obj)
+ if ! [[ -f "${ROOT}/${items[1]}" ]] ; then
+ echo "skip !type ${items[1]}"
+ elif [[ $(md5sum "${ROOT}/${items[1]}" | cut -d' ' -f1 ) != "${items[2]}" ]] ; then
+ echo "skip !md5 ${items[1]}"
+ elif [[ $(stat -c '%Y' "${ROOT}/${items[1]}" ) != "${items[3]}" ]] ; then
+ echo "skip !time ${items[1]}"
+ else
+ echo "remove ${items[1]}"
+ rm -f "${ROOT}/${items[1]}"
+ fi
+ ;;
+
+ misc)
+ if [[ -f "${ROOT}/${items[1]}" ]] ; then
+ echo "skip !type ${items[1]}"
+ elif [[ $(stat -c '%Y' "${ROOT}/${items[1]}" ) != "${items[2]}" ]] ; then
+ echo "skip !time ${items[1]}"
+ else
+ echo "remove ${items[1]}"
+ rm -f "${ROOT}/${items[1]}"
+ fi
+ ;;
+
+ *)
+ die "Unknown VDB entry kind '${kind}'"
+ ;;
+ esac
+ done
+
+ shopt -q dotglob
+ local olddotglob=$?
+ shopt -s dotglob
+
+ sort -r -t ' ' -k 2 < "${dbdir}/CONTENTS" | \
+ while read entry ; do
+ local items=( ${entry} )
+ case ${items[0]} in
+ dir)
+ if ! [[ -d "${ROOT}/${items[1]}" ]] ; then
+ echo "skip !type ${items[1]}"
+ elif [[ $(echo "${ROOT}/${items[1]}"/* ) != "${ROOT}/${items[1]}/*" ]] ; then
+ echo "skip !empty ${items[1]}"
+ else
+ echo "remove ${items[1]}"
+ rm -fr "${ROOT}/${items[1]}"
+ fi
+ ;;
+ esac
+ done
+
+ [[ $olddotglob != 0 ]] && shopt -u dotglob
+ shopt -q dotglob
+ [[ $olddotglob == $? ]] || ebuild_notice "warning" "shopt dotglob restore failed"
+
+ rm -fr "${dbdir}"
+}
+
+ebuild_f_unmerge()
+{
+ if hasq "unmerge" ${RESTRICT} ; then
+ ebuild_section "Skipping builtin_unmerge (RESTRICT)"
+ elif hasq "unmerge" ${SKIP_FUNCTIONS} ; then
+ ebuild_section "Skipping builtin_unmerge (SKIP_FUNCTIONS)"
+ else
+ ebuild_section "Starting builtin_unmerge"
+ builtin_unmerge
+ ebuild_section "Done builtin_unmerge"
+ fi
+}
+
+
diff --git a/ebuild/ebuild.bash b/ebuild/ebuild.bash
index 810a722..a23040f 100755
--- a/ebuild/ebuild.bash
+++ b/ebuild/ebuild.bash
@@ -87,7 +87,9 @@ for var in ${save_vars} ; do
eval "export save_var_${var}='${!var}'"
done
-ebuild_source_profile $(readlink -f "${PALUDIS_PROFILE_DIR}")
+if [[ -n "${PALUDIS_PROFILE_DIR}" ]] ; then
+ ebuild_source_profile $(readlink -f "${PALUDIS_PROFILE_DIR}")
+fi
unset ${save_vars}
@@ -134,31 +136,19 @@ ebuild_main()
for action in $@ ; do
case ${action} in
metadata)
- for f in cut tr ; do
- eval "export ebuild_real_${f}=\"$(which $f )\""
- eval "${f}() { ebuild_notice qa 'global scope ${f}' ; $(which $f ) \"\$@\" ; }"
- done
- PATH="" ebuild_load_ebuild "${ebuild}"
ebuild_load_module depend
- ebuild_f_depend || die "${action} failed"
;;
- init|fetch|merge|tidyup|strip)
+ init|fetch|merge|unmerge|tidyup|strip)
ebuild_load_module builtin_${action}
- ebuild_load_ebuild "${ebuild}"
- ebuild_f_${action} || die "${action} failed"
;;
unpack|compile|install|test)
ebuild_load_module src_${action}
- ebuild_load_ebuild "${ebuild}"
- ebuild_f_${action} || die "${action} failed"
;;
setup|config|nofetch|preinst|postinst|prerm|postrm)
ebuild_load_module pkg_${action}
- ebuild_load_ebuild "${ebuild}"
- ebuild_f_${action} || die "${action} failed"
;;
*)
@@ -168,6 +158,23 @@ ebuild_main()
;;
esac
done
+
+ if [[ $1 == metadata ]] ; then
+ for f in cut tr ; do
+ eval "export ebuild_real_${f}=\"$(which $f )\""
+ eval "${f}() { ebuild_notice qa 'global scope ${f}' ; $(which $f ) \"\$@\" ; }"
+ done
+ PATH="" ebuild_load_ebuild "${ebuild}"
+ ebuild_f_depend || die "${1} failed"
+ else
+ ebuild_load_ebuild "${ebuild}"
+ for action in $@ ; do
+ ebuild_f_${action} || die "${action} failed"
+ if [[ ${action} == "init" ]] ; then
+ ebuild_load_ebuild "${ebuild}"
+ fi
+ done
+ fi
}
ebuild_main $@
diff --git a/ebuild/pkg_postrm.bash b/ebuild/pkg_postrm.bash
index 8190200..c0d8f3f 100644
--- a/ebuild/pkg_postrm.bash
+++ b/ebuild/pkg_postrm.bash
@@ -23,5 +23,20 @@
pkg_postrm()
{
+ :
}
+ebuild_f_postrm()
+{
+ if hasq "postrm" ${RESTRICT} ; then
+ ebuild_section "Skipping pkg_postrm (RESTRICT)"
+ elif hasq "postrm" ${SKIP_FUNCTIONS} ; then
+ ebuild_section "Skipping pkg_postrm (SKIP_FUNCTIONS)"
+ else
+ ebuild_section "Starting pkg_postrm"
+ pkg_postrm
+ ebuild_section "Done pkg_postrm"
+ fi
+}
+
+
diff --git a/ebuild/pkg_prerm.bash b/ebuild/pkg_prerm.bash
index a725183..5a70f88 100644
--- a/ebuild/pkg_prerm.bash
+++ b/ebuild/pkg_prerm.bash
@@ -23,5 +23,19 @@
pkg_prerm()
{
+ :
+}
+
+ebuild_f_prerm()
+{
+ if hasq "prerm" ${RESTRICT} ; then
+ ebuild_section "Skipping pkg_prerm (RESTRICT)"
+ elif hasq "prerm" ${SKIP_FUNCTIONS} ; then
+ ebuild_section "Skipping pkg_prerm (SKIP_FUNCTIONS)"
+ else
+ ebuild_section "Starting pkg_prerm"
+ pkg_prerm
+ ebuild_section "Done pkg_prerm"
+ fi
}
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.
diff --git a/src/Makefile.am b/src/Makefile.am
index deeeaa2..e6c5eb1 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -14,6 +14,7 @@ paludis_SOURCES = \
command_line.hh command_line.cc \
colour.hh colour.cc \
install.hh install.cc \
+ uninstall.hh uninstall.cc \
list.hh list.cc \
query.hh query.cc \
sync.hh sync.cc \
diff --git a/src/command_line.cc b/src/command_line.cc
index cdd354c..aa765b9 100644
--- a/src/command_line.cc
+++ b/src/command_line.cc
@@ -23,9 +23,10 @@ CommandLine::CommandLine() :
ArgsHandler(),
action_args(this, "Actions (specify exactly one)"),
- a_query(&action_args, "query", 'q', "Query for package information"),
- a_install(&action_args, "install", 'i', "Install one or more packages"),
- a_sync(&action_args, "sync", '\0', "Sync repositories"),
+ a_query(&action_args, "query", 'q', "Query for package information"),
+ a_install(&action_args, "install", 'i', "Install one or more packages"),
+ a_uninstall(&action_args, "uninstall", 'u', "Uninstall one or more packages"),
+ a_sync(&action_args, "sync", '\0', "Sync repositories"),
a_list_repositories(&action_args, "list-repositories", '\0', "List available repositories"),
a_list_categories(&action_args, "list-categories", '\0', "List available categories"),
a_list_packages(&action_args, "list-packages", '\0', "List available packages"),
@@ -54,7 +55,7 @@ CommandLine::CommandLine() :
a_show_deps(&query_args, "show-deps", 'd', "Show dependencies"),
a_show_metadata(&query_args, "show-metadata", 'M', "Show raw metadata"),
- install_args(this, "Install options"),
+ install_args(this, "Install, Uninstall options"),
a_pretend(&install_args, "pretend", 'p', "Pretend only"),
dl_args(this, "DepList behaviour (use with caution)"),
diff --git a/src/command_line.hh b/src/command_line.hh
index ac707f5..aaa42c9 100644
--- a/src/command_line.hh
+++ b/src/command_line.hh
@@ -56,6 +56,9 @@ class CommandLine :
/// --install
paludis::args::SwitchArg a_install;
+ /// --uninstall
+ paludis::args::SwitchArg a_uninstall;
+
/// --sync
paludis::args::SwitchArg a_sync;
@@ -131,7 +134,7 @@ class CommandLine :
/// }
- /// \name Install arguments
+ /// \name (Un)Install arguments
/// {
/// Install arguments.
diff --git a/src/paludis.cc b/src/paludis.cc
index f36d1f5..d88c394 100644
--- a/src/paludis.cc
+++ b/src/paludis.cc
@@ -19,6 +19,7 @@
#include "src/command_line.hh"
#include "src/install.hh"
+#include "src/uninstall.hh"
#include "src/list.hh"
#include "src/query.hh"
#include "src/applets.hh"
@@ -91,6 +92,7 @@ main(int argc, char *argv[])
if (1 != (CommandLine::get_instance()->a_query.specified() +
CommandLine::get_instance()->a_version.specified() +
CommandLine::get_instance()->a_install.specified() +
+ CommandLine::get_instance()->a_uninstall.specified() +
CommandLine::get_instance()->a_sync.specified() +
CommandLine::get_instance()->a_list_repositories.specified() +
CommandLine::get_instance()->a_list_categories.specified() +
@@ -138,6 +140,14 @@ main(int argc, char *argv[])
return do_install();
}
+ if (CommandLine::get_instance()->a_uninstall.specified())
+ {
+ if (CommandLine::get_instance()->empty())
+ throw DoHelp("uninstall action requires at least one parameter");
+
+ return do_uninstall();
+ }
+
if (CommandLine::get_instance()->a_sync.specified())
{
/// \todo --sync foo?
diff --git a/src/uninstall.hh b/src/uninstall.hh
new file mode 100644
index 0000000..89ad30b
--- /dev/null
+++ b/src/uninstall.hh
@@ -0,0 +1,33 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaranm@gentoo.org>
+ *
+ * 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_SRC_UNINSTALL_HH
+#define PALUDIS_GUARD_SRC_UNINSTALL_HH 1
+
+#include "src/command_line.hh"
+
+/** \file
+ * Declaration for the do_uninstall function.
+ */
+
+/// Handle --uninstall.
+int do_uninstall();
+
+#endif
+