aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Saleem Abdulrasool <compnerd@compnerd.org> 2015-04-04 13:50:22 -0700
committerAvatar Saleem Abdulrasool <compnerd@compnerd.org> 2015-04-19 14:21:15 -0700
commita00ac54d6f4d928b71aaba2f6d3f6e24648ce594 (patch)
tree7972e79fa0174de95f3a7f38503828de1acfa3c4
parent351504abe2112351398e55cf0ab73b84418b4c08 (diff)
downloadpaludis-a00ac54d6f4d928b71aaba2f6d3f6e24648ce594.tar.gz
paludis-a00ac54d6f4d928b71aaba2f6d3f6e24648ce594.tar.xz
repositories: pull action option destination into a variable
This pulls the destination out into a variable since its often used. NFC.
-rw-r--r--paludis/repositories/e/do_install_action.cc38
-rw-r--r--paludis/repositories/e/do_pretend_action.cc23
-rw-r--r--paludis/repositories/unpackaged/unpackaged_id.cc15
3 files changed, 42 insertions, 34 deletions
diff --git a/paludis/repositories/e/do_install_action.cc b/paludis/repositories/e/do_install_action.cc
index 6fa587b..5730e2e 100644
--- a/paludis/repositories/e/do_install_action.cc
+++ b/paludis/repositories/e/do_install_action.cc
@@ -219,6 +219,7 @@ paludis::erepository::do_install_action(
auto choices(id->choices_key()->parse_value());
auto work_choice(choices->find_by_name_with_prefix(ELikeWorkChoiceValue::canonical_name_with_prefix()));
auto volatile_files(std::make_shared<FSPathSet>());
+ auto destination = install_action.options.destination();
EAPIPhases phases(id->eapi()->supported()->ebuild_phases()->ebuild_install());
for (EAPIPhases::ConstIterator phase(phases.begin_phases()), phase_end(phases.end_phases()) ;
@@ -264,9 +265,9 @@ paludis::erepository::do_install_action(
if (phase->option("merge") || phase->option("check_merge"))
{
- if (! (*install_action.options.destination()).destination_interface())
+ if (! destination->destination_interface())
throw ActionFailedError("Can't install '" + stringify(*id)
- + "' to destination '" + stringify(install_action.options.destination()->name())
+ + "' to destination '" + stringify(destination->name())
+ "' because destination does not provide destination_interface");
MergerOptions extra_merger_options;
@@ -274,7 +275,7 @@ paludis::erepository::do_install_action(
extra_merger_options += mo_nondestructive;
Timestamp build_start_time(FSPath(package_builddir / "temp" / "build_start_time").stat().mtim());
- (*install_action.options.destination()).destination_interface()->merge(
+ destination->destination_interface()->merge(
make_named_values<MergeParams>(
n::build_start_time() = build_start_time,
n::check() = phase->option("check_merge"),
@@ -303,12 +304,12 @@ paludis::erepository::do_install_action(
auto vstat = vabs.stat();
if (! vstat.is_regular_file_or_symlink_to_regular_file())
throw ActionFailedError("Can't install '" + stringify(*id)
- + "' to destination '" + stringify(install_action.options.destination()->name())
+ + "' to destination '" + stringify(destination->name())
+ "' because '" + stringify(v) + "' was marked using exvolatile, but it is not a regular "
"file or a symlink to a regular file");
if (vstat.is_symlink() && 0 == vabs.readlink().compare(0, 1, "/", 0, 1))
throw ActionFailedError("Can't install '" + stringify(*id)
- + "' to destination '" + stringify(install_action.options.destination()->name())
+ + "' to destination '" + stringify(destination->name())
+ "' because '" + stringify(v) + "' was marked using exvolatile, but volatile symlinks"
"must not be absolute");
}
@@ -319,8 +320,9 @@ paludis::erepository::do_install_action(
if ((! id->eapi()->supported()->is_pbin()) && (! strip_restrict))
{
std::string libdir("lib");
- FSPath root(install_action.options.destination()->installed_root_key() ?
- stringify(install_action.options.destination()->installed_root_key()->parse_value()) : "/");
+ FSPath root(destination->installed_root_key()
+ ? stringify(destination->installed_root_key()->parse_value())
+ : "/");
if ((root / "usr" / "lib").stat().is_symlink())
{
libdir = (root / "usr" / "lib").readlink();
@@ -350,8 +352,8 @@ paludis::erepository::do_install_action(
}
}
else if ((! phase->option("prepost")) ||
- ((*install_action.options.destination()).destination_interface() &&
- (*install_action.options.destination()).destination_interface()->want_pre_post_phases()))
+ (destination->destination_interface() &&
+ destination->destination_interface()->want_pre_post_phases()))
{
if (phase->option("optional_tests"))
{
@@ -403,9 +405,9 @@ paludis::erepository::do_install_action(
n::portdir() =
(params.master_repositories() && ! params.master_repositories()->empty()) ?
(*params.master_repositories()->begin())->params().location() : params.location(),
- n::root() = install_action.options.destination()->installed_root_key() ?
- stringify(install_action.options.destination()->installed_root_key()->parse_value()) :
- "/",
+ n::root() = destination->installed_root_key()
+ ? stringify(destination->installed_root_key()->parse_value())
+ : "/",
n::sandbox() = phase->option("sandbox"),
n::sydbox() = phase->option("sydbox"),
n::userpriv() = phase->option("userpriv") && userpriv_ok,
@@ -419,7 +421,7 @@ paludis::erepository::do_install_action(
n::accept_license() = accept_license,
n::config_protect() = repo->environment_updated_profile_variable("CONFIG_PROTECT"),
n::config_protect_mask() = repo->environment_updated_profile_variable("CONFIG_PROTECT_MASK"),
- n::destination() = install_action.options.destination(),
+ n::destination() = destination,
n::expand_vars() = expand_vars,
n::is_from_pbin() = id->eapi()->supported()->is_pbin(),
n::loadsaveenv_dir() = package_builddir / "temp",
@@ -467,9 +469,9 @@ paludis::erepository::do_install_action(
(params.master_repositories() && ! params.master_repositories()->empty())
? (*params.master_repositories()->begin())->params().location()
: params.location(),
- n::root() = install_action.options.destination()->installed_root_key() ?
- stringify(install_action.options.destination()->installed_root_key()->parse_value()) :
- "/",
+ n::root() = destination->installed_root_key()
+ ? stringify(destination->installed_root_key()->parse_value())
+ : "/",
n::sandbox() = tidyup_phase->option("sandbox"),
n::sydbox() = tidyup_phase->option("sydbox"),
n::userpriv() = tidyup_phase->option("userpriv") && userpriv_ok,
@@ -483,7 +485,7 @@ paludis::erepository::do_install_action(
n::accept_license() = accept_license,
n::config_protect() = repo->environment_updated_profile_variable("CONFIG_PROTECT"),
n::config_protect_mask() = repo->environment_updated_profile_variable("CONFIG_PROTECT_MASK"),
- n::destination() = install_action.options.destination(),
+ n::destination() = destination,
n::expand_vars() = expand_vars,
n::is_from_pbin() = id->eapi()->supported()->is_pbin(),
n::loadsaveenv_dir() = package_builddir / "temp",
@@ -507,7 +509,7 @@ paludis::erepository::do_install_action(
}
/* replacing for pbins is done during the merge */
- if (install_action.options.destination()->installed_root_key())
+ if (destination->installed_root_key())
for (PackageIDSequence::ConstIterator i(install_action.options.replacing()->begin()), i_end(install_action.options.replacing()->end()) ;
i != i_end ; ++i)
{
diff --git a/paludis/repositories/e/do_pretend_action.cc b/paludis/repositories/e/do_pretend_action.cc
index 4512cd8..3994e9a 100644
--- a/paludis/repositories/e/do_pretend_action.cc
+++ b/paludis/repositories/e/do_pretend_action.cc
@@ -105,6 +105,7 @@ paludis::erepository::do_pretend_action(
const auto params = repo->params();
const auto profile = repo->profile();
+ const auto destination = a.options.destination();
EbuildCommandParams command_params(make_named_values<EbuildCommandParams>(
n::builddir() = params.builddir(),
@@ -125,9 +126,9 @@ paludis::erepository::do_pretend_action(
n::portdir() =
(params.master_repositories() && ! params.master_repositories()->empty()) ?
(*params.master_repositories()->begin())->params().location() : params.location(),
- n::root() = a.options.destination()->installed_root_key() ?
- stringify(a.options.destination()->installed_root_key()->parse_value()) :
- "/",
+ n::root() = destination->installed_root_key()
+ ? stringify(destination->installed_root_key()->parse_value())
+ : "/",
n::sandbox() = phase->option("sandbox"),
n::sydbox() = phase->option("sydbox"),
n::userpriv() = phase->option("userpriv") && userpriv_ok,
@@ -172,6 +173,7 @@ paludis::erepository::do_pretend_action(
const auto params = repo->params();
const auto profile = repo->profile();
+ const auto destination = a.options.destination();
EbuildCommandParams command_params(make_named_values<EbuildCommandParams>(
n::builddir() = params.builddir(),
@@ -193,9 +195,9 @@ paludis::erepository::do_pretend_action(
(params.master_repositories() && ! params.master_repositories()->empty())
? (*params.master_repositories()->begin())->params().location()
: params.location(),
- n::root() = a.options.destination()->installed_root_key() ?
- stringify(a.options.destination()->installed_root_key()->parse_value()) :
- "/",
+ n::root() = destination->installed_root_key()
+ ? stringify(destination->installed_root_key()->parse_value())
+ : "/",
n::sandbox() = phase->option("sandbox"),
n::sydbox() = phase->option("sydbox"),
n::userpriv() = phase->option("userpriv") && userpriv_ok,
@@ -238,6 +240,7 @@ paludis::erepository::do_pretend_action(
const auto params = repo->params();
const auto profile = repo->profile();
+ const auto destination = a.options.destination();
EbuildCommandParams command_params(make_named_values<EbuildCommandParams>(
n::builddir() = params.builddir(),
@@ -259,9 +262,9 @@ paludis::erepository::do_pretend_action(
(params.master_repositories() && ! params.master_repositories()->empty())
? (*params.master_repositories()->begin())->params().location()
: params.location(),
- n::root() = a.options.destination()->installed_root_key() ?
- stringify(a.options.destination()->installed_root_key()->parse_value()) :
- "/",
+ n::root() = destination->installed_root_key()
+ ? stringify(destination->installed_root_key()->parse_value())
+ : "/",
n::sandbox() = phase->option("sandbox"),
n::sydbox() = phase->option("sydbox"),
n::userpriv() = phase->option("userpriv") && userpriv_ok,
@@ -270,7 +273,7 @@ paludis::erepository::do_pretend_action(
EbuildPretendCommand pretend_cmd(command_params,
make_named_values<EbuildPretendCommandParams>(
- n::destination() = a.options.destination(),
+ n::destination() = destination,
n::expand_vars() = expand_vars,
n::is_from_pbin() = id->eapi()->supported()->is_pbin(),
n::profiles() = params.profiles(),
diff --git a/paludis/repositories/unpackaged/unpackaged_id.cc b/paludis/repositories/unpackaged/unpackaged_id.cc
index 1fdea2a..118ece8 100644
--- a/paludis/repositories/unpackaged/unpackaged_id.cc
+++ b/paludis/repositories/unpackaged/unpackaged_id.cc
@@ -344,16 +344,19 @@ UnpackagedID::perform_action(Action & action) const
if (! install_action)
throw ActionFailedError("Unsupported action: " + action.simple_name());
- if (! (*install_action->options.destination()).destination_interface())
+ const auto destination = install_action->options.destination();
+
+ if (! destination->destination_interface())
throw ActionFailedError("Can't install '" + stringify(*this)
- + "' to destination '" + stringify(install_action->options.destination()->name())
+ + "' to destination '" + stringify(destination->name())
+ "' because destination does not provide destination_interface");
std::shared_ptr<OutputManager> output_manager(install_action->options.make_output_manager()(*install_action));
std::string libdir("lib");
- FSPath root(install_action->options.destination()->installed_root_key() ?
- stringify(install_action->options.destination()->installed_root_key()->parse_value()) : "/");
+ FSPath root(destination->installed_root_key()
+ ? stringify(destination->installed_root_key()->parse_value())
+ : "/");
if ((root / "usr" / "lib").stat().is_symlink())
{
libdir = (root / "usr" / "lib").readlink();
@@ -428,7 +431,7 @@ UnpackagedID::perform_action(Action & action) const
case wp_yes:
{
merge_params.check() = true;
- (*install_action->options.destination()).destination_interface()->merge(merge_params);
+ destination->destination_interface()->merge(merge_params);
}
break;
@@ -447,7 +450,7 @@ UnpackagedID::perform_action(Action & action) const
case wp_yes:
{
merge_params.check() = false;
- (*install_action->options.destination()).destination_interface()->merge(merge_params);
+ destination->destination_interface()->merge(merge_params);
}
break;