From eb140dee24ce6430836c4f3130b432f331ca11bf Mon Sep 17 00:00:00 2001 From: heracles Date: Sun, 21 Jan 2007 12:08:33 +0000 Subject: Squashed commit of the master branch svn path=/experimental/; revision=169 --- eclass/multislot.eclass | 86 +++++++++++++++++++++++++++++++++++++++++ eclass/postgresql-ext.eclass | 72 +++++++++++++++++++++++++++++++++++ eclass/postgresql.eclass | 91 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 249 insertions(+) create mode 100644 eclass/multislot.eclass create mode 100644 eclass/postgresql-ext.eclass create mode 100644 eclass/postgresql.eclass (limited to 'eclass') diff --git a/eclass/multislot.eclass b/eclass/multislot.eclass new file mode 100644 index 0000000..56fbfd8 --- /dev/null +++ b/eclass/multislot.eclass @@ -0,0 +1,86 @@ +# Copyright 1999-2007 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: $ + +# +# Original Author: root +# Purpose: Build extensions or plugins supporting multiple versions of framework +# simultaneously by building the package for all available slots +# + +ECLASS="multislot" +INHERITED="$INHERITED $ECLASS" +EXPORT_FUNCTIONS \ + src_unpack src_compile src_test src_install \ + slot_src_unpack slot_src_compile slot_src_test slot_src_install + +# Store unslotted workdir for future reference if it wasn't stored yet. +multislot_storeWD() { + [[ -z "${MULTISLOT_UNSLOTTED_WORKDIR}" ]] && MULTISLOT_UNSLOTTED_WORKDIR="${WORKDIR}" +} +# Discover what slots are we building for +multislot_storeSlots() { + [[ -z "${MULTISLOT_SLOTS}" ]] && MULTISLOT_SLOTS="$(slots_enumerate)" +} + +# Set up WORKDIR, S and SLOTSLOT variables for particular slot +# Usage: multislot_slot_vars +multislot_slot_vars() { + multislot_storeWD + local new_wd="${MULTISLOT_UNSLOTTED_WORKDIR}/$1" + S="${S/${WORKDIR}/${new_wd}}" + WORKDIR="${new_wd}" + SLOTSLOT="$1" +} + +multislot_src_unpack() { + multislot_storeSlots + local slot + for slot in ${MULTISLOT_SLOTS} ; do + multislot_slot_vars $slot + mkdir -p "${WORKDIR}" + cd "${WORKDIR}" + slot_src_unpack + done +} + +multislot_src_compile() { + multislot_storeSlots + local slot + for slot in ${MULTISLOT_SLOTS} ; do + multislot_slot_vars $slot + cd ${S} + slot_src_compile + done +} +multislot_src_test() { + multislot_storeSlots + local slot + for slot in ${MULTISLOT_SLOTS} ; do + multislot_slot_vars $slot + cd ${S} + slot_src_test + done +} +multislot_src_install() { + multislot_storeSlots + local slot + for slot in ${MULTISLOT_SLOTS} ; do + multislot_slot_vars $slot + cd ${S} + slot_src_install + done +} + +multislot_slot_src_unpack() { + unpack ${A} +} +multislot_slot_src_compile() { + : +} +multislot_slot_src_test() { + : +} +multislot_slot_src_install() { + : +} diff --git a/eclass/postgresql-ext.eclass b/eclass/postgresql-ext.eclass new file mode 100644 index 0000000..be260ba --- /dev/null +++ b/eclass/postgresql-ext.eclass @@ -0,0 +1,72 @@ +# Copyright 1999-2007 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: $ + +# +# Original Author: root +# Purpose: Installing postgresql extension for all available slots +# + +ECLASS="postgresql-ext" +INHERITED="$INHERITED $ECLASS" +inherit postgresql multislot +EXPORT_FUNCTIONS \ + src_unpack src_compile src_install \ + slot_src_unpack slot_src_compile slot_src_test slot_src_install \ + pgslot_src_unpack pgslot_src_compile pgslot_src_test pgslot_src_install \ + slots_enumerate + +postgresql-ext_slots_enumerate() { + postgresql_get_versions_range ${POSTGREXT_SLOTS} +} + +postgresql-ext_src_unpack() { + multislot_src_unpack "$@" +} +postgresql-ext_src_compile() { + multislot_src_compile "$@" +} +postgresql-ext_src_install() { + multislot_src_install "$@" +} +postgresql-ext_src_test() { + multislot_src_test "$@" +} + +postgresql-ext_slot_src_unpack() { + PATH="$(postgresql_get_bindir_for_slot $SLOTSLOT):${PATH}" pgslot_src_unpack +} +postgresql-ext_slot_src_compile() { + PATH="$(postgresql_get_bindir_for_slot $SLOTSLOT):${PATH}" pgslot_src_compile +} +postgresql-ext_slot_src_test() { + PATH="$(postgresql_get_bindir_for_slot $SLOTSLOT):${PATH}" pgslot_src_test +} +postgresql-ext_slot_src_install() { + PATH="$(postgresql_get_bindir_for_slot $SLOTSLOT):${PATH}" pgslot_src_install +} + +postgresql-ext_pgslot_src_unpack() { + multislot_slot_src_unpack +} +postgresql-ext_pgslot_src_compile() { + multislot_slot_src_compile +} +postgresql-ext_pgslot_src_test() { + multislot_slot_src_test +} +postgresql-ext_pgslot_src_install() { + multislot_slot_src_install +} + +pg_slots_depend() { + local vers=( ${POSTGREXT_SLOTS} ) + if [[ -z "${vers[0]}" ]] ; then + echo 'dev-db/postgresql-server' + else + echo ">=dev-db/postgresql-${vers[0]}*" + if [[ ! -z "${vers[1]}" ]] ; then + echo "<=dev-db/postgresql-${vers[1]}*" + fi + fi +} diff --git a/eclass/postgresql.eclass b/eclass/postgresql.eclass new file mode 100644 index 0000000..6ae0e27 --- /dev/null +++ b/eclass/postgresql.eclass @@ -0,0 +1,91 @@ +# Copyright 1999-2007 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: $ + +# +# Original Author: root +# Purpose: To handle the postgresql selection related tasks. +# + +inherit versionator +ECLASS="postgresql" +INHERITED="$INHERITED $ECLASS" + +# Usage: postgresql_version_in_range [version[ min_version[ max_version]]] +# Returns $?=0 if in range +postgresql_version_in_range() { + local v="$1" min="$2" max="$3" + if [[ ! -z "$min" ]] ; then + version_compare "$min" "$v" + [[ "$?" = "3" ]] && return 1 + fi + if [[ ! -z "$max" ]] ; then + version_compare "$max" "$v" + [[ "$?" = "1" ]] && return 2 + fi + return 0 +} + +# Usage: postgresql_get_versions_range [ min_version[ max_version]] +postgresql_get_versions_range() { + local min="$1" max="$2" + for s in /usr/lib/eselect-postgresql/slots/* ; do + [[ -d "$s" ]] || continue + local v="$(basename $s)" + postgresql_version_in_range "$v" "$min" "$max" || continue + echo "$v" + done +} +# Usage: postgresql_get_sorted_versions [ min_version[ max_version]] +postgresql_get_sorted_versions() { + version_sort $(postgresql_get_versions_range "$1" "$2") +} + +# Usage: postgresql_find_version [min_version[ max_version[ strategy]]] +# min_version - minimum supported version (empty string if any) +# max_version - maximum supported version (empty string if any) +# strategy - best, worst (that is, if eselected version isn't in range) +# (best is default) +# Returns selected version string +postgresql_find_version() { + local min="$1" max="$2" strategy="$3" + local eselected="$(eselect postgresql show)" + if [[ "$eselected" != "(none)" ]] ; then + postgresql_version_in_range "$eselected" "$min" "$max" && { echo "$eselected" ; return 0; } + fi + local vers=( $(postgresql_get_sorted_versions "$min" "$max") ) + case "$strategy" in + worst) + echo "${vers[0]}" + ;; + *) + echo "${vers[${#vers[@]}-1]}" + ;; + esac +} + +# Usage: postgresql_get_bindir [min_version[ max_version[ strategy]]] +# See postgresql_find_version +# Returns path to binaries +postgresql_get_bindir() { + local ver="$(postgresql_find_version "$1" "$2" "$3")" + (. /usr/lib/eselect-postgresql/slots/$ver/libs ; echo $postgres_bindir ) +} + +# Usage: postgresql_get_pgconfig [min_version[ max_version[ strategy]]] +# See postgresql_find_version +# Returns path to pg_config +postgresql_get_pgconfig() { + echo "$(postgresql_get_bindir "$1" "$2" "$3")/pg_config" +} + +# Usage: postgresql_get_bindir_for_slot slot +# Returns path to binaries for exact slot +postgresql_get_bindir_for_slot() { + (. /usr/lib/eselect-postgresql/slots/$1/libs ; echo $postgres_bindir) +} +# Usage: postgresql_get_pgconfig_for_slot slot +# Returns path to pg_config for exact slot +postgresql_get_pgconfig_for_slot() { + echo "$(. /usr/lib/eselect-postgresql/slots/$1/libs ; echo $postgres_bindir)/pg_config" +} -- cgit v1.2.3-65-gdbad