aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-04-17 20:34:31 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-04-17 20:34:31 +0000
commitacb2dfd9a3076cc553553ac6dde89dd958eda53f (patch)
tree48f0e0ac097fab4646e6fcee454215e8cb73a81b
parentaa03397c6085094753195830fd1f280c1f9b8e6a (diff)
downloadpaludis-acb2dfd9a3076cc553553ac6dde89dd958eda53f.tar.gz
paludis-acb2dfd9a3076cc553553ac6dde89dd958eda53f.tar.xz
Split ebuild execution code out into its own EbuildCommand classes
-rw-r--r--paludis/ebuild.cc269
-rw-r--r--paludis/ebuild.hh235
-rw-r--r--paludis/files.m41
-rw-r--r--paludis/portage_repository.cc185
-rw-r--r--paludis/repository.cc5
-rw-r--r--paludis/repository.hh11
-rw-r--r--paludis/vdb_repository.cc58
7 files changed, 617 insertions, 147 deletions
diff --git a/paludis/ebuild.cc b/paludis/ebuild.cc
new file mode 100644
index 0000000..02d76e1
--- /dev/null
+++ b/paludis/ebuild.cc
@@ -0,0 +1,269 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaran.mccreesh@blueyonder.co.uk>
+ *
+ * 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 "ebuild.hh"
+#include <paludis/util/system.hh>
+#include <paludis/util/pstream.hh>
+#include <paludis/util/log.hh>
+#include <paludis/environment.hh>
+#include <paludis/config_file.hh>
+
+using namespace paludis;
+
+EbuildCommand::EbuildCommand(const EbuildCommandParams & p) :
+ params(p)
+{
+}
+
+EbuildCommand::~EbuildCommand()
+{
+}
+
+bool
+EbuildCommand::success()
+{
+ return true;
+}
+
+bool
+EbuildCommand::failure()
+{
+ return false;
+}
+
+bool
+EbuildCommand::operator() ()
+{
+ MakeEnvCommand cmd(extend_command(make_env_command(
+ getenv_with_default("PALUDIS_EBUILD_DIR", LIBEXECDIR "/paludis") +
+ "/ebuild.bash '" +
+ stringify(params.get<ecpk_ebuild_dir>()) + "/" +
+ stringify(params.get<ecpk_db_entry>()->get<pde_name>().get<qpn_package>()) + "-" +
+ stringify(params.get<ecpk_db_entry>()->get<pde_version>()) +
+ ".ebuild' " + commands())
+ ("P", stringify(params.get<ecpk_db_entry>()->get<pde_name>().get<qpn_package>()) + "-" +
+ stringify(params.get<ecpk_db_entry>()->get<pde_version>().remove_revision()))
+ ("PV", stringify(params.get<ecpk_db_entry>()->get<pde_version>().remove_revision()))
+ ("PR", stringify(params.get<ecpk_db_entry>()->get<pde_version>().revision_only()))
+ ("PN", stringify(params.get<ecpk_db_entry>()->get<pde_name>().get<qpn_package>()))
+ ("PVR", stringify(params.get<ecpk_db_entry>()->get<pde_version>().remove_revision()) + "-" +
+ stringify(params.get<ecpk_db_entry>()->get<pde_version>().revision_only()))
+ ("PF", stringify(params.get<ecpk_db_entry>()->get<pde_name>().get<qpn_package>()) + "-" +
+ stringify(params.get<ecpk_db_entry>()->get<pde_version>()))
+ ("CATEGORY", stringify(params.get<ecpk_db_entry>()->get<pde_name>().get<qpn_category>()))
+ ("FILESDIR", stringify(params.get<ecpk_files_dir>()))
+ ("ECLASSDIR", stringify(params.get<ecpk_eclass_dir>()))
+ ("PORTDIR", stringify(params.get<ecpk_portdir>()))
+ ("DISTDIR", stringify(params.get<ecpk_distdir>()))
+ ("PALUDIS_TMPDIR", BIGTEMPDIR "/paludis/")
+ ("PALUDIS_CONFIG_DIR", SYSCONFDIR "/paludis/")
+ ("PALUDIS_BASHRC_FILES", params.get<ecpk_environment>()->bashrc_files())
+ ("PALUDIS_COMMAND", params.get<ecpk_environment>()->paludis_command())
+ ("KV", kernel_version())
+ ("PALUDIS_EBUILD_LOG_LEVEL", Log::get_instance()->log_level_string())
+ ("PALUDIS_EBUILD_DIR", getenv_with_default("PALUDIS_EBUILD_DIR", LIBEXECDIR "/paludis"))));
+
+ if (do_run_command(cmd))
+ return success();
+ else
+ return failure();
+}
+
+bool
+EbuildCommand::do_run_command(const std::string & cmd)
+{
+ return 0 == run_command(cmd);
+}
+
+EbuildMetadataCommand::EbuildMetadataCommand(const EbuildCommandParams & p) :
+ EbuildCommand(p),
+ _metadata(0)
+{
+}
+
+std::string
+EbuildMetadataCommand::commands() const
+{
+ return "metadata";
+}
+
+bool
+EbuildMetadataCommand::failure()
+{
+ return EbuildCommand::failure();
+}
+
+MakeEnvCommand
+EbuildMetadataCommand::extend_command(const MakeEnvCommand & cmd)
+{
+ return cmd;
+}
+
+bool
+EbuildMetadataCommand::do_run_command(const std::string & cmd)
+{
+ PStream prog(cmd);
+ KeyValueConfigFile f(&prog);
+ _metadata.assign(new VersionMetadata);
+
+ _metadata->set(vmk_depend, f.get("DEPEND"));
+ _metadata->set(vmk_rdepend, f.get("RDEPEND"));
+ _metadata->set(vmk_slot, f.get("SLOT"));
+ _metadata->set(vmk_src_uri, f.get("SRC_URI"));
+ _metadata->set(vmk_restrict, f.get("RESTRICT"));
+ _metadata->set(vmk_homepage, f.get("HOMEPAGE"));
+ _metadata->set(vmk_license, f.get("LICENSE"));
+ _metadata->set(vmk_description, f.get("DESCRIPTION"));
+ _metadata->set(vmk_keywords, f.get("KEYWORDS"));
+ _metadata->set(vmk_inherited, f.get("INHERITED"));
+ _metadata->set(vmk_iuse, f.get("IUSE"));
+ _metadata->set(vmk_pdepend, f.get("PDEPEND"));
+ _metadata->set(vmk_provide, f.get("PROVIDE"));
+ _metadata->set(vmk_eapi, f.get("EAPI"));
+ _metadata->set(vmk_virtual, "");
+ _metadata->set(vmk_e_keywords, f.get("E_KEYWORDS"));
+
+ if (prog.exit_status())
+ {
+ Log::get_instance()->message(ll_warning, "Could not generate cache for '"
+ + stringify(*params.get<ecpk_db_entry>()) + "'");
+ _metadata->set(vmk_eapi, "UNKNOWN");
+
+ return false;
+ }
+ return true;
+}
+
+std::string
+EbuildFetchCommand::commands() const
+{
+ return "fetch";
+}
+
+bool
+EbuildFetchCommand::failure()
+{
+ throw PackageFetchActionError("Fetch failed for '" + stringify(
+ *params.get<ecpk_db_entry>()) + "'");
+}
+
+MakeEnvCommand
+EbuildFetchCommand::extend_command(const MakeEnvCommand & cmd)
+{
+ MakeEnvCommand result(cmd
+ ("A", fetch_params.get<ecfpk_a>())
+ ("USE", fetch_params.get<ecfpk_use>())
+ ("USE_EXPAND", fetch_params.get<ecfpk_use_expand>())
+ ("FLAT_SRC_URI", fetch_params.get<ecfpk_flat_src_uri>())
+ ("ROOT", fetch_params.get<ecfpk_root>())
+ ("PALUDIS_PROFILE_DIR", fetch_params.get<ecfpk_profile>()));
+
+ for (std::map<std::string, std::string>::const_iterator
+ i(fetch_params.get<ecfpk_expand_vars>().begin()),
+ j(fetch_params.get<ecfpk_expand_vars>().end()) ; i != j ; ++i)
+ result = result(i->first, i->second);
+
+ return result;
+}
+
+EbuildFetchCommand::EbuildFetchCommand(const EbuildCommandParams & p,
+ const EbuildFetchCommandParams & f) :
+ EbuildCommand(p),
+ fetch_params(f)
+{
+}
+
+std::string
+EbuildInstallCommand::commands() const
+{
+ if (install_params.get<ecipk_merge_only>())
+ return "merge";
+ else
+ return "init setup unpack compile test install strip preinst "
+ "merge postinst updateenv tidyup";
+}
+
+bool
+EbuildInstallCommand::failure()
+{
+ throw PackageInstallActionError("Install failed for '" + stringify(
+ *params.get<ecpk_db_entry>()) + "'");
+}
+
+MakeEnvCommand
+EbuildInstallCommand::extend_command(const MakeEnvCommand & cmd)
+{
+ MakeEnvCommand result(cmd
+ ("USE", install_params.get<ecipk_use>())
+ ("USE_EXPAND", install_params.get<ecipk_use_expand>())
+ ("ROOT", install_params.get<ecipk_root>())
+ ("PALUDIS_EBUILD_OVERRIDE_CONFIG_PROTECT_MASK",
+ install_params.get<ecipk_disable_cfgpro>() ? "/" : "")
+ ("PALUDIS_PROFILE_DIR", install_params.get<ecipk_profile>())
+ ("SLOT", stringify(install_params.get<ecipk_slot>())));
+
+ for (std::map<std::string, std::string>::const_iterator
+ i(install_params.get<ecipk_expand_vars>().begin()),
+ j(install_params.get<ecipk_expand_vars>().end()) ; i != j ; ++i)
+ result = result(i->first, i->second);
+
+ return result;
+}
+
+EbuildInstallCommand::EbuildInstallCommand(const EbuildCommandParams & p,
+ const EbuildInstallCommandParams & f) :
+ EbuildCommand(p),
+ install_params(f)
+{
+}
+
+std::string
+EbuildUninstallCommand::commands() const
+{
+ if (uninstall_params.get<ecupk_unmerge_only>())
+ return "unmerge";
+ else
+ return "prerm unmerge postrm";
+}
+
+bool
+EbuildUninstallCommand::failure()
+{
+ throw PackageUninstallActionError("Uninstall failed for '" + stringify(
+ *params.get<ecpk_db_entry>()) + "'");
+}
+
+MakeEnvCommand
+EbuildUninstallCommand::extend_command(const MakeEnvCommand & cmd)
+{
+ MakeEnvCommand result(cmd
+ ("ROOT", uninstall_params.get<ecupk_root>())
+ ("PALUDIS_EBUILD_OVERRIDE_CONFIG_PROTECT_MASK",
+ uninstall_params.get<ecupk_disable_cfgpro>() ? "/" : ""));
+
+ return result;
+}
+
+EbuildUninstallCommand::EbuildUninstallCommand(const EbuildCommandParams & p,
+ const EbuildUninstallCommandParams & f) :
+ EbuildCommand(p),
+ uninstall_params(f)
+{
+}
+
diff --git a/paludis/ebuild.hh b/paludis/ebuild.hh
new file mode 100644
index 0000000..40a086e
--- /dev/null
+++ b/paludis/ebuild.hh
@@ -0,0 +1,235 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaran.mccreesh@blueyonder.co.uk>
+ *
+ * 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_PALUDIS_EBUILD_HH
+#define PALUDIS_GUARD_PALUDIS_EBUILD_HH 1
+
+#include <paludis/util/instantiation_policy.hh>
+#include <paludis/util/smart_record.hh>
+#include <paludis/util/fs_entry.hh>
+#include <paludis/util/attributes.hh>
+#include <paludis/package_database.hh>
+#include <string>
+#include <map>
+
+namespace paludis
+{
+ enum EbuildCommandParamsKeys
+ {
+ ecpk_environment,
+ ecpk_db_entry,
+ ecpk_ebuild_dir,
+ ecpk_files_dir,
+ ecpk_eclass_dir,
+ ecpk_portdir,
+ ecpk_distdir,
+ last_ecpk
+ };
+
+ class Environment;
+ class MakeEnvCommand;
+
+ struct EbuildCommandParamsTag :
+ SmartRecordTag<comparison_mode::NoComparisonTag, void>,
+ SmartRecordKeys<EbuildCommandParamsKeys, last_ecpk>,
+ SmartRecordKey<ecpk_environment, const Environment *>,
+ SmartRecordKey<ecpk_db_entry, const PackageDatabaseEntry *>,
+ SmartRecordKey<ecpk_ebuild_dir, const FSEntry>,
+ SmartRecordKey<ecpk_files_dir, const FSEntry>,
+ SmartRecordKey<ecpk_eclass_dir, const FSEntry>,
+ SmartRecordKey<ecpk_portdir, const FSEntry>,
+ SmartRecordKey<ecpk_distdir, const FSEntry>
+ {
+ };
+
+ typedef MakeSmartRecord<EbuildCommandParamsTag>::Type EbuildCommandParams;
+
+ class EbuildCommand :
+ private InstantiationPolicy<EbuildCommand, instantiation_method::NonCopyableTag>
+ {
+ protected:
+ const EbuildCommandParams params;
+
+ EbuildCommand(const EbuildCommandParams &);
+
+ virtual std::string commands() const = 0;
+
+ virtual bool success();
+
+ virtual bool failure() = 0;
+
+ virtual bool do_run_command(const std::string &);
+
+ virtual MakeEnvCommand extend_command(const MakeEnvCommand &) = 0;
+
+ public:
+ virtual ~EbuildCommand();
+
+ virtual bool operator() ();
+ };
+
+ class EbuildMetadataCommand :
+ public EbuildCommand
+ {
+ private:
+ VersionMetadata::Pointer _metadata;
+
+ protected:
+ virtual std::string commands() const;
+
+ virtual bool failure();
+
+ virtual MakeEnvCommand extend_command(const MakeEnvCommand &);
+
+ virtual bool do_run_command(const std::string &);
+
+ public:
+ EbuildMetadataCommand(const EbuildCommandParams &);
+
+ VersionMetadata::Pointer metadata() const
+ {
+ return _metadata;
+ }
+ };
+
+ enum EbuildFetchCommandParamsKeys
+ {
+ ecfpk_a,
+ ecfpk_use,
+ ecfpk_use_expand,
+ ecfpk_flat_src_uri,
+ ecfpk_root,
+ ecfpk_profile,
+ ecfpk_expand_vars,
+ last_ecfpk
+ };
+
+ struct EbuildFetchCommandParamsTag :
+ SmartRecordTag<comparison_mode::NoComparisonTag, void>,
+ SmartRecordKeys<EbuildFetchCommandParamsKeys, last_ecfpk>,
+ SmartRecordKey<ecfpk_a, std::string>,
+ SmartRecordKey<ecfpk_use, std::string>,
+ SmartRecordKey<ecfpk_use_expand, std::string>,
+ SmartRecordKey<ecfpk_flat_src_uri, std::string>,
+ SmartRecordKey<ecfpk_root, std::string>,
+ SmartRecordKey<ecfpk_profile, std::string>,
+ SmartRecordKey<ecfpk_expand_vars, std::map<std::string, std::string> >
+ {
+ };
+
+ typedef MakeSmartRecord<EbuildFetchCommandParamsTag>::Type EbuildFetchCommandParams;
+
+ class EbuildFetchCommand :
+ public EbuildCommand
+ {
+ protected:
+ const EbuildFetchCommandParams fetch_params;
+
+ virtual std::string commands() const;
+
+ virtual bool failure() PALUDIS_ATTRIBUTE((noreturn));
+
+ virtual MakeEnvCommand extend_command(const MakeEnvCommand &);
+
+ public:
+ EbuildFetchCommand(const EbuildCommandParams &, const EbuildFetchCommandParams &);
+ };
+
+ enum EbuildInstallCommandParamsKeys
+ {
+ ecipk_use,
+ ecipk_use_expand,
+ ecipk_root,
+ ecipk_profile,
+ ecipk_expand_vars,
+ ecipk_disable_cfgpro,
+ ecipk_merge_only,
+ ecipk_slot,
+ last_ecipk
+ };
+
+ struct EbuildInstallCommandParamsTag :
+ SmartRecordTag<comparison_mode::NoComparisonTag, void>,
+ SmartRecordKeys<EbuildInstallCommandParamsKeys, last_ecipk>,
+ SmartRecordKey<ecipk_use, std::string>,
+ SmartRecordKey<ecipk_use_expand, std::string>,
+ SmartRecordKey<ecipk_root, std::string>,
+ SmartRecordKey<ecipk_profile, std::string>,
+ SmartRecordKey<ecipk_expand_vars, std::map<std::string, std::string> >,
+ SmartRecordKey<ecipk_disable_cfgpro, bool>,
+ SmartRecordKey<ecipk_merge_only, bool>,
+ SmartRecordKey<ecipk_slot, SlotName>
+ {
+ };
+
+ typedef MakeSmartRecord<EbuildInstallCommandParamsTag>::Type EbuildInstallCommandParams;
+
+ class EbuildInstallCommand :
+ public EbuildCommand
+ {
+ protected:
+ const EbuildInstallCommandParams install_params;
+
+ virtual std::string commands() const;
+
+ virtual bool failure() PALUDIS_ATTRIBUTE((noreturn));
+
+ virtual MakeEnvCommand extend_command(const MakeEnvCommand &);
+
+ public:
+ EbuildInstallCommand(const EbuildCommandParams &, const EbuildInstallCommandParams &);
+ };
+
+ enum EbuildUninstallCommandParamsKeys
+ {
+ ecupk_root,
+ ecupk_disable_cfgpro,
+ ecupk_unmerge_only,
+ last_ecupk
+ };
+
+ struct EbuildUninstallCommandParamsTag :
+ SmartRecordTag<comparison_mode::NoComparisonTag, void>,
+ SmartRecordKeys<EbuildUninstallCommandParamsKeys, last_ecupk>,
+ SmartRecordKey<ecupk_root, std::string>,
+ SmartRecordKey<ecupk_disable_cfgpro, bool>,
+ SmartRecordKey<ecupk_unmerge_only, bool>
+ {
+ };
+
+ typedef MakeSmartRecord<EbuildUninstallCommandParamsTag>::Type EbuildUninstallCommandParams;
+
+ class EbuildUninstallCommand :
+ public EbuildCommand
+ {
+ protected:
+ const EbuildUninstallCommandParams uninstall_params;
+
+ virtual std::string commands() const;
+
+ virtual bool failure() PALUDIS_ATTRIBUTE((noreturn));
+
+ virtual MakeEnvCommand extend_command(const MakeEnvCommand &);
+
+ public:
+ EbuildUninstallCommand(const EbuildCommandParams &, const EbuildUninstallCommandParams &);
+ };
+}
+
+#endif
diff --git a/paludis/files.m4 b/paludis/files.m4
index a1480d6..0bbe050 100644
--- a/paludis/files.m4
+++ b/paludis/files.m4
@@ -19,6 +19,7 @@ add(`dep_atom_pretty_printer', `hh', `cc')
add(`dep_lexer', `hh', `cc', `test')
add(`dep_list', `hh', `cc', `test')
add(`dep_parser', `hh', `cc', `test')
+add(`ebuild', `hh', `cc')
add(`environment', `hh', `cc')
add(`fake_repository', `hh', `cc')
add(`hashed_containers', `hh', `cc', `test')
diff --git a/paludis/portage_repository.cc b/paludis/portage_repository.cc
index 70f1caa..9522284 100644
--- a/paludis/portage_repository.cc
+++ b/paludis/portage_repository.cc
@@ -23,6 +23,7 @@
#include <paludis/dep_atom.hh>
#include <paludis/dep_atom_flattener.hh>
#include <paludis/dep_parser.hh>
+#include <paludis/ebuild.hh>
#include <paludis/hashed_containers.hh>
#include <paludis/config_file.hh>
#include <paludis/match_package.hh>
@@ -768,63 +769,22 @@ PortageRepository::do_version_metadata(
Log::get_instance()->message(ll_warning, "No usable cache entry for '" + stringify(c) + "/" +
stringify(p) + "-" + stringify(v) + "' in '" + stringify(name()) + "'");
- std::string actions("metadata");
- std::string cmd(make_env_command(
- getenv_with_default("PALUDIS_EBUILD_DIR", LIBEXECDIR "/paludis") +
- "/ebuild.bash '" +
- stringify(_imp->location) + "/" +
- stringify(c) + "/" +
- stringify(p) + "/" +
- stringify(p) + "-" + stringify(v) + ".ebuild' " + actions)
- ("P", stringify(p) + "-" + stringify(v.remove_revision()))
- ("PV", stringify(v.remove_revision()))
- ("PR", v.revision_only())
- ("PN", stringify(p))
- ("PVR", stringify(v.remove_revision()) + "-" + v.revision_only())
- ("PF", stringify(p) + "-" + stringify(v))
- ("CATEGORY", stringify(c))
- ("FILESDIR", stringify(_imp->location) + "/" + stringify(c) + "/" +
- stringify(p) + "/files/")
- ("ECLASSDIR", stringify(_imp->eclassdir))
- ("PORTDIR", stringify(_imp->location) + "/")
- ("DISTDIR", stringify(_imp->distdir))
- ("PALUDIS_TMPDIR", BIGTEMPDIR "/paludis/")
- ("PALUDIS_BASHRC_FILES", _imp->env->bashrc_files())
- ("PALUDIS_COMMAND", _imp->env->paludis_command())
- ("KV", kernel_version())
- ("PALUDIS_EBUILD_LOG_LEVEL", Log::get_instance()->log_level_string())
- ("PALUDIS_EBUILD_DIR", getenv_with_default("PALUDIS_EBUILD_DIR", LIBEXECDIR "/paludis")));
-
-
- PStream prog(cmd);
- KeyValueConfigFile f(&prog);
-
- result->set(vmk_depend, f.get("DEPEND"));
- result->set(vmk_rdepend, f.get("RDEPEND"));
- result->set(vmk_slot, f.get("SLOT"));
- result->set(vmk_src_uri, f.get("SRC_URI"));
- result->set(vmk_restrict, f.get("RESTRICT"));
- result->set(vmk_homepage, f.get("HOMEPAGE"));
- result->set(vmk_license, f.get("LICENSE"));
- result->set(vmk_description, f.get("DESCRIPTION"));
- result->set(vmk_keywords, f.get("KEYWORDS"));
- result->set(vmk_inherited, f.get("INHERITED"));
- result->set(vmk_iuse, f.get("IUSE"));
- result->set(vmk_pdepend, f.get("PDEPEND"));
- result->set(vmk_provide, f.get("PROVIDE"));
- result->set(vmk_eapi, f.get("EAPI"));
- result->set(vmk_virtual, "");
- result->set(vmk_e_keywords, f.get("E_KEYWORDS"));
-
- if (prog.exit_status())
- {
- Log::get_instance()->message(ll_warning, "Could not generate cache for '"
- + stringify(c) + "/" + stringify(p) + "-" + stringify(v) + "' in repository '"
- + stringify(name()) + "'");
- result->set(vmk_eapi, "UNKNOWN");
- }
- else
- ok = true;
+ PackageDatabaseEntry e(QualifiedPackageName(c, p), v, name());
+ EbuildMetadataCommand cmd(EbuildCommandParams::create((
+ param<ecpk_environment>(_imp->env),
+ param<ecpk_db_entry>(&e),
+ param<ecpk_ebuild_dir>(_imp->location / stringify(c) / stringify(p)),
+ param<ecpk_files_dir>(_imp->location / stringify(c) / stringify(p) / "files"),
+ param<ecpk_eclass_dir>(_imp->eclassdir),
+ param<ecpk_portdir>(_imp->location),
+ param<ecpk_distdir>(_imp->distdir)
+ )));
+ if (! cmd())
+ Log::get_instance()->message(ll_warning, "No usable metadata for '" + stringify(c) + "/" +
+ stringify(p) + "-" + stringify(v) + "' in '" + stringify(name()) + "'");
+
+ if (0 == ((result = cmd.metadata())))
+ throw InternalError(PALUDIS_HERE, "cmd.metadata() is zero pointer???");
}
_imp->metadata.insert(std::make_pair(std::make_pair(QualifiedPackageName(c, p), v), result));
@@ -1103,7 +1063,8 @@ PortageRepository::do_is_mirror(const std::string & s) const
}
void
-PortageRepository::do_install(const QualifiedPackageName & q, const VersionSpec & v, const InstallOptions & o) const
+PortageRepository::do_install(const QualifiedPackageName & q, const VersionSpec & v,
+ const InstallOptions & o) const
{
if (! _imp->has_profile)
{
@@ -1197,20 +1158,6 @@ PortageRepository::do_install(const QualifiedPackageName & q, const VersionSpec
}
}
- std::string actions;
- if (o.get<io_fetchonly>())
- {
- if (metadata->get(vmk_virtual).empty())
- actions = "fetch";
- else
- actions = "";
- }
- else if (metadata->get(vmk_virtual).empty())
- actions = "init fetch setup unpack compile test install strip preinst "
- "merge postinst updateenv tidyup";
- else
- actions = "merge";
-
std::string use;
VersionMetadata::IuseIterator iuse_it=metadata->begin_iuse(), iuse_end=metadata->end_iuse();
for ( ; iuse_it != iuse_end; ++iuse_it)
@@ -1242,41 +1189,7 @@ PortageRepository::do_install(const QualifiedPackageName & q, const VersionSpec
use += stringify(*uu) + " ";
}
- MakeEnvCommand cmd(make_env_command(
- getenv_with_default("PALUDIS_EBUILD_DIR", LIBEXECDIR "/paludis") +
- "/ebuild.bash '" +
- stringify(_imp->location) + "/" +
- stringify(q.get<qpn_category>()) + "/" +
- stringify(q.get<qpn_package>()) + "/" +
- stringify(q.get<qpn_package>()) + "-" + stringify(v) + ".ebuild' " + actions)
- ("P", stringify(q.get<qpn_package>()) + "-" + stringify(v.remove_revision()))
- ("PV", stringify(v.remove_revision()))
- ("PR", v.revision_only())
- ("PN", stringify(q.get<qpn_package>()))
- ("PVR", stringify(v.remove_revision()) + "-" + v.revision_only())
- ("PF", stringify(q.get<qpn_package>()) + "-" + stringify(v))
- ("SLOT", metadata->get(vmk_slot))
- ("A", archives)
- ("USE", use)
- ("USE_EXPAND", join(_imp->expand_list.begin(), _imp->expand_list.end(), " "))
- ("FLAT_SRC_URI", flat_src_uri)
- ("CATEGORY", stringify(q.get<qpn_category>()))
- ("FILESDIR", stringify(_imp->location) + "/" + stringify(q.get<qpn_category>()) + "/" +
- stringify(q.get<qpn_package>()) + "/files/")
- ("ECLASSDIR", stringify(_imp->eclassdir))
- ("PORTDIR", stringify(_imp->location) + "/")
- ("DISTDIR", stringify(_imp->distdir))
- ("ROOT", stringify(_imp->root) + "/")
- ("PALUDIS_TMPDIR", BIGTEMPDIR "/paludis/")
- ("PALUDIS_CONFIG_DIR", SYSCONFDIR "/paludis/")
- ("PALUDIS_PROFILE_DIR", stringify(_imp->profile))
- ("PALUDIS_BASHRC_FILES", _imp->env->bashrc_files())
- ("PALUDIS_COMMAND", _imp->env->paludis_command())
- ("KV", kernel_version())
- ("PALUDIS_EBUILD_OVERRIDE_CONFIG_PROTECT_MASK", o.get<io_noconfigprotect>() ? "/" : "")
- ("PALUDIS_EBUILD_LOG_LEVEL", Log::get_instance()->log_level_string())
- ("PALUDIS_EBUILD_DIR", getenv_with_default("PALUDIS_EBUILD_DIR", LIBEXECDIR "/paludis")));
-
+ std::map<std::string, std::string> expand_vars;
for (UseFlagSet::const_iterator u(_imp->expand_list.begin()),
u_end(_imp->expand_list.end()) ; u != u_end ; ++u)
{
@@ -1290,12 +1203,62 @@ PortageRepository::do_install(const QualifiedPackageName & q, const VersionSpec
for (UseFlagNameCollection::Iterator xx(x->begin()), xx_end(x->end()) ;
xx != xx_end ; ++xx)
value.append(stringify(*xx).erase(0, stringify(*u).length() + 1) + " ");
- cmd = cmd(stringify(*u), value);
+
+ expand_vars.insert(std::make_pair(stringify(*u), value));
}
- if (0 != run_command(cmd))
- throw PackageInstallActionError("Can't install '" + stringify(q) + "-"
- + stringify(v) + "'");
+ EbuildFetchCommand fetch_cmd(EbuildCommandParams::create((
+ param<ecpk_environment>(_imp->env),
+ param<ecpk_db_entry>(&e),
+ param<ecpk_ebuild_dir>(_imp->location / stringify(q.get<qpn_category>()) /
+ stringify(q.get<qpn_package>())),
+ param<ecpk_files_dir>(_imp->location / stringify(q.get<qpn_category>()) /
+ stringify(q.get<qpn_package>()) / "files"),
+ param<ecpk_eclass_dir>(_imp->eclassdir),
+ param<ecpk_portdir>(_imp->location),
+ param<ecpk_distdir>(_imp->distdir)
+ )),
+ EbuildFetchCommandParams::create((
+ param<ecfpk_a>(archives),
+ param<ecfpk_use>(use),
+ param<ecfpk_use_expand>(join(_imp->expand_list.begin(),
+ _imp->expand_list.end(), " ")),
+ param<ecfpk_expand_vars>(expand_vars),
+ param<ecfpk_flat_src_uri>(flat_src_uri),
+ param<ecfpk_root>(stringify(_imp->root) + "/"),
+ param<ecfpk_profile>(stringify(_imp->profile))
+ )));
+
+ if (metadata->get(vmk_virtual).empty())
+ fetch_cmd();
+
+ if (o.get<io_fetchonly>())
+ return;
+
+ EbuildInstallCommand install_cmd(EbuildCommandParams::create((
+ param<ecpk_environment>(_imp->env),
+ param<ecpk_db_entry>(&e),
+ param<ecpk_ebuild_dir>(_imp->location / stringify(q.get<qpn_category>()) /
+ stringify(q.get<qpn_package>())),
+ param<ecpk_files_dir>(_imp->location / stringify(q.get<qpn_category>()) /
+ stringify(q.get<qpn_package>()) / "files"),
+ param<ecpk_eclass_dir>(_imp->eclassdir),
+ param<ecpk_portdir>(_imp->location),
+ param<ecpk_distdir>(_imp->distdir)
+ )),
+ EbuildInstallCommandParams::create((
+ param<ecipk_use>(use),
+ param<ecipk_use_expand>(join(_imp->expand_list.begin(),
+ _imp->expand_list.end(), " ")),
+ param<ecipk_expand_vars>(expand_vars),
+ param<ecipk_root>(stringify(_imp->root) + "/"),
+ param<ecipk_profile>(stringify(_imp->profile)),
+ param<ecipk_disable_cfgpro>(o.get<io_noconfigprotect>()),
+ param<ecipk_merge_only>(! metadata->get(vmk_virtual).empty()),
+ param<ecipk_slot>(SlotName(metadata->get(vmk_slot)))
+ )));
+
+ install_cmd();
}
DepAtom::Pointer
diff --git a/paludis/repository.cc b/paludis/repository.cc
index 3c59f86..6deb334 100644
--- a/paludis/repository.cc
+++ b/paludis/repository.cc
@@ -51,6 +51,11 @@ PackageInstallActionError::PackageInstallActionError(const std::string & msg) th
{
}
+PackageFetchActionError::PackageFetchActionError(const std::string & msg) throw () :
+ PackageActionError("Fetch error: " + msg)
+{
+}
+
PackageUninstallActionError::PackageUninstallActionError(const std::string & msg) throw () :
PackageActionError("Uninstall error: " + msg)
{
diff --git a/paludis/repository.hh b/paludis/repository.hh
index 2b57e34..e65ae3a 100644
--- a/paludis/repository.hh
+++ b/paludis/repository.hh
@@ -504,6 +504,17 @@ namespace paludis
};
/**
+ * Thrown if a fetch fails.
+ *
+ * \ingroup Exception.
+ */
+ class PackageFetchActionError : public PackageActionError
+ {
+ public:
+ PackageFetchActionError(const std::string & msg) throw ();
+ };
+
+ /**
* Thrown if an uninstall fails.
*
* \ingroup Exception.
diff --git a/paludis/vdb_repository.cc b/paludis/vdb_repository.cc
index 785b06d..0d49a86 100644
--- a/paludis/vdb_repository.cc
+++ b/paludis/vdb_repository.cc
@@ -20,6 +20,7 @@
#include <paludis/dep_atom.hh>
#include <paludis/dep_atom_flattener.hh>
#include <paludis/dep_parser.hh>
+#include <paludis/ebuild.hh>
#include <paludis/hashed_containers.hh>
#include <paludis/config_file.hh>
#include <paludis/match_package.hh>
@@ -535,42 +536,27 @@ VDBRepository::do_uninstall(const QualifiedPackageName & q, const VersionSpec &
metadata = version_metadata(q, v);
PackageDatabaseEntry e(q, v, name());
- std::string actions;
- if (metadata->get(vmk_virtual).empty())
- actions = "prerm unmerge postrm";
- else
- actions = "unmerge";
-
- std::string cmd(make_env_command(
- getenv_with_default("PALUDIS_EBUILD_DIR", LIBEXECDIR "/paludis") +
- "/ebuild.bash '" +
- stringify(_imp->location) + "/" +
- stringify(q.get<qpn_category>()) + "/" +
- stringify(q.get<qpn_package>()) + "-" + stringify(v) + "/" +
- stringify(q.get<qpn_package>()) + "-" + stringify(v) + ".ebuild' " + actions)
- ("P", stringify(q.get<qpn_package>()) + "-" + stringify(v.remove_revision()))
- ("PV", stringify(v.remove_revision()))
- ("PR", v.revision_only())
- ("PN", stringify(q.get<qpn_package>()))
- ("PVR", stringify(v.remove_revision()) + "-" + v.revision_only())
- ("PF", stringify(q.get<qpn_package>()) + "-" + stringify(v))
- ("CATEGORY", stringify(q.get<qpn_category>()))
- ("ECLASSDIR", stringify(_imp->location) + "/" +
- stringify(q.get<qpn_category>()) + "/" +
- stringify(q.get<qpn_package>()) + "-" + stringify(v) + "/")
- ("ROOT", stringify(_imp->root) + "/")
- ("PALUDIS_TMPDIR", BIGTEMPDIR "/paludis/")
- ("PALUDIS_CONFIG_DIR", SYSCONFDIR "/paludis/")
- ("PALUDIS_BASHRC_FILES", _imp->env->bashrc_files())
- ("PALUDIS_COMMAND", _imp->env->paludis_command())
- ("KV", kernel_version())
- ("PALUDIS_EBUILD_OVERRIDE_CONFIG_PROTECT_MASK", o.get<io_noconfigprotect>() ? "/" : "")
- ("PALUDIS_EBUILD_LOG_LEVEL", Log::get_instance()->log_level_string())
- ("PALUDIS_EBUILD_DIR", getenv_with_default("PALUDIS_EBUILD_DIR", LIBEXECDIR "/paludis")));
-
- if (0 != run_command(cmd))
- throw PackageInstallActionError("Couldn't uninstall '" + stringify(q) + "-" +
- stringify(v) + "'");
+
+ EbuildUninstallCommand uninstall_cmd(EbuildCommandParams::create((
+ param<ecpk_environment>(_imp->env),
+ param<ecpk_db_entry>(&e),
+ param<ecpk_ebuild_dir>(_imp->location / stringify(q.get<qpn_category>()) /
+ (stringify(q.get<qpn_package>()) + "-" + stringify(v))),
+ param<ecpk_files_dir>(_imp->location / stringify(q.get<qpn_category>()) /
+ (stringify(q.get<qpn_package>()) + "-" + stringify(v))),
+ param<ecpk_eclass_dir>(_imp->location / stringify(q.get<qpn_category>()) /
+ (stringify(q.get<qpn_package>()) + "-" + stringify(v))),
+ param<ecpk_portdir>(_imp->location),
+ param<ecpk_distdir>(_imp->location / stringify(q.get<qpn_category>()) /
+ (stringify(q.get<qpn_package>()) + "-" + stringify(v)))
+ )),
+ EbuildUninstallCommandParams::create((
+ param<ecupk_root>(stringify(_imp->root) + "/"),
+ param<ecupk_disable_cfgpro>(o.get<io_noconfigprotect>()),
+ param<ecupk_unmerge_only>(! metadata->get(vmk_virtual).empty())
+ )));
+
+ uninstall_cmd();
}
DepAtom::Pointer