aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2009-08-26 21:23:24 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2009-08-26 23:05:11 +0100
commitf5bad8c985a3d30389c7d482efbc1e21e71ab523 (patch)
treea4a7c95bfabea53b6131b844e28dcd0283f04dee
parenta9845e708dd034246d5ad1d04dad123f521013cb (diff)
downloadpaludis-f5bad8c985a3d30389c7d482efbc1e21e71ab523.tar.gz
paludis-f5bad8c985a3d30389c7d482efbc1e21e71ab523.tar.xz
src_fetch_extra
-rw-r--r--paludis/repositories/e/eapi.cc1
-rw-r--r--paludis/repositories/e/eapi.hh2
-rw-r--r--paludis/repositories/e/eapis/exheres-0.conf6
-rw-r--r--paludis/repositories/e/ebuild.cc55
-rw-r--r--paludis/repositories/e/ebuild.hh45
-rwxr-xr-xpaludis/repositories/e/ebuild/ebuild.bash3
-rw-r--r--paludis/repositories/e/ebuild/exheres-0/Makefile.am1
-rw-r--r--paludis/repositories/e/ebuild/exheres-0/src_fetch_extra.bash42
-rw-r--r--paludis/repositories/e/ebuild_entries.cc78
9 files changed, 217 insertions, 16 deletions
diff --git a/paludis/repositories/e/eapi.cc b/paludis/repositories/e/eapi.cc
index 027ab9d..eee0500 100644
--- a/paludis/repositories/e/eapi.cc
+++ b/paludis/repositories/e/eapi.cc
@@ -196,6 +196,7 @@ namespace
return make_shared_ptr(new EAPIEbuildPhases(make_named_values<EAPIEbuildPhases>(
value_for<n::ebuild_bad_options>(check_get(k, "ebuild_bad_options")),
value_for<n::ebuild_config>(check_get(k, "ebuild_config")),
+ value_for<n::ebuild_fetch_extra>(check_get(k, "ebuild_fetch_extra")),
value_for<n::ebuild_info>(check_get(k, "ebuild_info")),
value_for<n::ebuild_install>(check_get(k, "ebuild_install")),
value_for<n::ebuild_metadata>(check_get(k, "ebuild_metadata")),
diff --git a/paludis/repositories/e/eapi.hh b/paludis/repositories/e/eapi.hh
index 894e846..cab7d1e 100644
--- a/paludis/repositories/e/eapi.hh
+++ b/paludis/repositories/e/eapi.hh
@@ -64,6 +64,7 @@ namespace paludis
struct ebuild_bad_options;
struct ebuild_config;
struct ebuild_environment_variables;
+ struct ebuild_fetch_extra;
struct ebuild_functions;
struct ebuild_info;
struct ebuild_install;
@@ -393,6 +394,7 @@ namespace paludis
{
NamedValue<n::ebuild_bad_options, std::string> ebuild_bad_options;
NamedValue<n::ebuild_config, std::string> ebuild_config;
+ NamedValue<n::ebuild_fetch_extra, std::string> ebuild_fetch_extra;
NamedValue<n::ebuild_info, std::string> ebuild_info;
NamedValue<n::ebuild_install, std::string> ebuild_install;
NamedValue<n::ebuild_metadata, std::string> ebuild_metadata;
diff --git a/paludis/repositories/e/eapis/exheres-0.conf b/paludis/repositories/e/eapis/exheres-0.conf
index 564fdd2..594e790 100644
--- a/paludis/repositories/e/eapis/exheres-0.conf
+++ b/paludis/repositories/e/eapis/exheres-0.conf
@@ -118,7 +118,8 @@ ebuild_functions = \
builtin_saveenv builtin_tidyup builtin_variable \
pkg_config pkg_info pkg_nofetch pkg_postinst pkg_postrm \
pkg_preinst pkg_prerm pkg_pretend pkg_setup pkg_bad_options \
- src_compile src_configure src_install src_prepare src_test src_test_expensive src_unpack
+ src_compile src_configure src_fetch_extra src_install \
+ src_prepare src_test src_test_expensive src_unpack
ebuild_install = \
skipname=killold : killold ; \
@@ -163,6 +164,9 @@ ebuild_nofetch = \
sydbox userpriv : initmisc nofetch ; \
: tidyup
+ebuild_fetch_extra = \
+ skipname=fetch_extra skipifno=fetch_extra sydbox : fetch_extra
+
ebuild_variable = \
sydbox userpriv : variable
diff --git a/paludis/repositories/e/ebuild.cc b/paludis/repositories/e/ebuild.cc
index 9253f93..96381aa 100644
--- a/paludis/repositories/e/ebuild.cc
+++ b/paludis/repositories/e/ebuild.cc
@@ -1267,4 +1267,59 @@ EbuildBadOptionsCommand::EbuildBadOptionsCommand(const EbuildCommandParams & p,
{
}
+std::string
+EbuildFetchExtraCommand::commands() const
+{
+ return params.commands();
+}
+
+bool
+EbuildFetchExtraCommand::failure()
+{
+ throw InstallActionError("Extra fetch failed for '" + stringify(*params.package_id()) + "'");
+}
+
+Command
+EbuildFetchExtraCommand::extend_command(const Command & cmd)
+{
+ Command result(Command(cmd)
+ .with_setenv("ROOT", fetch_extra_params.root())
+ .with_setenv("PALUDIS_PROFILE_DIR", stringify(*fetch_extra_params.profiles()->begin()))
+ .with_setenv("PALUDIS_PROFILE_DIRS", join(fetch_extra_params.profiles()->begin(),
+ fetch_extra_params.profiles()->end(), " "))
+ .with_setenv("PALUDIS_ARCHIVES_VAR",
+ params.package_id()->eapi()->supported()->ebuild_environment_variables()->env_a())
+ );
+
+ if (! params.package_id()->eapi()->supported()->ebuild_environment_variables()->env_a().empty())
+ result.with_setenv(params.package_id()->eapi()->supported()->ebuild_environment_variables()->env_a(),
+ fetch_extra_params.a());
+ if (! params.package_id()->eapi()->supported()->ebuild_environment_variables()->env_aa().empty())
+ result.with_setenv(params.package_id()->eapi()->supported()->ebuild_environment_variables()->env_aa(),
+ fetch_extra_params.aa());
+ 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(),
+ fetch_extra_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(),
+ fetch_extra_params.use_expand());
+ if (! params.package_id()->eapi()->supported()->ebuild_environment_variables()->env_use_expand_hidden().empty())
+ result.with_setenv(params.package_id()->eapi()->supported()->ebuild_environment_variables()->env_use_expand_hidden(),
+ fetch_extra_params.use_expand_hidden());
+
+ for (Map<std::string, std::string>::ConstIterator
+ i(fetch_extra_params.expand_vars()->begin()),
+ j(fetch_extra_params.expand_vars()->end()) ; i != j ; ++i)
+ result.with_setenv(i->first, i->second);
+
+ return result;
+}
+
+EbuildFetchExtraCommand::EbuildFetchExtraCommand(const EbuildCommandParams & p,
+ const EbuildFetchExtraCommandParams & f) :
+ EbuildCommand(p),
+ fetch_extra_params(f)
+{
+}
+
diff --git a/paludis/repositories/e/ebuild.hh b/paludis/repositories/e/ebuild.hh
index 945cca4..919d42e 100644
--- a/paludis/repositories/e/ebuild.hh
+++ b/paludis/repositories/e/ebuild.hh
@@ -141,6 +141,25 @@ namespace paludis
};
/**
+ * Parameters for an EbuildFetchExtraCommand.
+ *
+ * \see EbuildFetchExtraCommand
+ * \ingroup grpebuildinterface
+ * \nosubgrouping
+ */
+ struct EbuildFetchExtraCommandParams
+ {
+ NamedValue<n::a, std::string> a;
+ NamedValue<n::aa, std::string> aa;
+ NamedValue<n::expand_vars, std::tr1::shared_ptr<const Map<std::string, std::string> > > expand_vars;
+ NamedValue<n::profiles, std::tr1::shared_ptr<const FSEntrySequence> > profiles;
+ NamedValue<n::root, std::string> root;
+ NamedValue<n::use, std::string> use;
+ NamedValue<n::use_expand, std::string> use_expand;
+ NamedValue<n::use_expand_hidden, std::string> use_expand_hidden;
+ };
+
+ /**
* Parameters for an EbuildInstallCommand.
*
* \see EbuildInstallCommand
@@ -465,6 +484,32 @@ namespace paludis
};
/**
+ * An EbuildFetchExtraCommand is used to perform extra fetches for an exheres from
+ * ERepository. On failure it throws.
+ *
+ * \ingroup grpebuildinterface
+ */
+ class EbuildFetchExtraCommand :
+ public EbuildCommand
+ {
+ protected:
+ /// Parameters for install.
+ const EbuildFetchExtraCommandParams fetch_extra_params;
+
+ virtual std::string commands() const;
+
+ virtual bool failure() PALUDIS_ATTRIBUTE((noreturn));
+
+ virtual Command extend_command(const Command &);
+
+ public:
+ /**
+ * Constructor.
+ */
+ EbuildFetchExtraCommand(const EbuildCommandParams &, const EbuildFetchExtraCommandParams &);
+ };
+
+ /**
* An EbuildUninstallCommand is used to uninstall a package in a VDBRepository.
*
* \ingroup grpebuildinterface
diff --git a/paludis/repositories/e/ebuild/ebuild.bash b/paludis/repositories/e/ebuild/ebuild.bash
index 0265113..0f6ebdd 100755
--- a/paludis/repositories/e/ebuild/ebuild.bash
+++ b/paludis/repositories/e/ebuild/ebuild.bash
@@ -166,7 +166,8 @@ done
builtin_saveenv builtin_tidyup builtin_tidyuprm builtin_variable
pkg_config pkg_info pkg_nofetch pkg_postinst pkg_postrm
pkg_preinst pkg_prerm pkg_pretend pkg_setup pkg_bad_options
- src_compile src_configure src_install src_prepare src_test src_unpack"
+ src_compile src_configure src_install src_prepare src_test src_unpack
+ src_fetch_extra"
# keep the upgrade from 0.36 to 0.38 working
[[ -z ${PALUDIS_EBUILD_PHASE_VAR} ]] && export PALUDIS_EBUILD_PHASE_VAR="EBUILD_PHASE"
diff --git a/paludis/repositories/e/ebuild/exheres-0/Makefile.am b/paludis/repositories/e/ebuild/exheres-0/Makefile.am
index a4084d9..2d53364 100644
--- a/paludis/repositories/e/ebuild/exheres-0/Makefile.am
+++ b/paludis/repositories/e/ebuild/exheres-0/Makefile.am
@@ -36,6 +36,7 @@ libexecprogexheres_SCRIPTS = \
portage_stubs.bash \
src_compile.bash \
src_configure.bash \
+ src_fetch_extra.bash \
src_install.bash \
src_test.bash \
src_test_expensive.bash \
diff --git a/paludis/repositories/e/ebuild/exheres-0/src_fetch_extra.bash b/paludis/repositories/e/ebuild/exheres-0/src_fetch_extra.bash
new file mode 100644
index 0000000..5b688a8
--- /dev/null
+++ b/paludis/repositories/e/ebuild/exheres-0/src_fetch_extra.bash
@@ -0,0 +1,42 @@
+#!/usr/bin/env bash
+# vim: set sw=4 sts=4 et :
+
+# Copyright (c) 2009 Ciaran McCreesh
+#
+# 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
+
+default_src_fetch_extra()
+{
+ :
+}
+
+src_fetch_extra()
+{
+ default "$@"
+}
+
+exheres_internal_fetch_extra()
+{
+ cd "${WORK}" || die "cd to \${WORK} (\"${WORK}\") failed"
+
+ if hasq "fetch_extra" ${SKIP_FUNCTIONS} ; then
+ ebuild_section "Skipping src_fetch_extra (SKIP_FUNCTIONS)"
+ else
+ ebuild_section "Starting src_fetch_extra"
+ src_fetch_extra
+ ebuild_section "Done src_fetch_extra"
+ fi
+}
+
+
diff --git a/paludis/repositories/e/ebuild_entries.cc b/paludis/repositories/e/ebuild_entries.cc
index a0632e0..8a034de 100644
--- a/paludis/repositories/e/ebuild_entries.cc
+++ b/paludis/repositories/e/ebuild_entries.cc
@@ -429,6 +429,13 @@ EbuildEntries::fetch(const std::tr1::shared_ptr<const ERepositoryID> & id,
std::tr1::shared_ptr<OutputManager> output_manager(fetch_action.options.make_output_manager()(fetch_action));
+ CheckFetchedFilesVisitor c(_imp->environment, id, _imp->e_repository->params().distdir(),
+ fetch_action.options.fetch_unneeded(), fetch_restrict,
+ ((_imp->e_repository->layout()->package_directory(id->name())) / "Manifest"),
+ _imp->e_repository->params().use_manifest(),
+ output_manager, fetch_action.options.exclude_unmirrorable(),
+ fetch_action.options.ignore_unfetched());
+
if (id->fetches_key())
{
/* always use mirror://gentoo/, where gentoo is the name of our first master repository,
@@ -448,25 +455,68 @@ EbuildEntries::fetch(const std::tr1::shared_ptr<const ERepositoryID> & id,
id->fetches_key()->value()->root()->accept(f);
}
- CheckFetchedFilesVisitor c(_imp->environment, id, _imp->e_repository->params().distdir(),
- fetch_action.options.fetch_unneeded(), fetch_restrict,
- ((_imp->e_repository->layout()->package_directory(id->name())) / "Manifest"),
- _imp->e_repository->params().use_manifest(),
- output_manager, fetch_action.options.exclude_unmirrorable(),
- fetch_action.options.ignore_unfetched());
id->fetches_key()->value()->root()->accept(c);
+ }
- if (c.need_nofetch())
+ if ((c.need_nofetch()) || (! id->eapi()->supported()->ebuild_phases()->ebuild_fetch_extra().empty()))
+ {
+ bool userpriv_ok((! userpriv_restrict) && (_imp->environment->reduced_gid() != getgid()) &&
+ check_userpriv(FSEntry(_imp->params.builddir()), _imp->environment,
+ id->eapi()->supported()->userpriv_cannot_use_root()));
+ std::string use(make_use(_imp->params.environment(), *id, p));
+ std::tr1::shared_ptr<Map<std::string, std::string> > expand_vars(make_expand(
+ _imp->params.environment(), *id, p));
+
+ std::tr1::shared_ptr<const FSEntrySequence> exlibsdirs(_imp->e_repository->layout()->exlibsdirs(id->name()));
+
+ EAPIPhases fetch_extra_phases(id->eapi()->supported()->ebuild_phases()->ebuild_fetch_extra());
+ if (fetch_extra_phases.begin_phases() != fetch_extra_phases.end_phases())
{
- bool userpriv_ok((! userpriv_restrict) && (_imp->environment->reduced_gid() != getgid()) &&
- check_userpriv(FSEntry(_imp->params.builddir()), _imp->environment,
- id->eapi()->supported()->userpriv_cannot_use_root()));
- std::string use(make_use(_imp->params.environment(), *id, p));
- std::tr1::shared_ptr<Map<std::string, std::string> > expand_vars(make_expand(
- _imp->params.environment(), *id, p));
+ for (EAPIPhases::ConstIterator phase(fetch_extra_phases.begin_phases()), phase_end(fetch_extra_phases.end_phases()) ;
+ phase != phase_end ; ++phase)
+ {
+ EbuildCommandParams command_params(make_named_values<EbuildCommandParams>(
+ value_for<n::builddir>(_imp->params.builddir()),
+ value_for<n::clearenv>(phase->option("clearenv")),
+ value_for<n::commands>(join(phase->begin_commands(), phase->end_commands(), " ")),
+ value_for<n::distdir>(_imp->params.distdir()),
+ value_for<n::ebuild_dir>(_imp->e_repository->layout()->package_directory(id->name())),
+ value_for<n::ebuild_file>(id->fs_location_key()->value()),
+ value_for<n::eclassdirs>(_imp->params.eclassdirs()),
+ value_for<n::environment>(_imp->params.environment()),
+ value_for<n::exlibsdirs>(exlibsdirs),
+ value_for<n::files_dir>(_imp->e_repository->layout()->package_directory(id->name()) / "files"),
+ value_for<n::maybe_output_manager>(output_manager),
+ value_for<n::package_builddir>(_imp->params.builddir() / (stringify(id->name().category()) + "-" + stringify(id->name().package()) + "-" + stringify(id->version()) + "-fetch_extra")),
+ value_for<n::package_id>(id),
+ value_for<n::portdir>(
+ (_imp->params.master_repositories() && ! _imp->params.master_repositories()->empty()) ?
+ (*_imp->params.master_repositories()->begin())->params().location() : _imp->params.location()),
+ value_for<n::sandbox>(phase->option("sandbox")),
+ value_for<n::sydbox>(phase->option("sydbox")),
+ value_for<n::userpriv>(phase->option("userpriv") && userpriv_ok)
+ ));
- std::tr1::shared_ptr<const FSEntrySequence> exlibsdirs(_imp->e_repository->layout()->exlibsdirs(id->name()));
+ EbuildFetchExtraCommand fetch_extra_cmd(command_params,
+ make_named_values<EbuildFetchExtraCommandParams>(
+ value_for<n::a>(archives),
+ value_for<n::aa>(all_archives),
+ value_for<n::expand_vars>(expand_vars),
+ value_for<n::profiles>(_imp->params.profiles()),
+ value_for<n::root>("/"),
+ value_for<n::use>(use),
+ value_for<n::use_expand>(join(p->use_expand()->begin(), p->use_expand()->end(), " ")),
+ value_for<n::use_expand_hidden>(join(p->use_expand_hidden()->begin(), p->use_expand_hidden()->end(), " "))
+ ));
+ if (! fetch_extra_cmd())
+ throw FetchActionError("Fetch of '" + stringify(*id) + "' failed", make_shared_ptr(
+ new Sequence<FetchActionFailure>));
+ }
+ }
+
+ if (c.need_nofetch())
+ {
EAPIPhases phases(id->eapi()->supported()->ebuild_phases()->ebuild_nofetch());
for (EAPIPhases::ConstIterator phase(phases.begin_phases()), phase_end(phases.end_phases()) ;
phase != phase_end ; ++phase)