aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-02-04 09:39:38 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-02-04 09:39:38 +0000
commit8e39d3b1de31417fcdfda7d455bd33297e78350c (patch)
tree2c40da3a0fe2d4e2e00414d2fd7ec188933d82bd
parent5db3a019e08d1cf9e488b95b1251cd33d2e21dd4 (diff)
downloadpaludis-8e39d3b1de31417fcdfda7d455bd33297e78350c.tar.gz
paludis-8e39d3b1de31417fcdfda7d455bd33297e78350c.tar.xz
Add --config support. Fixes: ticket:72
-rw-r--r--ebuild/pkg_config.bash33
-rw-r--r--paludis/ebuild.cc34
-rw-r--r--paludis/ebuild.hh25
-rw-r--r--paludis/ebuild.sr18
-rw-r--r--paludis/repositories/cran/cran_installed_repository.cc1
-rw-r--r--paludis/repositories/cran/cran_repository.cc1
-rw-r--r--paludis/repositories/fake/fake_installed_repository.cc1
-rw-r--r--paludis/repositories/fake/fake_repository.cc1
-rw-r--r--paludis/repositories/gems/gems_repository.cc1
-rw-r--r--paludis/repositories/nothing/nothing_repository.cc1
-rw-r--r--paludis/repositories/portage/portage_repository.cc1
-rw-r--r--paludis/repositories/vdb/vdb_repository.cc48
-rw-r--r--paludis/repositories/vdb/vdb_repository.hh3
-rw-r--r--paludis/repositories/virtuals/installed_virtuals_repository.cc1
-rw-r--r--paludis/repositories/virtuals/virtuals_repository.cc1
-rw-r--r--paludis/repository.cc9
-rw-r--r--paludis/repository.hh58
-rw-r--r--paludis/repository.sr1
-rw-r--r--src/clients/paludis/Makefile.am1
-rw-r--r--src/clients/paludis/command_line.cc1
-rw-r--r--src/clients/paludis/command_line.hh3
-rw-r--r--src/clients/paludis/do_config.cc134
-rw-r--r--src/clients/paludis/do_config.hh31
-rw-r--r--src/clients/paludis/paludis.cc10
24 files changed, 417 insertions, 1 deletions
diff --git a/ebuild/pkg_config.bash b/ebuild/pkg_config.bash
index 6666e99..f0bb49a 100644
--- a/ebuild/pkg_config.bash
+++ b/ebuild/pkg_config.bash
@@ -1,7 +1,7 @@
#!/bin/bash
# vim: set sw=4 sts=4 et :
-# Copyright (c) 2006 Ciaran McCreesh <ciaranm@ciaranm.org>
+# Copyright (c) 2006, 2007 Ciaran McCreesh <ciaranm@ciaranm.org>
#
# Based in part upon ebuild.sh from Portage, which is Copyright 1995-2005
# Gentoo Foundation and distributed under the terms of the GNU General
@@ -25,3 +25,34 @@ pkg_config()
eerror "No configuration function is defined"
}
+ebuild_f_config()
+{
+ local old_sandbox_write="${SANDBOX_WRITE}"
+ [[ -z "${PALUDIS_DO_NOTHING_SANDBOXY}" ]] && SANDBOX_WRITE="${SANDBOX_WRITE+${SANDBOX_WRITE}:}${ROOT%/}/"
+
+ if hasq "config" ${RESTRICT} ; then
+ ebuild_section "Skipping pkg_config (RESTRICT)"
+ elif hasq "config" ${SKIP_FUNCTIONS} ; then
+ ebuild_section "Skipping pkg_config (SKIP_FUNCTIONS)"
+ else
+ if [[ $(type -t pre_pkg_config ) == "function" ]] ; then
+ ebuild_section "Starting pre_pkg_config"
+ pre_pkg_config
+ ebuild_section "Done pre_pkg_config"
+ fi
+
+ ebuild_section "Starting pkg_config"
+ pkg_config
+ ebuild_section "Done pkg_config"
+
+ if [[ $(type -t post_pkg_config ) == "function" ]] ; then
+ ebuild_section "Starting post_pkg_config"
+ post_pkg_config
+ ebuild_section "Done post_pkg_config"
+ fi
+ fi
+
+ [[ -z "${PALUDIS_DO_NOTHING_SANDBOXY}" ]] && SANDBOX_WRITE="${old_sandbox_write}"
+ true
+}
+
diff --git a/paludis/ebuild.cc b/paludis/ebuild.cc
index 0c97ce0..92810e4 100644
--- a/paludis/ebuild.cc
+++ b/paludis/ebuild.cc
@@ -427,3 +427,37 @@ EbuildVersionMetadata::~EbuildVersionMetadata()
{
}
+std::string
+EbuildConfigCommand::commands() const
+{
+ return "config";
+}
+
+bool
+EbuildConfigCommand::failure()
+{
+ throw PackageConfigActionError("Configure failed for '" + stringify(
+ *params.db_entry) + "'");
+}
+
+MakeEnvCommand
+EbuildConfigCommand::extend_command(const MakeEnvCommand & cmd)
+{
+ MakeEnvCommand result(cmd
+ ("ROOT", config_params.root));
+
+ if (config_params.load_environment)
+ result = result
+ ("PALUDIS_LOAD_ENVIRONMENT", stringify(*config_params.load_environment))
+ ("PALUDIS_SKIP_INHERIT", "yes");
+
+ return result;
+}
+
+EbuildConfigCommand::EbuildConfigCommand(const EbuildCommandParams & p,
+ const EbuildConfigCommandParams & f) :
+ EbuildCommand(p),
+ config_params(f)
+{
+}
+
diff --git a/paludis/ebuild.hh b/paludis/ebuild.hh
index d65abda..5dfff94 100644
--- a/paludis/ebuild.hh
+++ b/paludis/ebuild.hh
@@ -299,6 +299,31 @@ namespace paludis
*/
EbuildUninstallCommand(const EbuildCommandParams &, const EbuildUninstallCommandParams &);
};
+
+ /**
+ * An EbuildConfigCommand is used to configure a package in a VDBRepository.
+ *
+ * \ingroup grpebuildinterface
+ */
+ class EbuildConfigCommand :
+ public EbuildCommand
+ {
+ protected:
+ /// Parameters for config.
+ const EbuildConfigCommandParams config_params;
+
+ virtual std::string commands() const;
+
+ virtual bool failure() PALUDIS_ATTRIBUTE((noreturn));
+
+ virtual MakeEnvCommand extend_command(const MakeEnvCommand &);
+
+ public:
+ /**
+ * Constructor.
+ */
+ EbuildConfigCommand(const EbuildCommandParams &, const EbuildConfigCommandParams &);
+ };
}
#endif
diff --git a/paludis/ebuild.sr b/paludis/ebuild.sr
index 1fc9745..d14d2c1 100644
--- a/paludis/ebuild.sr
+++ b/paludis/ebuild.sr
@@ -97,3 +97,21 @@ END
allow_named_args
}
+make_class_EbuildConfigCommandParams()
+{
+ key root std::string
+ key load_environment "const FSEntry *"
+
+ doxygen_comment << "END"
+ /**
+ * Parameters for an EbuildConfigCommand.
+ *
+ * \see EbuildConfigCommand
+ * \ingroup grpebuildinterface
+ * \nosubgrouping
+ */
+END
+
+ allow_named_args
+}
+
diff --git a/paludis/repositories/cran/cran_installed_repository.cc b/paludis/repositories/cran/cran_installed_repository.cc
index 56485f8..1317587 100644
--- a/paludis/repositories/cran/cran_installed_repository.cc
+++ b/paludis/repositories/cran/cran_installed_repository.cc
@@ -184,6 +184,7 @@ CRANInstalledRepository::CRANInstalledRepository(const CRANInstalledRepositoryPa
.mirrors_interface(0)
.virtuals_interface(0)
.provides_interface(0)
+ .config_interface(0)
.destination_interface(this),
"cran_installed"),
PrivateImplementationPattern<CRANInstalledRepository>(new Implementation<CRANInstalledRepository>(p))
diff --git a/paludis/repositories/cran/cran_repository.cc b/paludis/repositories/cran/cran_repository.cc
index ffc6d7d..9016344 100644
--- a/paludis/repositories/cran/cran_repository.cc
+++ b/paludis/repositories/cran/cran_repository.cc
@@ -182,6 +182,7 @@ CRANRepository::CRANRepository(const CRANRepositoryParams & p) :
.provides_interface(0)
.destination_interface(0)
.virtuals_interface(0)
+ .config_interface(0)
.contents_interface(0),
"cran"),
PrivateImplementationPattern<CRANRepository>(new Implementation<CRANRepository>(p))
diff --git a/paludis/repositories/fake/fake_installed_repository.cc b/paludis/repositories/fake/fake_installed_repository.cc
index d8fd7ac..c395665 100644
--- a/paludis/repositories/fake/fake_installed_repository.cc
+++ b/paludis/repositories/fake/fake_installed_repository.cc
@@ -40,6 +40,7 @@ FakeInstalledRepository::FakeInstalledRepository(const Environment * const e, co
.environment_variable_interface(0)
.provides_interface(this)
.virtuals_interface(0)
+ .config_interface(0)
.destination_interface(this),
"fake_installed")
{
diff --git a/paludis/repositories/fake/fake_repository.cc b/paludis/repositories/fake/fake_repository.cc
index 7d0097a..d5ca058 100644
--- a/paludis/repositories/fake/fake_repository.cc
+++ b/paludis/repositories/fake/fake_repository.cc
@@ -39,6 +39,7 @@ FakeRepository::FakeRepository(const Environment * const e, const RepositoryName
.environment_variable_interface(0)
.provides_interface(0)
.virtuals_interface(this)
+ .config_interface(0)
.destination_interface(0),
"fake"),
_virtual_packages(new VirtualsCollection::Concrete)
diff --git a/paludis/repositories/gems/gems_repository.cc b/paludis/repositories/gems/gems_repository.cc
index 869ec58..9feeb54 100644
--- a/paludis/repositories/gems/gems_repository.cc
+++ b/paludis/repositories/gems/gems_repository.cc
@@ -260,6 +260,7 @@ GemsRepository::GemsRepository(const GemsRepositoryParams & p) :
.mirrors_interface(0)
.virtuals_interface(0)
.provides_interface(0)
+ .config_interface(0)
.destination_interface(0),
"gems"),
PrivateImplementationPattern<GemsRepository>(new Implementation<GemsRepository>(p))
diff --git a/paludis/repositories/nothing/nothing_repository.cc b/paludis/repositories/nothing/nothing_repository.cc
index 8c408f8..13db408 100644
--- a/paludis/repositories/nothing/nothing_repository.cc
+++ b/paludis/repositories/nothing/nothing_repository.cc
@@ -106,6 +106,7 @@ NothingRepository::NothingRepository(const NothingRepositoryParams & p) try :
.mirrors_interface(0)
.virtuals_interface(0)
.provides_interface(0)
+ .config_interface(0)
.destination_interface(0),
"nothing"),
PrivateImplementationPattern<NothingRepository>(new Implementation<NothingRepository>(p))
diff --git a/paludis/repositories/portage/portage_repository.cc b/paludis/repositories/portage/portage_repository.cc
index 415e96a..ff093a8 100644
--- a/paludis/repositories/portage/portage_repository.cc
+++ b/paludis/repositories/portage/portage_repository.cc
@@ -269,6 +269,7 @@ PortageRepository::PortageRepository(const PortageRepositoryParams & p) :
.virtuals_interface(this)
.provides_interface(0)
.contents_interface(0)
+ .config_interface(0)
.destination_interface(0),
p.entry_format),
PrivateImplementationPattern<PortageRepository>(new Implementation<PortageRepository>(this, p))
diff --git a/paludis/repositories/vdb/vdb_repository.cc b/paludis/repositories/vdb/vdb_repository.cc
index 32e5d5f..4c455de 100644
--- a/paludis/repositories/vdb/vdb_repository.cc
+++ b/paludis/repositories/vdb/vdb_repository.cc
@@ -501,6 +501,7 @@ VDBRepository::VDBRepository(const VDBRepositoryParams & p) :
.provides_interface(this)
.virtuals_interface(0)
.destination_interface(this)
+ .config_interface(this)
.contents_interface(this),
"vdb"),
PrivateImplementationPattern<VDBRepository>(new Implementation<VDBRepository>(this, p))
@@ -943,6 +944,53 @@ VDBRepository::do_uninstall(const QualifiedPackageName & q, const VersionSpec &
uninstall_cmd();
}
+void
+VDBRepository::do_config(const QualifiedPackageName & q, const VersionSpec & v) const
+{
+ Context context("When configuring '" + stringify(q) + "-" + stringify(v) +
+ "' from '" + stringify(name()) + "':");
+
+ if (! _imp->root.is_directory())
+ throw PackageInstallActionError("Couldn't configure '" + stringify(q) + "-" +
+ stringify(v) + "' because root ('" + stringify(_imp->root) + "') is not a directory");
+
+ std::tr1::shared_ptr<const VersionMetadata> metadata;
+ if (! has_version(q, v))
+ throw PackageInstallActionError("Couldn't configure '" + stringify(q) + "-" +
+ stringify(v) + "' because has_version failed");
+ else
+ metadata = version_metadata(q, v);
+
+ PackageDatabaseEntry e(q, v, name());
+
+ std::tr1::shared_ptr<FSEntryCollection> eclassdirs(new FSEntryCollection::Concrete);
+ eclassdirs->append(FSEntry(_imp->location / stringify(q.category) /
+ (stringify(q.package) + "-" + stringify(v))));
+
+ FSEntry pkg_dir(_imp->location / stringify(q.category) /
+ (stringify(q.package) + "-" + stringify(v)));
+
+ std::tr1::shared_ptr<FSEntry> load_env;
+ if (is_full_env(pkg_dir))
+ load_env.reset(new FSEntry(pkg_dir / "environment.bz2"));
+
+ EbuildConfigCommand config_cmd(EbuildCommandParams::create()
+ .environment(_imp->env)
+ .db_entry(&e)
+ .ebuild_dir(pkg_dir)
+ .files_dir(pkg_dir)
+ .eclassdirs(eclassdirs)
+ .portdir(_imp->location)
+ .distdir(pkg_dir)
+ .buildroot(_imp->buildroot),
+
+ EbuildConfigCommandParams::create()
+ .root(stringify(_imp->root) + "/")
+ .load_environment(load_env.get()));
+
+ config_cmd();
+}
+
std::tr1::shared_ptr<DepAtom>
VDBRepository::do_package_set(const SetName & s) const
{
diff --git a/paludis/repositories/vdb/vdb_repository.hh b/paludis/repositories/vdb/vdb_repository.hh
index 780c7c3..56a6bd2 100644
--- a/paludis/repositories/vdb/vdb_repository.hh
+++ b/paludis/repositories/vdb/vdb_repository.hh
@@ -55,6 +55,7 @@ namespace paludis
public RepositoryProvidesInterface,
public RepositoryDestinationInterface,
public RepositoryContentsInterface,
+ public RepositoryConfigInterface,
public PrivateImplementationPattern<VDBRepository>
{
private:
@@ -118,6 +119,8 @@ namespace paludis
virtual void remove_string_from_world(const std::string &) const;
+ virtual void do_config(const QualifiedPackageName &, const VersionSpec &) const;
+
public:
/**
* Constructor.
diff --git a/paludis/repositories/virtuals/installed_virtuals_repository.cc b/paludis/repositories/virtuals/installed_virtuals_repository.cc
index a0e9ce2..1402620 100644
--- a/paludis/repositories/virtuals/installed_virtuals_repository.cc
+++ b/paludis/repositories/virtuals/installed_virtuals_repository.cc
@@ -63,6 +63,7 @@ InstalledVirtualsRepository::InstalledVirtualsRepository(const Environment * con
.provides_interface(0)
.virtuals_interface(0)
.contents_interface(0)
+ .config_interface(0)
.destination_interface(0),
"installed_virtuals"),
PrivateImplementationPattern<InstalledVirtualsRepository>(
diff --git a/paludis/repositories/virtuals/virtuals_repository.cc b/paludis/repositories/virtuals/virtuals_repository.cc
index 7023722..db0f581 100644
--- a/paludis/repositories/virtuals/virtuals_repository.cc
+++ b/paludis/repositories/virtuals/virtuals_repository.cc
@@ -89,6 +89,7 @@ VirtualsRepository::VirtualsRepository(const Environment * const env) :
.provides_interface(0)
.virtuals_interface(0)
.destination_interface(0)
+ .config_interface(0)
.contents_interface(0),
"virtuals"),
PrivateImplementationPattern<VirtualsRepository>(
diff --git a/paludis/repository.cc b/paludis/repository.cc
index a8de0d6..25bf8bf 100644
--- a/paludis/repository.cc
+++ b/paludis/repository.cc
@@ -85,6 +85,11 @@ PackageUninstallActionError::PackageUninstallActionError(const std::string & msg
{
}
+PackageConfigActionError::PackageConfigActionError(const std::string & msg) throw () :
+ PackageActionError("Configuration error: " + msg)
+{
+}
+
namespace paludis
{
/**
@@ -266,3 +271,7 @@ RepositoryContentsInterface::~RepositoryContentsInterface()
{
}
+RepositoryConfigInterface::~RepositoryConfigInterface()
+{
+}
+
diff --git a/paludis/repository.hh b/paludis/repository.hh
index 71a7846..7edd573 100644
--- a/paludis/repository.hh
+++ b/paludis/repository.hh
@@ -62,6 +62,7 @@ namespace paludis
class RepositoryVirtualsInterface;
class RepositoryDestinationInterface;
class RepositoryContentsInterface;
+ class RepositoryConfigInterface;
/**
* What debug build option to use when installing a package.
@@ -1043,6 +1044,47 @@ namespace paludis
};
/**
+ * Interface for handling actions for repositories supporting package configuration.
+ *
+ * \see Repository
+ * \ingroup grprepository
+ * \nosubgrouping
+ */
+ class RepositoryConfigInterface
+ {
+ protected:
+ ///\name Implementation details
+ ///\{
+
+ /**
+ * Override in descendents: do the configuration.
+ */
+ virtual void do_config(
+ const QualifiedPackageName &,
+ const VersionSpec &) const = 0;
+
+ ///\}
+
+ public:
+ ///\name Installed content queries
+ ///\{
+
+ /**
+ * Fetch contents.
+ */
+ void config(
+ const QualifiedPackageName & q,
+ const VersionSpec & v) const
+ {
+ return do_config(q, v);
+ }
+
+ ///\}
+
+ virtual ~RepositoryConfigInterface();
+ };
+
+ /**
* Thrown if a repository of the specified type does not exist.
*
* \ingroup grpexceptions
@@ -1123,6 +1165,22 @@ namespace paludis
};
/**
+ * Thrown if a configure fails.
+ *
+ * \ingroup grprepository
+ * \ingroup grpexceptions
+ * \nosubgrouping
+ */
+ class PackageConfigActionError : public PackageActionError
+ {
+ public:
+ /**
+ * Constructor.
+ */
+ PackageConfigActionError(const std::string & msg) throw ();
+ };
+
+ /**
* Thrown if an environment variable query fails.
*
* \ingroup grprepository
diff --git a/paludis/repository.sr b/paludis/repository.sr
index a1b5fe7..a3d4c1d 100644
--- a/paludis/repository.sr
+++ b/paludis/repository.sr
@@ -35,6 +35,7 @@ make_class_RepositoryCapabilities()
key virtuals_interface "RepositoryVirtualsInterface *"
key destination_interface "RepositoryDestinationInterface *"
key contents_interface "RepositoryContentsInterface *"
+ key config_interface "RepositoryConfigInterface *"
doxygen_comment << "END"
/**
diff --git a/src/clients/paludis/Makefile.am b/src/clients/paludis/Makefile.am
index f1017c0..0ff68ca 100644
--- a/src/clients/paludis/Makefile.am
+++ b/src/clients/paludis/Makefile.am
@@ -40,6 +40,7 @@ paludis_SOURCES = \
query.hh query.cc \
sync.hh sync.cc \
do_contents.hh do_contents.cc \
+ do_config.hh do_config.cc \
owner.hh owner.cc \
news.hh news.cc \
report.hh report.cc \
diff --git a/src/clients/paludis/command_line.cc b/src/clients/paludis/command_line.cc
index f71dd83..c548ba2 100644
--- a/src/clients/paludis/command_line.cc
+++ b/src/clients/paludis/command_line.cc
@@ -35,6 +35,7 @@ CommandLine::CommandLine() :
a_report(&action_args, "report", 'r', "Report the current state of the system"),
a_contents(&action_args, "contents", 'k', "Display contents of a package"),
a_owner(&action_args, "owner", 'o', "Display the owner of a file"),
+ a_config(&action_args, "config", '\0', "Run post-install configuration for a package"),
a_version(&action_args, "version", 'V', "Display program version"),
a_info(&action_args, "info", 'I', "Display program version and system information"),
a_help(&action_args, "help", 'h', "Display program help"),
diff --git a/src/clients/paludis/command_line.hh b/src/clients/paludis/command_line.hh
index 4ef5f18..a99f5d3 100644
--- a/src/clients/paludis/command_line.hh
+++ b/src/clients/paludis/command_line.hh
@@ -86,6 +86,9 @@ class CommandLine :
/// --owner
paludis::args::SwitchArg a_owner;
+ /// --config
+ paludis::args::SwitchArg a_config;
+
/// --version
paludis::args::SwitchArg a_version;
diff --git a/src/clients/paludis/do_config.cc b/src/clients/paludis/do_config.cc
new file mode 100644
index 0000000..99be418
--- /dev/null
+++ b/src/clients/paludis/do_config.cc
@@ -0,0 +1,134 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2007 Ciaran McCreesh <ciaranm@ciaranm.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
+ */
+
+#include "do_config.hh"
+#include "command_line.hh"
+#include <src/output/colour.hh>
+#include <paludis/paludis.hh>
+#include <paludis/environment/default/default_environment.hh>
+#include <iostream>
+
+using namespace paludis;
+using std::cout;
+using std::cerr;
+using std::endl;
+
+namespace
+{
+ struct AmbiguousConfigTarget :
+ public Exception
+ {
+ std::tr1::shared_ptr<const PackageDatabaseEntryCollection> matches;
+
+ AmbiguousConfigTarget(std::tr1::shared_ptr<const PackageDatabaseEntryCollection> & m) throw () :
+ Exception("Ambiguous config target"),
+ matches(m)
+ {
+ }
+ };
+
+ int
+ do_one_config_entry(Environment * const env, const PackageDatabaseEntry & p)
+ {
+ int return_code(0);
+
+ std::tr1::shared_ptr<const Repository> repo(env->package_database()->fetch_repository(p.repository));
+ const RepositoryConfigInterface * conf_if(repo->config_interface);
+
+ if (! conf_if)
+ {
+ std::cerr << "Repository '" << repo->name() <<
+ "' does not support post-install configuration" << std::endl;
+ return_code |= 1;
+ }
+ else
+ conf_if->config(p.name, p.version);
+
+ return return_code;
+ }
+
+ int
+ do_one_config(Environment * const env, const std::string & target)
+ {
+ Context local_context("When handling query '" + target + "':");
+
+ /* we might have a dep atom, but we might just have a simple package name
+ * without a category. either should work. */
+ std::tr1::shared_ptr<PackageDepAtom> atom(std::string::npos == target.find('/') ?
+ new PackageDepAtom(env->package_database()->fetch_unique_qualified_package_name(
+ PackageNamePart(target))) :
+ new PackageDepAtom(target));
+
+ std::tr1::shared_ptr<const PackageDatabaseEntryCollection>
+ entries(env->package_database()->query(*atom, is_installed_only, qo_order_by_version));
+
+ if (entries->empty())
+ throw NoSuchPackageError(target);
+
+ if (next(entries->begin()) != entries->end())
+ throw AmbiguousConfigTarget(entries);
+
+ return do_one_config_entry(env, *entries->begin());
+ }
+}
+
+int
+do_config()
+{
+ int ret_code(0);
+
+ Context context("When performing config action from command line:");
+ Environment * const env(DefaultEnvironment::get_instance());
+
+ CommandLine::ParametersIterator q(CommandLine::get_instance()->begin_parameters()),
+ q_end(CommandLine::get_instance()->end_parameters());
+ for ( ; q != q_end ; ++q)
+ {
+ try
+ {
+ ret_code |= do_one_config(env, *q);
+ }
+ catch (const AmbiguousPackageNameError & e)
+ {
+ cout << endl;
+ cerr << "Query error:" << endl;
+ cerr << " * " << e.backtrace("\n * ");
+ cerr << "Ambiguous package name '" << e.name() << "'. Did you mean:" << endl;
+ for (AmbiguousPackageNameError::OptionsIterator o(e.begin_options()),
+ o_end(e.end_options()) ; o != o_end ; ++o)
+ cerr << " * " << colour(cl_package_name, *o) << endl;
+ cerr << endl;
+ }
+ catch (const AmbiguousConfigTarget & e)
+ {
+ cout << endl;
+ cerr << "Query error:" << endl;
+ cerr << " * " << e.backtrace("\n * ");
+ cerr << "Ambiguous config target '" << *q << "'. Did you mean:" << endl;
+ for (PackageDatabaseEntryCollection::Iterator o(e.matches->begin()),
+ o_end(e.matches->end()) ; o != o_end ; ++o)
+ cerr << " * =" << colour(cl_package_name, *o) << endl;
+ cerr << endl;
+ }
+ }
+
+ return ret_code;
+}
+
+
diff --git a/src/clients/paludis/do_config.hh b/src/clients/paludis/do_config.hh
new file mode 100644
index 0000000..c1f24ef
--- /dev/null
+++ b/src/clients/paludis/do_config.hh
@@ -0,0 +1,31 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2007 Ciaran McCreesh <ciaranm@ciaranm.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_CONFIG_HH
+#define PALUDIS_GUARD_SRC_CONFIG_HH 1
+
+/** \file
+ * Declaration for the do_config function.
+ */
+
+/// Handle --config.
+int do_config();
+
+#endif
+
diff --git a/src/clients/paludis/paludis.cc b/src/clients/paludis/paludis.cc
index 63b887b..0bea7b9 100644
--- a/src/clients/paludis/paludis.cc
+++ b/src/clients/paludis/paludis.cc
@@ -21,6 +21,7 @@
#include "command_line.hh"
#include "config.h"
#include "do_contents.hh"
+#include "do_config.hh"
#include "install.hh"
#include "list.hh"
#include "news.hh"
@@ -212,6 +213,7 @@ main(int argc, char *argv[])
CommandLine::get_instance()->a_list_dep_tag_categories.specified() +
CommandLine::get_instance()->a_contents.specified() +
CommandLine::get_instance()->a_owner.specified() +
+ CommandLine::get_instance()->a_config.specified() +
CommandLine::get_instance()->a_has_version.specified() +
CommandLine::get_instance()->a_update_news.specified() +
CommandLine::get_instance()->a_regenerate_installed_cache.specified() +
@@ -364,6 +366,14 @@ main(int argc, char *argv[])
return do_uninstall();
}
+ if (CommandLine::get_instance()->a_config.specified())
+ {
+ if (CommandLine::get_instance()->empty())
+ throw args::DoHelp("config action requires at least one parameter");
+
+ return do_config();
+ }
+
if (CommandLine::get_instance()->a_uninstall_unused.specified())
{
if (! CommandLine::get_instance()->empty())