aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-09-23 20:55:39 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-09-23 20:55:39 +0000
commit4c0cb9770a2e5035028231942229df975c7e3b5f (patch)
tree9aadb37308e2833c682a97589e6ba6312de02dd4
parent821dd6b5b697bb660a494c485e5f46bfe24554b5 (diff)
downloadpaludis-4c0cb9770a2e5035028231942229df975c7e3b5f.tar.gz
paludis-4c0cb9770a2e5035028231942229df975c7e3b5f.tar.xz
Better --info, pkg_info support. Fixes: ticket:367
-rw-r--r--paludis/action-fwd.hh2
-rw-r--r--paludis/action.cc12
-rw-r--r--paludis/action.hh27
-rw-r--r--paludis/repositories/cran/cran_installed_repository.cc4
-rw-r--r--paludis/repositories/cran/cran_package_id.cc4
-rw-r--r--paludis/repositories/cran/cran_repository.cc4
-rw-r--r--paludis/repositories/e/e_key.cc10
-rw-r--r--paludis/repositories/e/e_repository.cc11
-rw-r--r--paludis/repositories/e/e_repository.hh2
-rw-r--r--paludis/repositories/e/e_repository_entries.hh6
-rw-r--r--paludis/repositories/e/eapi.cc1
-rw-r--r--paludis/repositories/e/eapi.sr1
-rw-r--r--paludis/repositories/e/eapis/0.conf4
-rw-r--r--paludis/repositories/e/eapis/exheres-0.conf3
-rw-r--r--paludis/repositories/e/eapis/paludis-1.conf3
-rw-r--r--paludis/repositories/e/ebuild.cc61
-rw-r--r--paludis/repositories/e/ebuild.hh25
-rw-r--r--paludis/repositories/e/ebuild.sr23
-rw-r--r--paludis/repositories/e/ebuild/Makefile.am2
-rw-r--r--paludis/repositories/e/ebuild/builtin_infovars.bash54
-rwxr-xr-xpaludis/repositories/e/ebuild/ebuild.bash4
-rw-r--r--paludis/repositories/e/ebuild/pkg_info.bash50
-rw-r--r--paludis/repositories/e/ebuild_entries.cc78
-rw-r--r--paludis/repositories/e/ebuild_entries.hh3
-rw-r--r--paludis/repositories/e/ebuild_id.cc12
-rw-r--r--paludis/repositories/e/vdb_id.cc10
-rw-r--r--paludis/repositories/e/vdb_repository.cc95
-rw-r--r--paludis/repositories/e/vdb_repository.hh2
-rw-r--r--paludis/repositories/fake/fake_installed_repository.cc4
-rw-r--r--paludis/repositories/fake/fake_package_id.cc7
-rw-r--r--paludis/repositories/fake/fake_repository.cc4
-rw-r--r--paludis/repositories/gems/gem_specification.cc7
-rw-r--r--paludis/repositories/gems/gems_repository.cc4
-rw-r--r--paludis/repositories/gems/installed_gems_repository.cc4
-rw-r--r--paludis/repositories/virtuals/installed_virtuals_repository.cc4
-rw-r--r--paludis/repositories/virtuals/package_id.cc7
-rw-r--r--paludis/repositories/virtuals/virtuals_repository.cc4
-rw-r--r--paludis/repository.hh7
-rw-r--r--src/clients/paludis/Makefile.am5
-rw-r--r--src/clients/paludis/command_line.cc2
-rw-r--r--src/clients/paludis/info.cc190
-rw-r--r--src/clients/paludis/info.hh29
-rw-r--r--src/clients/paludis/paludis.cc63
43 files changed, 783 insertions, 71 deletions
diff --git a/paludis/action-fwd.hh b/paludis/action-fwd.hh
index 0018ce8..e83037d 100644
--- a/paludis/action-fwd.hh
+++ b/paludis/action-fwd.hh
@@ -32,6 +32,7 @@ namespace paludis
class PretendAction;
class ConfigAction;
class FetchAction;
+ class InfoAction;
class SupportsActionTestBase;
template <typename A_> class SupportsActionTest;
@@ -45,6 +46,7 @@ namespace paludis
class FetchActionError;
class UninstallActionError;
class ConfigActionError;
+ class InfoActionError;
class FetchActionFailure;
diff --git a/paludis/action.cc b/paludis/action.cc
index 24d6c2b..876e473 100644
--- a/paludis/action.cc
+++ b/paludis/action.cc
@@ -30,6 +30,7 @@ using namespace paludis;
template class MutableAcceptInterfaceVisitsThis<ActionVisitorTypes, InstallAction>;
template class MutableAcceptInterfaceVisitsThis<ActionVisitorTypes, ConfigAction>;
+template class MutableAcceptInterfaceVisitsThis<ActionVisitorTypes, InfoAction>;
template class MutableAcceptInterfaceVisitsThis<ActionVisitorTypes, PretendAction>;
template class MutableAcceptInterfaceVisitsThis<ActionVisitorTypes, InstalledAction>;
template class MutableAcceptInterfaceVisitsThis<ActionVisitorTypes, UninstallAction>;
@@ -37,6 +38,7 @@ template class MutableAcceptInterfaceVisitsThis<ActionVisitorTypes, FetchAction>
template class MutableAcceptInterfaceVisitsThis<SupportsActionTestVisitorTypes, SupportsActionTest<InstallAction> >;
template class MutableAcceptInterfaceVisitsThis<SupportsActionTestVisitorTypes, SupportsActionTest<ConfigAction> >;
+template class MutableAcceptInterfaceVisitsThis<SupportsActionTestVisitorTypes, SupportsActionTest<InfoAction> >;
template class MutableAcceptInterfaceVisitsThis<SupportsActionTestVisitorTypes, SupportsActionTest<PretendAction> >;
template class MutableAcceptInterfaceVisitsThis<SupportsActionTestVisitorTypes, SupportsActionTest<InstalledAction> >;
template class MutableAcceptInterfaceVisitsThis<SupportsActionTestVisitorTypes, SupportsActionTest<UninstallAction> >;
@@ -205,6 +207,11 @@ namespace
s << "config";
}
+ void visit(const InfoAction &)
+ {
+ s << "info";
+ }
+
void visit(const FetchAction &)
{
s << "fetch";
@@ -258,3 +265,8 @@ ConfigActionError::ConfigActionError(const std::string & msg) throw () :
{
}
+InfoActionError::InfoActionError(const std::string & msg) throw () :
+ ActionError("Info error: " + msg)
+{
+}
+
diff --git a/paludis/action.hh b/paludis/action.hh
index e668b34..ec7a257 100644
--- a/paludis/action.hh
+++ b/paludis/action.hh
@@ -44,7 +44,8 @@ namespace paludis
InstalledAction,
UninstallAction,
PretendAction,
- ConfigAction
+ ConfigAction,
+ InfoAction
>
{
};
@@ -58,7 +59,8 @@ namespace paludis
SupportsActionTest<InstalledAction>,
SupportsActionTest<UninstallAction>,
SupportsActionTest<PretendAction>,
- SupportsActionTest<ConfigAction>
+ SupportsActionTest<ConfigAction>,
+ SupportsActionTest<InfoAction>
>
{
};
@@ -131,6 +133,12 @@ namespace paludis
{
};
+ class PALUDIS_VISIBLE InfoAction:
+ public Action,
+ public MutableAcceptInterfaceVisitsThis<ActionVisitorTypes, InfoAction>
+ {
+ };
+
class PALUDIS_VISIBLE SupportsActionTestBase :
public virtual MutableAcceptInterface<SupportsActionTestVisitorTypes>
{
@@ -233,6 +241,21 @@ namespace paludis
*/
ConfigActionError(const std::string & msg) throw ();
};
+
+ /**
+ * Thrown if an info fails.
+ *
+ * \ingroup grpexceptions
+ * \nosubgrouping
+ */
+ class PALUDIS_VISIBLE InfoActionError : public ActionError
+ {
+ public:
+ /**
+ * Constructor.
+ */
+ InfoActionError(const std::string & msg) throw ();
+ };
}
#endif
diff --git a/paludis/repositories/cran/cran_installed_repository.cc b/paludis/repositories/cran/cran_installed_repository.cc
index 917c173..8dc8880 100644
--- a/paludis/repositories/cran/cran_installed_repository.cc
+++ b/paludis/repositories/cran/cran_installed_repository.cc
@@ -640,6 +640,10 @@ namespace
{
result = true;
}
+
+ void visit(const SupportsActionTest<InfoAction> &)
+ {
+ }
};
}
diff --git a/paludis/repositories/cran/cran_package_id.cc b/paludis/repositories/cran/cran_package_id.cc
index 911ac42..cedfef3 100644
--- a/paludis/repositories/cran/cran_package_id.cc
+++ b/paludis/repositories/cran/cran_package_id.cc
@@ -508,6 +508,10 @@ namespace
void visit(const SupportsActionTest<UninstallAction> &)
{
}
+
+ void visit(const SupportsActionTest<InfoAction> &)
+ {
+ }
};
}
diff --git a/paludis/repositories/cran/cran_repository.cc b/paludis/repositories/cran/cran_repository.cc
index 9735aea..548c324 100644
--- a/paludis/repositories/cran/cran_repository.cc
+++ b/paludis/repositories/cran/cran_repository.cc
@@ -486,6 +486,10 @@ namespace
void visit(const SupportsActionTest<UninstallAction> &)
{
}
+
+ void visit(const SupportsActionTest<InfoAction> &)
+ {
+ }
};
}
diff --git a/paludis/repositories/e/e_key.cc b/paludis/repositories/e/e_key.cc
index fac6c54..807185f 100644
--- a/paludis/repositories/e/e_key.cc
+++ b/paludis/repositories/e/e_key.cc
@@ -154,7 +154,7 @@ std::string
EDependenciesKey::pretty_print(const DependencySpecTree::Formatter & f) const
{
StringifyFormatter ff(f);
- DepSpecPrettyPrinter p(_imp->env, _imp->id, ff, 12, true, false);
+ DepSpecPrettyPrinter p(_imp->env, _imp->id, ff, 0, true, false);
value()->accept(p);
return stringify(p);
}
@@ -252,7 +252,7 @@ std::string
ELicenseKey::pretty_print(const LicenseSpecTree::Formatter & f) const
{
StringifyFormatter ff(f);
- DepSpecPrettyPrinter p(_imp->env, _imp->id, ff, 12, true, true);
+ DepSpecPrettyPrinter p(_imp->env, _imp->id, ff, 0, true, true);
value()->accept(p);
return stringify(p);
}
@@ -339,7 +339,7 @@ std::string
EURIKey::pretty_print(const URISpecTree::Formatter & f) const
{
StringifyFormatter ff(f);
- DepSpecPrettyPrinter p(_imp->env, _imp->id, ff, 12, true, false);
+ DepSpecPrettyPrinter p(_imp->env, _imp->id, ff, 0, true, false);
value()->accept(p);
return stringify(p);
}
@@ -403,7 +403,7 @@ std::string
ERestrictKey::pretty_print(const RestrictSpecTree::Formatter & f) const
{
StringifyFormatter ff(f);
- DepSpecPrettyPrinter p(_imp->env, _imp->id, ff, 12, true, false);
+ DepSpecPrettyPrinter p(_imp->env, _imp->id, ff, 0, true, false);
value()->accept(p);
return stringify(p);
}
@@ -466,7 +466,7 @@ std::string
EProvideKey::pretty_print(const ProvideSpecTree::Formatter & f) const
{
StringifyFormatter ff(f);
- DepSpecPrettyPrinter p(_imp->env, _imp->id, ff, 12, true, false);
+ DepSpecPrettyPrinter p(_imp->env, _imp->id, ff, 0, true, false);
value()->accept(p);
return stringify(p);
}
diff --git a/paludis/repositories/e/e_repository.cc b/paludis/repositories/e/e_repository.cc
index 9caf05d..7237268 100644
--- a/paludis/repositories/e/e_repository.cc
+++ b/paludis/repositories/e/e_repository.cc
@@ -1129,6 +1129,11 @@ namespace
void visit(const SupportsActionTest<UninstallAction> &)
{
}
+
+ void visit(const SupportsActionTest<InfoAction> &)
+ {
+ result = true;
+ }
};
}
@@ -1237,3 +1242,9 @@ ERepository::arch_variable() const
params().profile_eapi)->supported->ebuild_environment_variables->env_arch;
}
+FSEntry
+ERepository::info_variables_file(const FSEntry & f) const
+{
+ return layout()->info_variables_file(f);
+}
+
diff --git a/paludis/repositories/e/e_repository.hh b/paludis/repositories/e/e_repository.hh
index 89eb767..6c5579f 100644
--- a/paludis/repositories/e/e_repository.hh
+++ b/paludis/repositories/e/e_repository.hh
@@ -206,6 +206,8 @@ namespace paludis
const ERepositoryParams & params() const;
+ virtual FSEntry info_variables_file(const FSEntry &) const;
+
///\}
///\name Profile setting and querying functions
diff --git a/paludis/repositories/e/e_repository_entries.hh b/paludis/repositories/e/e_repository_entries.hh
index 1fed153..1837bb5 100644
--- a/paludis/repositories/e/e_repository_entries.hh
+++ b/paludis/repositories/e/e_repository_entries.hh
@@ -100,6 +100,12 @@ namespace paludis
tr1::shared_ptr<const ERepositoryProfile>) const = 0;
/**
+ * Handle an info.
+ */
+ virtual void info(const tr1::shared_ptr<const ERepositoryID> &,
+ tr1::shared_ptr<const ERepositoryProfile>) const = 0;
+
+ /**
* Handle a merge.
*/
virtual void merge(const MergeOptions &) = 0;
diff --git a/paludis/repositories/e/eapi.cc b/paludis/repositories/e/eapi.cc
index 413f6db..f2e3545 100644
--- a/paludis/repositories/e/eapi.cc
+++ b/paludis/repositories/e/eapi.cc
@@ -115,6 +115,7 @@ namespace paludis
.ebuild_metadata(k.get("ebuild_metadata"))
.ebuild_nofetch(k.get("ebuild_nofetch"))
.ebuild_variable(k.get("ebuild_variable"))
+ .ebuild_info(k.get("ebuild_info"))
.ebuild_config(k.get("ebuild_config")))))
.ebuild_metadata_variables(make_shared_ptr(new EAPIEbuildMetadataVariables(
diff --git a/paludis/repositories/e/eapi.sr b/paludis/repositories/e/eapi.sr
index f8df460..9eaa68f 100644
--- a/paludis/repositories/e/eapi.sr
+++ b/paludis/repositories/e/eapi.sr
@@ -9,6 +9,7 @@ make_class_EAPIEbuildPhases()
key ebuild_install std::string
key ebuild_uninstall std::string
key ebuild_pretend std::string
+ key ebuild_info std::string
key ebuild_metadata std::string
key ebuild_nofetch std::string
key ebuild_variable std::string
diff --git a/paludis/repositories/e/eapis/0.conf b/paludis/repositories/e/eapis/0.conf
index 3dd5f0b..2ec1f98 100644
--- a/paludis/repositories/e/eapis/0.conf
+++ b/paludis/repositories/e/eapis/0.conf
@@ -86,6 +86,10 @@ ebuild_uninstall = \
ebuild_pretend =
+ebuild_info = \
+ sandbox userpriv installed=true : infovars info ; \
+ sandbox userpriv installed=false : infovars
+
ebuild_metadata = \
sandbox userpriv noexec : metadata
diff --git a/paludis/repositories/e/eapis/exheres-0.conf b/paludis/repositories/e/eapis/exheres-0.conf
index a420e5c..2e56980 100644
--- a/paludis/repositories/e/eapis/exheres-0.conf
+++ b/paludis/repositories/e/eapis/exheres-0.conf
@@ -87,6 +87,9 @@ ebuild_uninstall = \
ebuild_pretend = \
sandbox userpriv : pretend
+ebuild_info = \
+ sandbox userpriv : infovars
+
ebuild_metadata = \
sandbox userpriv noexec : metadata
diff --git a/paludis/repositories/e/eapis/paludis-1.conf b/paludis/repositories/e/eapis/paludis-1.conf
index f43ba41..99b4a45 100644
--- a/paludis/repositories/e/eapis/paludis-1.conf
+++ b/paludis/repositories/e/eapis/paludis-1.conf
@@ -89,6 +89,9 @@ ebuild_uninstall = \
ebuild_pretend = \
sandbox userpriv : pretend
+ebuild_info = \
+ sandbox userpriv : infovars
+
ebuild_metadata = \
sandbox userpriv noexec : metadata
diff --git a/paludis/repositories/e/ebuild.cc b/paludis/repositories/e/ebuild.cc
index bfe569c..85cb638 100644
--- a/paludis/repositories/e/ebuild.cc
+++ b/paludis/repositories/e/ebuild.cc
@@ -750,3 +750,64 @@ EbuildPretendCommand::EbuildPretendCommand(const EbuildCommandParams & p,
{
}
+std::string
+EbuildInfoCommand::commands() const
+{
+ return params.commands;
+}
+
+bool
+EbuildInfoCommand::failure()
+{
+ return false;
+}
+
+Command
+EbuildInfoCommand::extend_command(const Command & cmd)
+{
+ std::string info_vars;
+ if (info_params.info_vars.is_regular_file_or_symlink_to_regular_file())
+ {
+ LineConfigFile info_vars_f(info_params.info_vars, LineConfigFileOptions());
+ info_vars = join(info_vars_f.begin(), info_vars_f.end(), " ");
+ }
+
+ Command result(Command(cmd)
+ .with_stdout_prefix(" ")
+ .with_stderr_prefix(" ")
+ .with_prefix_discard_blank_output()
+ .with_prefix_blank_lines()
+ .with_setenv("ROOT", info_params.root)
+ .with_setenv("PALUDIS_INFO_VARS", info_vars)
+ .with_setenv("PALUDIS_PROFILE_DIR",
+ info_params.profiles->empty() ? std::string("") : stringify(*info_params.profiles->begin()))
+ .with_setenv("PALUDIS_PROFILE_DIRS", join(info_params.profiles->begin(),
+ info_params.profiles->end(), " ")));
+
+ if (! params.package_id->eapi()->supported->ebuild_environment_variables->env_use.empty())
+ result.with_setenv(params.package_id->eapi()->supported->ebuild_environment_variables->env_use, info_params.use);
+ if (! params.package_id->eapi()->supported->ebuild_environment_variables->env_use_expand.empty())
+ result.with_setenv(params.package_id->eapi()->supported->ebuild_environment_variables->env_use_expand, info_params.use_expand);
+
+ for (Map<std::string, std::string>::Iterator
+ i(info_params.expand_vars->begin()),
+ j(info_params.expand_vars->end()) ; i != j ; ++i)
+ result.with_setenv(i->first, i->second);
+
+ result.with_uid_gid(params.environment->reduced_uid(), params.environment->reduced_gid());
+
+ if (info_params.load_environment)
+ result
+ .with_setenv("PALUDIS_LOAD_ENVIRONMENT", stringify(*info_params.load_environment))
+ .with_setenv("PALUDIS_SKIP_INHERIT", "yes");
+
+ return result;
+}
+
+EbuildInfoCommand::EbuildInfoCommand(const EbuildCommandParams & p,
+ const EbuildInfoCommandParams & f) :
+ EbuildCommand(p),
+ info_params(f)
+{
+}
+
diff --git a/paludis/repositories/e/ebuild.hh b/paludis/repositories/e/ebuild.hh
index b72edee..495f832 100644
--- a/paludis/repositories/e/ebuild.hh
+++ b/paludis/repositories/e/ebuild.hh
@@ -291,6 +291,31 @@ namespace paludis
};
/**
+ * An EbuildInfoCommand is used to obtain information from a package in a VDBRepository.
+ *
+ * \ingroup grpebuildinterface
+ */
+ class EbuildInfoCommand :
+ public EbuildCommand
+ {
+ protected:
+ /// Parameters for config.
+ const EbuildInfoCommandParams info_params;
+
+ virtual std::string commands() const;
+
+ virtual bool failure();
+
+ virtual Command extend_command(const Command &);
+
+ public:
+ /**
+ * Constructor.
+ */
+ EbuildInfoCommand(const EbuildCommandParams &, const EbuildInfoCommandParams &);
+ };
+
+ /**
* Command for generating VDB entries (not a regular EbuildCommand).
*
* \ingroup grpebuildinterface
diff --git a/paludis/repositories/e/ebuild.sr b/paludis/repositories/e/ebuild.sr
index fbc452c..9e9c3c9 100644
--- a/paludis/repositories/e/ebuild.sr
+++ b/paludis/repositories/e/ebuild.sr
@@ -142,6 +142,29 @@ END
allow_named_args
}
+make_class_EbuildInfoCommandParams()
+{
+ key use std::string
+ key use_expand std::string
+ key root std::string
+ key profiles "tr1::shared_ptr<const FSEntrySequence>"
+ key expand_vars "tr1::shared_ptr<const Map<std::string, std::string> >"
+ key load_environment "const FSEntry *"
+ key info_vars "FSEntry"
+
+ doxygen_comment << "END"
+ /**
+ * Parameters for an EbuildInfoCommand.
+ *
+ * \see EbuildInfoCommand
+ * \ingroup grpebuildinterface
+ * \nosubgrouping
+ */
+END
+
+ allow_named_args
+}
+
make_class_WriteVDBEntryParams()
{
key environment "const Environment *"
diff --git a/paludis/repositories/e/ebuild/Makefile.am b/paludis/repositories/e/ebuild/Makefile.am
index 37c241f..c4121a0 100644
--- a/paludis/repositories/e/ebuild/Makefile.am
+++ b/paludis/repositories/e/ebuild/Makefile.am
@@ -8,6 +8,7 @@ libexecprogdir = $(libexecdir)/paludis/
libexecprog_SCRIPTS = \
build_functions.bash \
+ builtin_infovars.bash \
builtin_init.bash \
builtin_initbin.bash \
builtin_loadenv.bash \
@@ -28,6 +29,7 @@ libexecprog_SCRIPTS = \
list_functions.bash \
multilib_functions.bash \
pkg_config.bash \
+ pkg_info.bash \
pkg_nofetch.bash \
pkg_postinst.bash \
pkg_postrm.bash \
diff --git a/paludis/repositories/e/ebuild/builtin_infovars.bash b/paludis/repositories/e/ebuild/builtin_infovars.bash
new file mode 100644
index 0000000..f289e52
--- /dev/null
+++ b/paludis/repositories/e/ebuild/builtin_infovars.bash
@@ -0,0 +1,54 @@
+#!/bin/bash
+# vim: set sw=4 sts=4 et :
+
+# 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
+
+builtin_infovars()
+{
+ local var
+ for var in ${PALUDIS_INFO_VARS} ; do
+ echo "${var}=${!var}"
+ done
+}
+
+ebuild_f_infovars()
+{
+ if hasq "infovars" ${RESTRICT} ; then
+ ebuild_section "Skipping builtin_infovars (RESTRICT)"
+ elif hasq "infovars" ${SKIP_FUNCTIONS} ; then
+ ebuild_section "Skipping builtin_infovars (SKIP_FUNCTIONS)"
+ else
+ if [[ $(type -t pre_builtin_infovars ) == "function" ]] ; then
+ ebuild_section "Starting pre_builtin_infovars"
+ pre_builtin_infovars
+ ebuild_section "Done pre_builtin_infovars"
+ fi
+
+ ebuild_section "Starting builtin_infovars"
+ builtin_infovars
+ ebuild_section "Done builtin_infovars"
+
+ if [[ $(type -t post_builtin_infovars ) == "function" ]] ; then
+ ebuild_section "Starting post_builtin_infovars"
+ post_builtin_infovars
+ ebuild_section "Done post_builtin_infovars"
+ fi
+ fi
+
+ true
+}
+
+
diff --git a/paludis/repositories/e/ebuild/ebuild.bash b/paludis/repositories/e/ebuild/ebuild.bash
index 149677f..43aadf1 100755
--- a/paludis/repositories/e/ebuild/ebuild.bash
+++ b/paludis/repositories/e/ebuild/ebuild.bash
@@ -374,7 +374,7 @@ ebuild_main()
for action in $@ ; do
case ${action} in
metadata|variable|init|prepare|merge|unmerge|tidyup|\
- strip|loadenv|saveenv|initbin|unpackbin)
+ strip|loadenv|saveenv|initbin|unpackbin|infovars)
ebuild_load_module builtin_${action}
;;
@@ -382,7 +382,7 @@ ebuild_main()
ebuild_load_module src_${action}
;;
- setup|config|nofetch|preinst|postinst|prerm|postrm|pretend)
+ setup|config|nofetch|preinst|postinst|prerm|postrm|pretend|info)
ebuild_load_module pkg_${action}
;;
diff --git a/paludis/repositories/e/ebuild/pkg_info.bash b/paludis/repositories/e/ebuild/pkg_info.bash
new file mode 100644
index 0000000..bfe327e
--- /dev/null
+++ b/paludis/repositories/e/ebuild/pkg_info.bash
@@ -0,0 +1,50 @@
+#!/bin/bash
+# vim: set sw=4 sts=4 et :
+
+# 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
+
+pkg_info()
+{
+ echo "No additional information available"
+}
+
+ebuild_f_info()
+{
+ if hasq "info" ${RESTRICT} ; then
+ ebuild_section "Skipping pkg_info (RESTRICT)"
+ elif hasq "info" ${SKIP_FUNCTIONS} ; then
+ ebuild_section "Skipping pkg_info (SKIP_FUNCTIONS)"
+ else
+ if [[ $(type -t pre_pkg_info ) == "function" ]] ; then
+ ebuild_section "Starting pre_pkg_info"
+ pre_pkg_info
+ ebuild_section "Done pre_pkg_info"
+ fi
+
+ ebuild_section "Starting pkg_info"
+ pkg_info
+ ebuild_section "Done pkg_info"
+
+ if [[ $(type -t post_pkg_info ) == "function" ]] ; then
+ ebuild_section "Starting post_pkg_info"
+ post_pkg_info
+ ebuild_section "Done post_pkg_info"
+ fi
+ fi
+
+ true
+}
+
diff --git a/paludis/repositories/e/ebuild_entries.cc b/paludis/repositories/e/ebuild_entries.cc
index e4c8f92..f690b7a 100644
--- a/paludis/repositories/e/ebuild_entries.cc
+++ b/paludis/repositories/e/ebuild_entries.cc
@@ -662,6 +662,84 @@ EbuildEntries::install(const tr1::shared_ptr<const ERepositoryID> & id,
}
}
+void
+EbuildEntries::info(const tr1::shared_ptr<const ERepositoryID> & id,
+ tr1::shared_ptr<const ERepositoryProfile> p) const
+{
+ using namespace tr1::placeholders;
+
+ Context context("When infoing '" + stringify(*id) + "':");
+
+ bool userpriv_restrict;
+ {
+ DepSpecFlattener restricts(_imp->params.environment, id);
+ if (id->restrict_key())
+ id->restrict_key()->value()->accept(restricts);
+
+ userpriv_restrict =
+ restricts.end() != std::find_if(restricts.begin(), restricts.end(),
+ tr1::bind(std::equal_to<std::string>(), tr1::bind(tr1::mem_fn(&StringDepSpec::text), _1), "userpriv")) ||
+ restricts.end() != std::find_if(restricts.begin(), restricts.end(),
+ tr1::bind(std::equal_to<std::string>(), tr1::bind(tr1::mem_fn(&StringDepSpec::text), _1), "nouserpriv"));
+ }
+
+ /* make use */
+ std::string use(make_use(_imp->params.environment, *id, p));
+
+ /* add expand to use (iuse isn't reliable for use_expand things), and make the expand
+ * environment variables */
+ std::string expand_sep(stringify(id->eapi()->supported->ebuild_options->use_expand_separator));
+ tr1::shared_ptr<Map<std::string, std::string> > expand_vars(make_expand(
+ _imp->params.environment, *id, p, use, expand_sep));
+
+ tr1::shared_ptr<const FSEntrySequence> exlibsdirs(_imp->e_repository->layout()->exlibsdirs(id->name()));
+
+ EAPIPhases phases(id->eapi()->supported->ebuild_phases->ebuild_info);
+ for (EAPIPhases::Iterator phase(phases.begin_phases()), phase_end(phases.end_phases()) ;
+ phase != phase_end ; ++phase)
+ {
+ if (phase->option("installed=true"))
+ continue;
+
+ EbuildCommandParams command_params(EbuildCommandParams::create()
+ .environment(_imp->params.environment)
+ .package_id(id)
+ .ebuild_dir(_imp->e_repository->layout()->package_directory(id->name()))
+ .ebuild_file(_imp->e_repository->layout()->package_file(*id))
+ .files_dir(_imp->e_repository->layout()->package_directory(id->name()) / "files")
+ .eclassdirs(_imp->params.eclassdirs)
+ .exlibsdirs(exlibsdirs)
+ .portdir(_imp->params.master_repository ? _imp->params.master_repository->params().location :
+ _imp->params.location)
+ .distdir(_imp->params.distdir)
+ .commands(join(phase->begin_commands(), phase->end_commands(), " "))
+ .sandbox(phase->option("sandbox"))
+ .userpriv(phase->option("userpriv"))
+ .builddir(_imp->params.builddir));
+
+ FSEntry i(_imp->e_repository->layout()->info_variables_file(
+ _imp->e_repository->params().location / "profiles"));
+
+ if (_imp->e_repository->params().master_repository && ! i.exists())
+ i = _imp->e_repository->params().master_repository->layout()->info_variables_file(
+ _imp->e_repository->params().master_repository->params().location / "profiles");
+
+ EbuildInfoCommandParams info_params(
+ EbuildInfoCommandParams::create()
+ .use(use)
+ .use_expand(join(p->begin_use_expand(), p->end_use_expand(), " "))
+ .expand_vars(expand_vars)
+ .root(stringify(_imp->params.environment->root()))
+ .profiles(_imp->params.profiles)
+ .load_environment(0)
+ .info_vars(i)
+ );
+
+ EbuildInfoCommand cmd(command_params, info_params);
+ cmd();
+ }
+}
+
std::string
EbuildEntries::get_environment_variable(const tr1::shared_ptr<const ERepositoryID> & id,
const std::string & var, tr1::shared_ptr<const ERepositoryProfile>) const
diff --git a/paludis/repositories/e/ebuild_entries.hh b/paludis/repositories/e/ebuild_entries.hh
index d5848da..52ceefa 100644
--- a/paludis/repositories/e/ebuild_entries.hh
+++ b/paludis/repositories/e/ebuild_entries.hh
@@ -88,6 +88,9 @@ namespace paludis
virtual bool pretend(const tr1::shared_ptr<const ERepositoryID> &,
tr1::shared_ptr<const ERepositoryProfile>) const;
+ virtual void info(const tr1::shared_ptr<const ERepositoryID> &,
+ tr1::shared_ptr<const ERepositoryProfile>) const;
+
virtual std::string get_package_file_manifest_key(const FSEntry &, const QualifiedPackageName &) const;
};
}
diff --git a/paludis/repositories/e/ebuild_id.cc b/paludis/repositories/e/ebuild_id.cc
index 6fb57c0..e1a08e9 100644
--- a/paludis/repositories/e/ebuild_id.cc
+++ b/paludis/repositories/e/ebuild_id.cc
@@ -791,6 +791,11 @@ namespace
result = true;
}
+ void visit(const SupportsActionTest<InfoAction> &)
+ {
+ result = true;
+ }
+
void visit(const SupportsActionTest<UninstallAction> &)
{
}
@@ -843,6 +848,13 @@ namespace
tr1::static_pointer_cast<const ERepository>(id->repository())->profile());
}
+ void visit(const InfoAction &)
+ {
+ tr1::static_pointer_cast<const ERepository>(id->repository())->entries()->info(
+ tr1::static_pointer_cast<const ERepositoryID>(id),
+ tr1::static_pointer_cast<const ERepository>(id->repository())->profile());
+ }
+
void visit(const InstalledAction & a) PALUDIS_ATTRIBUTE((noreturn));
void visit(const UninstallAction & a) PALUDIS_ATTRIBUTE((noreturn));
void visit(const ConfigAction & a) PALUDIS_ATTRIBUTE((noreturn));
diff --git a/paludis/repositories/e/vdb_id.cc b/paludis/repositories/e/vdb_id.cc
index 46b1659..7646671 100644
--- a/paludis/repositories/e/vdb_id.cc
+++ b/paludis/repositories/e/vdb_id.cc
@@ -639,6 +639,11 @@ namespace
{
}
+ void visit(const SupportsActionTest<InfoAction> &)
+ {
+ result = true;
+ }
+
void visit(const SupportsActionTest<UninstallAction> &)
{
result = true;
@@ -681,6 +686,11 @@ namespace
tr1::static_pointer_cast<const VDBRepository>(id->repository())->perform_config(id);
}
+ void visit(const InfoAction &)
+ {
+ tr1::static_pointer_cast<const VDBRepository>(id->repository())->perform_info(id);
+ }
+
void visit(const InstallAction & a) PALUDIS_ATTRIBUTE((noreturn));
void visit(const PretendAction & a) PALUDIS_ATTRIBUTE((noreturn));
void visit(const FetchAction & a) PALUDIS_ATTRIBUTE((noreturn));
diff --git a/paludis/repositories/e/vdb_repository.cc b/paludis/repositories/e/vdb_repository.cc
index 1ad7f7b..c8e1b0a 100644
--- a/paludis/repositories/e/vdb_repository.cc
+++ b/paludis/repositories/e/vdb_repository.cc
@@ -25,6 +25,8 @@
#include <paludis/repositories/e/eapi.hh>
#include <paludis/repositories/e/dep_parser.hh>
#include <paludis/repositories/e/dep_spec_pretty_printer.hh>
+#include <paludis/repositories/e/e_repository_params.hh>
+#include <paludis/repositories/e/e_repository.hh>
#include <paludis/action.hh>
#include <paludis/config_file.hh>
@@ -493,6 +495,94 @@ VDBRepository::perform_config(const tr1::shared_ptr<const ERepositoryID> & id) c
}
}
+void
+VDBRepository::perform_info(const tr1::shared_ptr<const ERepositoryID> & id) const
+{
+ Context context("When infoing '" + stringify(*id) + "':");
+
+ if (! _imp->params.root.is_directory())
+ throw InstallActionError("Couldn't info '" + stringify(*id) +
+ "' because root ('" + stringify(_imp->params.root) + "') is not a directory");
+
+ tr1::shared_ptr<FSEntrySequence> eclassdirs(new FSEntrySequence);
+ eclassdirs->push_back(FSEntry(_imp->params.location / stringify(id->name().category) /
+ (stringify(id->name().package) + "-" + stringify(id->version()))));
+
+ FSEntry pkg_dir(_imp->params.location / stringify(id->name().category) /
+ (stringify(id->name().package) + "-" + stringify(id->version())));
+ tr1::shared_ptr<FSEntry> load_env(new FSEntry(pkg_dir / "environment.bz2"));
+
+ EAPIPhases phases(id->eapi()->supported->ebuild_phases->ebuild_info);
+
+ for (EAPIPhases::Iterator phase(phases.begin_phases()), phase_end(phases.end_phases()) ;
+ phase != phase_end ; ++phase)
+ {
+ if (phase->option("installed=false"))
+ continue;
+
+ /* try to find an info_vars file from the original repo */
+ FSEntry i("/dev/null");
+ if (id->source_origin_key())
+ {
+ RepositoryName rn(id->source_origin_key()->value());
+ if (_imp->params.environment->package_database()->has_repository_named(rn))
+ {
+ const tr1::shared_ptr<const Repository> r(_imp->params.environment->package_database()->fetch_repository(rn));
+ if (r->e_interface)
+ {
+ i = r->e_interface->info_variables_file(r->e_interface->params().location / "profiles");
+
+ /* also try its master, if it has one */
+ if ((! i.exists()) && r->e_interface->params().master_repository)
+ i = r->e_interface->info_variables_file(r->e_interface->params().master_repository->params().location / "profiles");
+ }
+ }
+ }
+
+ /* try to find an info_vars file from any repo */
+ if (i == FSEntry("/dev/null"))
+ {
+ for (PackageDatabase::RepositoryIterator r(_imp->params.environment->package_database()->begin_repositories()),
+ r_end(_imp->params.environment->package_database()->end_repositories()) ;
+ r != r_end ; ++r)
+ {
+ if (! (*r)->e_interface)
+ continue;
+
+ i = (*r)->e_interface->info_variables_file((*r)->e_interface->params().location / "profiles");
+ if (i.exists())
+ break;
+ }
+ }
+
+ EbuildInfoCommand info_cmd(EbuildCommandParams::create()
+ .environment(_imp->params.environment)
+ .package_id(id)
+ .ebuild_dir(pkg_dir)
+ .ebuild_file(pkg_dir / (stringify(id->name().package) + "-" + stringify(id->version()) + ".ebuild"))
+ .files_dir(pkg_dir)
+ .eclassdirs(eclassdirs)
+ .exlibsdirs(make_shared_ptr(new FSEntrySequence))
+ .portdir(_imp->params.location)
+ .distdir(pkg_dir)
+ .sandbox(phase->option("sandbox"))
+ .userpriv(phase->option("userpriv"))
+ .commands(join(phase->begin_commands(), phase->end_commands(), " "))
+ .builddir(_imp->params.builddir),
+
+ EbuildInfoCommandParams::create()
+ .root(stringify(_imp->params.root) + "/")
+ .use("")
+ .use_expand("")
+ .expand_vars(make_shared_ptr(new Map<std::string, std::string>))
+ .profiles(make_shared_ptr(new FSEntrySequence))
+ .info_vars(i)
+ .load_environment(load_env.get()));
+
+ info_cmd();
+ }
+}
+
tr1::shared_ptr<SetSpecTree::ConstItem>
VDBRepository::do_package_set(const SetName & s) const
{
@@ -1204,6 +1294,11 @@ namespace
{
}
+ void visit(const SupportsActionTest<InfoAction> &)
+ {
+ result = true;
+ }
+
void visit(const SupportsActionTest<UninstallAction> &)
{
result = true;
diff --git a/paludis/repositories/e/vdb_repository.hh b/paludis/repositories/e/vdb_repository.hh
index 058a293..36ebb7c 100644
--- a/paludis/repositories/e/vdb_repository.hh
+++ b/paludis/repositories/e/vdb_repository.hh
@@ -234,6 +234,8 @@ namespace paludis
void perform_config(const tr1::shared_ptr<const erepository::ERepositoryID> & id) const;
+ void perform_info(const tr1::shared_ptr<const erepository::ERepositoryID> & id) const;
+
///\}
};
diff --git a/paludis/repositories/fake/fake_installed_repository.cc b/paludis/repositories/fake/fake_installed_repository.cc
index ef39e40..4030c05 100644
--- a/paludis/repositories/fake/fake_installed_repository.cc
+++ b/paludis/repositories/fake/fake_installed_repository.cc
@@ -157,6 +157,10 @@ namespace
{
}
+ void visit(const SupportsActionTest<InfoAction> &)
+ {
+ }
+
void visit(const SupportsActionTest<UninstallAction> &)
{
}
diff --git a/paludis/repositories/fake/fake_package_id.cc b/paludis/repositories/fake/fake_package_id.cc
index 40d3c6a..90f5ac9 100644
--- a/paludis/repositories/fake/fake_package_id.cc
+++ b/paludis/repositories/fake/fake_package_id.cc
@@ -732,6 +732,13 @@ namespace
throw UnsupportedActionError(*id, a);
}
+ void visit(const InfoAction & a)
+ {
+ SupportsActionTest<InfoAction> t;
+ if (! id->repository()->some_ids_might_support_action(t))
+ throw UnsupportedActionError(*id, a);
+ }
+
void visit(const PretendAction & a)
{
SupportsActionTest<PretendAction> t;
diff --git a/paludis/repositories/fake/fake_repository.cc b/paludis/repositories/fake/fake_repository.cc
index 39f5772..219378b 100644
--- a/paludis/repositories/fake/fake_repository.cc
+++ b/paludis/repositories/fake/fake_repository.cc
@@ -141,6 +141,10 @@ namespace
{
}
+ void visit(const SupportsActionTest<InfoAction> &)
+ {
+ }
+
void visit(const SupportsActionTest<UninstallAction> &)
{
}
diff --git a/paludis/repositories/gems/gem_specification.cc b/paludis/repositories/gems/gem_specification.cc
index 78f178a..ac35ad9 100644
--- a/paludis/repositories/gems/gem_specification.cc
+++ b/paludis/repositories/gems/gem_specification.cc
@@ -629,6 +629,13 @@ namespace
throw UnsupportedActionError(*id, a);
}
+ void visit(const InfoAction & a)
+ {
+ SupportsActionTest<InfoAction> t;
+ if (! id->repository()->some_ids_might_support_action(t))
+ throw UnsupportedActionError(*id, a);
+ }
+
void visit(const PretendAction & a)
{
SupportsActionTest<PretendAction> t;
diff --git a/paludis/repositories/gems/gems_repository.cc b/paludis/repositories/gems/gems_repository.cc
index 4e74cad..2ce566b 100644
--- a/paludis/repositories/gems/gems_repository.cc
+++ b/paludis/repositories/gems/gems_repository.cc
@@ -290,6 +290,10 @@ namespace
{
}
+ void visit(const SupportsActionTest<InfoAction> &)
+ {
+ }
+
void visit(const SupportsActionTest<UninstallAction> &)
{
}
diff --git a/paludis/repositories/gems/installed_gems_repository.cc b/paludis/repositories/gems/installed_gems_repository.cc
index d5f4c7a..1411772 100644
--- a/paludis/repositories/gems/installed_gems_repository.cc
+++ b/paludis/repositories/gems/installed_gems_repository.cc
@@ -323,6 +323,10 @@ namespace
{
}
+ void visit(const SupportsActionTest<InfoAction> &)
+ {
+ }
+
void visit(const SupportsActionTest<UninstallAction> &)
{
result = true;
diff --git a/paludis/repositories/virtuals/installed_virtuals_repository.cc b/paludis/repositories/virtuals/installed_virtuals_repository.cc
index 1fe5dde..d85da73 100644
--- a/paludis/repositories/virtuals/installed_virtuals_repository.cc
+++ b/paludis/repositories/virtuals/installed_virtuals_repository.cc
@@ -310,6 +310,10 @@ namespace
{
}
+ void visit(const SupportsActionTest<InfoAction> &)
+ {
+ }
+
void visit(const SupportsActionTest<UninstallAction> &)
{
}
diff --git a/paludis/repositories/virtuals/package_id.cc b/paludis/repositories/virtuals/package_id.cc
index e3a5d19..9578361 100644
--- a/paludis/repositories/virtuals/package_id.cc
+++ b/paludis/repositories/virtuals/package_id.cc
@@ -433,6 +433,13 @@ namespace
throw UnsupportedActionError(*id, a);
}
+ void visit(const InfoAction & a)
+ {
+ SupportsActionTest<InfoAction> t;
+ if (! id->repository()->some_ids_might_support_action(t))
+ throw UnsupportedActionError(*id, a);
+ }
+
void visit(const PretendAction & a)
{
SupportsActionTest<PretendAction> t;
diff --git a/paludis/repositories/virtuals/virtuals_repository.cc b/paludis/repositories/virtuals/virtuals_repository.cc
index e60f699..22eed21 100644
--- a/paludis/repositories/virtuals/virtuals_repository.cc
+++ b/paludis/repositories/virtuals/virtuals_repository.cc
@@ -388,6 +388,10 @@ namespace
{
}
+ void visit(const SupportsActionTest<InfoAction> &)
+ {
+ }
+
void visit(const SupportsActionTest<UninstallAction> &)
{
}
diff --git a/paludis/repository.hh b/paludis/repository.hh
index 62ec2f2..52bb1bb 100644
--- a/paludis/repository.hh
+++ b/paludis/repository.hh
@@ -756,6 +756,13 @@ namespace paludis
///\}
+ ///\name Layout helpers
+ ///\{
+
+ virtual FSEntry info_variables_file(const FSEntry &) const = 0;
+
+ ///\}
+
virtual ~RepositoryEInterface();
};
diff --git a/src/clients/paludis/Makefile.am b/src/clients/paludis/Makefile.am
index 592f17b..8e741f0 100644
--- a/src/clients/paludis/Makefile.am
+++ b/src/clients/paludis/Makefile.am
@@ -4,7 +4,9 @@ DEFS= \
-DSYSCONFDIR=\"$(sysconfdir)\" \
-DDATADIR=\"$(datadir)\" \
-DLIBEXECDIR=\"$(libexecdir)\" \
- -DLIBDIR=\"$(libdir)\"
+ -DLIBDIR=\"$(libdir)\" \
+ -DPYTHONINSTALLDIR=\"$(PYTHON_INSTALL_DIR)\" \
+ -DRUBYINSTALLDIR=\"$(RUBY_INSTALL_DIR)\"
SUBDIRS = .
@@ -36,6 +38,7 @@ man_paludis_LDADD = \
paludis_SOURCES = \
applets.hh applets.cc \
command_line.hh command_line.cc \
+ info.hh info.cc \
install.hh install.cc \
uninstall.hh uninstall.cc \
list.hh list.cc \
diff --git a/src/clients/paludis/command_line.cc b/src/clients/paludis/command_line.cc
index 64905d6..f821ac5 100644
--- a/src/clients/paludis/command_line.cc
+++ b/src/clients/paludis/command_line.cc
@@ -263,7 +263,7 @@ CommandLine::CommandLine() :
add_usage_line("--contents target ...");
add_usage_line("--owner [owner options] files ...");
add_usage_line("--version");
- add_usage_line("--info");
+ add_usage_line("--info [target ...]");
add_usage_line("--help");
add_usage_line("--has-version spec");
diff --git a/src/clients/paludis/info.cc b/src/clients/paludis/info.cc
new file mode 100644
index 0000000..648fc95
--- /dev/null
+++ b/src/clients/paludis/info.cc
@@ -0,0 +1,190 @@
+/* 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 "info.hh"
+#include "command_line.hh"
+#include "src/output/colour.hh"
+#include <paludis/about.hh>
+#include <paludis/util/iterator.hh>
+#include <paludis/util/sequence.hh>
+#include <paludis/package_database.hh>
+#include <paludis/environment.hh>
+#include <paludis/repository_info.hh>
+#include <paludis/query.hh>
+#include <paludis/package_id.hh>
+#include <paludis/action.hh>
+#include <iostream>
+#include <iomanip>
+#include <libebt/libebt.hh>
+#include <libwrapiter/libwrapiter.hh>
+
+using namespace paludis;
+using std::endl;
+using std::cout;
+
+int do_one_info(
+ const tr1::shared_ptr<const Environment> & env,
+ const std::string & q)
+{
+ Context local_context("When handling query '" + q + "':");
+
+ tr1::shared_ptr<PackageDepSpec> spec;
+ if (std::string::npos != q.find('/'))
+ spec.reset(new PackageDepSpec(q, pds_pm_permissive));
+ else
+ spec.reset(new PackageDepSpec(tr1::shared_ptr<QualifiedPackageName>(new QualifiedPackageName(
+ env->package_database()->fetch_unique_qualified_package_name(PackageNamePart(q))))));
+
+ tr1::shared_ptr<const PackageIDSequence>
+ entries(env->package_database()->query(query::Matches(*spec), qo_order_by_version)),
+ preferred_entries(env->package_database()->query(
+ query::Matches(*spec) & query::InstalledAtRoot(env->root()), qo_order_by_version));
+
+ if (entries->empty())
+ throw NoSuchPackageError(q);
+ if (preferred_entries->empty())
+ preferred_entries = entries;
+
+ tr1::shared_ptr<const PackageID> display_entry(*preferred_entries->last());
+ for (PackageIDSequence::Iterator i(preferred_entries->begin()),
+ i_end(preferred_entries->end()) ; i != i_end ; ++i)
+ if (! (*i)->masked())
+ display_entry = *i;
+
+ InfoAction a;
+ try
+ {
+ cout << "Package " << colour(cl_package_name, *display_entry) << ":" << endl;
+ cout << endl;
+ display_entry->perform_action(a);
+ cout << endl;
+ }
+ catch (const UnsupportedActionError &)
+ {
+ cout << " No extra information available for '" << *display_entry << "'" << endl;
+ cout << endl;
+ return 1;
+ }
+
+ return 0;
+}
+
+int
+do_info(const tr1::shared_ptr<const Environment> & env)
+{
+ int return_code(0);
+
+ cout << "Paludis build information:" << endl;
+
+ cout << " " << colour(cl_heading, "Compiler:") << endl;
+ cout << " " << std::setw(22) << std::left << ("CXX:") << std::setw(0) << " " << PALUDIS_BUILD_CXX
+#if defined(__ICC)
+ << " " << __ICC
+#elif defined(__VERSION__)
+ << " " << __VERSION__
+#endif
+ << endl;
+
+ cout << " " << std::setw(22) << std::left << ("CXXFLAGS:") << std::setw(0) << " " << PALUDIS_BUILD_CXXFLAGS << endl;
+ cout << " " << std::setw(22) << std::left << ("LDFLAGS:") << std::setw(0) << " " << PALUDIS_BUILD_LDFLAGS << endl;
+ cout << " " << std::setw(22) << std::left << ("DATE:") << std::setw(0) << " " << PALUDIS_BUILD_DATE << endl;
+
+ cout << endl;
+
+ cout << " " << colour(cl_heading, "Libraries:") << endl;
+ cout << " " << std::setw(22) << std::left << ("C++ Library:") << std::setw(0) << " "
+#if defined(__GLIBCXX__)
+# define XSTRINGIFY(x) #x
+# define STRINGIFY(x) XSTRINGIFY(x)
+ << "GNU libstdc++ " << STRINGIFY(__GLIBCXX__)
+#endif
+ << endl;
+ cout << " " << std::setw(22) << std::left << ("libebt:") << std::setw(0) << " "
+ << LIBEBT_VERSION_MAJOR << "." << LIBEBT_VERSION_MINOR << "." << LIBEBT_VERSION_MICRO << endl;
+ cout << " " << std::setw(22) << std::left << ("libwrapiter:") << std::setw(0) << " "
+ << LIBWRAPITER_VERSION_MAJOR << "." << LIBWRAPITER_VERSION_MINOR << "." << LIBWRAPITER_VERSION_MICRO << endl;
+
+ cout << endl;
+
+ cout << " " << colour(cl_heading, "Paths:") << endl;
+
+ cout << " " << std::setw(22) << std::left << ("DATADIR:") << std::setw(0) << " " << DATADIR << endl;
+ cout << " " << std::setw(22) << std::left << ("LIBDIR:") << std::setw(0) << " " << LIBDIR << endl;
+ cout << " " << std::setw(22) << std::left << ("LIBEXECDIR:") << std::setw(0) << " " << LIBEXECDIR << endl;
+ cout << " " << std::setw(22) << std::left << ("SYSCONFDIR:") << std::setw(0) << " " << SYSCONFDIR << endl;
+ cout << " " << std::setw(22) << std::left << ("PYTHONINSTALLDIR:") << std::setw(0) << " " << PYTHONINSTALLDIR << endl;
+ cout << " " << std::setw(22) << std::left << ("RUBYINSTALLDIR:") << std::setw(0) << " " << RUBYINSTALLDIR << endl;
+
+ cout << endl;
+
+ for (IndirectIterator<PackageDatabase::RepositoryIterator, const Repository>
+ r(env->package_database()->begin_repositories()), r_end(env->package_database()->end_repositories()) ;
+ r != r_end ; ++r)
+ {
+ cout << "Repository " << colour(cl_repository_name, r->name()) << ":" << endl;
+
+ tr1::shared_ptr<const RepositoryInfo> ii(r->info(true));
+ for (RepositoryInfo::SectionIterator i(ii->begin_sections()),
+ i_end(ii->end_sections()) ; i != i_end ; ++i)
+ {
+ cout << " " << colour(cl_heading, (*i)->heading() + ":") << endl;
+ for (RepositoryInfoSection::KeyValueIterator k((*i)->begin_kvs()),
+ k_end((*i)->end_kvs()) ; k != k_end ; ++k)
+ cout << " " << std::setw(22) << std::left << (stringify(k->first) + ":")
+ << std::setw(0) << " " << k->second << endl;
+ cout << endl;
+ }
+ }
+
+ if (CommandLine::get_instance()->empty())
+ {
+ cout << endl;
+ cout << "No packages were specified on the command line, so detailed information is not" << endl;
+ cout << "available (Paludis can display detailed information for both installed and" << endl;
+ cout << "installable packages)." << endl;
+ cout << endl;
+ }
+ else
+ {
+ for (CommandLine::ParametersIterator q(CommandLine::get_instance()->begin_parameters()),
+ q_end(CommandLine::get_instance()->end_parameters()) ;
+ q != q_end ; ++q)
+ {
+ try
+ {
+ return_code |= do_one_info(env, *q);
+ }
+ catch (const AmbiguousPackageNameError & e)
+ {
+ cout << endl;
+ cout << "Query error:" << endl;
+ cout << " * " << e.backtrace("\n * ");
+ cout << "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)
+ cout << " * " << colour(cl_package_name, *o) << endl;
+ cout << endl;
+ return_code |= 1;
+ }
+ }
+ }
+
+ return return_code;
+}
+
diff --git a/src/clients/paludis/info.hh b/src/clients/paludis/info.hh
new file mode 100644
index 0000000..77cbdb1
--- /dev/null
+++ b/src/clients/paludis/info.hh
@@ -0,0 +1,29 @@
+/* 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_CLIENTS_PALUDIS_INFO_HH
+#define PALUDIS_GUARD_SRC_CLIENTS_PALUDIS_INFO_HH 1
+
+#include <paludis/util/tr1_memory.hh>
+#include <paludis/environment-fwd.hh>
+
+/// Handle --info.
+int do_info(const paludis::tr1::shared_ptr<const paludis::Environment> &);
+
+#endif
diff --git a/src/clients/paludis/paludis.cc b/src/clients/paludis/paludis.cc
index 5f8b3c7..b3dc2ba 100644
--- a/src/clients/paludis/paludis.cc
+++ b/src/clients/paludis/paludis.cc
@@ -24,6 +24,7 @@
#include "do_config.hh"
#include "install.hh"
#include "list.hh"
+#include "info.hh"
#include "owner.hh"
#include "query.hh"
#include "report.hh"
@@ -72,62 +73,7 @@ namespace
<< PALUDIS_VERSION_MINOR << "." << PALUDIS_VERSION_MICRO;
if (! std::string(PALUDIS_SUBVERSION_REVISION).empty())
cout << " svn " << PALUDIS_SUBVERSION_REVISION;
- cout << endl << endl;
- cout << "Built by " << PALUDIS_BUILD_USER << "@" << PALUDIS_BUILD_HOST
- << " on " << PALUDIS_BUILD_DATE << endl;
- cout << "CXX: " << PALUDIS_BUILD_CXX
-#if defined(__ICC)
- << " " << __ICC
-#elif defined(__VERSION__)
- << " " << __VERSION__
-#endif
- << endl;
- cout << "CXXFLAGS: " << PALUDIS_BUILD_CXXFLAGS << endl;
- cout << "LDFLAGS: " << PALUDIS_BUILD_LDFLAGS << endl;
- cout << "DATADIR: " << DATADIR << endl;
- cout << "LIBDIR: " << LIBDIR << endl;
- cout << "LIBEXECDIR: " << LIBEXECDIR << endl;
- cout << "SYSCONFDIR: " << SYSCONFDIR << endl;
- cout << "stdlib: "
-#if defined(__GLIBCXX__)
-# define XSTRINGIFY(x) #x
-# define STRINGIFY(x) XSTRINGIFY(x)
- << "GNU libstdc++ " << STRINGIFY(__GLIBCXX__)
-#endif
- << endl;
-
- cout << "libebt: " << LIBEBT_VERSION_MAJOR << "." << LIBEBT_VERSION_MINOR
- << "." << LIBEBT_VERSION_MICRO << endl;
- cout << "libwrapiter: " << LIBWRAPITER_VERSION_MAJOR << "." << LIBWRAPITER_VERSION_MINOR
- << "." << LIBWRAPITER_VERSION_MICRO << endl;
-#if HAVE_SANDBOX
- cout << "sandbox: enabled" << endl;
-#else
- cout << "sandbox: disabled" << endl;
-#endif
- }
-
- void display_info(tr1::shared_ptr<Environment> env)
- {
- for (IndirectIterator<PackageDatabase::RepositoryIterator, const Repository>
- r(env->package_database()->begin_repositories()), r_end(env->package_database()->end_repositories()) ;
- r != r_end ; ++r)
- {
- cout << "Repository " << colour(cl_repository_name, r->name()) << ":" << endl;
-
- tr1::shared_ptr<const RepositoryInfo> ii(r->info(true));
- for (RepositoryInfo::SectionIterator i(ii->begin_sections()),
- i_end(ii->end_sections()) ; i != i_end ; ++i)
- {
- cout << " " << colour(cl_heading, (*i)->heading() + ":") << endl;
- for (RepositoryInfoSection::KeyValueIterator k((*i)->begin_kvs()),
- k_end((*i)->end_kvs()) ; k != k_end ; ++k)
- cout << " " << std::setw(22) << std::left << (stringify(k->first) + ":")
- << std::setw(0) << " " << k->second << endl;
- cout << endl;
- }
- }
-
+ cout << endl;
}
}
@@ -359,10 +305,7 @@ main(int argc, char *argv[])
if (CommandLine::get_instance()->a_info.specified())
{
display_version();
- cout << endl;
- display_info(env);
- cout << endl;
- return EXIT_SUCCESS;
+ return do_info(env);
}
if (CommandLine::get_instance()->a_query.specified())