aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-06-05 23:07:01 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-06-05 23:07:01 +0000
commita372a401f02d3c0bceefc110e428fbe7dfbdb1c9 (patch)
tree7b148d520d113e0e0fc2d62ed7f0cd9d161c47f0
parentf379e5c032c9b37f6459f004829013f95d66c3dd (diff)
downloadpaludis-a372a401f02d3c0bceefc110e428fbe7dfbdb1c9.tar.gz
paludis-a372a401f02d3c0bceefc110e428fbe7dfbdb1c9.tar.xz
r3320@snowflake: ciaranm | 2007-06-06 00:05:28 +0100
Initial exlib support
-rw-r--r--paludis/repositories/gentoo/ebuild/Makefile.am1
-rwxr-xr-xpaludis/repositories/gentoo/ebuild/ebuild.bash1
-rw-r--r--paludis/repositories/gentoo/ebuild/exlib_functions.bash76
-rw-r--r--paludis/repositories/gentoo/ebuild_entries.cc62
-rw-r--r--paludis/repositories/gentoo/ebuild_entries.hh3
5 files changed, 103 insertions, 40 deletions
diff --git a/paludis/repositories/gentoo/ebuild/Makefile.am b/paludis/repositories/gentoo/ebuild/Makefile.am
index 64ea730..0ffbf4b 100644
--- a/paludis/repositories/gentoo/ebuild/Makefile.am
+++ b/paludis/repositories/gentoo/ebuild/Makefile.am
@@ -27,6 +27,7 @@ libexecprog_SCRIPTS = \
echo_functions.bash \
kernel_functions.bash \
eclass_functions.bash \
+ exlib_functions.bash \
install_functions.bash \
list_functions.bash \
multilib_functions.bash \
diff --git a/paludis/repositories/gentoo/ebuild/ebuild.bash b/paludis/repositories/gentoo/ebuild/ebuild.bash
index d0e6678..249f880 100755
--- a/paludis/repositories/gentoo/ebuild/ebuild.bash
+++ b/paludis/repositories/gentoo/ebuild/ebuild.bash
@@ -77,6 +77,7 @@ ebuild_load_module multilib_functions
ebuild_load_module install_functions
ebuild_load_module build_functions
ebuild_load_module eclass_functions
+ebuild_load_module exlib_functions
ebuild_load_module work_around_broken_utilities
export PALUDIS_HOME="$(canonicalise ${PALUDIS_HOME:-${HOME}} )"
diff --git a/paludis/repositories/gentoo/ebuild/exlib_functions.bash b/paludis/repositories/gentoo/ebuild/exlib_functions.bash
new file mode 100644
index 0000000..44dcbd8
--- /dev/null
+++ b/paludis/repositories/gentoo/ebuild/exlib_functions.bash
@@ -0,0 +1,76 @@
+#!/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
+
+export_exlib_phases()
+{
+ [[ -z "${CURRENT_EXLIB}" ]] && die "export_exlib_phases called but ECLASS undefined"
+
+ local e
+ for e in "$@" ; do
+ case "$e" in
+ pkg_nofetch|pkg_setup|pkg_prerm|pkg_postrm|pkg_preinst|pkg_postinst|pkg_config|pkg_pretend)
+ eval "${e}() { ${CURRENT_EXLIB}_${e} \"\$@\" ; }"
+ ;;
+
+ src_unpack|src_compile|src_install|src_test)
+ eval "${e}() { ${CURRENT_EXLIB}_${e} \"\$@\" ; }"
+ ;;
+
+ *)
+ eval "${e}() { ${CURRENT_EXLIB}_${e} \"\$@\" ; }"
+ ebuild_notice "qa" "$e should not be in export_exlib_phases for ${CURRENT_EXLIB}"
+ ;;
+ esac
+ done
+}
+
+require()
+{
+ local e ee location= v
+ for e in "$@" ; do
+ for ee in ${EXLIBSDIRS} ; do
+ [[ -f "${ee}/${e}.exlib" ]] && location="${ee}/${e}.exlib"
+ done
+ local old_CURRENT_EXLIB="${CURRENT_EXLIB}"
+ export CURRENT_EXLIB="${e}"
+
+ for v in ${PALUDIS_SOURCE_MERGED_VARIABLES} ; do
+ local c_v="current_${v}" u_v="unset_${v}"
+ local ${c_v}="${!v}"
+ local ${u_v}="${!v-unset}"
+ unset ${v}
+ done
+
+ [[ -z "${location}" ]] && die "Error finding exlib ${e} in ${EXLIBSDIRS}"
+ source "${location}" || die "Error sourcing exlib ${e}"
+ hasq "${CURRENT_EXLIB}" ${INHERITED} || export INHERITED="${INHERITED} ${CURRENT_EXLIB}"
+
+ for v in ${PALUDIS_SOURCE_MERGED_VARIABLES} ; do
+ local e_v="E_${v}"
+ export ${e_v}="${!e_v} ${!v}"
+ done
+
+ for v in ${PALUDIS_SOURCE_MERGED_VARIABLES} ; do
+ local c_v="current_${v}" u_v="unset_${v}"
+ [[ "unset" == ${!u_v} ]] && unset ${v} || export ${v}="${!c_v}"
+ done
+
+ export CURRENT_EXLIB="${old_CURRENT_EXLIB}"
+ done
+}
+
diff --git a/paludis/repositories/gentoo/ebuild_entries.cc b/paludis/repositories/gentoo/ebuild_entries.cc
index f7e1a5f..d864941 100644
--- a/paludis/repositories/gentoo/ebuild_entries.cc
+++ b/paludis/repositories/gentoo/ebuild_entries.cc
@@ -91,6 +91,24 @@ EbuildEntries::~EbuildEntries()
{
}
+tr1::shared_ptr<const FSEntryCollection>
+EbuildEntries::_exlibsdirs(const QualifiedPackageName & q) const
+{
+ tr1::shared_ptr<FSEntryCollection> exlibsdirs(new FSEntryCollection::Concrete);
+
+ if (_imp->params.master_repository)
+ exlibsdirs->push_back(_imp->params.master_repository->params().location / "exlibs");
+ exlibsdirs->push_back(_imp->params.location / "exlibs");
+ if (_imp->params.master_repository)
+ exlibsdirs->push_back(_imp->params.master_repository->layout()->category_directory(q.category) / "exlibs");
+ exlibsdirs->push_back(_imp->portage_repository->layout()->category_directory(q.category) / "exlibs");
+ if (_imp->params.master_repository)
+ exlibsdirs->push_back(_imp->params.master_repository->layout()->package_directory(q));
+ exlibsdirs->push_back(_imp->portage_repository->layout()->package_directory(q));
+
+ return exlibsdirs;
+}
+
tr1::shared_ptr<VersionMetadata>
EbuildEntries::generate_version_metadata(const QualifiedPackageName & q,
const VersionSpec & v) const
@@ -166,16 +184,7 @@ EbuildEntries::generate_version_metadata(const QualifiedPackageName & q,
throw EAPIConfigurationError("EAPI '" + eapi->name + "' defines "
+ (c == 0 ? "no" : stringify(c)) + " ebuild variable phases but expected exactly one");
- tr1::shared_ptr<FSEntryCollection> exlibsdirs(new FSEntryCollection::Concrete);
- if (_imp->params.master_repository)
- exlibsdirs->push_back(_imp->params.master_repository->params().location / "exlibs");
- exlibsdirs->push_back(_imp->params.location / "exlibs");
- if (_imp->params.master_repository)
- exlibsdirs->push_back(_imp->params.master_repository->layout()->category_directory(q.category) / "exlibs");
- exlibsdirs->push_back(_imp->portage_repository->layout()->category_directory(q.category) / "exlibs");
- if (_imp->params.master_repository)
- exlibsdirs->push_back(_imp->params.master_repository->layout()->package_directory(q) / "exlibs");
- exlibsdirs->push_back(_imp->portage_repository->layout()->package_directory(q) / "exlibs");
+ tr1::shared_ptr<const FSEntryCollection> exlibsdirs(_exlibsdirs(q));
EbuildMetadataCommand cmd(EbuildCommandParams::create()
.environment(_imp->environment)
@@ -518,16 +527,7 @@ EbuildEntries::install(const QualifiedPackageName & q, const VersionSpec & v,
tr1::shared_ptr<AssociativeCollection<std::string, std::string> > expand_vars(make_expand(
_imp->params.environment, e, metadata, p, use));
- tr1::shared_ptr<FSEntryCollection> exlibsdirs(new FSEntryCollection::Concrete);
- if (_imp->params.master_repository)
- exlibsdirs->push_back(_imp->params.master_repository->params().location / "exlibs");
- exlibsdirs->push_back(_imp->params.location / "exlibs");
- if (_imp->params.master_repository)
- exlibsdirs->push_back(_imp->params.master_repository->layout()->category_directory(q.category) / "exlibs");
- exlibsdirs->push_back(_imp->portage_repository->layout()->category_directory(q.category) / "exlibs");
- if (_imp->params.master_repository)
- exlibsdirs->push_back(_imp->params.master_repository->layout()->package_directory(q) / "exlibs");
- exlibsdirs->push_back(_imp->portage_repository->layout()->package_directory(q) / "exlibs");
+ tr1::shared_ptr<const FSEntryCollection> exlibsdirs(_exlibsdirs(e.name));
/* fetch */
{
@@ -704,16 +704,7 @@ EbuildEntries::get_environment_variable(const QualifiedPackageName & q,
throw EAPIConfigurationError("EAPI '" + metadata->eapi->name + "' defines "
+ (c == 0 ? "no" : stringify(c)) + " ebuild variable phases but expected exactly one");
- tr1::shared_ptr<FSEntryCollection> exlibsdirs(new FSEntryCollection::Concrete);
- if (_imp->params.master_repository)
- exlibsdirs->push_back(_imp->params.master_repository->params().location / "exlibs");
- exlibsdirs->push_back(_imp->params.location / "exlibs");
- if (_imp->params.master_repository)
- exlibsdirs->push_back(_imp->params.master_repository->layout()->category_directory(q.category) / "exlibs");
- exlibsdirs->push_back(_imp->portage_repository->layout()->category_directory(q.category) / "exlibs");
- if (_imp->params.master_repository)
- exlibsdirs->push_back(_imp->params.master_repository->layout()->package_directory(q) / "exlibs");
- exlibsdirs->push_back(_imp->portage_repository->layout()->package_directory(q) / "exlibs");
+ tr1::shared_ptr<const FSEntryCollection> exlibsdirs(_exlibsdirs(q));
EbuildVariableCommand cmd(EbuildCommandParams::create()
.environment(_imp->params.environment)
@@ -806,16 +797,7 @@ EbuildEntries::pretend(const QualifiedPackageName & q, const VersionSpec & v,
tr1::shared_ptr<AssociativeCollection<std::string, std::string> > expand_vars(make_expand(
_imp->params.environment, e, metadata, p, use));
- tr1::shared_ptr<FSEntryCollection> exlibsdirs(new FSEntryCollection::Concrete);
- if (_imp->params.master_repository)
- exlibsdirs->push_back(_imp->params.master_repository->params().location / "exlibs");
- exlibsdirs->push_back(_imp->params.location / "exlibs");
- if (_imp->params.master_repository)
- exlibsdirs->push_back(_imp->params.master_repository->layout()->category_directory(q.category) / "exlibs");
- exlibsdirs->push_back(_imp->portage_repository->layout()->category_directory(q.category) / "exlibs");
- if (_imp->params.master_repository)
- exlibsdirs->push_back(_imp->params.master_repository->layout()->package_directory(q) / "exlibs");
- exlibsdirs->push_back(_imp->portage_repository->layout()->package_directory(q) / "exlibs");
+ tr1::shared_ptr<const FSEntryCollection> exlibsdirs(_exlibsdirs(q));
EAPIPhases phases(metadata->eapi->supported->ebuild_phases->ebuild_pretend);
for (EAPIPhases::Iterator phase(phases.begin_phases()), phase_end(phases.end_phases()) ;
diff --git a/paludis/repositories/gentoo/ebuild_entries.hh b/paludis/repositories/gentoo/ebuild_entries.hh
index 533d8e0..617a185 100644
--- a/paludis/repositories/gentoo/ebuild_entries.hh
+++ b/paludis/repositories/gentoo/ebuild_entries.hh
@@ -44,6 +44,9 @@ namespace paludis
public PortageRepositoryEntries,
private PrivateImplementationPattern<EbuildEntries>
{
+ private:
+ tr1::shared_ptr<const FSEntryCollection> _exlibsdirs(const QualifiedPackageName &) const;
+
public:
/**
* Create an EbuildEntries instance.