aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-05-17 15:50:08 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-05-17 15:50:08 +0000
commitd76f3d55ab629e1f34c93ba73240249173804901 (patch)
treef1da20ac85ae7f10684beba6026cec59e4c53825
parent5109758e7332f0704a3e74788d8b59a79e555cad (diff)
downloadpaludis-d76f3d55ab629e1f34c93ba73240249173804901.tar.gz
paludis-d76f3d55ab629e1f34c93ba73240249173804901.tar.xz
pkg_pretend
-rw-r--r--paludis/eapi.cc8
-rw-r--r--paludis/eapi.sr1
-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/gentoo/ebin_entries.cc7
-rw-r--r--paludis/repositories/gentoo/ebin_entries.hh6
-rw-r--r--paludis/repositories/gentoo/ebuild.cc40
-rw-r--r--paludis/repositories/gentoo/ebuild.hh25
-rw-r--r--paludis/repositories/gentoo/ebuild.sr21
-rw-r--r--paludis/repositories/gentoo/ebuild/Makefile.am1
-rwxr-xr-xpaludis/repositories/gentoo/ebuild/ebuild.bash6
-rw-r--r--paludis/repositories/gentoo/ebuild/pkg_pretend.bash46
-rw-r--r--paludis/repositories/gentoo/ebuild_entries.cc175
-rw-r--r--paludis/repositories/gentoo/ebuild_entries.hh3
-rw-r--r--paludis/repositories/gentoo/portage_repository.cc8
-rw-r--r--paludis/repositories/gentoo/portage_repository.hh3
-rw-r--r--paludis/repositories/gentoo/portage_repository_entries.hh6
-rw-r--r--paludis/repositories/gentoo/vdb_repository.cc1
-rw-r--r--paludis/repositories/virtuals/installed_virtuals_repository.cc1
-rw-r--r--paludis/repositories/virtuals/virtuals_repository.cc1
-rw-r--r--paludis/repository-fwd.hh1
-rw-r--r--paludis/repository.cc10
-rw-r--r--paludis/repository.hh43
-rw-r--r--paludis/repository.sr1
-rw-r--r--paludis/tasks/install_task.cc14
28 files changed, 373 insertions, 60 deletions
diff --git a/paludis/eapi.cc b/paludis/eapi.cc
index 9455d85..2bab4c3 100644
--- a/paludis/eapi.cc
+++ b/paludis/eapi.cc
@@ -34,16 +34,16 @@ namespace paludis
Implementation()
{
values.insert(std::make_pair("0", EAPI("0", std::tr1::shared_ptr<SupportedEAPI>(new SupportedEAPI(
- pds_pm_eapi_0, pds_pm_eapi_0_strict, iuse_pm_eapi_0, iuse_pm_eapi_0_strict, false)))));
+ pds_pm_eapi_0, pds_pm_eapi_0_strict, iuse_pm_eapi_0, iuse_pm_eapi_0_strict, false, false)))));
values.insert(std::make_pair("", EAPI("", std::tr1::shared_ptr<SupportedEAPI>(new SupportedEAPI(
- pds_pm_eapi_0, pds_pm_eapi_0_strict, iuse_pm_eapi_0, iuse_pm_eapi_0_strict, false)))));
+ pds_pm_eapi_0, pds_pm_eapi_0_strict, iuse_pm_eapi_0, iuse_pm_eapi_0_strict, false, false)))));
values.insert(std::make_pair("paludis-1", EAPI("paludis-1", std::tr1::shared_ptr<SupportedEAPI>(new SupportedEAPI(
- pds_pm_permissive, pds_pm_permissive, iuse_pm_permissive, iuse_pm_permissive, true)))));
+ pds_pm_permissive, pds_pm_permissive, iuse_pm_permissive, iuse_pm_permissive, true, true)))));
values.insert(std::make_pair("CRAN-1", EAPI("CRAN-1", std::tr1::shared_ptr<SupportedEAPI>(new SupportedEAPI(
- pds_pm_permissive, pds_pm_permissive, iuse_pm_permissive, iuse_pm_permissive, true)))));
+ pds_pm_permissive, pds_pm_permissive, iuse_pm_permissive, iuse_pm_permissive, true, false)))));
}
};
}
diff --git a/paludis/eapi.sr b/paludis/eapi.sr
index 5e927b6..14cba9f 100644
--- a/paludis/eapi.sr
+++ b/paludis/eapi.sr
@@ -9,6 +9,7 @@ make_class_SupportedEAPI()
key strict_iuse_flag_parse_mode IUseFlagParseMode
key breaks_portage bool
+ key has_pretend_phase bool
allow_named_args
diff --git a/paludis/repositories/cran/cran_installed_repository.cc b/paludis/repositories/cran/cran_installed_repository.cc
index 166ad03..6af8664 100644
--- a/paludis/repositories/cran/cran_installed_repository.cc
+++ b/paludis/repositories/cran/cran_installed_repository.cc
@@ -188,6 +188,7 @@ CRANInstalledRepository::CRANInstalledRepository(const CRANInstalledRepositoryPa
.destination_interface(this)
.licenses_interface(0)
.portage_interface(0)
+ .pretend_interface(0)
.hook_interface(0),
"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 86826a4..2c05a31 100644
--- a/paludis/repositories/cran/cran_repository.cc
+++ b/paludis/repositories/cran/cran_repository.cc
@@ -181,6 +181,7 @@ CRANRepository::CRANRepository(const CRANRepositoryParams & p) :
.contents_interface(0)
.licenses_interface(0)
.portage_interface(0)
+ .pretend_interface(0)
.hook_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 6eb12b2..2a07eb9 100644
--- a/paludis/repositories/fake/fake_installed_repository.cc
+++ b/paludis/repositories/fake/fake_installed_repository.cc
@@ -44,6 +44,7 @@ FakeInstalledRepository::FakeInstalledRepository(const Environment * const e, co
.destination_interface(this)
.licenses_interface(0)
.portage_interface(0)
+ .pretend_interface(0)
.hook_interface(0),
"fake_installed")
{
diff --git a/paludis/repositories/fake/fake_repository.cc b/paludis/repositories/fake/fake_repository.cc
index 8a99e2b..9786ac3 100644
--- a/paludis/repositories/fake/fake_repository.cc
+++ b/paludis/repositories/fake/fake_repository.cc
@@ -42,6 +42,7 @@ FakeRepository::FakeRepository(const Environment * const e, const RepositoryName
.destination_interface(0)
.licenses_interface(0)
.portage_interface(0)
+ .pretend_interface(0)
.hook_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 3be4ea6..25dc302 100644
--- a/paludis/repositories/gems/gems_repository.cc
+++ b/paludis/repositories/gems/gems_repository.cc
@@ -254,6 +254,7 @@ GemsRepository::GemsRepository(const GemsRepositoryParams & p) :
.destination_interface(0)
.licenses_interface(0)
.portage_interface(0)
+ .pretend_interface(0)
.hook_interface(0),
"gems"),
PrivateImplementationPattern<GemsRepository>(new Implementation<GemsRepository>(p))
diff --git a/paludis/repositories/gentoo/ebin_entries.cc b/paludis/repositories/gentoo/ebin_entries.cc
index 8a7bd83..1e48efa 100644
--- a/paludis/repositories/gentoo/ebin_entries.cc
+++ b/paludis/repositories/gentoo/ebin_entries.cc
@@ -460,3 +460,10 @@ EbinEntries::extract_package_file_version(const QualifiedPackageName & n, const
return VersionSpec(strip_leading_string(strip_trailing_string(e.basename(), ".ebin"), stringify(n.package) + "-"));
}
+bool
+EbinEntries::pretend(const QualifiedPackageName &, const VersionSpec &,
+ std::tr1::shared_ptr<const PortageRepositoryProfile>) const
+{
+ return true;
+}
+
diff --git a/paludis/repositories/gentoo/ebin_entries.hh b/paludis/repositories/gentoo/ebin_entries.hh
index b21e0b0..e713254 100644
--- a/paludis/repositories/gentoo/ebin_entries.hh
+++ b/paludis/repositories/gentoo/ebin_entries.hh
@@ -61,13 +61,17 @@ namespace paludis
virtual std::string get_environment_variable(const QualifiedPackageName &,
const VersionSpec &, const std::string & var,
- std::tr1::shared_ptr<const PortageRepositoryProfile>) const;
+ std::tr1::shared_ptr<const PortageRepositoryProfile>) const
+ PALUDIS_ATTRIBUTE((noreturn));
virtual void install(const QualifiedPackageName &, const VersionSpec &,
const InstallOptions &, std::tr1::shared_ptr<const PortageRepositoryProfile>) const;
virtual void merge(const MergeOptions &);
+ virtual bool pretend(const QualifiedPackageName &, const VersionSpec &,
+ std::tr1::shared_ptr<const PortageRepositoryProfile>) const;
+
virtual bool is_package_file(const QualifiedPackageName &, const FSEntry &) const
PALUDIS_ATTRIBUTE((warn_unused_result));
diff --git a/paludis/repositories/gentoo/ebuild.cc b/paludis/repositories/gentoo/ebuild.cc
index b6c3db8..7d27989 100644
--- a/paludis/repositories/gentoo/ebuild.cc
+++ b/paludis/repositories/gentoo/ebuild.cc
@@ -597,3 +597,43 @@ VDBPostMergeCommand::operator() ()
throw PackageInstallActionError("VDB Entry post merge commands failed");
}
+std::string
+EbuildPretendCommand::commands() const
+{
+ return "pretend";
+}
+
+bool
+EbuildPretendCommand::failure()
+{
+ return false;
+}
+
+Command
+EbuildPretendCommand::extend_command(const Command & cmd)
+{
+ Command result(Command(cmd)
+ .with_setenv("USE", pretend_params.use)
+ .with_setenv("USE_EXPAND", pretend_params.use_expand)
+ .with_setenv("ROOT", pretend_params.root)
+ .with_setenv("PALUDIS_PROFILE_DIR", stringify(*pretend_params.profiles->begin()))
+ .with_setenv("PALUDIS_PROFILE_DIRS", join(pretend_params.profiles->begin(),
+ pretend_params.profiles->end(), " ")));
+
+ for (AssociativeCollection<std::string, std::string>::Iterator
+ i(pretend_params.expand_vars->begin()),
+ j(pretend_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());
+
+ return result;
+}
+
+EbuildPretendCommand::EbuildPretendCommand(const EbuildCommandParams & p,
+ const EbuildPretendCommandParams & f) :
+ EbuildCommand(p),
+ pretend_params(f)
+{
+}
+
diff --git a/paludis/repositories/gentoo/ebuild.hh b/paludis/repositories/gentoo/ebuild.hh
index 235752f..aefaf05 100644
--- a/paludis/repositories/gentoo/ebuild.hh
+++ b/paludis/repositories/gentoo/ebuild.hh
@@ -351,6 +351,31 @@ namespace paludis
};
/**
+ * An EbuildPretendCommand is used to configure a package in a VDBRepository.
+ *
+ * \ingroup grpebuildinterface
+ */
+ class EbuildPretendCommand :
+ public EbuildCommand
+ {
+ protected:
+ /// Parameters for config.
+ const EbuildPretendCommandParams pretend_params;
+
+ virtual std::string commands() const;
+
+ virtual bool failure();
+
+ virtual Command extend_command(const Command &);
+
+ public:
+ /**
+ * Constructor.
+ */
+ EbuildPretendCommand(const EbuildCommandParams &, const EbuildPretendCommandParams &);
+ };
+
+ /**
* Command for generating VDB entries (not a regular EbuildCommand).
*
* \ingroup grpebuildinterface
diff --git a/paludis/repositories/gentoo/ebuild.sr b/paludis/repositories/gentoo/ebuild.sr
index 053cef0..6a0afbc 100644
--- a/paludis/repositories/gentoo/ebuild.sr
+++ b/paludis/repositories/gentoo/ebuild.sr
@@ -83,6 +83,27 @@ END
allow_named_args
}
+make_class_EbuildPretendCommandParams()
+{
+ key use std::string
+ key use_expand std::string
+ key root std::string
+ key profiles "std::tr1::shared_ptr<const FSEntryCollection>"
+ key expand_vars "std::tr1::shared_ptr<const AssociativeCollection<std::string, std::string> >"
+
+ doxygen_comment << "END"
+ /**
+ * Parameters for an EbuildPretendCommand.
+ *
+ * \see EbuildPretendCommand
+ * \ingroup grpebuildinterface
+ * \nosubgrouping
+ */
+END
+
+ allow_named_args
+}
+
make_class_EbuildUninstallCommandParams()
{
key root std::string
diff --git a/paludis/repositories/gentoo/ebuild/Makefile.am b/paludis/repositories/gentoo/ebuild/Makefile.am
index 94c4b57..fd0857f 100644
--- a/paludis/repositories/gentoo/ebuild/Makefile.am
+++ b/paludis/repositories/gentoo/ebuild/Makefile.am
@@ -36,6 +36,7 @@ libexecprog_SCRIPTS = \
pkg_postrm.bash \
pkg_preinst.bash \
pkg_prerm.bash \
+ pkg_pretend.bash \
pkg_setup.bash \
portage_stubs.bash \
sandbox.bash \
diff --git a/paludis/repositories/gentoo/ebuild/ebuild.bash b/paludis/repositories/gentoo/ebuild/ebuild.bash
index c76e5ff..fb23b6c 100755
--- a/paludis/repositories/gentoo/ebuild/ebuild.bash
+++ b/paludis/repositories/gentoo/ebuild/ebuild.bash
@@ -311,7 +311,7 @@ ebuild_main()
if [[ ${#@} -ge 2 ]] ; then
ebuild_section "Running ebuild phases $@ as $(id -un ):$(id -gn )..."
- elif [[ ${1} != variable ]] && [[ ${1} != metadata ]] ; then
+ elif [[ ${1} != variable ]] && [[ ${1} != metadata ]] && [[ ${1} != pretend ]] ; then
ebuild_section "Running ebuild phase $@ as $(id -un ):$(id -gn )..."
fi
@@ -326,7 +326,7 @@ ebuild_main()
ebuild_load_module src_${action}
;;
- setup|config|nofetch|preinst|postinst|prerm|postrm)
+ setup|config|nofetch|preinst|postinst|prerm|postrm|pretend)
ebuild_load_module pkg_${action}
;;
@@ -373,7 +373,7 @@ ebuild_main()
if [[ ${#@} -ge 2 ]] ; then
ebuild_section "Completed ebuild phases $@"
- elif [[ ${1} != variable ]] && [[ ${1} != metadata ]] ; then
+ elif [[ ${1} != variable ]] && [[ ${1} != metadata ]] && [[ ${1} != pretend ]] ; then
ebuild_section "Completed ebuild phase $@"
fi
}
diff --git a/paludis/repositories/gentoo/ebuild/pkg_pretend.bash b/paludis/repositories/gentoo/ebuild/pkg_pretend.bash
new file mode 100644
index 0000000..dc95d0c
--- /dev/null
+++ b/paludis/repositories/gentoo/ebuild/pkg_pretend.bash
@@ -0,0 +1,46 @@
+#!/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_pretend()
+{
+ :
+}
+
+ebuild_f_pretend()
+{
+ if hasq "pretend" ${RESTRICT} ; then
+ ebuild_section "Skipping pkg_pretend (RESTRICT)"
+ elif hasq "pretend" ${SKIP_FUNCTIONS} ; then
+ ebuild_section "Skipping pkg_pretend (SKIP_FUNCTIONS)"
+ else
+ if [[ $(type -t pre_pkg_pretend ) == "function" ]] ; then
+ pre_pkg_pretend
+ fi
+
+ pkg_pretend
+
+ if [[ $(type -t post_pkg_pretend ) == "function" ]] ; then
+ post_pkg_pretend
+ fi
+ fi
+
+ [[ -z "${PALUDIS_DO_NOTHING_SANDBOXY}" ]] && SANDBOX_WRITE="${old_sandbox_write}"
+ true
+}
+
+
diff --git a/paludis/repositories/gentoo/ebuild_entries.cc b/paludis/repositories/gentoo/ebuild_entries.cc
index 9bfadf0..d46c2f0 100644
--- a/paludis/repositories/gentoo/ebuild_entries.cc
+++ b/paludis/repositories/gentoo/ebuild_entries.cc
@@ -242,6 +242,77 @@ namespace
return FSEntry("/");
}
+
+ std::string make_use(const Environment * const env,
+ const PackageDatabaseEntry & pde,
+ std::tr1::shared_ptr<const VersionMetadata> metadata,
+ std::tr1::shared_ptr<const PortageRepositoryProfile> profile)
+ {
+ std::string use;
+
+ for (IUseFlagCollection::Iterator i(metadata->ebuild_interface->iuse()->begin()),
+ i_end(metadata->ebuild_interface->iuse()->end()) ; i != i_end ; ++i)
+ if (env->query_use(i->flag, pde))
+ use += stringify(i->flag) + " ";
+
+ use += profile->environment_variable("ARCH") + " ";
+
+ return use;
+ }
+
+ std::tr1::shared_ptr<AssociativeCollection<std::string, std::string> >
+ make_expand(const Environment * const env,
+ const PackageDatabaseEntry & e,
+ std::tr1::shared_ptr<const PortageRepositoryProfile> profile,
+ std::string & use)
+ {
+ std::tr1::shared_ptr<AssociativeCollection<std::string, std::string> > expand_vars(
+ new AssociativeCollection<std::string, std::string>::Concrete);
+
+ for (PortageRepositoryProfile::UseExpandIterator x(profile->begin_use_expand()),
+ x_end(profile->end_use_expand()) ; x != x_end ; ++x)
+ {
+ std::string lower_x;
+ std::transform(x->data().begin(), x->data().end(), std::back_inserter(lower_x), &::tolower);
+
+ expand_vars->insert(stringify(*x), "");
+
+ /* possible values from profile */
+ std::set<UseFlagName> possible_values;
+ WhitespaceTokeniser::get_instance()->tokenise(profile->environment_variable(stringify(*x)),
+ create_inserter<UseFlagName>(std::inserter(possible_values, possible_values.end())));
+
+ /* possible values from environment */
+ std::tr1::shared_ptr<const UseFlagNameCollection> possible_values_from_env(
+ env->known_use_expand_names(*x, e));
+ for (UseFlagNameCollection::Iterator i(possible_values_from_env->begin()),
+ i_end(possible_values_from_env->end()) ; i != i_end ; ++i)
+ possible_values.insert(UseFlagName(stringify(*i).substr(lower_x.length() + 1)));
+
+ for (std::set<UseFlagName>::const_iterator u(possible_values.begin()), u_end(possible_values.end()) ;
+ u != u_end ; ++u)
+ {
+ if (! env->query_use(UseFlagName(lower_x + "_" + stringify(*u)), e))
+ continue;
+
+ use.append(lower_x + "_" + stringify(*u) + " ");
+
+ std::string value;
+ AssociativeCollection<std::string, std::string>::Iterator i(expand_vars->find(stringify(*x)));
+ if (expand_vars->end() != i)
+ {
+ value = i->second;
+ if (! value.empty())
+ value.append(" ");
+ expand_vars->erase(i);
+ }
+ value.append(stringify(*u));
+ expand_vars->insert(stringify(*x), value);
+ }
+ }
+
+ return expand_vars;
+ }
}
void
@@ -400,59 +471,12 @@ EbuildEntries::install(const QualifiedPackageName & q, const VersionSpec & v,
all_archives = strip_trailing(all_archives, " ");
/* make use */
- std::string use;
- for (IUseFlagCollection::Iterator i(metadata->ebuild_interface->iuse()->begin()),
- i_end(metadata->ebuild_interface->iuse()->end()) ; i != i_end ; ++i)
- if (_imp->params.environment->query_use(i->flag, e))
- use += stringify(i->flag) + " ";
-
- use += p->environment_variable("ARCH") + " ";
+ std::string use(make_use(_imp->params.environment, e, metadata, p));
/* add expand to use (iuse isn't reliable for use_expand things), and make the expand
* environment variables */
- std::tr1::shared_ptr<AssociativeCollection<std::string, std::string> > expand_vars(
- new AssociativeCollection<std::string, std::string>::Concrete);
- for (PortageRepositoryProfile::UseExpandIterator x(p->begin_use_expand()),
- x_end(p->end_use_expand()) ; x != x_end ; ++x)
- {
- std::string lower_x;
- std::transform(x->data().begin(), x->data().end(), std::back_inserter(lower_x), &::tolower);
-
- expand_vars->insert(stringify(*x), "");
-
- /* possible values from profile */
- std::set<UseFlagName> possible_values;
- WhitespaceTokeniser::get_instance()->tokenise(p->environment_variable(stringify(*x)),
- create_inserter<UseFlagName>(std::inserter(possible_values, possible_values.end())));
-
- /* possible values from environment */
- std::tr1::shared_ptr<const UseFlagNameCollection> possible_values_from_env(_imp->params.environment->
- known_use_expand_names(*x, e));
- for (UseFlagNameCollection::Iterator i(possible_values_from_env->begin()),
- i_end(possible_values_from_env->end()) ; i != i_end ; ++i)
- possible_values.insert(UseFlagName(stringify(*i).substr(lower_x.length() + 1)));
-
- for (std::set<UseFlagName>::const_iterator u(possible_values.begin()), u_end(possible_values.end()) ;
- u != u_end ; ++u)
- {
- if (! _imp->params.environment->query_use(UseFlagName(lower_x + "_" + stringify(*u)), e))
- continue;
-
- use.append(lower_x + "_" + stringify(*u) + " ");
-
- std::string value;
- AssociativeCollection<std::string, std::string>::Iterator i(expand_vars->find(stringify(*x)));
- if (expand_vars->end() != i)
- {
- value = i->second;
- if (! value.empty())
- value.append(" ");
- expand_vars->erase(i);
- }
- value.append(stringify(*u));
- expand_vars->insert(stringify(*x), value);
- }
- }
+ std::tr1::shared_ptr<AssociativeCollection<std::string, std::string> > expand_vars(make_expand(
+ _imp->params.environment, e, p, use));
EbuildCommandParams command_params(EbuildCommandParams::create()
.environment(_imp->params.environment)
@@ -677,3 +701,54 @@ EbuildEntries::extract_package_file_version(const QualifiedPackageName & n, cons
return VersionSpec(strip_leading_string(strip_trailing_string(e.basename(), ".ebuild"), stringify(n.package) + "-"));
}
+bool
+EbuildEntries::pretend(const QualifiedPackageName & q, const VersionSpec & v,
+ std::tr1::shared_ptr<const PortageRepositoryProfile> p) const
+{
+ using namespace std::tr1::placeholders;
+
+ Context context("When running pretend for '" + stringify(q) + "-" + stringify(v) + "':");
+
+ if (! _imp->portage_repository->has_version(q, v))
+ {
+ throw PackageInstallActionError("Can't run pretend for '" + stringify(q) + "-"
+ + stringify(v) + "' since has_version failed");
+ }
+
+ std::tr1::shared_ptr<const VersionMetadata> metadata(_imp->portage_repository->version_metadata(q, v));
+
+ if (! metadata->eapi.supported)
+ return true;
+ if (! metadata->eapi.supported->has_pretend_phase)
+ return true;
+
+ PackageDatabaseEntry e(q, v, _imp->portage_repository->name());
+
+ std::string use(make_use(_imp->params.environment, e, metadata, p));
+ std::tr1::shared_ptr<AssociativeCollection<std::string, std::string> > expand_vars(make_expand(
+ _imp->params.environment, e, p, use));
+
+ EbuildCommandParams command_params(EbuildCommandParams::create()
+ .environment(_imp->params.environment)
+ .db_entry(&e)
+ .ebuild_dir(_imp->params.location / stringify(q.category) /
+ stringify(q.package))
+ .files_dir(_imp->params.location / stringify(q.category) /
+ stringify(q.package) / "files")
+ .eclassdirs(_imp->params.eclassdirs)
+ .portdir(_imp->params.master_repository ? _imp->params.master_repository->params().location :
+ _imp->params.location)
+ .distdir(_imp->params.distdir)
+ .buildroot(_imp->params.buildroot));
+
+ EbuildPretendCommand pretend_cmd(command_params,
+ EbuildPretendCommandParams::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));
+
+ return pretend_cmd();
+}
+
diff --git a/paludis/repositories/gentoo/ebuild_entries.hh b/paludis/repositories/gentoo/ebuild_entries.hh
index 0614302..854f1b2 100644
--- a/paludis/repositories/gentoo/ebuild_entries.hh
+++ b/paludis/repositories/gentoo/ebuild_entries.hh
@@ -72,6 +72,9 @@ namespace paludis
virtual void install(const QualifiedPackageName &, const VersionSpec &,
const InstallOptions &, std::tr1::shared_ptr<const PortageRepositoryProfile>) const;
+ virtual bool pretend(const QualifiedPackageName &, const VersionSpec &,
+ std::tr1::shared_ptr<const PortageRepositoryProfile>) const;
+
virtual void merge(const MergeOptions &) PALUDIS_ATTRIBUTE((noreturn));
virtual bool is_package_file(const QualifiedPackageName &, const FSEntry &) const
diff --git a/paludis/repositories/gentoo/portage_repository.cc b/paludis/repositories/gentoo/portage_repository.cc
index 2af0879..824050b 100644
--- a/paludis/repositories/gentoo/portage_repository.cc
+++ b/paludis/repositories/gentoo/portage_repository.cc
@@ -265,6 +265,7 @@ PortageRepository::PortageRepository(const PortageRepositoryParams & p) :
.destination_interface(p.enable_destinations ? this : 0)
.licenses_interface(this)
.portage_interface(this)
+ .pretend_interface(this)
.hook_interface(this),
p.entry_format),
PrivateImplementationPattern<PortageRepository>(new Implementation<PortageRepository>(this, p))
@@ -568,6 +569,13 @@ PortageRepository::do_install(const QualifiedPackageName & q, const VersionSpec
_imp->entries_ptr->install(q, v, o, _imp->profile_ptr);
}
+bool
+PortageRepository::do_pretend(const QualifiedPackageName & q, const VersionSpec & v) const
+{
+ _imp->need_profiles();
+ return _imp->entries_ptr->pretend(q, v, _imp->profile_ptr);
+}
+
std::tr1::shared_ptr<DepSpec>
PortageRepository::do_package_set(const SetName & s) const
{
diff --git a/paludis/repositories/gentoo/portage_repository.hh b/paludis/repositories/gentoo/portage_repository.hh
index e7895b6..b2c5a66 100644
--- a/paludis/repositories/gentoo/portage_repository.hh
+++ b/paludis/repositories/gentoo/portage_repository.hh
@@ -60,6 +60,7 @@ namespace paludis
public RepositoryLicensesInterface,
public RepositoryPortageInterface,
public RepositoryHookInterface,
+ public RepositoryPretendInterface,
private PrivateImplementationPattern<PortageRepository>
{
private:
@@ -107,6 +108,8 @@ namespace paludis
virtual bool do_sync() const;
+ virtual bool do_pretend(const QualifiedPackageName &, const VersionSpec &) const;
+
virtual std::tr1::shared_ptr<const VirtualsCollection> virtual_packages() const;
virtual std::tr1::shared_ptr<const VersionMetadata> virtual_package_version_metadata(
diff --git a/paludis/repositories/gentoo/portage_repository_entries.hh b/paludis/repositories/gentoo/portage_repository_entries.hh
index b73a61b..97524d4 100644
--- a/paludis/repositories/gentoo/portage_repository_entries.hh
+++ b/paludis/repositories/gentoo/portage_repository_entries.hh
@@ -83,6 +83,12 @@ namespace paludis
const InstallOptions &, std::tr1::shared_ptr<const PortageRepositoryProfile>) const = 0;
/**
+ * Handle a pretend.
+ */
+ virtual bool pretend(const QualifiedPackageName &, const VersionSpec &,
+ std::tr1::shared_ptr<const PortageRepositoryProfile>) const = 0;
+
+ /**
* Handle a merge.
*/
virtual void merge(const MergeOptions &) = 0;
diff --git a/paludis/repositories/gentoo/vdb_repository.cc b/paludis/repositories/gentoo/vdb_repository.cc
index afa09c4..79b1032 100644
--- a/paludis/repositories/gentoo/vdb_repository.cc
+++ b/paludis/repositories/gentoo/vdb_repository.cc
@@ -530,6 +530,7 @@ VDBRepository::VDBRepository(const VDBRepositoryParams & p) :
.contents_interface(this)
.licenses_interface(0)
.portage_interface(0)
+ .pretend_interface(0)
.hook_interface(this),
"vdb"),
PrivateImplementationPattern<VDBRepository>(new Implementation<VDBRepository>(this, p))
diff --git a/paludis/repositories/virtuals/installed_virtuals_repository.cc b/paludis/repositories/virtuals/installed_virtuals_repository.cc
index 41099c3..c897a56 100644
--- a/paludis/repositories/virtuals/installed_virtuals_repository.cc
+++ b/paludis/repositories/virtuals/installed_virtuals_repository.cc
@@ -103,6 +103,7 @@ InstalledVirtualsRepository::InstalledVirtualsRepository(const Environment * con
.destination_interface(0)
.licenses_interface(0)
.portage_interface(0)
+ .pretend_interface(0)
.hook_interface(this),
"installed_virtuals"),
PrivateImplementationPattern<InstalledVirtualsRepository>(
diff --git a/paludis/repositories/virtuals/virtuals_repository.cc b/paludis/repositories/virtuals/virtuals_repository.cc
index f628602..16c8701 100644
--- a/paludis/repositories/virtuals/virtuals_repository.cc
+++ b/paludis/repositories/virtuals/virtuals_repository.cc
@@ -94,6 +94,7 @@ VirtualsRepository::VirtualsRepository(const Environment * const env) :
.contents_interface(0)
.licenses_interface(0)
.portage_interface(0)
+ .pretend_interface(0)
.hook_interface(0),
"virtuals"),
PrivateImplementationPattern<VirtualsRepository>(
diff --git a/paludis/repository-fwd.hh b/paludis/repository-fwd.hh
index 882fb44..36571ab 100644
--- a/paludis/repository-fwd.hh
+++ b/paludis/repository-fwd.hh
@@ -47,6 +47,7 @@ namespace paludis
class RepositoryDestinationInterface;
class RepositoryContentsInterface;
class RepositoryConfigInterface;
+ class RepositoryPretendInterface;
class RepositoryLicensesInterface;
class RepositoryPortageInterface;
class RepositoryHookInterface;
diff --git a/paludis/repository.cc b/paludis/repository.cc
index 58d1405..33123e4 100644
--- a/paludis/repository.cc
+++ b/paludis/repository.cc
@@ -330,6 +330,16 @@ RepositoryHookInterface::~RepositoryHookInterface()
{
}
+RepositoryPretendInterface::~RepositoryPretendInterface()
+{
+}
+
+bool
+RepositoryPretendInterface::pretend(const QualifiedPackageName & q, const VersionSpec & v) const
+{
+ return do_pretend(q, v);
+}
+
UseFlagState
RepositoryUseInterface::query_use(const UseFlagName & u, const PackageDatabaseEntry & pde) const
{
diff --git a/paludis/repository.hh b/paludis/repository.hh
index 8a87a4e..c05bdce 100644
--- a/paludis/repository.hh
+++ b/paludis/repository.hh
@@ -1030,7 +1030,7 @@ namespace paludis
///\}
public:
- ///\name Installed content queries
+ ///\name Configuration actions
///\{
/**
@@ -1049,6 +1049,47 @@ namespace paludis
};
/**
+ * Interface for handling actions for repositories supporting
+ * pretend-phase functions.
+ *
+ * \see Repository
+ * \ingroup grprepository
+ * \nosubgrouping
+ */
+ class PALUDIS_VISIBLE RepositoryPretendInterface
+ {
+ protected:
+ ///\name Implementation details
+ ///\{
+
+ /**
+ * Override in descendents: do the pretend.
+ */
+ virtual bool do_pretend(
+ const QualifiedPackageName &,
+ const VersionSpec &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
+
+ ///\}
+
+ public:
+ ///\name Pretend phase actions
+ ///\{
+
+ /**
+ * Do the pretend.
+ */
+ bool pretend(
+ const QualifiedPackageName & q,
+ const VersionSpec & v) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ ///\}
+
+ virtual ~RepositoryPretendInterface();
+ };
+
+ /**
* Interface for handling actions relating to licenses.
*
* \see Repository
diff --git a/paludis/repository.sr b/paludis/repository.sr
index d809b1f..ca8b91e 100644
--- a/paludis/repository.sr
+++ b/paludis/repository.sr
@@ -58,6 +58,7 @@ make_class_RepositoryCapabilities()
key destination_interface "RepositoryDestinationInterface *"
key contents_interface "RepositoryContentsInterface *"
key config_interface "RepositoryConfigInterface *"
+ key pretend_interface "RepositoryPretendInterface *"
key licenses_interface "RepositoryLicensesInterface *"
key portage_interface "RepositoryPortageInterface *"
key hook_interface "RepositoryHookInterface *"
diff --git a/paludis/tasks/install_task.cc b/paludis/tasks/install_task.cc
index 660ddad..63a0eca 100644
--- a/paludis/tasks/install_task.cc
+++ b/paludis/tasks/install_task.cc
@@ -189,6 +189,18 @@ InstallTask::execute()
/* we're done displaying our task list */
on_display_merge_list_post();
+ /* do pretend phase things */
+ bool pretend_failed(false);
+
+ for (DepList::Iterator dep(_imp->dep_list.begin()), dep_end(_imp->dep_list.end()) ;
+ dep != dep_end ; ++dep)
+ {
+ const RepositoryPretendInterface * const pretend_interface(
+ _imp->env->package_database()->fetch_repository(dep->package.repository)->pretend_interface);
+ if (pretend_interface)
+ pretend_failed |= ! pretend_interface->pretend(dep->package.name, dep->package.version);
+ }
+
if (_imp->pretend)
{
if (0 != perform_hook(Hook("install_pretend_post")("TARGETS", join(
@@ -197,7 +209,7 @@ InstallTask::execute()
return;
}
- if (_imp->dep_list.has_errors())
+ if (_imp->dep_list.has_errors() || pretend_failed)
{
on_not_continuing_due_to_errors();
return;