import new eclass files from upstream

Nothing uses these currently, so pull them all in in one go.

BUG=None
TEST=`cbuildbot chromiumos-sdk` worked

Change-Id: I04d8e12acd1c2a7fa0c1d0246931ae63347231c6
Reviewed-on: https://gerrit.chromium.org/gerrit/39048
Reviewed-by: David James <davidjames@chromium.org>
Commit-Ready: Mike Frysinger <vapier@chromium.org>
Tested-by: Mike Frysinger <vapier@chromium.org>
This commit is contained in:
Mike Frysinger 2012-12-01 15:53:14 -05:00 committed by Gerrit
parent 9acbbedbf5
commit a8cf809074
48 changed files with 8572 additions and 1 deletions

View File

@ -0,0 +1,38 @@
--- ltmain.sh.orig 2012-08-19 10:18:57.929178597 +0200
+++ ltmain.sh 2012-08-19 10:31:43.409388998 +0200
@@ -5798,10 +5798,15 @@
IFS="$save_ifs"
func_stripname ' ' '' "$arg"
arg=$func_stripname_result
;;
+ -Wl,--as-needed|-Wl,--no-as-needed)
+ deplibs="$deplibs $arg"
+ continue
+ ;;
+
-Wl,*)
func_stripname '-Wl,' '' "$arg"
args=$func_stripname_result
arg=
save_ifs="$IFS"; IFS=','
@@ -6158,10 +6163,19 @@
for deplib in $libs; do
lib=
found=no
case $deplib in
+ -Wl,--as-needed|-Wl,--no-as-needed)
+ if test "$linkmode,$pass" = "prog,link"; then
+ compile_deplibs="$deplib $compile_deplibs"
+ finalize_deplibs="$deplib $finalize_deplibs"
+ else
+ deplibs="$deplib $deplibs"
+ fi
+ continue
+ ;;
-mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \
|-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*)
if test "$linkmode,$pass" = "prog,link"; then
compile_deplibs="$deplib $compile_deplibs"
finalize_deplibs="$deplib $finalize_deplibs"

View File

@ -2,11 +2,12 @@ Index: tiff-3.8.2/configure
===================================================================
--- tiff-3.8.2.orig/configure
+++ tiff-3.8.2/configure
@@ -8199,7 +8199,13 @@ freebsd* | dragonfly*)
@@ -8199,7 +8199,14 @@ freebsd* | dragonfly*)
*) objformat=elf ;;
esac
fi
- version_type=freebsd-$objformat
+ # Handle Gentoo/FreeBSD as it was Linux
+ case $host_vendor in
+ gentoo)
+ version_type=linux ;;

View File

@ -0,0 +1,14 @@
Unbreak x86_64-pc-solaris2.1[01], it IS 64-bits too. Without this,
libtool thinks the linker is called ld_sol2.
--- configure
+++ configure
@@ -1383,7 +1383,7 @@
case $lt_cv_prog_gnu_ld in
yes*)
case $host in
- i?86-*-solaris*)
+ i?86-*-solaris*|x86_64-*-solaris*)
LD="${LD-ld} -m elf_x86_64"
;;
sparc*-*-solaris*)

View File

@ -0,0 +1,11 @@
--- libltdl/config/ltmain.sh
+++ libltdl/config/ltmain.sh
@@ -1180,7 +1180,7 @@
test "$opt_debug" = : || func_append preserve_args " --debug"
case $host in
- *cygwin* | *mingw* | *pw32* | *cegcc*)
+ *cygwin* | *mingw* | *pw32* | *cegcc* | *solaris2*)
# don't eliminate duplications in $postdeps and $predeps
opt_duplicate_compiler_generated_deps=:
;;

View File

@ -0,0 +1,72 @@
# Copyright 1999-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/eclass/autotools-multilib.eclass,v 1.1 2012/10/08 18:44:30 mgorny Exp $
# @ECLASS: autotools-multilib.eclass
# @MAINTAINER:
# Michał Górny <mgorny@gentoo.org>
# @BLURB: autotools-utils wrapper for multilib builds
# @DESCRIPTION:
# The autotools-multilib.eclass is an autotools-utils.eclass(5) wrapper
# introducing support for building for more than one ABI (multilib).
#
# Inheriting this eclass sets IUSE=multilib and exports autotools-utils
# phase function wrappers which build the package for each supported ABI
# if the flag is enabled. Otherwise, it works like regular
# autotools-utils.
#
# Note that the multilib support requires out-of-source builds to be
# enabled. Thus, it is impossible to use AUTOTOOLS_IN_SOURCE_BUILD with
# it.
case ${EAPI:-0} in
2|3|4) ;;
*) die "EAPI=${EAPI} is not supported" ;;
esac
if [[ ${AUTOTOOLS_IN_SOURCE_BUILD} ]]; then
die "${ECLASS}: multilib support requires out-of-source builds."
fi
inherit autotools-utils multilib
EXPORT_FUNCTIONS src_configure src_compile src_test src_install
IUSE=multilib
# @FUNCTION: autotools-multilib_foreach_abi
# @USAGE: argv...
# @DESCRIPTION:
# If multilib support is enabled, sets the toolchain up for each
# supported ABI along with the ABI variable and correct
# AUTOTOOLS_BUILD_DIR, and runs the given commands with them.
#
# If multilib support is disabled, it just runs the commands. No setup
# is done.
autotools-multilib_foreach_abi() {
if use multilib; then
local ABI
for ABI in $(get_all_abis); do
multilib_toolchain_setup "${ABI}"
AUTOTOOLS_BUILD_DIR=${S%%/}-${ABI} "${@}"
done
else
"${@}"
fi
}
autotools-multilib_src_configure() {
autotools-multilib_foreach_abi autotools-utils_src_configure
}
autotools-multilib_src_compile() {
autotools-multilib_foreach_abi autotools-utils_src_compile
}
autotools-multilib_src_test() {
autotools-multilib_foreach_abi autotools-utils_src_test
}
autotools-multilib_src_install() {
autotools-multilib_foreach_abi autotools-utils_src_install
}

View File

@ -0,0 +1,95 @@
# Copyright 1999-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/eclass/boost-utils.eclass,v 1.3 2012/10/07 08:29:49 mgorny Exp $
if [[ ! ${_BOOST_ECLASS} ]]; then
# @ECLASS: boost-utils.eclass
# @MAINTAINER:
# Michał Górny <mgorny@gentoo.org>
# Tiziano Müller <dev-zero@gentoo.org>
# Sebastian Luther <SebastianLuther@gmx.de>
# Arfrever Frehtes Taifersar Arahesis <arfrever.fta@gmail.com>
# @BLURB: helper functions for packages using Boost C++ library
# @DESCRIPTION:
# Helper functions to be used when building packages using the Boost C++
# library collection.
#
# Please note that this eclass does not set the dependencies for you.
# You need to do that yourself.
#
# For cmake & autotools it is usually necessary to set BOOST_ROOT using
# boost-utils_export_root. However, other build system may require more
# hackery or even appending -I$(boost-utils_get_includedir) to CFLAGS
# and -L$(boost-utils_get_libdir) to LDFLAGS.
case ${EAPI:-0} in
0|1|2|3|4|5) ;;
*) die "${ECLASS}.eclass API in EAPI ${EAPI} not yet established."
esac
inherit multilib versionator
# @ECLASS-VARIABLE: BOOST_MAX_SLOT
# @DEFAULT_UNSET
# @DESCRIPTION:
# The maximal (newest) boost slot supported by the package. If unset,
# there is no limit (the newest installed version will be used).
# @FUNCTION: boost-utils_get_best_slot
# @DESCRIPTION:
# Get newest installed slot of Boost. If BOOST_MAX_SLOT is set, the version
# returned will be at most in the specified slot.
boost-utils_get_best_slot() {
local pkg=dev-libs/boost
[[ ${BOOST_MAX_SLOT} ]] && pkg="<=${pkg}-${BOOST_MAX_SLOT}.9999"
local cpv=$(best_version ${pkg})
get_version_component_range 1-2 ${cpv#dev-libs/boost-}
}
# @FUNCTION: boost-utils_get_includedir
# @USAGE: [slot]
# @DESCRIPTION:
# Get the includedir for the given Boost slot. If no slot is given,
# defaults to the newest installed Boost slot (but not newer than
# BOOST_MAX_SLOT if that variable is set).
#
# Outputs the sole path (without -I).
boost-utils_get_includedir() {
local slot=${1:-$(boost-utils_get_best_slot)}
has "${EAPI:-0}" 0 1 2 && ! use prefix && EPREFIX=
echo -n "${EPREFIX}/usr/include/boost-${slot/./_}"
}
# @FUNCTION: boost-utils_get_libdir
# @USAGE: [slot]
# @DESCRIPTION:
# Get the libdir for the given Boost slot. If no slot is given, defaults
# to the newest installed Boost slot (but not newer than BOOST_MAX_SLOT
# if that variable is set).
#
# Outputs the sole path (without -L).
boost-utils_get_libdir() {
local slot=${1:-$(boost-utils_get_best_slot)}
has "${EAPI:-0}" 0 1 2 && ! use prefix && EPREFIX=
echo -n "${EPREFIX}/usr/$(get_libdir)/boost-${slot/./_}"
}
# @FUNCTION: boost-utils_export_root
# @USAGE: [slot]
# @DESCRIPTION:
# Set the BOOST_ROOT variable to includedir for the given Boost slot.
# If no slot is given, defaults to the newest installed Boost slot(but
# not newer than BOOST_MAX_SLOT if that variable is set).
#
# This variable satisfies both cmake and sys-devel/boost-m4 autoconf
# macros.
boost-utils_export_root() {
export BOOST_ROOT=$(boost-utils_get_includedir "${@}")
}
_BOOST_ECLASS=1
fi # _BOOST_ECLASS

View File

@ -0,0 +1,247 @@
# Copyright 1999-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/eclass/cdrom.eclass,v 1.5 2012/01/18 12:42:06 vapier Exp $
# @ECLASS: cdrom.eclass
# @MAINTAINER:
# games@gentoo.org
# @BLURB: Functions for CD-ROM handling
# @DESCRIPTION:
# Acquire cd(s) for those lovely cd-based emerges. Yes, this violates
# the whole 'non-interactive' policy, but damnit I want CD support!
#
# With these cdrom functions we handle all the user interaction and
# standardize everything. All you have to do is call cdrom_get_cds()
# and when the function returns, you can assume that the cd has been
# found at CDROM_ROOT.
if [[ -z ${___ECLASS_ONCE_CDROM} ]]; then
___ECLASS_ONCE_CDROM=1
inherit portability
# @ECLASS-VARIABLE: CDROM_OPTIONAL
# @DEFAULT_UNSET
# @DESCRIPTION:
# By default, the eclass sets PROPERTIES="interactive" on the assumption
# that people will be using these. If your package optionally supports
# disc based installed, then set this to "yes", and we'll set things
# conditionally based on USE=cdinstall.
if [[ ${CDROM_OPTIONAL} == "yes" ]] ; then
IUSE="cdinstall"
PROPERTIES="cdinstall? ( interactive )"
else
PROPERTIES="interactive"
fi
# @FUNCTION: cdrom_get_cds
# @USAGE: <file on cd1> [file on cd2] [file on cd3] [...]
# @DESCRIPTION:
# The function will attempt to locate a cd based upon a file that is on
# the cd. The more files you give this function, the more cds the cdrom
# functions will handle.
#
# Normally the cdrom functions will refer to the cds as 'cd #1', 'cd #2',
# etc... If you want to give the cds better names, then just export
# the appropriate CDROM_NAME variable before calling cdrom_get_cds().
# Use CDROM_NAME for one cd, or CDROM_NAME_# for multiple cds. You can
# also use the CDROM_NAME_SET bash array.
#
# For those multi cd ebuilds, see the cdrom_load_next_cd() function.
cdrom_get_cds() {
# first we figure out how many cds we're dealing with by
# the # of files they gave us
local cdcnt=0
local f=
for f in "$@" ; do
((++cdcnt))
export CDROM_CHECK_${cdcnt}="$f"
done
export CDROM_TOTAL_CDS=${cdcnt}
export CDROM_CURRENT_CD=1
# now we see if the user gave use CD_ROOT ...
# if they did, let's just believe them that it's correct
if [[ -n ${CD_ROOT}${CD_ROOT_1} ]] ; then
local var=
cdcnt=0
while [[ ${cdcnt} -lt ${CDROM_TOTAL_CDS} ]] ; do
((++cdcnt))
var="CD_ROOT_${cdcnt}"
[[ -z ${!var} ]] && var="CD_ROOT"
if [[ -z ${!var} ]] ; then
eerror "You must either use just the CD_ROOT"
eerror "or specify ALL the CD_ROOT_X variables."
eerror "In this case, you will need" \
"${CDROM_TOTAL_CDS} CD_ROOT_X variables."
die "could not locate CD_ROOT_${cdcnt}"
fi
done
export CDROM_ROOT=${CD_ROOT_1:-${CD_ROOT}}
einfo "Found CD #${CDROM_CURRENT_CD} root at ${CDROM_ROOT}"
export CDROM_SET=-1
for f in ${CDROM_CHECK_1//:/ } ; do
((++CDROM_SET))
[[ -e ${CDROM_ROOT}/${f} ]] && break
done
export CDROM_MATCH=${f}
return
fi
# User didn't help us out so lets make sure they know they can
# simplify the whole process ...
if [[ ${CDROM_TOTAL_CDS} -eq 1 ]] ; then
einfo "This ebuild will need the ${CDROM_NAME:-cdrom for ${PN}}"
echo
einfo "If you do not have the CD, but have the data files"
einfo "mounted somewhere on your filesystem, just export"
einfo "the variable CD_ROOT so that it points to the"
einfo "directory containing the files."
echo
einfo "For example:"
einfo "export CD_ROOT=/mnt/cdrom"
echo
else
if [[ -n ${CDROM_NAME_SET} ]] ; then
# Translate the CDROM_NAME_SET array into CDROM_NAME_#
cdcnt=0
while [[ ${cdcnt} -lt ${CDROM_TOTAL_CDS} ]] ; do
((++cdcnt))
export CDROM_NAME_${cdcnt}="${CDROM_NAME_SET[$((${cdcnt}-1))]}"
done
fi
einfo "This package will need access to ${CDROM_TOTAL_CDS} cds."
cdcnt=0
while [[ ${cdcnt} -lt ${CDROM_TOTAL_CDS} ]] ; do
((++cdcnt))
var="CDROM_NAME_${cdcnt}"
[[ ! -z ${!var} ]] && einfo " CD ${cdcnt}: ${!var}"
done
echo
einfo "If you do not have the CDs, but have the data files"
einfo "mounted somewhere on your filesystem, just export"
einfo "the following variables so they point to the right place:"
einfon ""
cdcnt=0
while [[ ${cdcnt} -lt ${CDROM_TOTAL_CDS} ]] ; do
((++cdcnt))
echo -n " CD_ROOT_${cdcnt}"
done
echo
einfo "Or, if you have all the files in the same place, or"
einfo "you only have one cdrom, you can export CD_ROOT"
einfo "and that place will be used as the same data source"
einfo "for all the CDs."
echo
einfo "For example:"
einfo "export CD_ROOT_1=/mnt/cdrom"
echo
fi
export CDROM_SET=""
export CDROM_CURRENT_CD=0
cdrom_load_next_cd
}
# @FUNCTION: cdrom_load_next_cd
# @DESCRIPTION:
# Some packages are so big they come on multiple CDs. When you're done
# reading files off a CD and want access to the next one, just call this
# function. Again, all the messy details of user interaction are taken
# care of for you. Once this returns, just read the variable CDROM_ROOT
# for the location of the mounted CD. Note that you can only go forward
# in the CD list, so make sure you only call this function when you're
# done using the current CD.
cdrom_load_next_cd() {
local var
((++CDROM_CURRENT_CD))
unset CDROM_ROOT
var=CD_ROOT_${CDROM_CURRENT_CD}
[[ -z ${!var} ]] && var="CD_ROOT"
if [[ -z ${!var} ]] ; then
var="CDROM_CHECK_${CDROM_CURRENT_CD}"
_cdrom_locate_file_on_cd ${!var}
else
export CDROM_ROOT=${!var}
fi
einfo "Found CD #${CDROM_CURRENT_CD} root at ${CDROM_ROOT}"
}
# this is used internally by the cdrom_get_cds() and cdrom_load_next_cd()
# functions. this should *never* be called from an ebuild.
# all it does is try to locate a give file on a cd ... if the cd isn't
# found, then a message asking for the user to insert the cdrom will be
# displayed and we'll hang out here until:
# (1) the file is found on a mounted cdrom
# (2) the user hits CTRL+C
_cdrom_locate_file_on_cd() {
local mline=""
local showedmsg=0 showjolietmsg=0
while [[ -z ${CDROM_ROOT} ]] ; do
local i=0
local -a cdset=(${*//:/ })
if [[ -n ${CDROM_SET} ]] ; then
cdset=(${cdset[${CDROM_SET}]})
fi
while [[ -n ${cdset[${i}]} ]] ; do
local dir=$(dirname ${cdset[${i}]})
local file=$(basename ${cdset[${i}]})
local point= node= fs= foo=
while read point node fs foo ; do
[[ " cd9660 iso9660 udf " != *" ${fs} "* ]] && \
! [[ ${fs} == "subfs" && ",${opts}," == *",fs=cdfss,"* ]] \
&& continue
point=${point//\040/ }
[[ ! -d ${point}/${dir} ]] && continue
[[ -z $(find "${point}/${dir}" -maxdepth 1 -iname "${file}") ]] \
&& continue
export CDROM_ROOT=${point}
export CDROM_SET=${i}
export CDROM_MATCH=${cdset[${i}]}
return
done <<< "$(get_mounts)"
((++i))
done
echo
if [[ ${showedmsg} -eq 0 ]] ; then
if [[ ${CDROM_TOTAL_CDS} -eq 1 ]] ; then
if [[ -z ${CDROM_NAME} ]] ; then
einfo "Please insert+mount the cdrom for ${PN} now !"
else
einfo "Please insert+mount the ${CDROM_NAME} cdrom now !"
fi
else
if [[ -z ${CDROM_NAME_1} ]] ; then
einfo "Please insert+mount cd #${CDROM_CURRENT_CD}" \
"for ${PN} now !"
else
local var="CDROM_NAME_${CDROM_CURRENT_CD}"
einfo "Please insert+mount the ${!var} cdrom now !"
fi
fi
showedmsg=1
fi
einfo "Press return to scan for the cd again"
einfo "or hit CTRL+C to abort the emerge."
echo
if [[ ${showjolietmsg} -eq 0 ]] ; then
showjolietmsg=1
else
ewarn "If you are having trouble with the detection"
ewarn "of your CD, it is possible that you do not have"
ewarn "Joliet support enabled in your kernel. Please"
ewarn "check that CONFIG_JOLIET is enabled in your kernel."
fi
read || die "something is screwed with your system"
done
}
fi

View File

@ -0,0 +1,262 @@
# Copyright 1999-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/eclass/chromium.eclass,v 1.7 2012/09/11 08:15:08 phajdan.jr Exp $
# @ECLASS: chromium.eclass
# @MAINTAINER:
# Chromium Herd <chromium@gentoo.org>
# @AUTHOR:
# Mike Gilbert <floppym@gentoo.org>
# @BLURB: Shared functions for chromium and google-chrome
inherit eutils fdo-mime gnome2-utils linux-info
EXPORT_FUNCTIONS pkg_preinst pkg_postinst pkg_postrm
if [[ ${PN} == chromium ]]; then
IUSE+=" custom-cflags"
fi
# @FUNCTION: chromium_suid_sandbox_check_kernel_config
# @USAGE:
# @DESCRIPTION:
# Ensures the system kernel supports features needed for SUID sandbox to work.
chromium_suid_sandbox_check_kernel_config() {
has "${EAPI:-0}" 0 1 2 3 && die "EAPI=${EAPI} is not supported"
if [[ "${MERGE_TYPE}" == "source" || "${MERGE_TYPE}" == "binary" ]]; then
# Warn if the kernel does not support features needed for sandboxing.
# Bug #363987.
ERROR_PID_NS="PID_NS is required for sandbox to work"
ERROR_NET_NS="NET_NS is required for sandbox to work"
CONFIG_CHECK="~PID_NS ~NET_NS"
check_extra_config
fi
}
# @ECLASS-VARIABLE: CHROMIUM_LANGS
# @DEFAULT_UNSET
# @DESCRIPTION:
# List of language packs available for this package.
_chromium_set_linguas_IUSE() {
[[ ${EAPI:-0} == 0 ]] && die "EAPI=${EAPI} is not supported"
local lang
for lang in ${CHROMIUM_LANGS}; do
# Default to enabled since we bundle them anyway.
# USE-expansion will take care of disabling the langs the user has not
# selected via LINGUAS.
IUSE+=" +linguas_${lang}"
done
}
if [[ ${CHROMIUM_LANGS} ]]; then
_chromium_set_linguas_IUSE
fi
_chromium_crlang() {
local x
for x in "$@"; do
case $x in
es_LA) echo es-419 ;;
*) echo "${x/_/-}" ;;
esac
done
}
_chromium_syslang() {
local x
for x in "$@"; do
case $x in
es-419) echo es_LA ;;
*) echo "${x/-/_}" ;;
esac
done
}
_chromium_strip_pak() {
local x
for x in "$@"; do
echo "${x%.pak}"
done
}
# @FUNCTION: chromium_remove_language_paks
# @USAGE:
# @DESCRIPTION:
# Removes pak files from the current directory for languages that the user has
# not selected via the LINGUAS variable.
# Also performs QA checks to ensure CHROMIUM_LANGS has been set correctly.
chromium_remove_language_paks() {
local crlangs=$(_chromium_crlang ${CHROMIUM_LANGS})
local present_crlangs=$(_chromium_strip_pak *.pak)
local present_langs=$(_chromium_syslang ${present_crlangs})
local lang
# Look for missing pak files.
for lang in ${crlangs}; do
if ! has ${lang} ${present_crlangs}; then
eqawarn "LINGUAS warning: no .pak file for ${lang} (${lang}.pak not found)"
fi
done
# Look for extra pak files.
# Remove pak files that the user does not want.
for lang in ${present_langs}; do
if [[ ${lang} == en_US ]]; then
continue
fi
if ! has ${lang} ${CHROMIUM_LANGS}; then
eqawarn "LINGUAS warning: no ${lang} in LANGS"
continue
fi
if ! use linguas_${lang}; then
rm "$(_chromium_crlang ${lang}).pak" || die
fi
done
}
chromium_pkg_preinst() {
gnome2_icon_savelist
}
chromium_pkg_postinst() {
fdo-mime_desktop_database_update
gnome2_icon_cache_update
# For more info see bug #292201, bug #352263, bug #361859.
if ! has_version x11-themes/gnome-icon-theme &&
! has_version x11-themes/oxygen-icons ; then
elog
elog "Depending on your desktop environment, you may need"
elog "to install additional packages to get icons on the Downloads page."
elog
elog "For KDE, the required package is kde-base/oxygen-icons."
elog
elog "For other desktop environments, try one of the following:"
elog " - x11-themes/gnome-icon-theme"
elog " - x11-themes/tango-icon-theme"
fi
# For more info see bug #359153.
elog
elog "Some web pages may require additional fonts to display properly."
elog "Try installing some of the following packages if some characters"
elog "are not displayed properly:"
elog " - media-fonts/arphicfonts"
elog " - media-fonts/bitstream-cyberbit"
elog " - media-fonts/droid"
elog " - media-fonts/ipamonafont"
elog " - media-fonts/ja-ipafonts"
elog " - media-fonts/takao-fonts"
elog " - media-fonts/wqy-microhei"
elog " - media-fonts/wqy-zenhei"
}
chromium_pkg_postrm() {
gnome2_icon_cache_update
}
chromium_pkg_die() {
if [[ "${EBUILD_PHASE}" != "compile" ]]; then
return
fi
# Prevent user problems like bug #348235.
eshopts_push -s extglob
if is-flagq '-g?(gdb)?([1-9])'; then
ewarn
ewarn "You have enabled debug info (i.e. -g or -ggdb in your CFLAGS/CXXFLAGS)."
ewarn "This produces very large build files causes the linker to consume large"
ewarn "amounts of memory."
ewarn
ewarn "Please try removing -g{,gdb} before reporting a bug."
ewarn
fi
eshopts_pop
# ccache often causes bogus compile failures, especially when the cache gets
# corrupted.
if has ccache ${FEATURES}; then
ewarn
ewarn "You have enabled ccache. Please try disabling ccache"
ewarn "before reporting a bug."
ewarn
fi
# No ricer bugs.
if use_if_iuse custom-cflags; then
ewarn
ewarn "You have enabled the custom-cflags USE flag."
ewarn "Please disable it before reporting a bug."
ewarn
fi
# If the system doesn't have enough memory, the compilation is known to
# fail. Print info about memory to recognize this condition.
einfo
einfo "$(grep MemTotal /proc/meminfo)"
einfo "$(grep SwapTotal /proc/meminfo)"
einfo
}
# @VARIABLE: EGYP_CHROMIUM_COMMAND
# @DESCRIPTION:
# Path to the gyp_chromium script.
: ${EGYP_CHROMIUM_COMMAND:=build/gyp_chromium}
# @VARIABLE: EGYP_CHROMIUM_DEPTH
# @DESCRIPTION:
# Depth for egyp_chromium.
: ${EGYP_CHROMIUM_DEPTH:=.}
# @FUNCTION: egyp_chromium
# @USAGE: [gyp arguments]
# @DESCRIPTION:
# Calls EGYP_CHROMIUM_COMMAND with depth EGYP_CHROMIUM_DEPTH and given
# arguments. The full command line is echoed for logging.
egyp_chromium() {
set -- "${EGYP_CHROMIUM_COMMAND}" --depth="${EGYP_CHROMIUM_DEPTH}" "$@"
echo "$@"
"$@"
}
# @FUNCTION: gyp_use
# @USAGE: <USE flag> [GYP flag] [true suffix] [false suffix]
# @DESCRIPTION:
# If USE flag is set, echo -D[GYP flag]=[true suffix].
#
# If USE flag is not set, echo -D[GYP flag]=[false suffix].
#
# [GYP flag] defaults to use_[USE flag] with hyphens converted to underscores.
#
# [true suffix] defaults to 1. [false suffix] defaults to 0.
gyp_use() {
local gypflag="-D${2:-use_${1//-/_}}="
usex "$1" "${gypflag}" "${gypflag}" "${3-1}" "${4-0}"
}
# @FUNCTION: chromium_bundled_v8_version
# @USAGE: [path to version.cc]
# @DESCRIPTION:
# Outputs the version of v8 parsed from a (bundled) copy of the source code.
chromium_bundled_v8_version() {
local vf=${1:-v8/src/version.cc}
local major minor build patch
major=$(sed -ne 's/#define MAJOR_VERSION *\([0-9]*\)/\1/p' "${vf}")
minor=$(sed -ne 's/#define MINOR_VERSION *\([0-9]*\)/\1/p' "${vf}")
build=$(sed -ne 's/#define BUILD_NUMBER *\([0-9]*\)/\1/p' "${vf}")
patch=$(sed -ne 's/#define PATCH_LEVEL *\([0-9]*\)/\1/p' "${vf}")
echo "${major}.${minor}.${build}.${patch}"
}
# @FUNCTION: chromium_installed_v8_version
# @USAGE:
# @DESCRIPTION:
# Outputs the version of dev-lang/v8 currently installed on the host system.
chromium_installed_v8_version() {
local cpf=$(best_version dev-lang/v8)
local pvr=${cpf#dev-lang/v8-}
echo "${pvr%-r*}"
}

View File

@ -0,0 +1,444 @@
# Copyright 1999-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/eclass/distutils-r1.eclass,v 1.20 2012/11/26 10:05:11 mgorny Exp $
# @ECLASS: distutils-r1
# @MAINTAINER:
# Michał Górny <mgorny@gentoo.org>
# Python herd <python@gentoo.org>
# @AUTHOR:
# Author: Michał Górny <mgorny@gentoo.org>
# Based on the work of: Krzysztof Pawlik <nelchael@gentoo.org>
# @BLURB: A simple eclass to build Python packages using distutils.
# @DESCRIPTION:
# A simple eclass providing functions to build Python packages using
# the distutils build system. It exports phase functions for all
# the src_* phases. Each of the phases runs two pseudo-phases:
# python_..._all() (e.g. python_prepare_all()) once in ${S}, then
# python_...() (e.g. python_prepare()) for each implementation
# (see: python_foreach_impl() in python-r1).
#
# In distutils-r1_src_prepare(), the 'all' function is run before
# per-implementation ones (because it creates the implementations),
# per-implementation functions are run in a random order.
#
# In remaining phase functions, the per-implementation functions are run
# before the 'all' one, and they are ordered from the least to the most
# preferred implementation (so that 'better' files overwrite 'worse'
# ones).
#
# If the ebuild doesn't specify a particular pseudo-phase function,
# the default one will be used (distutils-r1_...). Defaults are provided
# for all per-implementation pseudo-phases, python_prepare_all()
# and python_install_all(); whenever writing your own pseudo-phase
# functions, you should consider calling the defaults (and especially
# distutils-r1_python_prepare_all).
#
# Please note that distutils-r1 sets RDEPEND and DEPEND unconditionally
# for you.
#
# Also, please note that distutils-r1 will always inherit python-r1
# as well. Thus, all the variables defined and documented there are
# relevant to the packages using distutils-r1.
#
# For more information, please see the python-r1 Developer's Guide:
# http://www.gentoo.org/proj/en/Python/python-r1/dev-guide.xml
case "${EAPI:-0}" in
0|1|2|3)
die "Unsupported EAPI=${EAPI:-0} (too old) for ${ECLASS}"
;;
4|5)
;;
*)
die "Unsupported EAPI=${EAPI} (unknown) for ${ECLASS}"
;;
esac
if [[ ! ${_DISTUTILS_R1} ]]; then
inherit eutils python-r1
fi
EXPORT_FUNCTIONS src_prepare src_configure src_compile src_test src_install
if [[ ! ${_DISTUTILS_R1} ]]; then
RDEPEND=${PYTHON_DEPS}
DEPEND=${PYTHON_DEPS}
# @ECLASS-VARIABLE: PATCHES
# @DEFAULT_UNSET
# @DESCRIPTION:
# An array containing patches to be applied to the sources before
# copying them.
#
# If unset, no custom patches will be applied.
#
# Please note, however, that at some point the eclass may apply
# additional distutils patches/quirks independently of this variable.
#
# Example:
# @CODE
# PATCHES=( "${FILESDIR}"/${P}-make-gentoo-happy.patch )
# @CODE
# @ECLASS-VARIABLE: DOCS
# @DEFAULT_UNSET
# @DESCRIPTION:
# An array containing documents installed using dodoc. The files listed
# there must exist in the directory from which
# distutils-r1_python_install_all() is run (${S} by default).
#
# If unset, the function will instead look up files matching default
# filename pattern list (from the Package Manager Specification),
# and install those found.
#
# Example:
# @CODE
# DOCS=( NEWS README )
# @CODE
# @ECLASS-VARIABLE: HTML_DOCS
# @DEFAULT_UNSET
# @DESCRIPTION:
# An array containing documents installed using dohtml. The files
# and directories listed there must exist in the directory from which
# distutils-r1_python_install_all() is run (${S} by default).
#
# If unset, no HTML docs will be installed.
#
# Example:
# @CODE
# HTML_DOCS=( doc/html/ )
# @CODE
# @ECLASS-VARIABLE: DISTUTILS_IN_SOURCE_BUILD
# @DEFAULT_UNSET
# @DESCRIPTION:
# If set to a non-null value, in-source builds will be enabled.
# If unset, the default is to use in-source builds when python_prepare()
# is declared, and out-of-source builds otherwise.
#
# If in-source builds are used, the eclass will create a copy of package
# sources for each Python implementation in python_prepare_all(),
# and work on that copy afterwards.
#
# If out-of-source builds are used, the eclass will instead work
# on the sources directly, prepending setup.py arguments with
# 'build --build-base ${BUILD_DIR}' to enforce keeping & using built
# files in the specific root.
# @ECLASS-VARIABLE: mydistutilsargs
# @DEFAULT_UNSET
# @DESCRIPTION:
# An array containing options to be passed to setup.py.
#
# Example:
# @CODE
# python_configure_all() {
# mydistutilsargs=( --enable-my-hidden-option )
# }
# @CODE
# @FUNCTION: esetup.py
# @USAGE: [<args>...]
# @DESCRIPTION:
# Run the setup.py using currently selected Python interpreter
# (if ${PYTHON} is set; fallback 'python' otherwise). The setup.py will
# be passed default command-line arguments, then ${mydistutilsargs[@]},
# then any parameters passed to this command.
#
# This command dies on failure.
esetup.py() {
debug-print-function ${FUNCNAME} "${@}"
local args=()
if [[ ! ${DISTUTILS_IN_SOURCE_BUILD} ]]; then
if [[ ! ${BUILD_DIR} ]]; then
die 'Out-of-source build requested, yet BUILD_DIR unset.'
fi
args+=(
build
--build-base "${BUILD_DIR}"
# using a single directory for them helps us export ${PYTHONPATH}
--build-lib "${BUILD_DIR}/lib"
)
fi
set -- "${PYTHON:-python}" setup.py \
"${args[@]}" "${mydistutilsargs[@]}" "${@}"
echo "${@}" >&2
"${@}" || die
}
# @FUNCTION: distutils-r1_python_prepare_all
# @DESCRIPTION:
# The default python_prepare_all(). It applies the patches from PATCHES
# array, then user patches and finally calls python_copy_sources to
# create copies of resulting sources for each Python implementation.
#
# At some point in the future, it may also apply eclass-specific
# distutils patches and/or quirks.
distutils-r1_python_prepare_all() {
debug-print-function ${FUNCNAME} "${@}"
[[ ${PATCHES} ]] && epatch "${PATCHES[@]}"
epatch_user
# by default, use in-source build if python_prepare() is used
if [[ ! ${DISTUTILS_IN_SOURCE_BUILD+1} ]]; then
if declare -f python_prepare >/dev/null; then
DISTUTILS_IN_SOURCE_BUILD=1
fi
fi
if [[ ${DISTUTILS_IN_SOURCE_BUILD} ]]; then
# create source copies for each implementation
python_copy_sources
fi
}
# @FUNCTION: distutils-r1_python_prepare
# @DESCRIPTION:
# The default python_prepare(). Currently it is a no-op
# but in the future it may apply implementation-specific quirks
# to the build system.
distutils-r1_python_prepare() {
debug-print-function ${FUNCNAME} "${@}"
:
}
# @FUNCTION: distutils-r1_python_configure
# @DESCRIPTION:
# The default python_configure(). Currently a no-op.
distutils-r1_python_configure() {
debug-print-function ${FUNCNAME} "${@}"
:
}
# @FUNCTION: distutils-r1_python_compile
# @USAGE: [additional-args...]
# @DESCRIPTION:
# The default python_compile(). Runs 'esetup.py build'. Any parameters
# passed to this function will be passed to setup.py.
distutils-r1_python_compile() {
debug-print-function ${FUNCNAME} "${@}"
esetup.py build "${@}"
}
# @FUNCTION: distutils-r1_python_test
# @DESCRIPTION:
# The default python_test(). Currently a no-op.
distutils-r1_python_test() {
debug-print-function ${FUNCNAME} "${@}"
:
}
# @FUNCTION: distutils-r1_rename_scripts
# @DESCRIPTION:
# Renames installed Python scripts to be implementation-suffixed.
# ${PYTHON} has to be set to the expected Python executable (which
# hashbang will be grepped for), and ${EPYTHON} to the implementation
# name (for new name).
distutils-r1_rename_scripts() {
debug-print-function ${FUNCNAME} "${@}"
local f
# XXX: change this if we ever allow directories in bin/sbin
for f in "${D}"/{bin,sbin,usr/bin,usr/sbin}/*; do
if [[ -x ${f} ]]; then
debug-print "${FUNCNAME}: found executable at ${f#${D}/}"
if [[ "$(head -n 1 "${f}")" == '#!'*${EPYTHON}* ]]
then
debug-print "${FUNCNAME}: matching shebang: $(head -n 1 "${f}")"
local newf=${f}-${EPYTHON}
debug-print "${FUNCNAME}: renamed to ${newf#${D}/}"
mv "${f}" "${newf}" || die
fi
fi
done
}
# @FUNCTION: distutils-r1_python_install
# @USAGE: [additional-args...]
# @DESCRIPTION:
# The default python_install(). Runs 'esetup.py install', appending
# the optimization flags. Then calls distutils-r1_rename_scripts.
# Any parameters passed to this function will be passed to setup.py.
distutils-r1_python_install() {
debug-print-function ${FUNCNAME} "${@}"
local flags
case "${EPYTHON}" in
jython*)
flags=(--compile);;
*)
flags=(--compile -O2);;
esac
debug-print "${FUNCNAME}: [${EPYTHON}] flags: ${flags}"
# enable compilation for the install phase.
local PYTHONDONTWRITEBYTECODE
export PYTHONDONTWRITEBYTECODE
esetup.py install "${flags[@]}" --root="${D}" "${@}"
distutils-r1_rename_scripts
}
# @FUNCTION: distutils-r1_python_install_all
# @DESCRIPTION:
# The default python_install_all(). It symlinks wrappers
# for the implementation-suffixed executables and installs
# documentation.
distutils-r1_python_install_all() {
debug-print-function ${FUNCNAME} "${@}"
if declare -p DOCS &>/dev/null; then
dodoc "${DOCS[@]}" || die "dodoc failed"
else
local f
# same list as in PMS
for f in README* ChangeLog AUTHORS NEWS TODO CHANGES \
THANKS BUGS FAQ CREDITS CHANGELOG; do
if [[ -s ${f} ]]; then
dodoc "${f}" || die "(default) dodoc ${f} failed"
fi
done
fi
if declare -p HTML_DOCS &>/dev/null; then
dohtml -r "${HTML_DOCS[@]}" || die "dohtml failed"
fi
# note: keep in sync with ...rename_scripts()
# also, we assume that each script is installed for all impls
local EPYTHON
python_export_best EPYTHON
local f
while IFS= read -r -d '' f; do
debug-print "${FUNCNAME}: found executable at ${f#${D}/}"
local wrapf=${f%-${EPYTHON}}
_python_ln_rel "${ED}"/usr/bin/python-exec "${wrapf}" || die
done < <(find "${D}" -type f -executable -name "*-${EPYTHON}" -print0)
}
# @FUNCTION: distutils-r1_run_phase
# @USAGE: [<argv>...]
# @INTERNAL
# @DESCRIPTION:
# Run the given command.
#
# If out-of-source builds are used, the phase function is run in source
# directory, with BUILD_DIR pointing at the build directory
# and PYTHONPATH having an entry for the module build directory.
#
# If in-source builds are used, the command is executed in the BUILD_DIR
# (the directory holding per-implementation copy of sources).
distutils-r1_run_phase() {
debug-print-function ${FUNCNAME} "${@}"
if [[ ${DISTUTILS_IN_SOURCE_BUILD} ]]; then
pushd "${BUILD_DIR}" &>/dev/null || die
else
local PYTHONPATH="${BUILD_DIR}/lib:${PYTHONPATH}"
export PYTHONPATH
fi
"${@}" || die "${1} failed."
if [[ ${DISTUTILS_IN_SOURCE_BUILD} ]]; then
popd &>/dev/null || die
fi
}
distutils-r1_src_prepare() {
debug-print-function ${FUNCNAME} "${@}"
# common preparations
if declare -f python_prepare_all >/dev/null; then
python_prepare_all
else
distutils-r1_python_prepare_all
fi
if declare -f python_prepare >/dev/null; then
python_foreach_impl distutils-r1_run_phase python_prepare
else
python_foreach_impl distutils-r1_run_phase distutils-r1_python_prepare
fi
}
distutils-r1_src_configure() {
if declare -f python_configure >/dev/null; then
python_foreach_impl distutils-r1_run_phase python_configure
else
python_foreach_impl distutils-r1_run_phase distutils-r1_python_configure
fi
if declare -f python_configure_all >/dev/null; then
python_configure_all
fi
}
distutils-r1_src_compile() {
debug-print-function ${FUNCNAME} "${@}"
if declare -f python_compile >/dev/null; then
python_foreach_impl distutils-r1_run_phase python_compile
else
python_foreach_impl distutils-r1_run_phase distutils-r1_python_compile
fi
if declare -f python_compile_all >/dev/null; then
python_compile_all
fi
}
distutils-r1_src_test() {
debug-print-function ${FUNCNAME} "${@}"
if declare -f python_test >/dev/null; then
python_foreach_impl distutils-r1_run_phase python_test
else
python_foreach_impl distutils-r1_run_phase distutils-r1_python_test
fi
if declare -f python_test_all >/dev/null; then
python_test_all
fi
}
distutils-r1_src_install() {
debug-print-function ${FUNCNAME} "${@}"
if declare -f python_install >/dev/null; then
python_foreach_impl distutils-r1_run_phase python_install
else
python_foreach_impl distutils-r1_run_phase distutils-r1_python_install
fi
if declare -f python_install_all >/dev/null; then
python_install_all
else
distutils-r1_python_install_all
fi
}
_DISTUTILS_R1=1
fi

View File

@ -0,0 +1,132 @@
# Copyright 1999-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/eclass/emboss.eclass,v 1.3 2012/09/27 16:35:41 axs Exp $
# @ECLASS: emboss.eclass
# @MAINTAINER:
# sci-biology@gentoo.org
# jlec@gentoo.org
# @AUTHOR:
# Original author: Author Olivier Fisette <ofisette@gmail.com>
# Next gen author: Justin Lecher <jlec@gentoo.org>
# @BLURB: Use this to easy install EMBOSS and EMBASSY programs (EMBOSS add-ons).
# @DESCRIPTION:
# The inheriting ebuild must set EAPI=4 and provide EBO_DESCRIPTION before the inherit line.
# KEYWORDS should be set. Additionally "(R|P)DEPEND"encies and other standard
# ebuild variables can be extended (FOO+=" bar").
# Default installation of following DOCS="AUTHORS ChangeLog NEWS README"
#
# Example:
#
# EAPI="4"
#
# EBO_DESCRIPTION="applications from the CBS group"
#
# inherit emboss
# @ECLASS-VARIABLE: EBO_DESCRIPTION
# @DESCRIPTION:
# Should be set. Completes the generic description of the embassy module as follows:
#
# EMBOSS integrated version of ${EBO_DESCRIPTION},
# e.g.
# "EMBOSS integrated version of applications from the CBS group"
#
# Defaults to the upstream name of the module.
# @ECLASS-VARIABLE: EBO_EAUTORECONF
# @DESCRIPTION:
# Set to 'no', if you don't want eautoreconf to be run after patching.
: ${EBO_EAUTORECONF:=yes}
# @ECLASS-VARIABLE: EBO_EXTRA_ECONF
# @DEFAULT_UNSET
# @DESCRIPTION:
# Extra config options passed to econf, similar to EXTRA_ECONF.
case ${EAPI:-0} in
4|5) ;;
*) die "this eclass doesn't support < EAPI 4" ;;
esac
inherit autotools eutils
HOMEPAGE="http://emboss.sourceforge.net/"
LICENSE="LGPL-2 GPL-2"
SLOT="0"
IUSE="mysql pdf png postgres static-libs X"
DEPEND="
dev-libs/expat
dev-libs/libpcre:3
sci-libs/plplot
sys-libs/zlib
mysql? ( dev-db/mysql )
pdf? ( media-libs/libharu )
png? ( media-libs/gd[png] )
postgres? ( dev-db/postgresql-base )
X? ( x11-libs/libXt )"
RDEPEND="${DEPEND}"
if [[ ${PN} == embassy-* ]]; then
# The EMBASSY package name, retrieved from the inheriting ebuild's name
EN=${PN:8}
# The full name and version of the EMBASSY package (excluding the Gentoo
# revision number)
EF=$(echo ${EN} | tr "[:lower:]" "[:upper:]")-${PV}
: ${EBO_DESCRIPTION:=${EN}}
DESCRIPTION="EMBOSS integrated version of ${EBO_DESCRIPTION}"
SRC_URI="ftp://emboss.open-bio.org/pub/EMBOSS/${EF}.tar.gz -> embassy-${EN}-${PV}.tar.gz"
DEPEND+=" >=sci-biology/emboss-6.3.1_p4[mysql=,pdf=,png=,postgres=,static-libs=,X=]"
S="${WORKDIR}"/${EF}
fi
DOCS="AUTHORS ChangeLog NEWS README"
# @FUNCTION: emboss_src_prepare
# @DESCRIPTION:
# Does following things
#
# 1. Patches with "${FILESDIR}"/${PF}.patch, if present
# 2. Runs eautoreconf, unless EBO_EAUTORECONF is set to no
#
emboss_src_prepare() {
[[ -f ${FILESDIR}/${PF}.patch ]] && epatch "${FILESDIR}"/${PF}.patch
[[ ${EBO_EAUTORECONF} == yes ]] && eautoreconf
}
# @FUNCTION: emboss_src_configure
# @DESCRIPTION:
# runs econf with following options.
#
# $(use_with X x)
# $(use_with png pngdriver)
# $(use_with pdf hpdf)
# $(use_with mysql mysql)
# $(use_with postgres postgresql)
# $(use_enable static-libs static)
# --enable-large
# --without-java
# --enable-systemlibs
# --docdir="${EPREFIX}/usr/share/doc/${PF}"
# ${EBO_EXTRA_ECONF}
emboss_src_configure() {
econf \
$(use_with X x) \
$(use_with png pngdriver) \
$(use_with pdf hpdf) \
$(use_with mysql mysql) \
$(use_with postgres postgresql) \
$(use_enable static-libs static) \
--enable-large \
--without-java \
--enable-systemlibs \
--docdir="${EPREFIX}/usr/share/doc/${PF}" \
${EBO_EXTRA_ECONF}
}
EXPORT_FUNCTIONS src_prepare src_configure

View File

@ -0,0 +1,226 @@
# Copyright 1999-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/eclass/fortran-2.eclass,v 1.16 2012/11/28 13:03:30 jlec Exp $
# @ECLASS: fortran-2.eclass
# @MAINTAINER:
# jlec@gentoo.org
# sci@gentoo.org
# @AUTHOR:
# Author Justin Lecher <jlec@gentoo.org>
# Test functions provided by Sebastien Fabbro and Kacper Kowalik
# @BLURB: Simplify fortran compiler management
# @DESCRIPTION:
# If you need a fortran compiler, then you should be inheriting this eclass.
# In case you only need optional support, please export FORTRAN_NEEDED before
# inheriting the eclass.
#
# The eclass tests for working fortran compilers
# and exports the variables FC and F77.
# Optionally, it checks for extended capabilities based on
# the variable options selected in the ebuild
# The only phase function exported is fortran-2_pkg_setup.
# @EXAMPLE:
# FORTRAN_NEEDED="lapack fortran"
#
# inherit fortran-2
#
# FORTRAN_NEED_OPENMP=1
# @ECLASS-VARIABLE: FORTRAN_NEED_OPENMP
# @DESCRIPTION:
# Set to "1" in order to automatically have the eclass abort if the fortran
# compiler lacks openmp support.
: ${FORTRAN_NEED_OPENMP:=0}
# @ECLASS-VARIABLE: FORTRAN_STANDARD
# @DESCRIPTION:
# Set this, if a special dialect needs to be supported.
# Generally not needed as default is sufficient.
#
# Valid settings are any combination of: 77 90 95 2003
: ${FORTRAN_STANDARD:=77}
# @ECLASS-VARIABLE: FORTRAN_NEEDED
# @DESCRIPTION:
# If your package has an optional fortran support, set this variable
# to the space seperated list of USE triggering the fortran
# dependence.
#
# e.g. FORTRAN_NEEDED=lapack would result in
#
# DEPEND="lapack? ( virtual/fortran )"
#
# If unset, we always depend on virtual/fortran.
: ${FORTRAN_NEEDED:=always}
inherit eutils toolchain-funcs
for _f_use in ${FORTRAN_NEEDED}; do
case ${_f_use} in
always)
DEPEND+=" virtual/fortran"
break
;;
no)
break
;;
*)
DEPEND+=" ${_f_use}? ( virtual/fortran )"
;;
esac
done
RDEPEND="${DEPEND}"
# @FUNCTION: _fortran_write_testsuite
# @INTERNAL
# @DESCRIPTION:
# writes fortran test code
_fortran_write_testsuite() {
local filebase=${T}/test-fortran
# f77 code
cat <<- EOF > "${filebase}.f"
end
EOF
# f90/95 code
cat <<- EOF > "${filebase}.f90"
end
EOF
# f2003 code
cat <<- EOF > "${filebase}.f03"
procedure(), pointer :: p
end
EOF
}
# @FUNCTION: _fortran_compile_test
# @USAGE: <compiler> [dialect]
# @INTERNAL
# @DESCRIPTION:
# Takes fortran compiler as first argument and dialect as second.
# Checks whether the passed fortran compiler speaks the fortran dialect
_fortran_compile_test() {
local filebase=${T}/test-fortran
local fcomp=${1}
local fdia=${2}
local fcode=${filebase}.f${fdia}
local ret
[[ $# -lt 1 ]] && die "_fortran_compile_test() needs at least one arguments"
[[ -f ${fcode} ]] || _fortran_write_testsuite
${fcomp} "${fcode}" -o "${fcode}.x" &>> "${T}"/_fortran_compile_test.log
ret=$?
rm -f "${fcode}.x"
return ${ret}
}
# @FUNCTION: _fortran-has-openmp
# @RETURN: compilers return value
# @INTERNAL
# @DESCRIPTION:
# See if the fortran supports OpenMP.
_fortran-has-openmp() {
local flag
local filebase=${T}/test-fc-openmp
local fcode=${filebase}.f
local ret
local _fc=$(tc-getFC)
cat <<- EOF > "${fcode}"
call omp_get_num_threads
end
EOF
for flag in -fopenmp -xopenmp -openmp -mp -omp -qsmp=omp; do
${_fc} ${flag} "${fcode}" -o "${fcode}.x" &>> "${T}"/_fortran_compile_test.log
ret=$?
(( ${ret} )) || break
done
rm -f "${fcode}.x"
return ${ret}
}
# @FUNCTION: _fortran_die_msg
# @INTERNAL
# @DESCRIPTION:
# Detailed description how to handle fortran support
_fortran_die_msg() {
echo
eerror "Please install currently selected gcc version with USE=fortran."
eerror "If you intend to use a different compiler then gfortran, please"
eerror "set FC variable accordingly and take care that the neccessary"
eerror "fortran dialects are support."
echo
die "Currently no working fortran compiler is available"
}
# @FUNCTION: _fortran_test_function
# @INTERNAL
# @DESCRIPTION:
# Internal testfunction for working fortran compiler. It is called in fortran-2_pkg_setup
_fortran_test_function() {
local dialect
: ${F77:=$(tc-getFC)}
: ${FORTRAN_STANDARD:=77}
for dialect in ${FORTRAN_STANDARD}; do
case ${dialect} in
77) _fortran_compile_test $(tc-getF77) || _fortran_die_msg ;;
90|95) _fortran_compile_test $(tc-getFC) 90 || _fortran_die_msg ;;
2003) _fortran_compile_test $(tc-getFC) 03 || _fortran_die_msg ;;
2008) die "Future" ;;
*) die "${dialect} is not a Fortran dialect." ;;
esac
done
tc-export F77 FC
einfo "Using following Fortran compiler:"
einfo " F77: ${F77}"
einfo " FC: ${FC}"
if [[ ${FORTRAN_NEED_OPENMP} == 1 ]]; then
if _fortran-has-openmp; then
einfo "${FC} has OPENMP support"
else
die "Please install current gcc with USE=openmp or set the FC variable to a compiler that supports OpenMP"
fi
fi
}
# @FUNCTION: fortran-2_pkg_setup
# @DESCRIPTION:
# Setup functionallity, checks for a valid fortran compiler and optionally for its openmp support.
fortran-2_pkg_setup() {
for _f_use in ${FORTRAN_NEEDED}; do
case ${_f_use} in
always)
_fortran_test_function && break
;;
no)
einfo "Forcing fortran support off"
break
;;
*)
if use ${_f_use}; then
_fortran_test_function && break
else
unset FC
unset F77
fi
;;
esac
done
}
case ${EAPI:-0} in
0|1|2|3|4|5) EXPORT_FUNCTIONS pkg_setup ;;
*) die "EAPI=${EAPI} is not supported" ;;
esac

View File

@ -0,0 +1,260 @@
# Copyright 1999-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/eclass/intel-sdp.eclass,v 1.4 2012/09/20 13:54:56 jlec Exp $
# @ECLASS: intel-sdp.eclass
# @MAINTAINER:
# Sébastien Fabbro <bicatali@gentoo.org>
# Justin Lecher <jlec@gentoo.org>
# Sci Team <sci@gentoo.org>
# @BLURB: Handling of Intel's Software Development Products package management
# @ECLASS-VARIABLE: INTEL_DID
# @DEFAULT_UNSET
# @DESCRIPTION:
# The package download ID from Intel.
# To find out its value, see the links to download in
# https://registrationcenter.intel.com/RegCenter/MyProducts.aspx
#
# e.g. 2504
#
# Must be defined before inheriting the eclass
# @ECLASS-VARIABLE: INTEL_DPN
# @DEFAULT_UNSET
# @DESCRIPTION:
# The package name to download from Intel.
# To find out its value, see the links to download in
# https://registrationcenter.intel.com/RegCenter/MyProducts.aspx
#
# e.g. parallel_studio_xe
#
# Must be defined before inheriting the eclass
# @ECLASS-VARIABLE: INTEL_DPV
# @DEFAULT_UNSET
# @DESCRIPTION:
# The package download version from Intel.
# To find out its value, see the links to download in
# https://registrationcenter.intel.com/RegCenter/MyProducts.aspx
#
# e.g. 2011_sp1_update2
#
# Must be defined before inheriting the eclass
# @ECLASS-VARIABLE: INTEL_SUBDIR
# @DEFAULT_UNSET
# @DESCRIPTION:
# The package sub-directory where it will end-up in /opt/intel
# To find out its value, you have to do a raw install from the Intel tar ball
# @ECLASS-VARIABLE: INTEL_RPMS_DIRS
# @DESCRIPTION:
# List of subdirectories in the main archive which contains the
# rpms to extract.
: ${INTEL_RPMS_DIRS:=rpm}
# @ECLASS-VARIABLE: INTEL_X86
# @DESCRIPTION:
# 32bit arch in rpm names
#
# e.g. i484
: ${INTEL_X86:=i486}
# @ECLASS-VARIABLE: INTEL_BIN_RPMS
# @DEFAULT_UNSET
# @DESCRIPTION:
# Functional name of rpm without any version/arch tag
#
# e.g. compilerprof
# @ECLASS-VARIABLE: INTEL_DAT_RPMS
# @DEFAULT_UNSET
# @DESCRIPTION:
# Functional name of rpm of common data which are arch free
# without any version tag
#
# e.g. openmp
inherit check-reqs multilib versionator
_INTEL_PV1=$(get_version_component_range 1)
_INTEL_PV2=$(get_version_component_range 2)
_INTEL_PV3=$(get_version_component_range 3)
_INTEL_PV4=$(get_version_component_range 4)
_INTEL_URI="http://registrationcenter-download.intel.com/irc_nas/${INTEL_DID}/${INTEL_DPN}"
SRC_URI="
amd64? ( multilib? ( ${_INTEL_URI}_${INTEL_DPV}.tgz ) )
amd64? ( !multilib? ( ${_INTEL_URI}_${INTEL_DPV}_intel64.tgz ) )
x86? ( ${_INTEL_URI}_${INTEL_DPV}_ia32.tgz )"
LICENSE="Intel-SDP"
# Future work, #394411
#SLOT="${_INTEL_PV1}.${_INTEL_PV2}"
SLOT="0"
IUSE="multilib"
KEYWORDS="-* ~amd64 ~x86 ~amd64-linux ~x86-linux"
RESTRICT="mirror"
RDEPEND=""
DEPEND=">=app-arch/rpm2targz-9.0.0.3g"
_INTEL_SDP_YEAR=${INTEL_DPV%_update*}
_INTEL_SDP_YEAR=${INTEL_DPV%_sp*}
# @ECLASS-VARIABLE: INTEL_SDP_DIR
# @DEFAULT_UNSET
# @DESCRIPTION:
# Full rootless path to installation dir
INTEL_SDP_DIR="opt/intel/${INTEL_SUBDIR}-${_INTEL_SDP_YEAR:-${_INTEL_PV1}}.${_INTEL_PV3}.${_INTEL_PV4}"
# @ECLASS-VARIABLE: INTEL_SDP_EDIR
# @DEFAULT_UNSET
# @DESCRIPTION:
# Full rooted path to installation dir
INTEL_SDP_EDIR="${EROOT%/}/${INTEL_SDP_DIR}"
S="${WORKDIR}"
QA_PREBUILT="${INTEL_SDP_DIR}/*"
intel-sdp_pkg_pretend() {
: ${CHECKREQS_DISK_BUILD:=256M}
check-reqs_pkg_pretend
}
# @ECLASS-VARIABLE: INTEL_ARCH
# @DEFAULT_UNSET
# @DESCRIPTION:
# Intels internal names of the arches; will be set at runtime accordingly
#
# e.g. amd64-multilib -> INTEL_ARCH="intel64 ia32"
intel-sdp_pkg_setup() {
local arch a p
if use x86; then
arch=${INTEL_X86}
INTEL_ARCH="ia32"
elif use amd64; then
arch=x86_64
INTEL_ARCH="intel64"
if has_multilib_profile; then
arch="x86_64 ${INTEL_X86}"
INTEL_ARCH="intel64 ia32"
fi
fi
INTEL_RPMS=""
for p in ${INTEL_BIN_RPMS}; do
for a in ${arch}; do
INTEL_RPMS="${INTEL_RPMS} intel-${p}-${_INTEL_PV4}-${_INTEL_PV1}.${_INTEL_PV2}-${_INTEL_PV3}.${a}.rpm"
done
done
for p in ${INTEL_DAT_RPMS}; do
INTEL_RPMS="${INTEL_RPMS} intel-${p}-${_INTEL_PV4}-${_INTEL_PV1}.${_INTEL_PV2}-${_INTEL_PV3}.noarch.rpm"
done
case "${EAPI:-0}" in
0|1|2|3) intel-sdp_pkg_pretend ;;
esac
}
intel-sdp_src_unpack() {
local l r t rpmdir
for t in ${A}; do
for r in ${INTEL_RPMS}; do
# Find which subdirectory of the archive the rpm is in
rpm_found="false"
for subdir in ${INTEL_RPMS_DIRS}; do
[[ "${rpm_found}" == "true" ]] && continue
rpmdir=${t%%.*}/${subdir}
l=.${r}_$(date +'%d%m%y_%H%M%S').log
tar xf "${DISTDIR}"/${t} ${rpmdir}/${r} 2> /dev/null || continue
einfo "Unpacking ${r}"
rpm_found="true"
rpm2tar -O "./${rpmdir}/${r}" | tar xvf - | sed -e \
"s:^\.:${EROOT#/}:g" > ${l} || die "unpacking ${r} failed"
mv ${l} opt/intel/ || die "failed moving extract log file"
done
done
done
mv -v opt/intel/* ${INTEL_SDP_DIR} || die "mv to INTEL_SDP_DIR failed"
}
intel_link_eclipse_plugins() {
pushd ${INTEL_SDP_DIR}/eclipse_support > /dev/null
local c f
for c in cdt*; do
local cv=${c#cdt} ev=3.$(( ${cv:0:1} - 1))
if has_version "dev-util/eclipse-sdk:${ev}"; then
einfo "Linking eclipse (v${ev}) plugin cdt (v${cv})"
for f in cdt${cv}/eclipse/features/*; do
dodir /usr/$(get_libdir)/eclipse-${ev}/features
dosym "${INTEL_SDP_EDIR}"/eclipse_support/${f} \
/usr/$(get_libdir)/eclipse-${ev}/features/ || die
done
for f in cdt${cv}/eclipse/plugins/*; do
dodir /usr/$(get_libdir)/eclipse-${ev}/plugins
dosym "${INTEL_SDP_EDIR}"/eclipse_support/${f} \
/usr/$(get_libdir)/eclipse-${ev}/plugins/ || die
done
fi
done
popd > /dev/null
}
intel-sdp_src_install() {
[[ -d ${INTEL_SDP_DIR}/eclipse_support ]] && \
has eclipse ${IUSE} && \
use eclipse && \
intel_link_eclipse_plugins
einfo "Tagging ${PN}"
find opt -name \*sh -type f -exec sed -i \
-e "s:<.*DIR>:${INTEL_SDP_EDIR}:g" \
'{}' \;
mkdir -p "${ED:-${D}}"/ || die
mv opt "${ED:-${D}}"/ || die "moving files failed"
}
# @ECLASS-VARIABLE: INTEL_SDP_DB
# @DESCRIPTION:
# Full path to intel registry db
INTEL_SDP_DB="${EROOT%/}"/opt/intel/intel-sdp-products.db
intel-sdp_pkg_postinst() {
elog "Make sure you have recieved the an Intel license."
elog "To receive a non-commercial license, you need to register at:"
elog "http://software.intel.com/en-us/articles/non-commercial-software-development/"
elog "Install the license file into ${EROOT}opt/intel/licenses."
# add product registry to intel "database"
local l r
for r in ${INTEL_RPMS}; do
l="$(ls -1 ${EROOT%/}/opt/intel/.${r}_*.log | head -n 1)"
echo >> ${INTEL_SDP_DB} \
"<:${r%-${_INTEL_PV4}*}-${_INTEL_PV4}:${r}:${INTEL_SDP_EDIR}:${l}:>"
done
}
intel-sdp_pkg_postrm() {
# remove from intel "database"
if [[ -e ${INTEL_SDP_DB} ]]; then
local r
for r in ${INTEL_RPMS}; do
sed -i \
-e "/${r}/d" \
${INTEL_SDP_DB}
done
fi
}
EXPORT_FUNCTIONS pkg_setup src_unpack src_install pkg_postinst pkg_postrm
case "${EAPI:-0}" in
0|1|2|3) ;;
4) EXPORT_FUNCTIONS pkg_pretend ;;
*) die "EAPI=${EAPI} is not supported" ;;
esac

View File

@ -0,0 +1,25 @@
# Copyright 1999-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/eclass/kde4-meta-pkg.eclass,v 1.9 2012/10/13 22:54:37 johu Exp $
# @ECLASS: kde4-meta-pkg.eclass
# @MAINTAINER:
# kde@gentoo.org
# @BLURB: This eclass contains boilerplate for kde 4.X meta packages
# @DESCRIPTION:
# This eclass should only be used for defining meta packages for KDE4.
inherit kde4-functions
HOMEPAGE="http://www.kde.org/"
LICENSE="metapackage"
IUSE="aqua"
# Only add the kdeprefix USE flag for older versions, to help
# non-portage package managers handle the upgrade
if [[ ${PV} < 4.6.4 && ( ${PN} != kdepim-meta || ${PV} < 4.6 ) ]]; then
IUSE+=" kdeprefix"
fi
SLOT=4

View File

@ -0,0 +1,119 @@
# Copyright 1999-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/eclass/l10n.eclass,v 1.2 2012/07/26 09:34:55 yngwin Exp $
# @ECLASS: l10n.eclass
# @MAINTAINER:
# Ben de Groot <yngwin@gentoo.org>
# @BLURB: convenience functions to handle localizations
# @DESCRIPTION:
# The l10n (localization) eclass offers a number of functions to more
# conveniently handle localizations (translations) offered by packages.
# These are meant to prevent code duplication for such boring tasks as
# determining the cross-section between the user's set LINGUAS and what
# is offered by the package; and generating the right list of linguas_*
# USE flags.
# @ECLASS-VARIABLE: PLOCALES
# @DEFAULT_UNSET
# @DESCRIPTION:
# Variable listing the locales for which localizations are offered by
# the package. Check profiles/desc/linguas.desc to see if the locales
# are listed there. Add any missing ones there.
#
# Example: PLOCALES="cy de el_GR en_US pt_BR vi zh_CN"
# @ECLASS-VARIABLE: PLOCALE_BACKUP
# @DEFAULT_UNSET
# @DESCRIPTION:
# In some cases the package fails when none of the offered PLOCALES are
# selected by the user. In that case this variable should be set to a
# default locale (usually 'en' or 'en_US') as backup.
#
# Example: PLOCALE_BACKUP="en_US"
# Add linguas useflags
for u in ${PLOCALES}; do
IUSE+=" linguas_${u}"
done
# @FUNCTION: l10n_for_each_locale_do
# @USAGE: <function>
# @DESCRIPTION:
# Convenience function for processing localizations. The parameter should
# be a function (defined in the consuming eclass or ebuild) which takes
# an individual localization as (last) parameter.
#
# Example: l10n_for_each_locale_do install_locale
l10n_for_each_locale_do() {
local locs x
locs=$(l10n_get_locales)
for x in ${locs}; do
"${@}" ${x} || die "failed to process enabled ${x} locale"
done
}
# @FUNCTION: l10n_for_each_disabled_locale_do
# @USAGE: <function>
# @DESCRIPTION:
# Complementary to l10n_for_each_locale_do, this function will process
# locales that are disabled. This could be used for example to remove
# locales from a Makefile, to prevent them from being built needlessly.
l10n_for_each_disabled_locale_do() {
local locs x
locs=$(l10n_get_locales disabled)
for x in ${locs}; do
"${@}" ${x} || die "failed to process disabled ${x} locale"
done
}
# @FUNCTION: l10n_find_plocales_changes
# @USAGE: <translations dir> <filename pre pattern> <filename post pattern>
# @DESCRIPTION:
# Ebuild maintenance helper function to find changes in package offered
# locales when doing a version bump. This could be added for example to
# src_prepare
#
# Example: l10n_find_plocales_changes "${S}/src/translations" "${PN}_" '.ts'
l10n_find_plocales_changes() {
[[ $# -ne 3 ]] && die "Exactly 3 arguments are needed!"
einfo "Looking in ${1} for new locales ..."
pushd "${1}" >/dev/null || die "Cannot access ${1}"
local current= x=
for x in ${2}*${3} ; do
x=${x#"${2}"}
x=${x%"${3}"}
current+="${x} "
done
popd >/dev/null
if [[ ${PLOCALES} != ${current%[[:space:]]} ]] ; then
einfo "There are changes in locales! This ebuild should be updated to:"
einfo "PLOCALES=\"${current%[[:space:]]}\""
else
einfo "Done"
fi
}
# @FUNCTION: l10n_get_locales
# @USAGE: [disabled]
# @DESCRIPTION:
# Determine which LINGUAS USE flags the user has enabled that are offered
# by the package, as listed in PLOCALES, and return them. In case no locales
# are selected, fall back on PLOCALE_BACKUP. When the disabled argument is
# given, return the disabled useflags instead of the enabled ones.
l10n_get_locales() {
local disabled_locales enabled_locales loc locs
for loc in ${PLOCALES}; do
if use linguas_${loc}; then
enabled_locales+="${loc} "
else
disabled_locales+="${loc} "
fi
done
if [[ ${1} == disabled ]]; then
locs=${disabled_locales}
else
locs=${enabled_locales:-$PLOCALE_BACKUP}
fi
printf "%s" "${locs}"
}

View File

@ -0,0 +1,84 @@
# Copyright 1999-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/eclass/leechcraft.eclass,v 1.7 2012/10/14 12:19:32 pinkbyte Exp $
#
# @ECLASS: leechcraft.eclass
# @MAINTAINER:
# leechcraft@gentoo.org
# @AUTHOR:
# 0xd34df00d@gmail.com
# NightNord@niifaq.ru
# @BLURB: Common functions and setup utilities for the LeechCraft app
# @DESCRIPTION:
# The leechcraft eclass contains a common set of functions and steps
# needed to build LeechCraft core or its plugins.
#
# Though this eclass seems to be small at the moment, it seems like a
# good idea to make all plugins inherit from it, since all plugins
# have mostly the same configuring/build process.
#
# Thanks for original eclass to Andrian Nord <NightNord@niifaq.ru>.
#
# Only EAPI >1 supported
case ${EAPI:-0} in
2|3|4|5) ;;
0|1) die "EAPI not supported, bug ebuild mantainer" ;;
*) die "Unknown EAPI, bug eclass maintainers" ;;
esac
inherit cmake-utils toolchain-funcs versionator
if [[ ${PV} == 9999 ]]; then
EGIT_REPO_URI="git://github.com/0xd34df00d/leechcraft.git"
EGIT_PROJECT="leechcraft"
inherit git-2
else
local suffix
if version_is_at_least 0.4.95; then
DEPEND="app-arch/xz-utils"
suffix="xz"
else
suffix="bz2"
fi
SRC_URI="mirror://sourceforge/leechcraft/leechcraft-${PV}.tar.${suffix}"
S="${WORKDIR}/leechcraft-${PV}"
fi
HOMEPAGE="http://leechcraft.org/"
LICENSE="GPL-3"
# @ECLASS-VARIABLE: LEECHCRAFT_PLUGIN_CATEGORY
# @DEFAULT_UNSET
# @DESCRIPTION:
# Set this to the category of the plugin, if any.
: ${LEECHCRAFT_PLUGIN_CATEGORY:=}
if [[ "${LEECHCRAFT_PLUGIN_CATEGORY}" ]]; then
CMAKE_USE_DIR="${S}"/src/plugins/${LEECHCRAFT_PLUGIN_CATEGORY}/${PN#leechcraft-}
elif [[ ${PN} != leechcraft-core ]]; then
CMAKE_USE_DIR="${S}"/src/plugins/${PN#leechcraft-}
else
CMAKE_USE_DIR="${S}"/src
fi
EXPORT_FUNCTIONS "pkg_pretend"
# @FUNCTION: leechcraft_pkg_pretend
# @DESCRIPTION:
# Determine active compiler version and refuse to build
# if it is not satisfied at least to minimal version,
# supported by upstream developers
leechcraft_pkg_pretend() {
debug-print-function ${FUNCNAME} "$@"
if version_is_at_least 0.5.85; then
# 0.5.85 and later requires at least gcc 4.6
if [[ ${MERGE_TYPE} != binary ]]; then
[[ $(gcc-major-version) -lt 4 ]] || \
( [[ $(gcc-major-version) -eq 4 && $(gcc-minor-version) -lt 6 ]] ) \
&& die "Sorry, but gcc 4.6 or higher is required."
fi
fi
}

View File

@ -0,0 +1,144 @@
# Copyright 1999-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/eclass/mozlinguas.eclass,v 1.5 2012/09/27 16:35:41 axs Exp $
# @ECLASS: mozlinguas.eclass
# @MAINTAINER:
# mozilla@gentoo.org
# @AUTHOR:
# Nirbheek Chauhan <nirbheek@gentoo.org>
# @BLURB: Handle language packs for mozilla products
# @DESCRIPTION:
# Sets IUSE according to MOZ_LANGS (language packs available). Also exports
# src_unpack and src_install for use in ebuilds.
inherit mozextension
case "${EAPI:-0}" in
0|1)
die "EAPI ${EAPI:-0} does not support the '->' SRC_URI operator";;
2|3|4|5)
EXPORT_FUNCTIONS src_unpack src_install;;
*)
die "EAPI ${EAPI} is not supported, contact eclass maintainers";;
esac
# @ECLASS-VARIABLE: MOZ_LANGS
# @DESCRIPTION:
# Array containing the list of language pack xpis available for
# this release. The list can be updated with scripts/get_langs.sh from the
# mozilla overlay.
# @DEFAULT-UNSET
: ${MOZ_LANGS:=()}
# @ECLASS-VARIABLE: MOZ_PV
# @DESCRIPTION:
# Ebuild package version converted to equivalent upstream version.
# Defaults to ${PV}, and should be overridden for alphas, betas, and RCs
: ${MOZ_PV:="${PV}"}
# @ECLASS-VARIABLE: MOZ_PN
# @DESCRIPTION:
# Ebuild package name converted to equivalent upstream name.
# Defaults to ${PN}, and should be overridden for binary ebuilds.
: ${MOZ_PN:="${PN}"}
# @ECLASS-VARIABLE: MOZ_P
# @DESCRIPTION:
# Ebuild package name + version converted to upstream equivalent.
# Defaults to ${MOZ_PN}-${MOZ_PV}
: ${MOZ_P:="${MOZ_PN}-${MOZ_PV}"}
# @ECLASS-VARIABLE: MOZ_FTP_URI
# @DEFAULT-UNSET
# @DESCRIPTION:
# The ftp URI prefix for the release tarballs and language packs.
: ${MOZ_FTP_URI:=""}
# @ECLASS-VARIABLE: MOZ_LANGPACK_PREFIX
# @DESCRIPTION:
# The relative path till the lang code in the langpack file URI.
# Defaults to ${MOZ_PV}/linux-i686/xpi/
: ${MOZ_LANGPACK_PREFIX:="${MOZ_PV}/linux-i686/xpi/"}
# @ECLASS-VARIABLE: MOZ_LANGPACK_SUFFIX
# @DESCRIPTION:
# The suffix after the lang code in the langpack file URI.
# Defaults to '.xpi'
: ${MOZ_LANGPACK_SUFFIX:=".xpi"}
# Add linguas_* to IUSE according to available language packs
# No language packs for alphas and betas
if ! [[ ${PV} =~ alpha|beta ]] || { [[ ${PN} == seamonkey ]] && ! [[ ${PV} =~ alpha ]] ; } ; then
for x in "${MOZ_LANGS[@]}" ; do
# en and en_US are handled internally
if [[ ${x} == en ]] || [[ ${x} == en-US ]]; then
continue
fi
SRC_URI+="
linguas_${x/-/_}?
( ${MOZ_FTP_URI}/${MOZ_LANGPACK_PREFIX}${x}${MOZ_LANGPACK_SUFFIX} -> ${MOZ_P}-${x}.xpi )"
IUSE+=" linguas_${x/-/_}"
# We used to do some magic if specific/generic locales were missing, but
# we stopped doing that due to bug 325195.
done
fi
unset x
# @FUNCTION: mozlinguas_export
# @INTERNAL
# @DESCRIPTION:
# Generate the list of language packs called "mozlinguas"
# This list is used to unpack and install the xpi language packs
mozlinguas_export() {
if [[ ${PN} == seamonkey ]] ; then
[[ ${PV} =~ alpha ]] && return
else
[[ ${PV} =~ alpha|beta ]] && return
fi
local lingua
mozlinguas=()
for lingua in ${LINGUAS}; do
if has ${lingua} en en_US; then
# For mozilla products, en and en_US are handled internally
continue
# If this language is supported by ${P},
elif has ${lingua} "${MOZ_LANGS[@]//-/_}"; then
# Add the language to mozlinguas, if it isn't already there
has ${lingua//_/-} "${mozlinguas[@]}" || mozlinguas+=(${lingua//_/-})
continue
# For each short lingua that isn't in MOZ_LANGS,
# We used to add *all* long MOZ_LANGS to the mozlinguas list,
# but we stopped doing that due to bug 325195.
else
:
fi
ewarn "Sorry, but ${P} does not support the ${lingua} locale"
done
}
# @FUNCTION: mozlinguas_src_unpack
# @DESCRIPTION:
# Unpack xpi language packs according to the user's LINGUAS settings
mozlinguas_src_unpack() {
local x
mozlinguas_export
for x in "${mozlinguas[@]}"; do
# FIXME: Add support for unpacking xpis to portage
xpi_unpack "${MOZ_P}-${x}.xpi"
done
if [[ "${mozlinguas[*]}" != "" && "${mozlinguas[*]}" != "en" ]]; then
einfo "Selected language packs (first will be default): ${mozlinguas[*]}"
fi
}
# @FUNCTION: mozlinguas_src_install
# @DESCRIPTION:
# Install xpi language packs according to the user's LINGUAS settings
mozlinguas_src_install() {
local x
mozlinguas_export
for x in "${mozlinguas[@]}"; do
xpi_install "${WORKDIR}/${MOZ_P}-${x}"
done
}

View File

@ -0,0 +1,120 @@
# Copyright 1999-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/eclass/myspell-r2.eclass,v 1.8 2012/10/24 14:44:40 scarabeus Exp $
# @ECLASS: aspell-dict.eclass
# @MAINTAINER:
# app-dicts@gentoo.org
# @AUTHOR:
# Tomáš Chvátal <scarabeus@gentoo.org>
# @BLURB: An eclass to ease the construction of ebuilds for myspell dicts
# @DESCRIPTION:
inherit base
EXPORT_FUNCTIONS src_unpack src_install
# @ECLASS-VARIABLE: MYSPELL_DICT
# @DEFAULT_UNSET
# @DESCRIPTION:
# Array variable containing list of all dictionary files.
# MYSPELL_DICT=( "file.dic" "dir/file2.aff" )
# @ECLASS-VARIABLE: MYSPELL_HYPH
# @DESCRIPTION:
# Array variable containing list of all hyphenation files.
# MYSPELL_HYPH=( "file.dic" "dir/file2.dic" )
# @ECLASS-VARIABLE: MYSPELL_THES
# @DESCRIPTION:
# Array variable containing list of all thesarus files.
# MYSPELL_HYPH=( "file.dat" "dir/file2.idx" )
# Basically no extra deps needed.
# Unzip is required for .oxt libreoffice extensions
# which are just fancy zip files.
DEPEND="app-arch/unzip"
RDEPEND=""
# by default this stuff does not have any folder in the pack
S="${WORKDIR}"
# @FUNCTION: myspell-r2_src_unpack
# @DESCRIPTION:
# Unpack all variants of weird stuff.
# In our case .oxt packs.
myspell-r2_src_unpack() {
debug-print-function ${FUNCNAME} "$@"
local f
for f in ${A}; do
case ${f} in
*.oxt)
echo ">>> Unpacking "${DISTDIR}/${f}" to ${PWD}"
unzip -qoj ${DISTDIR}/${f}
assert "failed unpacking ${DISTDIR}/${f}"
;;
*) unpack ${f} ;;
esac
done
}
# @FUNCTION: myspell-r2_src_install
# @DESCRIPTION:
# Install the dictionaries to the right places.
myspell-r2_src_install() {
debug-print-function ${FUNCNAME} "$@"
local x target
# Following the debian directory layout here.
# DICT: /usr/share/hunspell
# THES: /usr/share/mythes
# HYPH: /usr/share/hyphen
# We just need to copy the required files to proper places.
# TODO: backcompat dosym remove when all dictionaries and libreoffice
# ebuilds in tree use only the new paths
# Very old installs have hunspell to be symlink to myspell.
# This results in fcked up install/symlink stuff.
if [[ -L "${EPREFIX}/usr/share/hunspell" ]] ; then
eerror "\"${EPREFIX}/usr/share/hunspell\" is a symlink."
eerror "Please remove it so it is created properly as folder"
die "\"${EPREFIX}/usr/share/hunspell\" is a symlink."
fi
insinto /usr/share/hunspell
for x in "${MYSPELL_DICT[@]}"; do
target="${x##*/}"
newins "${x}" "${target}" || die
dosym /usr/share/hunspell/"${target}" /usr/share/myspell/"${target}" || die
done
insinto /usr/share/mythes
for x in "${MYSPELL_THES[@]}"; do
target="${x##*/}"
newins "${x}" "${target}" || die
dosym /usr/share/mythes/"${target}" /usr/share/myspell/"${target}" || die
done
insinto /usr/share/hyphen
for x in "${MYSPELL_HYPH[@]}"; do
target="${x##*/}"
newins "${x}" "${target}" || die
dosym /usr/share/hyphen/"${target}" /usr/share/myspell/"${target}" || die
done
# Remove licenses as they suffix them with .txt too
rm -rf COPYING*
rm -rf LICENSE*
rm -rf LICENCE*
rm -rf license*
rm -rf licence*
# Readme and so on
for x in *.txt README*; do
if [[ -f ${x} ]]; then
dodoc ${x} || die
fi
done
}

View File

@ -0,0 +1,633 @@
# Copyright 1999-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/eclass/mysql-autotools.eclass,v 1.10 2012/11/01 23:57:50 robbat2 Exp $
# @ECLASS: mysql-autotools.eclass
# @MAINTAINER:
# MySQL Team <mysql-bugs@gentoo.org>
# Robin H. Johnson <robbat2@gentoo.org>
# Jorge Manuel B. S. Vicetto <jmbsvicetto@gentoo.org>
# Luca Longinotti <chtekk@gentoo.org>
# @AUTHOR:
# Francesco Riosa <vivo@gentoo.org> (retired)
# @BLURB: This eclass provides support for autotools based mysql releases
# @DESCRIPTION:
# The mysql-autotools.eclass provides the support to build the mysql
# ebuilds using the autotools build system. This eclass provides
# the src_unpack, src_prepare, src_configure, src_compile, scr_install,
# pkg_preinst, pkg_postinst, pkg_config and pkg_postrm phase hooks.
inherit autotools flag-o-matic multilib
#
# HELPER FUNCTIONS:
#
# @FUNCTION: mysql-autotools_disable_test
# @DESCRIPTION:
# Helper function to disable specific tests.
mysql-autotools_disable_test() {
local rawtestname testname testsuite reason mysql_disable_file
rawtestname="${1}" ; shift
reason="${@}"
ewarn "test '${rawtestname}' disabled: '${reason}'"
testsuite="${rawtestname/.*}"
testname="${rawtestname/*.}"
mysql_disable_file="${S}/mysql-test/t/disabled.def"
#einfo "rawtestname=${rawtestname} testname=${testname} testsuite=${testsuite}"
echo "${testname} : ${reason}" >> "${mysql_disable_file}"
# ${S}/mysql-tests/t/disabled.def
#
# ${S}/mysql-tests/suite/federated/disabled.def
#
# ${S}/mysql-tests/suite/jp/t/disabled.def
# ${S}/mysql-tests/suite/ndb/t/disabled.def
# ${S}/mysql-tests/suite/rpl/t/disabled.def
# ${S}/mysql-tests/suite/parts/t/disabled.def
# ${S}/mysql-tests/suite/rpl_ndb/t/disabled.def
# ${S}/mysql-tests/suite/ndb_team/t/disabled.def
# ${S}/mysql-tests/suite/binlog/t/disabled.def
# ${S}/mysql-tests/suite/innodb/t/disabled.def
if [ -n "${testsuite}" ]; then
for mysql_disable_file in \
${S}/mysql-test/suite/${testsuite}/disabled.def \
${S}/mysql-test/suite/${testsuite}/t/disabled.def \
FAILED ; do
[ -f "${mysql_disable_file}" ] && break
done
if [ "${mysql_disabled_file}" != "FAILED" ]; then
echo "${testname} : ${reason}" >> "${mysql_disable_file}"
else
ewarn "Could not find testsuite disabled.def location for ${rawtestname}"
fi
fi
}
# @FUNCTION: mysql-autotools_configure_minimal
# @DESCRIPTION:
# Helper function to configure a minimal build
mysql-autotools_configure_minimal() {
# These are things we exclude from a minimal build, please
# note that the server actually does get built and installed,
# but we then delete it before packaging.
local minimal_exclude_list="server embedded-server extra-tools innodb bench berkeley-db row-based-replication readline"
for i in ${minimal_exclude_list} ; do
myconf="${myconf} --without-${i}"
done
myconf="${myconf} --with-extra-charsets=none"
myconf="${myconf} --enable-local-infile"
if use static ; then
myconf="${myconf} --with-client-ldflags=-all-static"
myconf="${myconf} --disable-shared --with-pic"
else
myconf="${myconf} --enable-shared --enable-static"
fi
if ! use latin1 ; then
myconf="${myconf} --with-charset=utf8"
myconf="${myconf} --with-collation=utf8_general_ci"
else
myconf="${myconf} --with-charset=latin1"
myconf="${myconf} --with-collation=latin1_swedish_ci"
fi
# MariaDB requires this flag in order to link to GPLv3 readline v6 or greater
# A note is added to the configure output
if [[ "${PN}" == "mariadb" ]] && mysql_version_is_at_least "5.1.61" ; then
myconf="${myconf} --disable-distribution"
fi
}
# @FUNCTION: mysql-autotools_configure_common
# @DESCRIPTION:
# Helper function to configure the common builds
mysql-autotools_configure_common() {
myconf="${myconf} $(use_with big-tables)"
myconf="${myconf} --enable-local-infile"
myconf="${myconf} --with-extra-charsets=all"
myconf="${myconf} --with-mysqld-user=mysql"
myconf="${myconf} --with-server"
myconf="${myconf} --with-unix-socket-path=${EPREFIX}/var/run/mysqld/mysqld.sock"
myconf="${myconf} --without-libwrap"
if use static ; then
myconf="${myconf} --with-mysqld-ldflags=-all-static"
myconf="${myconf} --with-client-ldflags=-all-static"
myconf="${myconf} --disable-shared --with-pic"
else
myconf="${myconf} --enable-shared --enable-static"
fi
if use debug ; then
myconf="${myconf} --with-debug=full"
else
myconf="${myconf} --without-debug"
if ( use cluster ); then
myconf="${myconf} --without-ndb-debug"
fi
fi
if [ -n "${MYSQL_DEFAULT_CHARSET}" -a -n "${MYSQL_DEFAULT_COLLATION}" ]; then
ewarn "You are using a custom charset of ${MYSQL_DEFAULT_CHARSET}"
ewarn "and a collation of ${MYSQL_DEFAULT_COLLATION}."
ewarn "You MUST file bugs without these variables set."
myconf="${myconf} --with-charset=${MYSQL_DEFAULT_CHARSET}"
myconf="${myconf} --with-collation=${MYSQL_DEFAULT_COLLATION}"
elif ! use latin1 ; then
myconf="${myconf} --with-charset=utf8"
myconf="${myconf} --with-collation=utf8_general_ci"
else
myconf="${myconf} --with-charset=latin1"
myconf="${myconf} --with-collation=latin1_swedish_ci"
fi
if use embedded ; then
myconf="${myconf} --with-embedded-privilege-control"
myconf="${myconf} --with-embedded-server"
else
myconf="${myconf} --without-embedded-privilege-control"
myconf="${myconf} --without-embedded-server"
fi
}
# @FUNCTION: mysql-autotools_configure_51
# @DESCRIPTION:
# Helper function to configure 5.1 and later builds
mysql-autotools_configure_51() {
# TODO: !!!! readd --without-readline
# the failure depend upon config/ac-macros/readline.m4 checking into
# readline.h instead of history.h
myconf="${myconf} $(use_with ssl ssl "${EPREFIX}"/usr)"
myconf="${myconf} --enable-assembler"
myconf="${myconf} --with-geometry"
myconf="${myconf} --with-readline"
myconf="${myconf} --with-zlib-dir=${EPREFIX}/usr/"
myconf="${myconf} --without-pstack"
myconf="${myconf} --with-plugindir=${EPREFIX}/usr/$(get_libdir)/mysql/plugin"
# This is an explict die here, because if we just forcibly disable it, then the
# user's data is not accessible.
use max-idx-128 && die "Bug #336027: upstream has a corruption issue with max-idx-128 presently"
#use max-idx-128 && myconf="${myconf} --with-max-indexes=128"
myconf="${myconf} $(use_enable community community-features)"
if use community; then
myconf="${myconf} $(use_enable profiling)"
else
myconf="${myconf} --disable-profiling"
fi
# Scan for all available plugins
local plugins_avail="$(
LANG=C \
find "${S}" \
\( \
-name 'plug.in' \
-o -iname 'configure.in' \
-o -iname 'configure.ac' \
\) \
-print0 \
| xargs -0 sed -r -n \
-e '/^MYSQL_STORAGE_ENGINE/{
s~MYSQL_STORAGE_ENGINE\([[:space:]]*\[?([-_a-z0-9]+)\]?.*,~\1 ~g ;
s~^([^ ]+).*~\1~gp;
}' \
| tr -s '\n' ' '
)"
# 5.1 introduces a new way to manage storage engines (plugins)
# like configuration=none
# This base set are required, and will always be statically built.
local plugins_sta="csv myisam myisammrg heap"
local plugins_dyn=""
local plugins_dis="example ibmdb2i"
# These aren't actually required by the base set, but are really useful:
plugins_sta="${plugins_sta} archive blackhole"
# Now the extras
if use extraengine ; then
# like configuration=max-no-ndb, archive and example removed in 5.1.11
# not added yet: ibmdb2i
# Not supporting as examples: example,daemon_example,ftexample
plugins_sta="${plugins_sta} partition"
if [[ "${PN}" != "mariadb" ]] ; then
elog "Before using the Federated storage engine, please be sure to read"
elog "http://dev.mysql.com/doc/refman/5.1/en/federated-limitations.html"
plugins_dyn="${plugins_dyn} federated"
else
elog "MariaDB includes the FederatedX engine. Be sure to read"
elog "http://askmonty.org/wiki/index.php/Manual:FederatedX_storage_engine"
plugins_dyn="${plugins_dyn} federatedx"
fi
else
plugins_dis="${plugins_dis} partition federated"
fi
# Upstream specifically requests that InnoDB always be built:
# - innobase, innodb_plugin
# Build falcon if available for 6.x series.
for i in innobase falcon ; do
[ -e "${S}"/storage/${i} ] && plugins_sta="${plugins_sta} ${i}"
done
for i in innodb_plugin ; do
[ -e "${S}"/storage/${i} ] && plugins_dyn="${plugins_dyn} ${i}"
done
# like configuration=max-no-ndb
if ( use cluster ) ; then
plugins_sta="${plugins_sta} ndbcluster partition"
plugins_dis="${plugins_dis//partition}"
myconf="${myconf} --with-ndb-binlog"
else
plugins_dis="${plugins_dis} ndbcluster"
fi
if [[ "${PN}" == "mariadb" ]] ; then
# In MariaDB, InnoDB is packaged in the xtradb directory, so it's not
# caught above.
# This is not optional, without it several upstream testcases fail.
# Also strongly recommended by upstream.
if [[ "${PV}" < "5.2.0" ]] ; then
myconf="${myconf} --with-maria-tmp-tables"
plugins_sta="${plugins_sta} maria"
else
myconf="${myconf} --with-aria-tmp-tables"
plugins_sta="${plugins_sta} aria"
fi
[ -e "${S}"/storage/innobase ] || [ -e "${S}"/storage/xtradb ] ||
die "The ${P} package doesn't provide innobase nor xtradb"
for i in innobase xtradb ; do
[ -e "${S}"/storage/${i} ] && plugins_sta="${plugins_sta} ${i}"
done
myconf="${myconf} $(use_with libevent)"
if mysql_version_is_at_least "5.2" ; then
for i in oqgraph ; do
use ${i} \
&& plugins_dyn="${plugins_dyn} ${i}" \
|| plugins_dis="${plugins_dis} ${i}"
done
fi
if mysql_version_is_at_least "5.2.5" ; then
for i in sphinx ; do
use ${i} \
&& plugins_dyn="${plugins_dyn} ${i}" \
|| plugins_dis="${plugins_dis} ${i}"
done
fi
fi
if pbxt_available && [[ "${PBXT_NEWSTYLE}" == "1" ]]; then
use pbxt \
&& plugins_sta="${plugins_sta} pbxt" \
|| plugins_dis="${plugins_dis} pbxt"
fi
use static && \
plugins_sta="${plugins_sta} ${plugins_dyn}" && \
plugins_dyn=""
einfo "Available plugins: ${plugins_avail}"
einfo "Dynamic plugins: ${plugins_dyn}"
einfo "Static plugins: ${plugins_sta}"
einfo "Disabled plugins: ${plugins_dis}"
# These are the static plugins
myconf="${myconf} --with-plugins=${plugins_sta// /,}"
# And the disabled ones
for i in ${plugins_dis} ; do
myconf="${myconf} --without-plugin-${i}"
done
}
pbxt_src_configure() {
mysql_init_vars
pushd "${WORKDIR}/pbxt-${PBXT_VERSION}" &>/dev/null
einfo "Reconfiguring dir '${PWD}'"
eautoreconf
local myconf=""
myconf="${myconf} --with-mysql=${S} --libdir=${EPREFIX}/usr/$(get_libdir)"
use debug && myconf="${myconf} --with-debug=full"
econf ${myconf} || die "Problem configuring PBXT storage engine"
}
pbxt_src_compile() {
# TODO: is it safe/needed to use emake here ?
make || die "Problem making PBXT storage engine (${myconf})"
popd
# TODO: modify test suite for PBXT
}
pbxt_src_install() {
pushd "${WORKDIR}/pbxt-${PBXT_VERSION}" &>/dev/null
emake install DESTDIR="${D}" || die "Failed to install PBXT"
popd
}
#
# EBUILD FUNCTIONS
#
# @FUNCTION: mysql-autotools_src_prepare
# @DESCRIPTION:
# Apply patches to the source code and remove unneeded bundled libs.
mysql-autotools_src_prepare() {
cd "${S}"
# Apply the patches for this MySQL version
EPATCH_SUFFIX="patch"
mkdir -p "${EPATCH_SOURCE}" || die "Unable to create epatch directory"
# Clean out old items
rm -f "${EPATCH_SOURCE}"/*
# Now link in right patches
mysql_mv_patches
# And apply
epatch
# last -fPIC fixup, per bug #305873
i="${S}"/storage/innodb_plugin/plug.in
[ -f "${i}" ] && sed -i -e '/CFLAGS/s,-prefer-non-pic,,g' "${i}"
# Additional checks, remove bundled zlib
rm -f "${S}/zlib/"*.[ch]
sed -i -e "s/zlib\/Makefile dnl/dnl zlib\/Makefile/" "${S}/configure.in"
rm -f "scripts/mysqlbug"
# Make charsets install in the right place
find . -name 'Makefile.am' \
-exec sed --in-place -e 's!$(pkgdatadir)!'${MY_SHAREDSTATEDIR}'!g' {} \;
# Remove what needs to be recreated, so we're sure it's actually done
einfo "Cleaning up old buildscript files"
find . -name Makefile \
-o -name Makefile.in \
-o -name configure \
-exec rm -f {} \;
rm -f "ltmain.sh"
rm -f "scripts/mysqlbug"
local rebuilddirlist d
if xtradb_patch_available && use xtradb ; then
einfo "Adding storage engine: Percona XtraDB (replacing InnoDB)"
pushd "${S}"/storage >/dev/null
i="innobase"
o="${WORKDIR}/storage-${i}.mysql-upstream"
# Have we been here already?
[ -d "${o}" ] && rm -f "${i}"
# Or maybe we haven't
[ -d "${i}" -a ! -d "${o}" ] && mv "${i}" "${o}"
cp -ral "${WORKDIR}/${XTRADB_P}" "${i}"
popd >/dev/null
fi
if pbxt_patch_available && [[ "${PBXT_NEWSTYLE}" == "1" ]] && use pbxt ; then
einfo "Adding storage engine: PBXT"
pushd "${S}"/storage >/dev/null
i='pbxt'
[ -d "${i}" ] && rm -rf "${i}"
cp -ral "${WORKDIR}/${PBXT_P}" "${i}"
popd >/dev/null
fi
rebuilddirlist="."
# This does not seem to be needed presently. robbat2 2010/02/23
#einfo "Updating innobase cmake"
## TODO: check this with a cmake expert
#cmake \
# -DCMAKE_C_COMPILER=$(type -P $(tc-getCC)) \
# -DCMAKE_CXX_COMPILER=$(type -P $(tc-getCXX)) \
# "storage/innobase"
for d in ${rebuilddirlist} ; do
einfo "Reconfiguring dir '${d}'"
pushd "${d}" &>/dev/null
eautoreconf
popd &>/dev/null
done
}
# @FUNCTION: mysql-autotools_src_configure
# @DESCRIPTION:
# Configure mysql to build the code for Gentoo respecting the use flags.
mysql-autotools_src_configure() {
# Make sure the vars are correctly initialized
mysql_init_vars
# $myconf is modified by the configure_* functions
local myconf=""
if use minimal ; then
mysql-autotools_configure_minimal
else
mysql-autotools_configure_common
mysql-autotools_configure_51
fi
# Bug #114895, bug #110149
filter-flags "-O" "-O[01]"
# glib-2.3.2_pre fix, bug #16496
append-flags "-DHAVE_ERRNO_AS_DEFINE=1"
# As discovered by bug #246652, doing a double-level of SSP causes NDB to
# fail badly during cluster startup.
if [[ $(gcc-major-version) -lt 4 ]]; then
filter-flags "-fstack-protector-all"
fi
CXXFLAGS="${CXXFLAGS} -fno-exceptions -fno-strict-aliasing"
CXXFLAGS="${CXXFLAGS} -felide-constructors -fno-rtti"
mysql_version_is_at_least "5.0" \
&& CXXFLAGS="${CXXFLAGS} -fno-implicit-templates"
export CXXFLAGS
# bug #283926, with GCC4.4, this is required to get correct behavior.
append-flags -fno-strict-aliasing
# bug #335185, #335995, with >= GCC4.3.3 on x86 only, omit-frame-pointer
# causes a mis-compile.
# Upstream bugs:
# http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38562
# http://bugs.mysql.com/bug.php?id=45205
use x86 && version_is_at_least "4.3.3" "$(gcc-fullversion)" && \
append-flags -fno-omit-frame-pointer && \
filter-flags -fomit-frame-pointer
econf \
--libexecdir="${EPREFIX}/usr/sbin" \
--sysconfdir="${MY_SYSCONFDIR}" \
--localstatedir="${MY_LOCALSTATEDIR}" \
--sharedstatedir="${MY_SHAREDSTATEDIR}" \
--libdir="${MY_LIBDIR}" \
--includedir="${MY_INCLUDEDIR}" \
--with-low-memory \
--with-client-ldflags=-lstdc++ \
--enable-thread-safe-client \
--with-comment="Gentoo Linux ${PF}" \
--without-docs \
--with-LIBDIR="$(get_libdir)" \
${myconf} || die "econf failed"
# TODO: Move this before autoreconf !!!
find . -type f -name Makefile -print0 \
| xargs -0 -n100 sed -i \
-e 's|^pkglibdir *= *$(libdir)/mysql|pkglibdir = $(libdir)|;s|^pkgincludedir *= *$(includedir)/mysql|pkgincludedir = $(includedir)|'
if [[ $EAPI == 2 ]] && [[ "${PBXT_NEWSTYLE}" != "1" ]]; then
pbxt_patch_available && use pbxt && pbxt_src_configure
fi
}
# @FUNCTION: mysql-autotools_src_compile
# @DESCRIPTION:
# Compile the mysql code.
mysql-autotools_src_compile() {
emake || die "emake failed"
if [[ "${PBXT_NEWSTYLE}" != "1" ]]; then
pbxt_patch_available && use pbxt && pbxt_src_compile
fi
}
# @FUNCTION: mysql-autotools_src_install
# @DESCRIPTION:
# Install mysql.
mysql-autotools_src_install() {
# Make sure the vars are correctly initialized
mysql_init_vars
emake install \
DESTDIR="${D}" \
benchdir_root="${MY_SHAREDSTATEDIR}" \
testroot="${MY_SHAREDSTATEDIR}" \
|| die "emake install failed"
if [[ "${PBXT_NEWSTYLE}" != "1" ]]; then
pbxt_patch_available && use pbxt && pbxt_src_install
fi
# Convenience links
einfo "Making Convenience links for mysqlcheck multi-call binary"
dosym "/usr/bin/mysqlcheck" "/usr/bin/mysqlanalyze"
dosym "/usr/bin/mysqlcheck" "/usr/bin/mysqlrepair"
dosym "/usr/bin/mysqlcheck" "/usr/bin/mysqloptimize"
# Various junk (my-*.cnf moved elsewhere)
einfo "Removing duplicate /usr/share/mysql files"
rm -Rf "${ED}/usr/share/info"
for removeme in "mysql-log-rotate" mysql.server* \
binary-configure* my-*.cnf mi_test_all*
do
rm -f "${D}"/${MY_SHAREDSTATEDIR}/${removeme}
done
# Clean up stuff for a minimal build
if use minimal ; then
einfo "Remove all extra content for minimal build"
rm -Rf "${D}${MY_SHAREDSTATEDIR}"/{mysql-test,sql-bench}
rm -f "${ED}"/usr/bin/{mysql{_install_db,manager*,_secure_installation,_fix_privilege_tables,hotcopy,_convert_table_format,d_multi,_fix_extensions,_zap,_explain_log,_tableinfo,d_safe,_install,_waitpid,binlog,test},myisam*,isam*,pack_isam}
rm -f "${ED}/usr/sbin/mysqld"
rm -f "${D}${MY_LIBDIR}"/lib{heap,merge,nisam,my{sys,strings,sqld,isammrg,isam},vio,dbug}.a
fi
# Unless they explicitly specific USE=test, then do not install the
# testsuite. It DOES have a use to be installed, esp. when you want to do a
# validation of your database configuration after tuning it.
if use !test ; then
rm -rf "${D}"/${MY_SHAREDSTATEDIR}/mysql-test
fi
# Configuration stuff
case ${MYSQL_PV_MAJOR} in
5.[1-9]|6*|7*) mysql_mycnf_version="5.1" ;;
esac
einfo "Building default my.cnf (${mysql_mycnf_version})"
insinto "${MY_SYSCONFDIR#${EPREFIX}}"
doins scripts/mysqlaccess.conf
mycnf_src="my.cnf-${mysql_mycnf_version}"
sed -e "s!@DATADIR@!${MY_DATADIR}!g" \
-e "s!/tmp!${EPREFIX}/tmp!" \
-e "s!/usr!${EPREFIX}/usr!" \
-e "s!= /var!= ${EPREFIX}/var!" \
"${FILESDIR}/${mycnf_src}" \
> "${TMPDIR}/my.cnf.ok"
if use latin1 ; then
sed -i \
-e "/character-set/s|utf8|latin1|g" \
"${TMPDIR}/my.cnf.ok"
fi
newins "${TMPDIR}/my.cnf.ok" my.cnf
# Minimal builds don't have the MySQL server
if ! use minimal ; then
einfo "Creating initial directories"
# Empty directories ...
diropts "-m0750"
if [[ "${PREVIOUS_DATADIR}" != "yes" ]] ; then
dodir "${MY_DATADIR#${EPREFIX}}"
keepdir "${MY_DATADIR#${EPREFIX}}"
chown -R mysql:mysql "${D}/${MY_DATADIR}"
fi
diropts "-m0755"
for folder in "${MY_LOGDIR#${EPREFIX}}" "/var/run/mysqld" ; do
dodir "${folder}"
keepdir "${folder}"
chown -R mysql:mysql "${ED}/${folder}"
done
fi
# Docs
einfo "Installing docs"
for i in README ChangeLog EXCEPTIONS-CLIENT INSTALL-SOURCE ; do
[[ -f "$i" ]] && dodoc "$i"
done
doinfo "${S}"/Docs/mysql.info
# Minimal builds don't have the MySQL server
if ! use minimal ; then
einfo "Including support files and sample configurations"
docinto "support-files"
for script in \
"${S}"/support-files/my-*.cnf \
"${S}"/support-files/magic \
"${S}"/support-files/ndb-config-2-node.ini
do
[[ -f "$script" ]] && dodoc "${script}"
done
docinto "scripts"
for script in "${S}"/scripts/mysql* ; do
[[ -f "$script" ]] && [[ "${script%.sh}" == "${script}" ]] && dodoc "${script}"
done
fi
mysql_lib_symlinks "${ED}"
}

View File

@ -0,0 +1,387 @@
# Copyright 1999-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/eclass/mysql-cmake.eclass,v 1.10 2012/11/01 23:57:50 robbat2 Exp $
# @ECLASS: mysql-cmake.eclass
# @MAINTAINER:
# Maintainers:
# - MySQL Team <mysql-bugs@gentoo.org>
# - Robin H. Johnson <robbat2@gentoo.org>
# - Jorge Manuel B. S. Vicetto <jmbsvicetto@gentoo.org>
# @BLURB: This eclass provides the support for cmake based mysql releases
# @DESCRIPTION:
# The mysql-cmake.eclass provides the support to build the mysql
# ebuilds using the cmake build system. This eclass provides
# the src_unpack, src_prepare, src_configure, src_compile, scr_install,
# pkg_preinst, pkg_postinst, pkg_config and pkg_postrm phase hooks.
inherit cmake-utils flag-o-matic multilib
#
# HELPER FUNCTIONS:
#
# @FUNCTION: mysql_cmake_disable_test
# @DESCRIPTION:
# Helper function to disable specific tests.
mysql-cmake_disable_test() {
local rawtestname testname testsuite reason mysql_disabled_file mysql_disabled_dir
rawtestname="${1}" ; shift
reason="${@}"
ewarn "test '${rawtestname}' disabled: '${reason}'"
testsuite="${rawtestname/.*}"
testname="${rawtestname/*.}"
for mysql_disabled_file in \
${S}/mysql-test/disabled.def \
${S}/mysql-test/t/disabled.def ; do
[ -f "${mysql_disabled_file}" ] && break
done
#mysql_disabled_file="${S}/mysql-test/t/disabled.def"
#einfo "rawtestname=${rawtestname} testname=${testname} testsuite=${testsuite}"
echo ${testname} : ${reason} >> "${mysql_disabled_file}"
if [ -n "${testsuite}" ] && [ "${testsuite}" != "main" ]; then
for mysql_disabled_file in \
${S}/mysql-test/suite/${testsuite}/disabled.def \
${S}/mysql-test/suite/${testsuite}/t/disabled.def \
FAILED ; do
[ -f "${mysql_disabled_file}" ] && break
done
if [ "${mysql_disabled_file}" != "FAILED" ]; then
echo "${testname} : ${reason}" >> "${mysql_disabled_file}"
else
for mysql_disabled_dir in \
${S}/mysql-test/suite/${testsuite} \
${S}/mysql-test/suite/${testsuite}/t \
FAILED ; do
[ -d "${mysql_disabled_dir}" ] && break
done
if [ "${mysql_disabled_dir}" != "FAILED" ]; then
echo "${testname} : ${reason}" >> "${mysql_disabled_dir}/disabled.def"
else
ewarn "Could not find testsuite disabled.def location for ${rawtestname}"
fi
fi
fi
}
# @FUNCTION: configure_cmake_locale
# @DESCRIPTION:
# Helper function to configure locale cmake options
configure_cmake_locale() {
if ! use minimal && [ -n "${MYSQL_DEFAULT_CHARSET}" -a -n "${MYSQL_DEFAULT_COLLATION}" ]; then
ewarn "You are using a custom charset of ${MYSQL_DEFAULT_CHARSET}"
ewarn "and a collation of ${MYSQL_DEFAULT_COLLATION}."
ewarn "You MUST file bugs without these variables set."
mycmakeargs+=(
-DDEFAULT_CHARSET=${MYSQL_DEFAULT_CHARSET}
-DDEFAULT_COLLATION=${MYSQL_DEFAULT_COLLATION}
)
elif ! use latin1 ; then
mycmakeargs+=(
-DDEFAULT_CHARSET=utf8
-DDEFAULT_COLLATION=utf8_general_ci
)
else
mycmakeargs+=(
-DDEFAULT_CHARSET=latin1
-DDEFAULT_COLLATION=latin1_swedish_ci
)
fi
}
# @FUNCTION: configure_cmake_minimal
# @DESCRIPTION:
# Helper function to configure minimal build
configure_cmake_minimal() {
mycmakeargs+=(
-DWITHOUT_SERVER=1
-DWITHOUT_EMBEDDED_SERVER=1
-DENABLED_LOCAL_INFILE=1
-DEXTRA_CHARSETS=none
-DINSTALL_SQLBENCHDIR=
-DWITH_SSL=system
-DWITH_ZLIB=system
-DWITHOUT_LIBWRAP=1
-DWITHOUT_READLINE=1
-DWITHOUT_ARCHIVE_STORAGE_ENGINE=1
-DWITHOUT_BLACKHOLE_STORAGE_ENGINE=1
-DWITHOUT_CSV_STORAGE_ENGINE=1
-DWITHOUT_FEDERATED_STORAGE_ENGINE=1
-DWITHOUT_HEAP_STORAGE_ENGINE=1
-DWITHOUT_INNOBASE_STORAGE_ENGINE=1
-DWITHOUT_MYISAMMRG_STORAGE_ENGINE=1
-DWITHOUT_MYISAM_STORAGE_ENGINE=1
-DWITHOUT_PARTITION_STORAGE_ENGINE=1
-DWITHOUT_INNOBASE_STORAGE_ENGINE=1
)
}
# @FUNCTION: configure_cmake_standard
# @DESCRIPTION:
# Helper function to configure standard build
configure_cmake_standard() {
mycmakeargs+=(
-DENABLED_LOCAL_INFILE=1
-DEXTRA_CHARSETS=all
-DMYSQL_USER=mysql
-DMYSQL_UNIX_ADDR=${EPREFIX}/var/run/mysqld/mysqld.sock
-DWITHOUT_READLINE=1
-DWITH_ZLIB=system
-DWITHOUT_LIBWRAP=1
)
mycmakeargs+=(
$(cmake-utils_use_disable !static SHARED)
$(cmake-utils_use_with debug)
$(cmake-utils_use_with embedded EMBEDDED_SERVER)
$(cmake-utils_use_with profiling)
$(cmake-utils_use_enable systemtap DTRACE)
)
if use ssl; then
mycmakeargs+=( -DWITH_SSL=system )
else
mycmakeargs+=( -DWITH_SSL=0 )
fi
if mysql_version_is_at_least "5.5" && use jemalloc; then
mycmakeargs+=( -DCMAKE_EXE_LINKER_FLAGS='-ljemalloc' -DWITH_SAFEMALLOC=OFF )
fi
if mysql_version_is_at_least "5.5" && use tcmalloc; then
mycmakeargs+=( -DCMAKE_EXE_LINKER_FLAGS='-ltcmalloc' -DWITH_SAFEMALLOC=OFF )
fi
# Storage engines
mycmakeargs+=(
-DWITH_ARCHIVE_STORAGE_ENGINE=1
-DWITH_BLACKHOLE_STORAGE_ENGINE=1
-DWITH_CSV_STORAGE_ENGINE=1
-DWITH_HEAP_STORAGE_ENGINE=1
-DWITH_INNOBASE_STORAGE_ENGINE=1
-DWITH_MYISAMMRG_STORAGE_ENGINE=1
-DWITH_MYISAM_STORAGE_ENGINE=1
-DWITH_PARTITION_STORAGE_ENGINE=1
$(cmake-utils_use_with extraengine FEDERATED_STORAGE_ENGINE)
)
if pbxt_available ; then
mycmakeargs+=( $(cmake-utils_use_with pbxt PBXT_STORAGE_ENGINE) )
fi
if [ "${PN}" == "mariadb" ]; then
mycmakeargs+=(
$(cmake-utils_use_with oqgraph OQGRAPH_STORAGE_ENGINE)
$(cmake-utils_use_with sphinx SPHINX_STORAGE_ENGINE)
$(cmake-utils_use_with extraengine FEDERATEDX_STORAGE_ENGINE)
)
fi
}
#
# EBUILD FUNCTIONS
#
# @FUNCTION: mysql-cmake_src_prepare
# @DESCRIPTION:
# Apply patches to the source code and remove unneeded bundled libs.
mysql-cmake_src_prepare() {
debug-print-function ${FUNCNAME} "$@"
cd "${S}"
# Apply the patches for this MySQL version
EPATCH_SUFFIX="patch"
mkdir -p "${EPATCH_SOURCE}" || die "Unable to create epatch directory"
# Clean out old items
rm -f "${EPATCH_SOURCE}"/*
# Now link in right patches
mysql_mv_patches
# And apply
epatch
# last -fPIC fixup, per bug #305873
i="${S}"/storage/innodb_plugin/plug.in
[ -f "${i}" ] && sed -i -e '/CFLAGS/s,-prefer-non-pic,,g' "${i}"
rm -f "scripts/mysqlbug"
}
# @FUNCTION: mysql-cmake_src_configure
# @DESCRIPTION:
# Configure mysql to build the code for Gentoo respecting the use flags.
mysql-cmake_src_configure() {
debug-print-function ${FUNCNAME} "$@"
CMAKE_BUILD_TYPE="RelWithDebInfo"
mycmakeargs=(
-DCMAKE_INSTALL_PREFIX=${EPREFIX}/usr
-DMYSQL_DATADIR=${EPREFIX}/var/lib/mysql
-DSYSCONFDIR=${EPREFIX}/etc/mysql
-DINSTALL_BINDIR=bin
-DINSTALL_DOCDIR=share/doc/${P}
-DINSTALL_DOCREADMEDIR=share/doc/${P}
-DINSTALL_INCLUDEDIR=include/mysql
-DINSTALL_INFODIR=share/info
-DINSTALL_LIBDIR=$(get_libdir)/mysql
-DINSTALL_MANDIR=share/man
-DINSTALL_MYSQLDATADIR=${EPREFIX}/var/lib/mysql
-DINSTALL_MYSQLSHAREDIR=share/mysql
-DINSTALL_MYSQLTESTDIR=share/mysql/mysql-test
-DINSTALL_PLUGINDIR=$(get_libdir)/mysql/plugin
-DINSTALL_SBINDIR=sbin
-DINSTALL_SCRIPTDIR=share/mysql/scripts
-DINSTALL_SQLBENCHDIR=share/mysql
-DINSTALL_SUPPORTFILESDIR=${EPREFIX}/usr/share/mysql
-DWITH_COMMENT="Gentoo Linux ${PF}"
-DWITHOUT_UNIT_TESTS=1
)
# Bug 412851
# MariaDB requires this flag to compile with GPLv3 readline linked
# Adds a warning about redistribution to configure
if [[ "${PN}" == "mariadb" ]] ; then
mycmakeargs+=( -DNOT_FOR_DISTRIBUTION=1 )
fi
configure_cmake_locale
if use minimal ; then
configure_cmake_minimal
else
configure_cmake_standard
fi
# Bug #114895, bug #110149
filter-flags "-O" "-O[01]"
CXXFLAGS="${CXXFLAGS} -fno-exceptions -fno-strict-aliasing"
CXXFLAGS="${CXXFLAGS} -felide-constructors -fno-rtti"
CXXFLAGS="${CXXFLAGS} -fno-implicit-templates"
export CXXFLAGS
# bug #283926, with GCC4.4, this is required to get correct behavior.
append-flags -fno-strict-aliasing
cmake-utils_src_configure
}
# @FUNCTION: mysql-cmake_src_compile
# @DESCRIPTION:
# Compile the mysql code.
mysql-cmake_src_compile() {
debug-print-function ${FUNCNAME} "$@"
cmake-utils_src_compile
}
# @FUNCTION: mysql-cmake_src_install
# @DESCRIPTION:
# Install mysql.
mysql-cmake_src_install() {
debug-print-function ${FUNCNAME} "$@"
# Make sure the vars are correctly initialized
mysql_init_vars
cmake-utils_src_install
# Convenience links
einfo "Making Convenience links for mysqlcheck multi-call binary"
dosym "/usr/bin/mysqlcheck" "/usr/bin/mysqlanalyze"
dosym "/usr/bin/mysqlcheck" "/usr/bin/mysqlrepair"
dosym "/usr/bin/mysqlcheck" "/usr/bin/mysqloptimize"
# INSTALL_LAYOUT=STANDALONE causes cmake to create a /usr/data dir
rm -Rf "${ED}/usr/data"
# Various junk (my-*.cnf moved elsewhere)
einfo "Removing duplicate /usr/share/mysql files"
# Clean up stuff for a minimal build
# if use minimal ; then
# einfo "Remove all extra content for minimal build"
# rm -Rf "${D}${MY_SHAREDSTATEDIR}"/{mysql-test,sql-bench}
# rm -f "${ED}"/usr/bin/{mysql{_install_db,manager*,_secure_installation,_fix_privilege_tables,hotcopy,_convert_table_format,d_multi,_fix_extensions,_zap,_explain_log,_tableinfo,d_safe,_install,_waitpid,binlog,test},myisam*,isam*,pack_isam}
# rm -f "${ED}/usr/sbin/mysqld"
# rm -f "${D}${MY_LIBDIR}"/lib{heap,merge,nisam,my{sys,strings,sqld,isammrg,isam},vio,dbug}.a
# fi
# Unless they explicitly specific USE=test, then do not install the
# testsuite. It DOES have a use to be installed, esp. when you want to do a
# validation of your database configuration after tuning it.
if ! use test ; then
rm -rf "${D}"/${MY_SHAREDSTATEDIR}/mysql-test
fi
# Configuration stuff
case ${MYSQL_PV_MAJOR} in
5.[1-9]|6*|7*) mysql_mycnf_version="5.1" ;;
esac
einfo "Building default my.cnf (${mysql_mycnf_version})"
insinto "${MY_SYSCONFDIR}"
doins scripts/mysqlaccess.conf
mycnf_src="my.cnf-${mysql_mycnf_version}"
sed -e "s!@DATADIR@!${MY_DATADIR}!g" \
"${FILESDIR}/${mycnf_src}" \
> "${TMPDIR}/my.cnf.ok"
if use latin1 ; then
sed -i \
-e "/character-set/s|utf8|latin1|g" \
"${TMPDIR}/my.cnf.ok"
fi
newins "${TMPDIR}/my.cnf.ok" my.cnf
# Minimal builds don't have the MySQL server
if ! use minimal ; then
einfo "Creating initial directories"
# Empty directories ...
diropts "-m0750"
if [[ "${PREVIOUS_DATADIR}" != "yes" ]] ; then
dodir "${MY_DATADIR#${EPREFIX}}"
keepdir "${MY_DATADIR#${EPREFIX}}"
chown -R mysql:mysql "${D}/${MY_DATADIR}"
fi
diropts "-m0755"
for folder in "${MY_LOGDIR#${EPREFIX}}" "/var/run/mysqld" ; do
dodir "${folder}"
keepdir "${folder}"
chown -R mysql:mysql "${ED}/${folder}"
done
fi
# Minimal builds don't have the MySQL server
if ! use minimal ; then
einfo "Including support files and sample configurations"
docinto "support-files"
for script in \
"${S}"/support-files/my-*.cnf.sh \
"${S}"/support-files/magic \
"${S}"/support-files/ndb-config-2-node.ini.sh
do
[[ -f "$script" ]] && dodoc "${script}"
done
docinto "scripts"
for script in "${S}"/scripts/mysql* ; do
[[ -f "$script" ]] && [[ "${script%.sh}" == "${script}" ]] && dodoc "${script}"
done
fi
mysql_lib_symlinks "${ED}"
}

View File

@ -0,0 +1,768 @@
# Copyright 1999-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/eclass/mysql-v2.eclass,v 1.21 2012/11/01 23:57:50 robbat2 Exp $
# @ECLASS: mysql-v2.eclass
# @MAINTAINER:
# Maintainers:
# - MySQL Team <mysql-bugs@gentoo.org>
# - Robin H. Johnson <robbat2@gentoo.org>
# - Jorge Manuel B. S. Vicetto <jmbsvicetto@gentoo.org>
# @BLURB: This eclass provides most of the functions for mysql ebuilds
# @DESCRIPTION:
# The mysql-v2.eclass is the base eclass to build the mysql and
# alternative projects (mariadb) ebuilds.
# This eclass uses the mysql-autotools and mysql-cmake eclasses for the
# specific bits related to the build system.
# It provides the src_unpack, src_prepare, src_configure, src_compile,
# src_install, pkg_preinst, pkg_postinst, pkg_config and pkg_postrm
# phase hooks.
# @ECLASS-VARIABLE: BUILD
# @DESCRIPTION:
# Build type of the mysql version
: ${BUILD:=autotools}
case ${BUILD} in
"cmake")
BUILD_INHERIT="mysql-cmake"
;;
"autotools")
BUILD_INHERIT="mysql-autotools"
WANT_AUTOCONF="latest"
WANT_AUTOMAKE="latest"
;;
*)
die "${BUILD} is not a valid build system for mysql"
;;
esac
MYSQL_EXTRAS=""
# @ECLASS-VARIABLE: MYSQL_EXTRAS_VER
# @DESCRIPTION:
# The version of the MYSQL_EXTRAS repo to use to build mysql
# Use "none" to disable it's use
[[ "${MY_EXTRAS_VER}" == "live" ]] && MYSQL_EXTRAS="git-2"
inherit eutils flag-o-matic gnuconfig ${MYSQL_EXTRAS} ${BUILD_INHERIT} mysql_fx versionator toolchain-funcs
#
# Supported EAPI versions and export functions
#
case "${EAPI:-0}" in
3|4|5) ;;
*) die "Unsupported EAPI: ${EAPI}" ;;
esac
EXPORT_FUNCTIONS pkg_setup src_unpack src_prepare src_configure src_compile src_install pkg_preinst pkg_postinst pkg_config pkg_postrm
#
# VARIABLES:
#
# Shorten the path because the socket path length must be shorter than 107 chars
# and we will run a mysql server during test phase
S="${WORKDIR}/mysql"
[[ "${MY_EXTRAS_VER}" == "latest" ]] && MY_EXTRAS_VER="20090228-0714Z"
if [[ "${MY_EXTRAS_VER}" == "live" ]]; then
EGIT_PROJECT=mysql-extras
EGIT_REPO_URI="git://git.overlays.gentoo.org/proj/mysql-extras.git"
fi
# @ECLASS-VARIABLE: MYSQL_PV_MAJOR
# @DESCRIPTION:
# Upstream MySQL considers the first two parts of the version number to be the
# major version. Upgrades that change major version should always run
# mysql_upgrade.
MYSQL_PV_MAJOR="$(get_version_component_range 1-2 ${PV})"
# @ECLASS-VARIABLE: MYSQL_VERSION_ID
# @DESCRIPTION:
# MYSQL_VERSION_ID will be:
# major * 10e6 + minor * 10e4 + micro * 10e2 + gentoo revision number, all [0..99]
# This is an important part, because many of the choices the MySQL ebuild will do
# depend on this variable.
# In particular, the code below transforms a $PVR like "5.0.18-r3" in "5001803"
# We also strip off upstream's trailing letter that they use to respin tarballs
MYSQL_VERSION_ID=""
tpv="${PV%[a-z]}"
tpv=( ${tpv//[-._]/ } ) ; tpv[3]="${PVR:${#PV}}" ; tpv[3]="${tpv[3]##*-r}"
for vatom in 0 1 2 3 ; do
# pad to length 2
tpv[${vatom}]="00${tpv[${vatom}]}"
MYSQL_VERSION_ID="${MYSQL_VERSION_ID}${tpv[${vatom}]:0-2}"
done
# strip leading "0" (otherwise it's considered an octal number by BASH)
MYSQL_VERSION_ID=${MYSQL_VERSION_ID##"0"}
# This eclass should only be used with at least mysql-5.1.50
mysql_version_is_at_least "5.1.50" || die "This eclass should only be used with >=mysql-5.1.50"
# @ECLASS-VARIABLE: XTRADB_VER
# @DEFAULT_UNSET
# @DESCRIPTION:
# Version of the XTRADB storage engine
# @ECLASS-VARIABLE: PERCONA_VER
# @DEFAULT_UNSET
# @DESCRIPTION:
# Designation by PERCONA for a MySQL version to apply an XTRADB release
# Work out the default SERVER_URI correctly
if [ -z "${SERVER_URI}" ]; then
[ -z "${MY_PV}" ] && MY_PV="${PV//_/-}"
if [ "${PN}" == "mariadb" ]; then
MARIA_FULL_PV="$(replace_version_separator 3 '-' ${MY_PV})"
MARIA_FULL_P="${PN}-${MARIA_FULL_PV}"
SERVER_URI="
http://ftp.osuosl.org/pub/mariadb/${MARIA_FULL_P}/kvm-tarbake-jaunty-x86/${MARIA_FULL_P}.tar.gz
http://ftp.rediris.es/mirror/MariaDB/${MARIA_FULL_P}/kvm-tarbake-jaunty-x86/${MARIA_FULL_P}.tar.gz
http://maria.llarian.net/download/${MARIA_FULL_P}/kvm-tarbake-jaunty-x86/${MARIA_FULL_P}.tar.gz
http://launchpad.net/maria/${MYSQL_PV_MAJOR}/ongoing/+download/${MARIA_FULL_P}.tar.gz
http://mirrors.fe.up.pt/pub/${PN}/${MARIA_FULL_P}/kvm-tarbake-jaunty-x86/${MARIA_FULL_P}.tar.gz
http://ftp-stud.hs-esslingen.de/pub/Mirrors/${PN}/${MARIA_FULL_P}/kvm-tarbake-jaunty-x86/${MARIA_FULL_P}.tar.gz
"
else
URI_DIR="MySQL"
URI_FILE="mysql"
URI_A="${URI_FILE}-${MY_PV}.tar.gz"
MIRROR_PV=$(get_version_component_range 1-2 ${PV})
# Recently upstream switched to an archive site, and not on mirrors
SERVER_URI="http://downloads.mysql.com/archives/${URI_FILE}-${MIRROR_PV}/${URI_A}
mirror://mysql/Downloads/${URI_DIR}-${PV%.*}/${URI_A}"
fi
fi
# Define correct SRC_URIs
SRC_URI="${SERVER_URI}"
# Gentoo patches to MySQL
[[ ${MY_EXTRAS_VER} != live ]] && [[ ${MY_EXTRAS_VER} != none ]] \
&& SRC_URI="${SRC_URI}
mirror://gentoo/mysql-extras-${MY_EXTRAS_VER}.tar.bz2
http://g3nt8.org/patches/mysql-extras-${MY_EXTRAS_VER}.tar.bz2
http://dev.gentoo.org/~robbat2/distfiles/mysql-extras-${MY_EXTRAS_VER}.tar.bz2
http://dev.gentoo.org/~jmbsvicetto/distfiles/mysql-extras-${MY_EXTRAS_VER}.tar.bz2"
DESCRIPTION="A fast, multi-threaded, multi-user SQL database server."
HOMEPAGE="http://www.mysql.com/"
if [[ "${PN}" == "mariadb" ]]; then
HOMEPAGE="http://mariadb.org/"
DESCRIPTION="MariaDB is a MySQL fork with 3rd-party patches and additional storage engines merged."
fi
LICENSE="GPL-2"
SLOT="0"
case "${BUILD}" in
"autotools")
IUSE="big-tables debug embedded minimal +perl selinux ssl static test"
;;
"cmake")
IUSE="debug embedded minimal +perl selinux ssl static test"
;;
esac
IUSE="${IUSE} latin1"
IUSE="${IUSE} extraengine"
IUSE="${IUSE} cluster"
IUSE="${IUSE} max-idx-128"
IUSE="${IUSE} berkdb"
IUSE="${IUSE} +community profiling"
[[ ${PN} == "mariadb" ]] \
&& mysql_check_version_range "5.1.38 to 5.3.99" \
&& IUSE="${IUSE} libevent"
[[ ${PN} == "mariadb" ]] \
&& mysql_version_is_at_least "5.2" \
&& IUSE="${IUSE} oqgraph"
[[ ${PN} == "mariadb" ]] \
&& mysql_version_is_at_least "5.2.5" \
&& IUSE="${IUSE} sphinx"
if mysql_version_is_at_least "5.5"; then
REQUIRED_USE="tcmalloc? ( !jemalloc ) jemalloc? ( !tcmalloc )"
IUSE="${IUSE} jemalloc tcmalloc"
fi
mysql_version_is_at_least "5.5.7" \
&& IUSE="${IUSE} systemtap"
#
# DEPENDENCIES:
#
# Be warned, *DEPEND are version-dependant
# These are used for both runtime and compiletime
DEPEND="
ssl? ( >=dev-libs/openssl-0.9.6d )
kernel_linux? ( sys-process/procps )
>=sys-apps/sed-4
>=sys-apps/texinfo-4.7-r1
>=sys-libs/readline-4.1
>=sys-libs/zlib-1.2.3
"
[[ ${PN} == mariadb ]] \
&& mysql_check_version_range "5.1.38 to 5.3.99" \
&& DEPEND="${DEPEND} libevent? ( >=dev-libs/libevent-1.4 )"
# Having different flavours at the same time is not a good idea
for i in "mysql" "mariadb" ; do
[[ ${i} == ${PN} ]] ||
DEPEND="${DEPEND} !dev-db/${i}"
done
# prefix: first need to implement something for #196294
RDEPEND="${DEPEND}
!minimal? ( !prefix? ( dev-db/mysql-init-scripts ) )
selinux? ( sec-policy/selinux-mysql )
"
DEPEND="${DEPEND}
virtual/yacc
"
DEPEND="${DEPEND} static? ( sys-libs/ncurses[static-libs] )"
# compile-time-only
DEPEND="${DEPEND} >=dev-util/cmake-2.4.3"
# compile-time-only
mysql_version_is_at_least "5.5.8" \
&& DEPEND="${DEPEND} >=dev-util/cmake-2.6.3"
[[ "${PN}" == "mariadb" ]] \
&& mysql_version_is_at_least "5.2" \
&& DEPEND="${DEPEND} oqgraph? ( >=dev-libs/boost-1.40.0 )"
[[ "${PN}" == "mariadb" ]] \
&& mysql_version_is_at_least "5.2.5" \
&& DEPEND="${DEPEND} sphinx? ( app-misc/sphinx )"
mysql_version_is_at_least "5.5.7" \
&& DEPEND="${DEPEND} systemtap? ( >=dev-util/systemtap-1.3 )" \
&& DEPEND="${DEPEND} kernel_linux? ( dev-libs/libaio )"
mysql_version_is_at_least "5.5" \
&& DEPEND="${DEPEND} jemalloc? ( dev-libs/jemalloc )"
mysql_version_is_at_least "5.5" \
&& DEPEND="${DEPEND} tcmalloc? ( dev-util/google-perftools )"
# dev-perl/DBD-mysql is needed by some scripts installed by MySQL
PDEPEND="perl? ( >=dev-perl/DBD-mysql-2.9004 )"
# For other stuff to bring us in
PDEPEND="${PDEPEND} =virtual/mysql-${MYSQL_PV_MAJOR}"
#
# External patches
#
# MariaDB has integrated PBXT
# PBXT_VERSION means that we have a PBXT patch for this PV
# PBXT was only introduced after 5.1.12
pbxt_patch_available() {
[[ ${PN} != "mariadb" ]] \
&& [[ -n "${PBXT_VERSION}" ]]
return $?
}
pbxt_available() {
pbxt_patch_available || [[ ${PN} == "mariadb" ]]
return $?
}
# Get the percona tarball if XTRADB_VER and PERCONA_VER are both set
# MariaDB has integrated XtraDB
# XTRADB_VERS means that we have a XTRADB patch for this PV
# XTRADB was only introduced after 5.1.26
xtradb_patch_available() {
[[ ${PN} != "mariadb" ]] \
&& [[ -n "${XTRADB_VER}" && -n "${PERCONA_VER}" ]]
return $?
}
if pbxt_patch_available; then
PBXT_P="pbxt-${PBXT_VERSION}"
PBXT_SRC_URI="http://www.primebase.org/download/${PBXT_P}.tar.gz mirror://sourceforge/pbxt/${PBXT_P}.tar.gz"
SRC_URI="${SRC_URI} pbxt? ( ${PBXT_SRC_URI} )"
fi
# PBXT_NEWSTYLE means pbxt is in storage/ and gets enabled as other plugins
# vs. built outside the dir
if pbxt_available; then
IUSE="${IUSE} pbxt"
PBXT_NEWSTYLE=1
fi
if xtradb_patch_available; then
XTRADB_P="percona-xtradb-${XTRADB_VER}"
XTRADB_SRC_URI_COMMON="${PERCONA_VER}/source/${XTRADB_P}.tar.gz"
XTRADB_SRC_B1="http://www.percona.com/"
XTRADB_SRC_B2="${XTRADB_SRC_B1}/percona-builds/"
XTRADB_SRC_URI1="${XTRADB_SRC_B2}/Percona-Server/Percona-Server-${XTRADB_SRC_URI_COMMON}"
XTRADB_SRC_URI2="${XTRADB_SRC_B2}/xtradb/${XTRADB_SRC_URI_COMMON}"
XTRADB_SRC_URI3="${XTRADB_SRC_B1}/${PN}/xtradb/${XTRADB_SRC_URI_COMMON}"
SRC_URI="${SRC_URI} xtradb? ( ${XTRADB_SRC_URI1} ${XTRADB_SRC_URI2} ${XTRADB_SRC_URI3} )"
IUSE="${IUSE} xtradb"
fi
#
# HELPER FUNCTIONS:
#
# @FUNCTION: mysql-v2_disable_test
# @DESCRIPTION:
# Helper function to disable specific tests.
mysql-v2_disable_test() {
${BUILD_INHERIT}_disable_test "$@"
}
# @FUNCTION: mysql-v2_configure_minimal
# @DESCRIPTION:
# Helper function to configure minimal build
configure_minimal() {
${BUILD_INHERIT}_configure_minimal "$@"
}
# @FUNCTION: mysql-v2_configure_common
# @DESCRIPTION:
# Helper function to configure common builds
configure_common() {
${BUILD_INHERIT}_configure_common "$@"
}
#
# EBUILD FUNCTIONS
#
# @FUNCTION: mysql-v2_pkg_setup
# @DESCRIPTION:
# Perform some basic tests and tasks during pkg_setup phase:
# die if FEATURES="test", USE="-minimal" and not using FEATURES="userpriv"
# check for conflicting use flags
# create new user and group for mysql
# warn about deprecated features
mysql-v2_pkg_setup() {
if has test ${FEATURES} ; then
if ! use minimal ; then
if ! has userpriv ${FEATURES} ; then
eerror "Testing with FEATURES=-userpriv is no longer supported by upstream. Tests MUST be run as non-root."
fi
fi
fi
# Check for USE flag problems in pkg_setup
if use static && use ssl ; then
M="MySQL does not support being built statically with SSL support enabled!"
eerror "${M}"
die "${M}"
fi
if ! mysql_version_is_at_least "5.2" \
&& use debug ; then
# Also in package.use.mask
die "Bug #344885: Upstream has broken USE=debug for 5.1 series >=5.1.51"
fi
if ( use cluster || use extraengine || use embedded ) \
&& use minimal ; then
M="USE flags 'cluster', 'extraengine', 'embedded' conflict with 'minimal' USE flag!"
eerror "${M}"
die "${M}"
fi
if xtradb_patch_available \
&& use xtradb \
&& use embedded ; then
M="USE flags 'xtradb' and 'embedded' conflict and cause build failures"
eerror "${M}"
die "${M}"
fi
# This should come after all of the die statements
enewgroup mysql 60 || die "problem adding 'mysql' group"
enewuser mysql 60 -1 /dev/null mysql || die "problem adding 'mysql' user"
if use cluster; then
ewarn "Upstream has noted that the NDB cluster support in the 5.0 and"
ewarn "5.1 series should NOT be put into production. In the near"
ewarn "future, it will be disabled from building."
fi
}
# @FUNCTION: mysql-v2_src_unpack
# @DESCRIPTION:
# Unpack the source code
mysql-v2_src_unpack() {
# Initialize the proper variables first
mysql_init_vars
unpack ${A}
# Grab the patches
[[ "${MY_EXTRAS_VER}" == "live" ]] && S="${WORKDIR}/mysql-extras" git-2_src_unpack
mv -f "${WORKDIR}/${MY_SOURCEDIR}" "${S}"
}
# @FUNCTION: mysql-v2_src_prepare
# @DESCRIPTION:
# Apply patches to the source code and remove unneeded bundled libs.
mysql-v2_src_prepare() {
${BUILD_INHERIT}_src_prepare "$@"
}
# @FUNCTION: mysql-v2_src_configure
# @DESCRIPTION:
# Configure mysql to build the code for Gentoo respecting the use flags.
mysql-v2_src_configure() {
${BUILD_INHERIT}_src_configure "$@"
}
# @FUNCTION: mysql-v2_src_compile
# @DESCRIPTION:
# Compile the mysql code.
mysql-v2_src_compile() {
${BUILD_INHERIT}_src_compile "$@"
}
# @FUNCTION: mysql-v2_src_install
# @DESCRIPTION:
# Install mysql.
mysql-v2_src_install() {
${BUILD_INHERIT}_src_install "$@"
}
# @FUNCTION: mysql-v2_pkg_preinst
# @DESCRIPTION:
# Create the user and groups for mysql - die if that fails.
mysql-v2_pkg_preinst() {
enewgroup mysql 60 || die "problem adding 'mysql' group"
enewuser mysql 60 -1 /dev/null mysql || die "problem adding 'mysql' user"
}
# @FUNCTION: mysql-v2_pkg_postinst
# @DESCRIPTION:
# Run post-installation tasks:
# create the dir for logfiles if non-existant
# touch the logfiles and secure them
# install scripts
# issue required steps for optional features
# issue deprecation warnings
mysql-v2_pkg_postinst() {
# Make sure the vars are correctly initialized
mysql_init_vars
# Check FEATURES="collision-protect" before removing this
[[ -d "${ROOT}${MY_LOGDIR}" ]] || install -d -m0750 -o mysql -g mysql "${ROOT}${MY_LOGDIR}"
# Secure the logfiles
touch "${ROOT}${MY_LOGDIR}"/mysql.{log,err}
chown mysql:mysql "${ROOT}${MY_LOGDIR}"/mysql*
chmod 0660 "${ROOT}${MY_LOGDIR}"/mysql*
# Minimal builds don't have the MySQL server
if ! use minimal ; then
docinto "support-files"
for script in \
support-files/my-*.cnf \
support-files/magic \
support-files/ndb-config-2-node.ini
do
[[ -f "${script}" ]] \
&& dodoc "${script}"
done
docinto "scripts"
for script in scripts/mysql* ; do
[[ -f "${script}" ]] \
&& [[ "${script%.sh}" == "${script}" ]] \
&& dodoc "${script}"
done
einfo
elog "You might want to run:"
elog "\"emerge --config =${CATEGORY}/${PF}\""
elog "if this is a new install."
einfo
einfo
elog "If you are upgrading major versions, you should run the"
elog "mysql_upgrade tool."
einfo
fi
if pbxt_available && use pbxt ; then
elog "Note: PBXT is now statically built when enabled."
elog ""
elog "If, you previously installed as a plugin and "
elog "you cannot start the MySQL server,"
elog "remove the ${MY_DATADIR}/mysql/plugin.* files, then"
elog "use the MySQL upgrade script to restore the table"
elog "or execute the following SQL command:"
elog " CREATE TABLE IF NOT EXISTS plugin ("
elog " name char(64) binary DEFAULT '' NOT NULL,"
elog " dl char(128) DEFAULT '' NOT NULL,"
elog " PRIMARY KEY (name)"
elog " ) CHARACTER SET utf8 COLLATE utf8_bin;"
fi
mysql_check_version_range "4.0 to 5.0.99.99" \
&& use berkdb \
&& elog "Berkeley DB support is deprecated and will be removed in future versions!"
}
# @FUNCTION: mysql-v2_getopt
# @DESCRIPTION:
# Use my_print_defaults to extract specific config options
mysql-v2_getopt() {
local mypd="${EROOT}"/usr/bin/my_print_defaults
section="$1"
flag="--${2}="
"${mypd}" $section | sed -n "/^${flag}/p"
}
# @FUNCTION: mysql-v2_getoptval
# @DESCRIPTION:
# Use my_print_defaults to extract specific config options
mysql-v2_getoptval() {
local mypd="${EROOT}"/usr/bin/my_print_defaults
section="$1"
flag="--${2}="
"${mypd}" $section | sed -n "/^${flag}/s,${flag},,gp"
}
# @FUNCTION: mysql-v2_pkg_config
# @DESCRIPTION:
# Configure mysql environment.
mysql-v2_pkg_config() {
local old_MY_DATADIR="${MY_DATADIR}"
local old_HOME="${HOME}"
# my_print_defaults needs to read stuff in $HOME/.my.cnf
export HOME=/root
# Make sure the vars are correctly initialized
mysql_init_vars
[[ -z "${MY_DATADIR}" ]] && die "Sorry, unable to find MY_DATADIR"
if built_with_use ${CATEGORY}/${PN} minimal ; then
die "Minimal builds do NOT include the MySQL server"
fi
if [[ ( -n "${MY_DATADIR}" ) && ( "${MY_DATADIR}" != "${old_MY_DATADIR}" ) ]]; then
local MY_DATADIR_s="${ROOT}/${MY_DATADIR}"
MY_DATADIR_s="${MY_DATADIR_s%%/}"
local old_MY_DATADIR_s="${ROOT}/${old_MY_DATADIR}"
old_MY_DATADIR_s="${old_MY_DATADIR_s%%/}"
if [[ -d "${old_MY_DATADIR_s}" ]] && [[ "${old_MY_DATADIR_s}" != / ]]; then
if [[ -d "${MY_DATADIR_s}" ]]; then
ewarn "Both ${old_MY_DATADIR_s} and ${MY_DATADIR_s} exist"
ewarn "Attempting to use ${MY_DATADIR_s} and preserving ${old_MY_DATADIR_s}"
else
elog "Moving MY_DATADIR from ${old_MY_DATADIR_s} to ${MY_DATADIR_s}"
mv --strip-trailing-slashes -T "${old_MY_DATADIR_s}" "${MY_DATADIR_s}" \
|| die "Moving MY_DATADIR failed"
fi
else
ewarn "Previous MY_DATADIR (${old_MY_DATADIR_s}) does not exist"
if [[ -d "${MY_DATADIR_s}" ]]; then
ewarn "Attempting to use ${MY_DATADIR_s}"
else
eerror "New MY_DATADIR (${MY_DATADIR_s}) does not exist"
die "Configuration Failed! Please reinstall ${CATEGORY}/${PN}"
fi
fi
fi
local pwd1="a"
local pwd2="b"
local maxtry=15
if [ -z "${MYSQL_ROOT_PASSWORD}" ]; then
MYSQL_ROOT_PASSWORD="$(mysql-v2_getoptval 'client mysql' password)"
fi
MYSQL_TMPDIR="$(mysql-v2_getoptval mysqld tmpdir)"
# These are dir+prefix
MYSQL_RELAY_LOG="$(mysql-v2_getoptval mysqld relay-log)"
MYSQL_RELAY_LOG=${MYSQL_RELAY_LOG%/*}
MYSQL_LOG_BIN="$(mysql-v2_getoptval mysqld log-bin)"
MYSQL_LOG_BIN=${MYSQL_LOG_BIN%/*}
if [[ ! -d "${EROOT}"/$MYSQL_TMPDIR ]]; then
einfo "Creating MySQL tmpdir $MYSQL_TMPDIR"
install -d -m 770 -o mysql -g mysql "${EROOT}"/$MYSQL_TMPDIR
fi
if [[ ! -d "${EROOT}"/$MYSQL_LOG_BIN ]]; then
einfo "Creating MySQL log-bin directory $MYSQL_LOG_BIN"
install -d -m 770 -o mysql -g mysql "${EROOT}"/$MYSQL_LOG_BIN
fi
if [[ ! -d "${EROOT}"/$MYSQL_RELAY_LOG ]]; then
einfo "Creating MySQL relay-log directory $MYSQL_RELAY_LOG"
install -d -m 770 -o mysql -g mysql "${EROOT}"/$MYSQL_RELAY_LOG
fi
if [[ -d "${ROOT}/${MY_DATADIR}/mysql" ]] ; then
ewarn "You have already a MySQL database in place."
ewarn "(${ROOT}/${MY_DATADIR}/*)"
ewarn "Please rename or delete it if you wish to replace it."
die "MySQL database already exists!"
fi
# Bug #213475 - MySQL _will_ object strenously if your machine is named
# localhost. Also causes weird failures.
[[ "${HOSTNAME}" == "localhost" ]] && die "Your machine must NOT be named localhost"
if [ -z "${MYSQL_ROOT_PASSWORD}" ]; then
einfo "Please provide a password for the mysql 'root' user now, in the"
einfo "MYSQL_ROOT_PASSWORD env var or through the /root/.my.cnf file."
ewarn "Avoid [\"'\\_%] characters in the password"
read -rsp " >" pwd1 ; echo
einfo "Retype the password"
read -rsp " >" pwd2 ; echo
if [[ "x$pwd1" != "x$pwd2" ]] ; then
die "Passwords are not the same"
fi
MYSQL_ROOT_PASSWORD="${pwd1}"
unset pwd1 pwd2
fi
local options="--log-warnings=0"
local sqltmp="$(emktemp)"
local help_tables="${ROOT}${MY_SHAREDSTATEDIR}/fill_help_tables.sql"
[[ -r "${help_tables}" ]] \
&& cp "${help_tables}" "${TMPDIR}/fill_help_tables.sql" \
|| touch "${TMPDIR}/fill_help_tables.sql"
help_tables="${TMPDIR}/fill_help_tables.sql"
# Figure out which options we need to disable to do the setup
helpfile="${TMPDIR}/mysqld-help"
${EROOT}/usr/sbin/mysqld --verbose --help >"${helpfile}" 2>/dev/null
for opt in grant-tables host-cache name-resolve networking slave-start bdb \
federated innodb ssl log-bin relay-log slow-query-log external-locking \
ndbcluster log-slave-updates \
; do
optexp="--(skip-)?${opt}" optfull="--loose-skip-${opt}"
egrep -sq -- "${optexp}" "${helpfile}" && options="${options} ${optfull}"
done
# But some options changed names
egrep -sq external-locking "${helpfile}" && \
options="${options/skip-locking/skip-external-locking}"
use prefix || options="${options} --user=mysql"
pushd "${TMPDIR}" &>/dev/null
#cmd="'${EROOT}/usr/share/mysql/scripts/mysql_install_db' '--basedir=${EPREFIX}/usr' ${options}"
cmd=${EROOT}usr/share/mysql/scripts/mysql_install_db
[ -f ${cmd} ] || cmd=${EROOT}usr/bin/mysql_install_db
cmd="'$cmd' '--basedir=${EPREFIX}/usr' ${options}"
einfo "Command: $cmd"
eval $cmd \
>"${TMPDIR}"/mysql_install_db.log 2>&1
if [ $? -ne 0 ]; then
grep -B5 -A999 -i "ERROR" "${TMPDIR}"/mysql_install_db.log 1>&2
die "Failed to run mysql_install_db. Please review ${EPREFIX}/var/log/mysql/mysqld.err AND ${TMPDIR}/mysql_install_db.log"
fi
popd &>/dev/null
[[ -f "${ROOT}/${MY_DATADIR}/mysql/user.frm" ]] \
|| die "MySQL databases not installed"
chown -R mysql:mysql "${ROOT}/${MY_DATADIR}" 2>/dev/null
chmod 0750 "${ROOT}/${MY_DATADIR}" 2>/dev/null
# Filling timezones, see
# http://dev.mysql.com/doc/mysql/en/time-zone-support.html
"${EROOT}/usr/bin/mysql_tzinfo_to_sql" "${EROOT}/usr/share/zoneinfo" > "${sqltmp}" 2>/dev/null
if [[ -r "${help_tables}" ]] ; then
cat "${help_tables}" >> "${sqltmp}"
fi
einfo "Creating the mysql database and setting proper"
einfo "permissions on it ..."
local socket="${EROOT}/var/run/mysqld/mysqld${RANDOM}.sock"
local pidfile="${EROOT}/var/run/mysqld/mysqld${RANDOM}.pid"
local mysqld="${EROOT}/usr/sbin/mysqld \
${options} \
--user=mysql \
--log-warnings=0 \
--basedir=${EROOT}/usr \
--datadir=${ROOT}/${MY_DATADIR} \
--max_allowed_packet=8M \
--net_buffer_length=16K \
--default-storage-engine=MyISAM \
--socket=${socket} \
--pid-file=${pidfile}"
#einfo "About to start mysqld: ${mysqld}"
ebegin "Starting mysqld"
einfo "Command ${mysqld}"
${mysqld} &
rc=$?
while ! [[ -S "${socket}" || "${maxtry}" -lt 1 ]] ; do
maxtry=$((${maxtry}-1))
echo -n "."
sleep 1
done
eend $rc
if ! [[ -S "${socket}" ]]; then
die "Completely failed to start up mysqld with: ${mysqld}"
fi
ebegin "Setting root password"
# Do this from memory, as we don't want clear text passwords in temp files
local sql="UPDATE mysql.user SET Password = PASSWORD('${MYSQL_ROOT_PASSWORD}') WHERE USER='root'"
"${EROOT}/usr/bin/mysql" \
--socket=${socket} \
-hlocalhost \
-e "${sql}"
eend $?
ebegin "Loading \"zoneinfo\", this step may require a few seconds ..."
"${EROOT}/usr/bin/mysql" \
--socket=${socket} \
-hlocalhost \
-uroot \
--password="${MYSQL_ROOT_PASSWORD}" \
mysql < "${sqltmp}"
rc=$?
eend $?
[ $rc -ne 0 ] && ewarn "Failed to load zoneinfo!"
# Stop the server and cleanup
einfo "Stopping the server ..."
kill $(< "${pidfile}" )
rm -f "${sqltmp}"
wait %1
einfo "Done"
}
# @FUNCTION: mysql-v2_pkg_postrm
# @DESCRIPTION:
# Remove mysql symlinks.
mysql-v2_pkg_postrm() {
: # mysql_lib_symlinks "${ED}"
}

View File

@ -0,0 +1,120 @@
# Copyright 1999-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/eclass/oasis.eclass,v 1.3 2012/03/27 22:44:41 aballier Exp $
# @ECLASS: oasis.eclass
# @MAINTAINER:
# ml@gentoo.org
# @AUTHOR:
# Original Author: Alexis Ballier <aballier@gentoo.org>
# @BLURB: Provides common ebuild phases for oasis-based packages.
# @DESCRIPTION:
# Provides common ebuild phases for oasis-based packages.
# Most of these packages will just have to inherit the eclass, set their
# dependencies and the DOCS variable for base.eclass to install it and be done.
#
# It inherits multilib, findlib, eutils and base eclasses.
# Ebuilds using oasis.eclass must be EAPI>=3.
# @ECLASS-VARIABLE: OASIS_BUILD_DOCS
# @DESCRIPTION:
# Will make oasis_src_compile build the documentation if this variable is
# defined and the doc useflag is enabled.
# The eclass takes care of setting doc in IUSE but the ebuild should take care
# of the extra dependencies it may need.
# Set before inheriting the eclass.
# @ECLASS-VARIABLE: OASIS_BUILD_TESTS
# @DESCRIPTION:
# Will make oasis_src_configure enable building the tests if the test useflag is
# enabled. oasis_src_test will then run them.
# Note that you sometimes need to enable this for src_test to be useful,
# sometimes not. It has to be enabled on a per-case basis.
# The eclass takes care of setting test in IUSE but the ebuild should take care
# of the extra dependencies it may need.
# Set before inheriting the eclass.
# @ECLASS-VARIABLE: OASIS_NO_DEBUG
# @DESCRIPTION:
# Disable debug useflag usage. Old oasis versions did not support it so we allow
# disabling it in those cases.
# The eclass takes care of setting debug in IUSE.
# Set before inheriting the eclass.
inherit multilib findlib eutils base
case ${EAPI:-0} in
0|1|2) die "You need at least EAPI-3 to use oasis.eclass";;
esac
IUSE="+ocamlopt"
[ -n "${OASIS_NO_DEBUG}" ] || IUSE="${IUSE} debug"
[ -n "${OASIS_BUILD_DOCS}" ] && IUSE="${IUSE} doc"
[ -n "${OASIS_BUILD_TESTS}" ] && IUSE="${IUSE} test"
RDEPEND=">=dev-lang/ocaml-3.12[ocamlopt?]"
DEPEND="${RDEPEND}"
# @FUNCTION: oasis_use_enable
# @USAGE: < useflag > < variable >
# @DESCRIPTION:
# A use_enable-like function for oasis configure variables.
# Outputs '--override variable (true|false)', whether useflag is enabled or
# not.
# Typical usage: $(oasis_use_enable ocamlopt is_native) as an oasis configure
# argument.
oasis_use_enable() {
echo "--override $2 $(usex $1 true false)"
}
# @FUNCTION: oasis_src_configure
# @DESCRIPTION:
# src_configure phase shared by oasis-based packages.
# Extra arguments may be passed via oasis_configure_opts.
oasis_src_configure() {
local confargs=""
[ -n "${OASIS_BUILD_TESTS}" ] && confargs="${confargs} $(use_enable test tests)"
[ -n "${OASIS_NO_DEBUG}" ] || confargs="${confargs} $(oasis_use_enable debug debug)"
ocaml setup.ml -configure \
--prefix "${EPREFIX}/usr" \
--libdir "${EPREFIX}/usr/$(get_libdir)" \
--docdir "${EPREFIX}/usr/share/doc/${PF}/html" \
--destdir "${D}" \
$(oasis_use_enable ocamlopt is_native) \
${confargs} \
${oasis_configure_opts} \
|| die
}
# @FUNCTION: oasis_src_compile
# @DESCRIPTION:
# Builds an oasis-based package.
# Will build documentation if OASIS_BUILD_DOCS is defined and the doc useflag is
# enabled.
oasis_src_compile() {
ocaml setup.ml -build || die
if [ -n "${OASIS_BUILD_DOCS}" ] && use doc; then
ocaml setup.ml -doc || die
fi
}
# @FUNCTION: oasis_src_test
# @DESCRIPTION:
# Runs the testsuite of an oasis-based package.
oasis_src_test() {
LD_LIBRARY_PATH="${S}/_build/lib" ocaml setup.ml -test || die
}
# @FUNCTION: oasis_src_install
# @DESCRIPTION:
# Installs an oasis-based package.
# It calls base_src_install_docs, so will install documentation declared in the
# DOCS variable.
oasis_src_install() {
findlib_src_preinst
ocaml setup.ml -install || die
base_src_install_docs
}
EXPORT_FUNCTIONS src_configure src_compile src_test src_install

View File

@ -0,0 +1,43 @@
# Copyright 1999-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/eclass/obs-download.eclass,v 1.4 2012/10/02 10:57:52 scarabeus Exp $
# @ECLASS: obs-download.eclass
# @MAINTAINER:
# suse@gentoo.org
# @BLURB: Simplifies downloading from openSUSE Build Service.
# @DESCRIPTION:
# This eclass constructs OBS_URI based on provided project in openSUSE Build
# Service and package name. It can be used by packages/eclasses to download
# actual files.
#
# All you need to do in order to use it is set OBS_PROJECT and OBS_PACKAGE and
# inherit this eclass. It will provide OBS_URI in return which you will prepend
# to your files and use it in SRC_URI. Alternatively you can just set
# OPENSUSE_RELEASE and OBS_PACKAGE and it will give you back OBS_URI for
# downloading files from obs project corresponding to the specified openSUSE
# release.
# @ECLASS-VARIABLE: OPENSUSE_RELEASE
# @DEFAULT_UNSET
# @DESCRIPTION:
# From which openSUSE realease to take files.
# Eg.: 12.1, 12.2, Factory
# @ECLASS-VARIABLE: OBS_PROJECT
# @DEFAULT_UNSET
# @DESCRIPTION:
# In which obs project pakage is.
# This variable does not have to be set and is overriden, if
# OPENSUSE_RELEASE is provided.
# @ECLASS-VARIABLE: OBS_PACKAGE
# @DESCRIPTION:
# Name of the package we want to take files from.
# By default taken from ${PN}.
[[ -z ${OPENSUSE_RELEASE} ]] || OBS_PROJECT="openSUSE:${OPENSUSE_RELEASE}"
[[ -n ${OBS_PROJECT} ]] || die "OBS_PROJECT not set!"
[[ -n ${OBS_PACKAGE} ]] || OBS_PACKAGE="${PN}"
OBS_URI="https://api.opensuse.org/public/source/${OBS_PROJECT}/${OBS_PACKAGE}"

View File

@ -0,0 +1,109 @@
# Copyright 1999-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/eclass/obs-service.eclass,v 1.8 2012/11/15 20:06:34 scarabeus Exp $
# @ECLASS: obs-service.eclass
# @MAINTAINER:
# suse@gentoo.org
# @BLURB: Reduces code duplication in the Open Build Service services.
# @DESCRIPTION:
# This eclass makes it easier to package Open Build Service services. Based on
# provided information it will set all needed variables and takes care of
# installation.
#
# @EXAMPLE:
# Typical ebuild using obs-service.eclass:
#
# @CODE
# EAPI=4
#
# inherit obs-service
#
# KEYWORDS=""
#
# DEPEND=""
# RDEPEND="${DEPEND}"
#
# @CODE
# @ECLASS-VARIABLE: OBS_SERVICE_NAME
# @DESCRIPTION:
# Name of the service. If not set, it is taken from ${PN}.
# @ECLASS-VARIABLE: ADDITIONAL_FILES
# @DEFAULT_UNSET
# @DESCRIPTION:
# If any additional files are needed.
case "${EAPI:-0}" in
4|5) : ;;
*) die "EAPI=${EAPI} is not supported" ;;
esac
HOMEPAGE="http://en.opensuse.org/openSUSE:OSC"
LICENSE="GPL-2"
SLOT="0"
IUSE=""
RDEPEND="
dev-util/osc
dev-util/suse-build
"
[[ -n ${OBS_SERVICE_NAME} ]] || OBS_SERVICE_NAME=${PN/obs-service-/}
OBS_PROJECT="openSUSE:Tools"
DESCRIPTION="Open Build Service client module - ${OBS_SERVICE_NAME} service"
inherit obs-download
# As it aint versioned at all use arrows to deal with it
SRC_URI="${OBS_URI}/${OBS_SERVICE_NAME} -> ${OBS_SERVICE_NAME}-${PV}"
SRC_URI+=" ${OBS_URI}/${OBS_SERVICE_NAME}.service -> ${OBS_SERVICE_NAME}-${PV}.service"
for i in ${ADDITIONAL_FILES}; do
SRC_URI+=" ${OBS_URI}/${i}"
done
# @FUNCTION: obs-service_src_unpack
# @DESCRIPTION:
# Just copy files. Files are not compressed.
obs-service_src_unpack() {
debug-print-function ${FUNCNAME} "$@"
cd "${DISTDIR}"
mkdir -p "${S}"
cp ${A} "${S}"
}
# @FUNCTION: obs-service_src_prepare
# @DESCRIPTION:
# Replaces all /usr/lib/build directories with /usr/share/suse-build to reflect
# where suse-build is installed in Gentoo.
obs-service_src_prepare() {
debug-print-function ${FUNCNAME} "$@"
debug-print "Replacing all paths to find suse-build in Gentoo"
find "${S}" -type f -exec \
sed -i 's|/usr/lib/build|/usr/share/suse-build|g' {} +
}
# @FUNCTION: obs-service_src_install
# @DESCRIPTION:
# Does the installation of the downloaded files.
obs-service_src_install() {
debug-print-function ${FUNCNAME} "$@"
debug-print "Installing service \"${OBS_SERVICE_NAME}\""
exeinto /usr/lib/obs/service
newexe "${S}"/${OBS_SERVICE_NAME}-${PV} ${OBS_SERVICE_NAME}
insinto /usr/lib/obs/service
newins "${S}"/${OBS_SERVICE_NAME}-${PV}.service ${OBS_SERVICE_NAME}.service
if [[ -n ${ADDITIONAL_FILES} ]]; then
debug-print "Installing following additional files:"
debug-print " ${ADDITIONAL_FILES}"
exeinto /usr/lib/obs/service/${OBS_SERVICE_NAME}.files
for i in ${ADDITIONAL_FILES}; do
doexe "${S}"/${i}
done
fi
}
EXPORT_FUNCTIONS src_install src_prepare src_unpack

View File

@ -0,0 +1,178 @@
# Copyright 1999-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/eclass/office-ext.eclass,v 1.7 2012/09/27 16:35:41 axs Exp $
# @ECLASS: office-ext.eclass
# @MAINTAINER:
# The office team <openoffice@gentoo.org>
# @AUTHOR:
# Tomáš Chvátal <scarabeus@gentoo.org>
# @BLURB: Eclass for installing libreoffice/openoffice extensions
# @DESCRIPTION:
# Eclass for easing maitenance of libreoffice/openoffice extensions.
case "${EAPI:-0}" in
4|5) OEXT_EXPORTED_FUNCTIONS="src_unpack src_install pkg_postinst pkg_prerm" ;;
*) die "EAPI=${EAPI} is not supported" ;;
esac
inherit eutils multilib
UNOPKG_BINARY="${EPREFIX}/usr/bin/unopkg"
# @ECLASS-VARIABLE: OO_EXTENSIONS
# @REQUIRED
# @DESCRIPTION:
# Array containing list of extensions to install.
[[ -z ${OO_EXTENSIONS} ]] && die "OO_EXTENSIONS variable is unset."
if [[ "$(declare -p OO_EXTENSIONS 2>/dev/null 2>&1)" != "declare -a"* ]]; then
die "OO_EXTENSIONS variable is not an array."
fi
DEPEND="virtual/ooo"
RDEPEND="virtual/ooo"
# Most projects actually do not provide any workdir and we do not unpack the
# .oxt file at all.
S="${WORKDIR}"
# @FUNCTION: office-ext_src_unpack
# @DESCRIPTION:
# Flush the cache after removal of an extension.
office-ext_src_unpack() {
debug-print-function ${FUNCNAME} "$@"
local i
default
for i in ${OO_EXTENSIONS[@]}; do
# Copy only if the oxt is present, sometimes they are in tarballs
# so we want to fail only when we do need to do the cp.
if [[ -f "${DISTDIR}/${i}" ]] ; then
debug-print "${FUNCNAME}: cp -v \"${DISTDIR}/${i}\" \"${S}\""
cp -v "${DISTDIR}/${i}" "${S}" || die
fi
done
}
# @FUNCTION: office-ext_flush_unopkg_cache
# @DESCRIPTION:
# Flush the cache after removal of an extension.
office-ext_flush_unopkg_cache() {
debug-print-function ${FUNCNAME} "$@"
debug-print "${FUNCNAME}: ${UNOPKG_BINARY} list --shared > /dev/null"
${UNOPKG_BINARY} list --shared > /dev/null
}
# @FUNCTION: office-ext_get_implementation
# @DESCRIPTION:
# Determine the implementation we are building against.
office-ext_get_implementation() {
debug-print-function ${FUNCNAME} "$@"
local implementations=(
"libreoffice"
"openoffice"
)
local i
for i in "${implementations[@]}"; do
if [[ -d "${EPREFIX}/usr/$(get_libdir)/${i}" ]]; then
debug-print "${FUNCNAME}: Determined implementation is: \"${EPREFIX}/usr/$(get_libdir)/${i}\""
echo "${EPREFIX}/usr/$(get_libdir)/${i}"
return
fi
done
die "Unable to determine libreoffice/openoffice implementation!"
}
# @FUNCTION: office-ext_add_extension
# @DESCRIPTION:
# Install the extension into the libreoffice/openoffice.
office-ext_add_extension() {
debug-print-function ${FUNCNAME} "$@"
local ext=$1
local tmpdir=$(mktemp -d --tmpdir="${T}")
debug-print "${FUNCNAME}: ${UNOPKG_BINARY} add --shared \"${ext}\""
ebegin "Adding office extension: \"${ext}\""
${UNOPKG_BINARY} add --suppress-license \
--shared "${ext}" \
"-env:UserInstallation=file:///${tmpdir}" \
"-env:JFW_PLUGIN_DO_NOT_CHECK_ACCESSIBILITY=1"
eend $?
rm -rf "${tmpdir}"
}
# @FUNCTION: office-ext_remove_extension
# @DESCRIPTION:
# Remove the extension from the libreoffice/openoffice.
office-ext_remove_extension() {
debug-print-function ${FUNCNAME} "$@"
local ext=$1
local tmpdir=$(mktemp -d --tmpdir="${T}")
debug-print "${FUNCNAME}: ${UNOPKG_BINARY} remove --shared \"${ext}\""
ebegin "Removing office extension: \"${ext}\""
${UNOPKG_BINARY} remove --suppress-license \
--shared "${ext}" \
"-env:UserInstallation=file:///${tmpdir}" \
"-env:JFW_PLUGIN_DO_NOT_CHECK_ACCESSIBILITY=1"
eend $?
office-ext_flush_unopkg_cache
rm -rf "${tmpdir}"
}
# @FUNCTION: office-ext_src_install
# @DESCRIPTION:
# Install the extension source to the proper location.
office-ext_src_install() {
debug-print-function ${FUNCNAME} "$@"
debug-print "Extensions: ${OO_EXTENSIONS[@]}"
local i
# subshell to not pollute rest of the env with the insinto redefinition
(
dodir $(office-ext_get_implementation)/share/extension/install/
insinto $(office-ext_get_implementation)/share/extension/install/
for i in ${OO_EXTENSIONS[@]}; do
doins "${i}"
done
)
einfo "Remember that if you replace your office implementation,"
einfo "you need to recompile all the extensions."
einfo "Your current implementation location is: "
einfo " $(office-ext_get_implementation)"
}
# @FUNCTION: office-ext_pkg_postinst
# @DESCRIPTION:
# Add the extensions to the libreoffice/openoffice.
office-ext_pkg_postinst() {
debug-print-function ${FUNCNAME} "$@"
debug-print "Extensions: ${OO_EXTENSIONS[@]}"
local i
for i in ${OO_EXTENSIONS[@]}; do
office-ext_add_extension "$(office-ext_get_implementation)/share/extension/install/${i}"
done
}
# @FUNCTION: office-ext_pkg_prerm
# @DESCRIPTION:
# Remove the extensions from the libreoffice/openoffice.
office-ext_pkg_prerm() {
debug-print-function ${FUNCNAME} "$@"
debug-print "Extensions: ${OO_EXTENSIONS[@]}"
local i
for i in ${OO_EXTENSIONS[@]}; do
office-ext_remove_extension "${i}"
done
}
EXPORT_FUNCTIONS ${OEXT_EXPORTED_FUNCTIONS}
unset OEXT_EXPORTED_FUNCTIONS

View File

@ -0,0 +1,132 @@
# Copyright 1999-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/eclass/openib.eclass,v 1.9 2012/10/14 18:18:20 alexxy Exp $
# @ECLASS: openib.eclass
# @AUTHOR:
# Original Author: Alexey Shvetsov <alexxy@gentoo.org>
# @BLURB: Simplify working with OFED packages
inherit base eutils rpm versionator
EXPORT_FUNCTIONS src_unpack
HOMEPAGE="http://www.openfabrics.org/"
LICENSE="|| ( GPL-2 BSD-2 )"
# @ECLASS-VARIABLE: OFED_VER
# @DESCRIPTION:
# Defines OFED version eg 1.4 or 1.4.0.1
# @ECLASS-VARIABLE: OFED_RC
# @DESCRIPTION:
# Sets if this version is RC
# @ECLASS-VARIABLE: OFED_RC_VER
# @DESCRIPTION:
# Sets RC version
# @ECLASS-VARIABLE: OFED_SUFFIX
# @DESCRIPTION:
# Defines OFED package suffix eg -1.ofed1.4
# @ECLASS-VARIABLE: OFED_SNAPSHOT
# @DESCRIPTION:
# Defines if src tarball is git snapshot
SLOT="${OFED_VER}"
# @ECLASS-VARIABLE: OFED_VERSIONS
# @DESCRIPTION:
# Defines array of ofed version supported by eclass
OFED_VERSIONS=(
"1.5.1"
"1.5.2"
"1.5.3"
"1.5.3.1"
"1.5.3.2"
"1.5.4"
"1.5.4.1"
"3.5"
)
# @FUNCTION: block_other_ofed_versions
# @DESCRIPTION:
# function that creates blockers list for ofed
block_other_ofed_versions() {
local slot
RDEPEND="${RDEPEND} !sys-infiniband/${PN}:0"
for slot in ${OFED_VERSIONS[@]}; do
if [[ ${slot} != ${SLOT} ]]; then
RDEPEND+=" !sys-infiniband/${PN}:${slot}"
fi
done
}
OFED_BASE_VER=$(get_version_component_range 1-3 ${OFED_VER})
if [ -z $OFED_RC ] ; then
SRC_URI="http://www.openfabrics.org/downloads/OFED/ofed-${OFED_BASE_VER}/OFED-${OFED_VER}.tgz"
else
SRC_URI="http://www.openfabrics.org/downloads/OFED/ofed-${OFED_BASE_VER}/OFED-${OFED_VER}-rc${OFED_RC_VER}.tgz"
fi
case ${PN} in
ofed)
case ${PV} in
1.5.*|1.5.*.*)
MY_PN="ofa_kernel"
;;
*)
MY_PN="compat-rdma"
;;
esac
;;
*)
MY_PN="${PN}"
;;
esac
case ${PV} in
*p*)
MY_PV="${PV/p/}"
;;
*)
MY_PV="${PV}"
;;
esac
case ${MY_PN} in
ofa_kernel|compat-rdma)
EXT="tgz"
;;
*)
EXT="tar.gz"
;;
esac
if [ -z ${OFED_SRC_SNAPSHOT} ]; then
S="${WORKDIR}/${MY_PN}-${MY_PV}"
else
S="${WORKDIR}/${MY_PN}-${MY_PV}-${OFED_SUFFIX}"
fi
# @FUNCTION: openib_src_unpack
# @DESCRIPTION:
# This function will unpack OFED packages
openib_src_unpack() {
unpack ${A}
if [ -z ${OFED_RC} ]; then
rpm_unpack "./OFED-${OFED_VER}/SRPMS/${MY_PN}-${MY_PV}-${OFED_SUFFIX}.src.rpm"
else
rpm_unpack "./OFED-${OFED_VER}-rc${OFED_RC_VER}/SRPMS/${MY_PN}-${MY_PV}-${OFED_SUFFIX}.src.rpm"
fi
if [ -z ${OFED_SNAPSHOT} ]; then
unpack ./${MY_PN}-${MY_PV}.${EXT}
else
unpack ./${MY_PN}-${MY_PV}-${OFED_SUFFIX}.${EXT}
fi
}

View File

@ -0,0 +1,105 @@
# Copyright 1999-2011 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/eclass/php-ext-pecl-r2.eclass,v 1.6 2011/08/22 04:46:32 vapier Exp $
# @ECLASS: php-ext-pecl-r1.eclass
# @MAINTAINER:
# Gentoo PHP team <php-bugs@gentoo.org>
# @AUTHOR:
# Author: Tal Peer <coredumb@gentoo.org>
# Author: Luca Longinotti <chtekk@gentoo.org>
# Author: Jakub Moc <jakub@gentoo.org>
# @BLURB: A uniform way of installing PECL extensions
# @DESCRIPTION:
# This eclass should be used by all dev-php[45]/pecl-* ebuilds
# as a uniform way of installing PECL extensions.
# For more information about PECL, see http://pecl.php.net/
# @ECLASS-VARIABLE: PHP_EXT_PECL_PKG
# @DESCRIPTION:
# Set in ebuild before inheriting this eclass if the tarball name
# differs from ${PN/pecl-/} so that SRC_URI and HOMEPAGE gets set
# correctly by the eclass.
#
# Setting this variable manually also affects PHP_EXT_NAME and ${S}
# unless you override those in ebuild. Also see PHP_EXT_PECL_FILENAME
# if this is not desired for whatever reason.
# @ECLASS-VARIABLE: PHP_EXT_PECL_FILENAME
# @DESCRIPTION:
# Set in ebuild before inheriting this eclass if the tarball name
# differs from ${PN/pecl-/} so that SRC_URI gets set correctly by
# the eclass.
#
# Unlike PHP_EXT_PECL_PKG, setting this variable does not affect
# HOMEPAGE, PHP_EXT_NAME or ${S}.
[[ -z "${PHP_EXT_PECL_PKG}" ]] && PHP_EXT_PECL_PKG="${PN/pecl-/}"
[[ -z ${MY_PV} ]] && MY_PV=${PV}
PECL_PKG="${PHP_EXT_PECL_PKG}"
MY_PV="${MY_PV/_/}"
PECL_PKG_V="${PECL_PKG}-${MY_PV}"
[[ -z "${PHP_EXT_NAME}" ]] && PHP_EXT_NAME="${PECL_PKG}"
S="${WORKDIR}/${PECL_PKG_V}"
inherit php-ext-source-r2
EXPORT_FUNCTIONS src_compile src_install src_test
if [[ -n "${PHP_EXT_PECL_FILENAME}" ]] ; then
FILENAME="${PHP_EXT_PECL_FILENAME}-${MY_PV}.tgz"
else
FILENAME="${PECL_PKG_V}.tgz"
fi
SRC_URI="http://pecl.php.net/get/${FILENAME}"
HOMEPAGE="http://pecl.php.net/${PECL_PKG}"
# @FUNCTION: php-ext-pecl-r1_src_compile
# @DESCRIPTION:
# Takes care of standard compile for PECL packages.
php-ext-pecl-r2_src_compile() {
php-ext-source-r2_src_compile
}
# @FUNCTION: php-ext-pecl-r1_src_install
# @DESCRIPTION:
# Takes care of standard install for PECL packages.
# You can also simply add examples to IUSE to automagically install
# examples supplied with the package.
# @VARIABLE: DOCS
# @DESCRIPTION:
# Set in ebuild if you wish to install additional, package-specific documentation.
php-ext-pecl-r2_src_install() {
php-ext-source-r2_src_install
for doc in ${DOCS} "${WORKDIR}"/package.xml CREDITS ; do
[[ -s ${doc} ]] && dodoc ${doc}
done
if has examples ${IUSE} && use examples ; then
insinto /usr/share/doc/${CATEGORY}/${PF}/examples
doins -r examples/*
fi
}
# @FUNCTION: php-ext-pecl-r2_src_test
# @DESCRIPTION:
# Takes care of running any tests delivered with the PECL package.
# Standard phpize generates a run-tests.php file that is executed in make test
# We only need to force it to non-interactive mode
php-ext-pecl-r2_src_test() {
for slot in `php_get_slots`; do
php_init_slot_env ${slot}
NO_INTERACTION="yes" emake test || die "emake test failed for slot ${slot}"
done
}

View File

@ -0,0 +1,372 @@
# Copyright 1999-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/eclass/php-ext-source-r2.eclass,v 1.30 2012/09/27 16:35:41 axs Exp $
# @ECLASS: php-ext-source-r2.eclass
# @MAINTAINER:
# Gentoo PHP team <php-bugs@gentoo.org>
# @AUTHOR:
# Author: Tal Peer <coredumb@gentoo.org>
# Author: Stuart Herbert <stuart@gentoo.org>
# Author: Luca Longinotti <chtekk@gentoo.org>
# Author: Jakub Moc <jakub@gentoo.org> (documentation)
# Author: Ole Markus With <olemarkus@gentoo.org>
# @BLURB: A unified interface for compiling and installing standalone PHP extensions.
# @DESCRIPTION:
# This eclass provides a unified interface for compiling and installing standalone
# PHP extensions (modules).
inherit flag-o-matic autotools multilib
EXPORT_FUNCTIONS src_unpack src_prepare src_configure src_compile src_install
DEPEND=">=sys-devel/m4-1.4.3
>=sys-devel/libtool-1.5.18"
RDEPEND=""
# Because of USE deps, we require at least EAPI 2
case ${EAPI} in
2|3|4|5) ;;
*)
die "php-ext-source-r2 is not compatible with EAPI=${EAPI}"
esac
# @ECLASS-VARIABLE: PHP_EXT_NAME
# @DESCRIPTION:
# The extension name. This must be set, otherwise the eclass dies.
# Only automagically set by php-ext-pecl-r2.eclass, so unless your ebuild
# inherits that eclass, you must set this manually before inherit.
[[ -z "${PHP_EXT_NAME}" ]] && die "No module name specified for the php-ext-source-r2 eclass"
# @ECLASS-VARIABLE: PHP_EXT_INI
# @DESCRIPTION:
# Controls whether or not to add a line to php.ini for the extension.
# Defaults to "yes" and should not be changed in most cases.
[[ -z "${PHP_EXT_INI}" ]] && PHP_EXT_INI="yes"
# @ECLASS-VARIABLE: PHP_EXT_ZENDEXT
# @DESCRIPTION:
# Controls whether the extension is a ZendEngine extension or not.
# Defaults to "no" and if you don't know what is it, you don't need it.
[[ -z "${PHP_EXT_ZENDEXT}" ]] && PHP_EXT_ZENDEXT="no"
# @ECLASS-VARIABLE: USE_PHP
# @DESCRIPTION:
# Lists the PHP slots compatibile the extension is compatibile with
[[ -z "${USE_PHP}" ]] && USE_PHP="php5-3"
# @ECLASS-VARIABLE: PHP_EXT_OPTIONAL_USE
# @DESCRIPTION:
# If set, this is the USE flag that the PHP dependencies are behind
# Most commonly set as PHP_EXT_OPTIONAL_USE=php to get the dependencies behind
# USE=php.
# @ECLASS-VARIABLE: PHP_EXT_S
# @DESCRIPTION:
# The relative location of the temporary build directory for the PHP extension within
# the source package. This is useful for packages that bundle the PHP extension.
# Defaults to ${S}
[[ -z "${PHP_EXT_S}" ]] && PHP_EXT_S="${S}"
#Make sure at least one target is installed. Abuses USE dependencies.
for target in ${USE_PHP}; do
IUSE="${IUSE} php_targets_${target}"
target=${target/+}
SELFDEPEND="${SELFDEPEND} =${CATEGORY}/${PF}[php_targets_${target}]"
slot=${target/php}
slot=${slot/-/.}
PHPDEPEND="${PHPDEPEND}
php_targets_${target}? ( dev-lang/php:${slot} )"
done
RDEPEND="${RDEPEND}
${PHP_EXT_OPTIONAL_USE}${PHP_EXT_OPTIONAL_USE:+? ( }
|| ( ${SELFDEPEND} )
${PHPDEPEND}
${PHP_EXT_OPTIONAL_USE:+ )}"
DEPEND="${DEPEND}
${PHP_EXT_OPTIONAL_USE}${PHP_EXT_OPTIONAL_USE:+? ( }
${PHPDEPEND}
${PHP_EXT_OPTIONAL_USE:+ )}
"
# @FUNCTION: php-ext-source-r2_src_unpack
# @DESCRIPTION:
# runs standard src_unpack + _phpize
# @VARIABLE: PHP_EXT_SKIP_PHPIZE
# @DESCRIPTION:
# phpize will be run by default for all ebuilds that use
# php-ext-source-r2_src_unpack
# Set PHP_EXT_SKIP_PHPIZE="yes" in your ebuild if you do not want to run phpize.
php-ext-source-r2_src_unpack() {
unpack ${A}
local slot orig_s="${PHP_EXT_S}"
for slot in $(php_get_slots); do
cp -r "${orig_s}" "${WORKDIR}/${slot}" || die "Failed to copy source ${orig_s} to PHP target directory"
done
}
php-ext-source-r2_src_prepare() {
local slot orig_s="${PHP_EXT_S}"
for slot in $(php_get_slots); do
php_init_slot_env ${slot}
php-ext-source-r2_phpize
done
}
# @FUNCTION: php-ext-source-r2_phpize
# @DESCRIPTION:
# Runs phpize and autotools in addition to the standard src_unpack
php-ext-source-r2_phpize() {
if [[ "${PHP_EXT_SKIP_PHPIZE}" != 'yes' ]] ; then
# Create configure out of config.m4
# I wish I could run this to solve #329071, but I cannot
#autotools_run_tool ${PHPIZE}
${PHPIZE}
# force run of libtoolize and regeneration of related autotools
# files (bug 220519)
rm aclocal.m4
eautoreconf
fi
}
# @FUNCTION: php-ext-source-r2_src_configure
# @DESCRIPTION:
# Takes care of standard configure for PHP extensions (modules).
# @VARIABLE: my_conf
# @DESCRIPTION:
# Set this in the ebuild to pass configure options to econf.
php-ext-source-r2_src_configure() {
# net-snmp creates this file #385403
addpredict /usr/share/snmp/mibs/.index
addpredict /var/lib/net-snmp/mib_indexes
local slot
for slot in $(php_get_slots); do
php_init_slot_env ${slot}
# Set the correct config options
econf --with-php-config=${PHPCONFIG} ${my_conf} || die "Unable to configure code to compile"
done
}
# @FUNCTION: php-ext-source-r2_src_compile
# @DESCRIPTION:
# Takes care of standard compile for PHP extensions (modules).
php-ext-source-r2_src_compile() {
# net-snmp creates this file #324739
addpredict /usr/share/snmp/mibs/.index
addpredict /var/lib/net-snmp/mib_indexes
# shm extension createss a semaphore file #173574
addpredict /session_mm_cli0.sem
local slot
for slot in $(php_get_slots); do
php_init_slot_env ${slot}
emake || die "Unable to make code"
done
}
# @FUNCTION: php-ext-source-r2_src_install
# @DESCRIPTION:
# Takes care of standard install for PHP extensions (modules).
# @VARIABLE: DOCS
# @DESCRIPTION:
# Set in ebuild if you wish to install additional, package-specific documentation.
php-ext-source-r2_src_install() {
local slot
for slot in $(php_get_slots); do
php_init_slot_env ${slot}
# Let's put the default module away
insinto "${EXT_DIR}"
newins "modules/${PHP_EXT_NAME}.so" "${PHP_EXT_NAME}.so" || die "Unable to install extension"
local doc
for doc in ${DOCS} ; do
[[ -s ${doc} ]] && dodoc ${doc}
done
INSTALL_ROOT="${D}" emake install-headers
done
php-ext-source-r2_createinifiles
}
php_get_slots() {
local s slot
for slot in ${USE_PHP}; do
use php_targets_${slot} && s+=" ${slot/-/.}"
done
echo $s
}
php_init_slot_env() {
libdir=$(get_libdir)
PHPIZE="/usr/${libdir}/${1}/bin/phpize"
PHPCONFIG="/usr/${libdir}/${1}/bin/php-config"
PHPCLI="/usr/${libdir}/${1}/bin/php"
PHPCGI="/usr/${libdir}/${1}/bin/php-cgi"
PHP_PKG="$(best_version =dev-lang/php-${1:3}*)"
PHPPREFIX="/usr/${libdir}/${slot}"
EXT_DIR="$(${PHPCONFIG} --extension-dir 2>/dev/null)"
PHP_CURRENTSLOT=${1:3}
PHP_EXT_S="${WORKDIR}/${1}"
cd "${PHP_EXT_S}"
}
php-ext-source-r2_buildinilist() {
# Work out the list of <ext>.ini files to edit/add to
if [[ -z "${PHPSAPILIST}" ]] ; then
PHPSAPILIST="apache2 cli cgi fpm embed"
fi
PHPINIFILELIST=""
local x
for x in ${PHPSAPILIST} ; do
if [[ -f "/etc/php/${x}-${1}/php.ini" ]] ; then
PHPINIFILELIST="${PHPINIFILELIST} etc/php/${x}-${1}/ext/${PHP_EXT_NAME}.ini"
fi
done
PHPFULLINIFILELIST="${PHPFULLINIFILELIST} ${PHPINIFILELIST}"
}
# @FUNCTION: php-ext-source-r2_createinifiles
# @DESCRIPTION:
# Builds ini files for every enabled slot and SAPI
php-ext-source-r2_createinifiles() {
local slot
for slot in $(php_get_slots); do
php_init_slot_env ${slot}
# Pull in the PHP settings
# Build the list of <ext>.ini files to edit/add to
php-ext-source-r2_buildinilist ${slot}
# Add the needed lines to the <ext>.ini files
local file
if [[ "${PHP_EXT_INI}" = "yes" ]] ; then
for file in ${PHPINIFILELIST}; do
php-ext-source-r2_addextension "${PHP_EXT_NAME}.so" "${file}"
done
fi
# Symlink the <ext>.ini files from ext/ to ext-active/
local inifile
for inifile in ${PHPINIFILELIST} ; do
if [[ -n "${PHP_EXT_INIFILE}" ]]; then
cat "${FILESDIR}/${PHP_EXT_INIFILE}" > "${inifile}"
einfo "Added content of ${FILESDIR}/${PHP_EXT_INIFILE} to ${inifile}"
fi
inidir="${inifile/${PHP_EXT_NAME}.ini/}"
inidir="${inidir/ext/ext-active}"
dodir "/${inidir}"
dosym "/${inifile}" "/${inifile/ext/ext-active}"
done
# Add support for installing PHP files into a version dependant directory
PHP_EXT_SHARED_DIR="/usr/share/php/${PHP_EXT_NAME}"
done
}
php-ext-source-r2_addextension() {
if [[ "${PHP_EXT_ZENDEXT}" = "yes" ]] ; then
# We need the full path for ZendEngine extensions
# and we need to check for debugging enabled!
if has_version "dev-lang/php:${PHP_CURRENTSLOT}[threads]" ; then
if has_version "dev-lang/php:${PHP_CURRENTSLOT}[debug]" ; then
ext_type="zend_extension_debug_ts"
else
ext_type="zend_extension_ts"
fi
ext_file="${EXT_DIR}/${1}"
else
if has_version "dev-lang/php:${PHP_CURRENTSLOT}[debug]"; then
ext_type="zend_extension_debug"
else
ext_type="zend_extension"
fi
ext_file="${EXT_DIR}/${1}"
fi
# php-5.3 unifies zend_extension loading and just requires the
# zend_extension keyword with no suffix
# TODO: drop previous code and this check once <php-5.3 support is
# discontinued
if has_version '>=dev-lang/php-5.3' ; then
ext_type="zend_extension"
fi
else
# We don't need the full path for normal extensions!
ext_type="extension"
ext_file="${1}"
fi
php-ext-source-r2_addtoinifile "${ext_type}" "${ext_file}" "${2}" "Extension added"
}
# $1 - Setting name
# $2 - Setting value
# $3 - File to add to
# $4 - Sanitized text to output
php-ext-source-r2_addtoinifile() {
local inifile="${WORKDIR}/${3}"
if [[ ! -d $(dirname ${inifile}) ]] ; then
mkdir -p $(dirname ${inifile})
fi
# Are we adding the name of a section?
if [[ ${1:0:1} == "[" ]] ; then
echo "${1}" >> "${inifile}"
my_added="${1}"
else
echo "${1}=${2}" >> "${inifile}"
my_added="${1}=${2}"
fi
if [[ -z "${4}" ]] ; then
einfo "Added '${my_added}' to /${3}"
else
einfo "${4} to /${3}"
fi
insinto /$(dirname ${3})
doins "${inifile}"
}
# @FUNCTION: php-ext-source-r2_addtoinifiles
# @USAGE: <setting name> <setting value> [message to output]; or just [section name]
# @DESCRIPTION:
# Add value settings to php.ini file installed by the extension (module).
# You can also add a [section], see examples below.
#
# @CODE
# Add some settings for the extension:
#
# php-ext-source-r2_addtoinifiles "zend_optimizer.optimization_level" "15"
# php-ext-source-r2_addtoinifiles "zend_optimizer.enable_loader" "0"
# php-ext-source-r2_addtoinifiles "zend_optimizer.disable_licensing" "0"
#
# Adding values to a section in php.ini file installed by the extension:
#
# php-ext-source-r2_addtoinifiles "[Debugger]"
# php-ext-source-r2_addtoinifiles "debugger.enabled" "on"
# php-ext-source-r2_addtoinifiles "debugger.profiler_enabled" "on"
# @CODE
php-ext-source-r2_addtoinifiles() {
local x
for x in ${PHPFULLINIFILELIST} ; do
php-ext-source-r2_addtoinifile "${1}" "${2}" "${x}" "${3}"
done
}

View File

@ -0,0 +1,407 @@
# Copyright 1999-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/eclass/python-distutils-ng.eclass,v 1.29 2012/10/30 17:22:33 mgorny Exp $
# @ECLASS: python-distutils-ng
# @MAINTAINER:
# Python herd <python@gentoo.org>
# @AUTHOR:
# Author: Krzysztof Pawlik <nelchael@gentoo.org>
# @BLURB: Install Python packages using distutils.
# @DESCRIPTION:
# The Python eclass is designed to allow an easier installation of Python
# packages and their incorporation into the Gentoo Linux system.
#
# This eclass provides functions for following phases:
# - src_prepare - you can define python_prepare_all function that will be run
# before creating implementation-specific directory and python_prepare
# function that will be run for each implementation
# - src_configure - you can define python_configure function that will be run
# for each implementation
# - src_compile - you can define python_compile function that will be run for
# each implementation, default function will run `setup.py build'
# - src_test - you can define python_test function that will be run for each
# implementation
# - src_install - you can define python_install function that will be run for
# each implementation and python_install_all that will be run in original
# directory (so it will not contain any implementation-specific files)
# @ECLASS-VARIABLE: PYTHON_COMPAT
# @DEFAULT_UNSET
# @DESCRIPTION:
# This variable contains a space separated list of implementations (see above) a
# package is compatible to. It must be set before the `inherit' call. The
# default is to enable all implementations.
if [[ -z "${PYTHON_COMPAT}" ]]; then
# Default: pure python, support all implementations
PYTHON_COMPAT=" python2_5 python2_6 python2_7"
PYTHON_COMPAT+=" python3_1 python3_2"
PYTHON_COMPAT+=" jython2_5"
PYTHON_COMPAT+=" pypy1_8 pypy1_9"
fi
# @ECLASS-VARIABLE: PYTHON_OPTIONAL
# @DEFAULT_UNSET
# @DESCRIPTION:
# Set the value to "yes" to make the dependency on a Python interpreter
# optional.
# @ECLASS-VARIABLE: PYTHON_DISABLE_COMPILATION
# @DEFAULT_UNSET
# @DESCRIPTION:
# Set the value to "yes" to skip compilation and/or optimization of Python
# modules.
# @ECLASS-VARIABLE: PYTHON_DISABLE_SCRIPT_REDOS
# @DEFAULT_UNSET
# @DESCRIPTION:
# Set to any value to disable automatic reinstallation of scripts in bin
# directories. See python-distutils-ng_src_install function.
# @ECLASS-VARIABLE: PYTHON_USE
# @DEFAULT_UNSET
# @DESCRIPTION:
# Comma-separated list of useflags needed for all(!) allowed
# implementations. This is directly substituted into one or more of
# dev-lang/python[${PYTHON_USE}], dev-python/pypy[${PYTHON_USE}] and
# dev-java/jython[${PYTHON_USE}].
# @CODE
# example 1: PYTHON_USE="xml,sqlite"
# example 2: PYTHON_USE="xml?,threads?,-foo"
# @CODE
EXPORT_FUNCTIONS src_prepare src_configure src_compile src_test src_install
case "${EAPI}" in
0|1|2|3)
die "Unsupported EAPI=${EAPI} (too old) for python-distutils-ng.eclass" ;;
4|5)
# EAPI=4 needed for REQUIRED_USE
S="${S:-${WORKDIR}/${P}}"
;;
*)
die "Unsupported EAPI=${EAPI} (unknown) for python-distutils-ng.eclass" ;;
esac
DEPEND="${DEPEND} !<sys-apps/portage-2.1.10.58"
# @FUNCTION: _python-distutils-ng_get_binary_for_implementation
# @USAGE: implementation
# @RETURN: Full path to Python binary for given implementation.
# @DESCRIPTION:
# This function returns full path for Python binary for given implementation.
#
# Binary returned by this function should be used instead of simply calling
# `python'.
_python-distutils-ng_get_binary_for_implementation() {
local impl="${1/_/.}"
case "${impl}" in
python?.?|jython?.?)
echo "${EPREFIX}/usr/bin/${impl}" ;;
pypy?.?)
echo "${EPREFIX}/usr/bin/pypy-c${impl: -3}" ;;
*)
die "Unsupported implementation: ${1}" ;;
esac
}
required_use_str=""
for impl in ${PYTHON_COMPAT}; do
required_use_str+=" python_targets_${impl}"
done
required_use_str=" || ( ${required_use_str} )"
if [[ "${PYTHON_OPTIONAL}" = "yes" ]]; then
IUSE+=" python"
REQUIRED_USE+=" python? ( ${required_use_str} )"
else
REQUIRED_USE+=" ${required_use_str}"
fi
unset required_use_str
# avoid empty use deps
_PYTHON_USE="${PYTHON_USE:+[${PYTHON_USE}]}"
# set python DEPEND and RDEPEND
for impl in ${PYTHON_COMPAT}; do
IUSE+=" python_targets_${impl}"
dep_str="${impl/_/.}"
case "${dep_str}" in
python?.?)
dep_str="dev-lang/python:${dep_str: -3}${_PYTHON_USE}" ;;
jython?.?)
dep_str="dev-java/jython:${dep_str: -3}${_PYTHON_USE}" ;;
pypy?.?)
dep_str="dev-python/pypy:${dep_str: -3}${_PYTHON_USE}" ;;
*)
die "Unsupported implementation: ${impl}" ;;
esac
dep_str="python_targets_${impl}? ( ${dep_str} )"
if [[ "${PYTHON_OPTIONAL}" = "yes" ]]; then
RDEPEND="${RDEPEND} python? ( ${dep_str} )"
DEPEND="${DEPEND} python? ( ${dep_str} )"
else
RDEPEND="${RDEPEND} ${dep_str}"
DEPEND="${DEPEND} ${dep_str}"
fi
unset dep_str
done
_PACKAGE_SPECIFIC_S="${S#${WORKDIR}/}"
# @FUNCTION: _python-distutils-ng_run_for_impl
# @USAGE: implementation command_to_run
# @DESCRIPTION:
# Run command_to_run using specified Python implementation.
#
# This will run the command_to_run in implementation-specific working directory.
_python-distutils-ng_run_for_impl() {
local impl="${1}"
local command="${2}"
local S="${WORKDIR}/impl_${impl}/${_PACKAGE_SPECIFIC_S}"
PYTHON="$(_python-distutils-ng_get_binary_for_implementation "${impl}")"
EPYTHON="${impl/_/.}"
einfo "Running ${command} in ${S} for ${impl}"
pushd "${S}" &> /dev/null
"${command}" "${impl}" "${PYTHON}"
popd &> /dev/null
}
# @FUNCTION: _python-distutils-ng_run_for_each_impl
# @USAGE: command_to_run
# @DESCRIPTION:
# Run command_to_run for all enabled Python implementations.
#
# See also _python-distutils-ng_run_for_impl
_python-distutils-ng_run_for_each_impl() {
local command="${1}"
for impl in ${PYTHON_COMPAT}; do
use "python_targets_${impl}" ${PYTHON_COMPAT} || continue
_python-distutils-ng_run_for_impl "${impl}" "${command}"
done
}
# @FUNCTION: _python-distutils-ng_default_distutils_compile
# @DESCRIPTION:
# Default src_compile for distutils-based packages.
_python-distutils-ng_default_distutils_compile() {
"${PYTHON}" setup.py build || die
}
# @FUNCTION: _python-distutils-ng_default_distutils_install
# @DESCRIPTION:
# Default src_install for distutils-based packages.
_python-distutils-ng_default_distutils_install() {
local compile_flags="--compile -O2"
case "${1}" in
jython*)
# Jython does not support optimizations
compile_flags="--compile" ;;
esac
unset PYTHONDONTWRITEBYTECODE
[[ -n "${PYTHON_DISABLE_COMPILATION}" ]] && compile_flags="--no-compile"
"${PYTHON}" setup.py install ${compile_flags} --root="${D}" || die
}
# @FUNCTION: python-distutils-ng_rewrite_hashbang
# @USAGE: script_file_name implementation
# @DESCRIPTION:
# Rewrite #! line in named script, dies if #! line is not for Python or missing.
python-distutils-ng_rewrite_hashbang() {
[[ -n "${1}" ]] || die "Missing file name"
[[ -n "${2}" ]] || die "Missing implementation"
local file_name="${1}"
local binary="$(_python-distutils-ng_get_binary_for_implementation "${2}")"
[[ $(head -n 1 "${file_name}") == '#!'*(python|jython|pypy-c)* ]] || \
die "Missing or invalid #! line in ${file_name}"
sed -i -e "1c#!${binary}" "${file_name}" || die
}
# @FUNCTION: python-distutils-ng_redoscript
# @USAGE: script_file_path [destination_directory]
# @DESCRIPTION:
# Reinstall script installed already by setup.py. This works by first moving the
# script to ${T} directory and later running python-distutils-ng_doscript on it.
# script_file_path has to be a full path relative to ${D}.
# Warning: this function can be run automatically by the eclass in src_install,
# see python-distutils-ng_src_install and PYTHON_DISABLE_SCRIPT_REDOS variable.
python-distutils-ng_redoscript() {
local sbn="$(basename "${1}")"
mkdir -p "${T}/_${sbn}/" || die "failed to create directory"
mv "${D}${1}" "${T}/_${sbn}/${sbn}" || die "failed to move file"
python-distutils-ng_doscript "${T}/_${sbn}/${sbn}" "${2}"
}
# @FUNCTION: python-distutils-ng_doscript
# @USAGE: script_file_name [destination_directory]
# @DESCRIPTION:
# Install given script file in destination directory (for default value check
# python-distutils-ng_newscript) for all enabled implementations using original
# script name as a base name.
#
# See also python-distutils-ng_newscript for more details.
python-distutils-ng_doscript() {
python-distutils-ng_newscript "${1}" "$(basename "${1}")" "${2}"
}
# @FUNCTION: python-distutils-ng_newscript
# @USAGE: script_file_name new_file_name [destination_directory]
# @DESCRIPTION:
# Install given script file in destination directory for all enabled
# implementations using new_file_name as a base name.
#
# Destination directory defaults to /usr/bin.
#
# If only one Python implementation is enabled the script will be installed
# as-is. Otherwise each script copy will have the name mangled to
# "new_file_name-IMPLEMENTATION". For every installed script new hash-bang line
# will be inserted to reference specific Python interpreter.
#
# In case of multiple implementations there will be also a symlink with name
# equal to new_file_name that will be a symlink to default implementation, which
# defaults to value of PYTHON_DEFAULT_IMPLEMENTATION, if not specified the
# function will pick default implementation: it will the be first enabled one
# from the following list:
# python2_7, python2_6, python2_5, python3_2, python3_1, pypy1_8, pypy1_7, jython2_5
python-distutils-ng_newscript() {
[[ -n "${1}" ]] || die "Missing source file name"
[[ -n "${2}" ]] || die "Missing destination file name"
local source_file="${1}"
local destination_file="${2}"
local default_impl="${PYTHON_DEFAULT_IMPLEMENTATION}"
local enabled_impls=0
local destination_directory="/usr/bin"
[[ -n "${3}" ]] && destination_directory="${3}"
for impl in ${PYTHON_COMPAT}; do
use "python_targets_${impl}" || continue
enabled_impls=$((enabled_impls + 1))
done
if [[ -z "${default_impl}" ]]; then
for impl in python{2_7,2_6,2_5,3_2,3_1} pypy{1_9,1_8,1_7} jython2_5; do
use "python_targets_${impl}" || continue
default_impl="${impl}"
break
done
else
use "python_targets_${default_impl}" || \
die "default implementation ${default_impl} not enabled"
fi
[[ -n "${default_impl}" ]] || die "Could not select default implementation"
dodir "${destination_directory}"
insinto "${destination_directory}"
if [[ "${enabled_impls}" = "1" ]]; then
einfo "Installing ${source_file} for single implementation (${default_impl}) in ${destination_directory}"
newins "${source_file}" "${destination_file}"
fperms 755 "${destination_directory}/${destination_file}"
python-distutils-ng_rewrite_hashbang "${D}${destination_directory}/${destination_file}" "${default_impl}"
else
einfo "Installing ${source_file} for multiple implementations (default: ${default_impl}) in ${destination_directory}"
for impl in ${PYTHON_COMPAT}; do
use "python_targets_${impl}" ${PYTHON_COMPAT} || continue
newins "${source_file}" "${destination_file}-${impl}"
fperms 755 "${destination_directory}/${destination_file}-${impl}"
python-distutils-ng_rewrite_hashbang "${D}${destination_directory}/${destination_file}-${impl}" "${impl}"
done
dosym "${destination_file}-${default_impl}" "${destination_directory}/${destination_file}"
fi
}
# Phase function: src_prepare
python-distutils-ng_src_prepare() {
[[ "${PYTHON_OPTIONAL}" = "yes" ]] && { use python || return; }
# Try to run binary for each implementation:
for impl in ${PYTHON_COMPAT}; do
use "python_targets_${impl}" ${PYTHON_COMPAT} || continue
$(_python-distutils-ng_get_binary_for_implementation "${impl}") \
-c "import sys" || die
done
# Run prepare shared by all implementations:
if type python_prepare_all &> /dev/null; then
einfo "Running python_prepare_all in ${S} for all"
python_prepare_all
fi
# Create a copy of S for each implementation:
for impl in ${PYTHON_COMPAT}; do
use "python_targets_${impl}" ${PYTHON_COMPAT} || continue
einfo "Creating copy for ${impl} in ${WORKDIR}/impl_${impl}"
mkdir -p "${WORKDIR}/impl_${impl}" || die
cp -pr "${S}" "${WORKDIR}/impl_${impl}/${_PACKAGE_SPECIFIC_S}" || die
done
# Run python_prepare for each implementation:
if type python_prepare &> /dev/null; then
_python-distutils-ng_run_for_each_impl python_prepare
fi
}
# Phase function: src_configure
python-distutils-ng_src_configure() {
[[ "${PYTHON_OPTIONAL}" = "yes" ]] && { use python || return; }
if type python_configure &> /dev/null; then
_python-distutils-ng_run_for_each_impl python_configure
fi
}
# Phase function: src_compile
python-distutils-ng_src_compile() {
[[ "${PYTHON_OPTIONAL}" = "yes" ]] && { use python || return; }
if type python_compile &> /dev/null; then
_python-distutils-ng_run_for_each_impl python_compile
else
_python-distutils-ng_run_for_each_impl \
_python-distutils-ng_default_distutils_compile
fi
}
# Phase function: src_test
python-distutils-ng_src_test() {
[[ "${PYTHON_OPTIONAL}" = "yes" ]] && { use python || return; }
if type python_test &> /dev/null; then
_python-distutils-ng_run_for_each_impl python_test
fi
}
# Phase function: src_install
python-distutils-ng_src_install() {
[[ "${PYTHON_OPTIONAL}" = "yes" ]] && { use python || return; }
if type python_install &> /dev/null; then
_python-distutils-ng_run_for_each_impl python_install
else
_python-distutils-ng_run_for_each_impl \
_python-distutils-ng_default_distutils_install
fi
if type python_install_all &> /dev/null; then
einfo "Running python_install_all in ${S} for all"
pushd "${S}" &> /dev/null
python_install_all
popd &> /dev/null
fi
if [[ -z "${PYTHON_DISABLE_SCRIPT_REDOS}" ]]; then
for script_file in $(find "${ED}"{,usr/}{,s}bin/ -type f -executable 2> /dev/null); do
python-distutils-ng_redoscript "/${script_file#${D}}"
done
fi
}

View File

@ -0,0 +1,506 @@
# Copyright 1999-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/eclass/python-r1.eclass,v 1.24 2012/11/30 11:40:15 mgorny Exp $
# @ECLASS: python-r1
# @MAINTAINER:
# Michał Górny <mgorny@gentoo.org>
# Python herd <python@gentoo.org>
# @AUTHOR:
# Author: Michał Górny <mgorny@gentoo.org>
# Based on work of: Krzysztof Pawlik <nelchael@gentoo.org>
# @BLURB: A common, simple eclass for Python packages.
# @DESCRIPTION:
# A common eclass providing helper functions to build and install
# packages supporting being installed for multiple Python
# implementations.
#
# This eclass sets correct IUSE and REQUIRED_USE. It exports PYTHON_DEPS
# and PYTHON_USEDEP so you can create correct dependencies for your
# package easily. It also provides methods to easily run a command for
# each enabled Python implementation and duplicate the sources for them.
#
# Please note that python-r1 will always inherit python-utils-r1 as
# well. Thus, all the functions defined there can be used
# in the packages using python-r1, and there is no need ever to inherit
# both.
#
# For more information, please see the python-r1 Developer's Guide:
# http://www.gentoo.org/proj/en/Python/python-r1/dev-guide.xml
case "${EAPI:-0}" in
0|1|2|3)
die "Unsupported EAPI=${EAPI:-0} (too old) for ${ECLASS}"
;;
4|5)
# EAPI=4 needed for REQUIRED_USE
;;
*)
die "Unsupported EAPI=${EAPI} (unknown) for ${ECLASS}"
;;
esac
if [[ ! ${_PYTHON_R1} ]]; then
if [[ ${_PYTHON_SINGLE_R1} ]]; then
die 'python-r1.eclass can not be used with python-single-r1.eclass.'
fi
inherit python-utils-r1
# @ECLASS-VARIABLE: PYTHON_COMPAT
# @REQUIRED
# @DESCRIPTION:
# This variable contains a list of Python implementations the package
# supports. It must be set before the `inherit' call. It has to be
# an array.
#
# Example:
# @CODE
# PYTHON_COMPAT=( python2_5 python2_6 python2_7 )
# @CODE
#
# Please note that you can also use bash brace expansion if you like:
# @CODE
# PYTHON_COMPAT=( python{2_5,2_6,2_7} )
# @CODE
if ! declare -p PYTHON_COMPAT &>/dev/null; then
if [[ ${CATEGORY}/${PN} == dev-python/python-exec ]]; then
PYTHON_COMPAT=( "${_PYTHON_ALL_IMPLS[@]}" )
else
die 'PYTHON_COMPAT not declared.'
fi
fi
# @ECLASS-VARIABLE: PYTHON_REQ_USE
# @DEFAULT_UNSET
# @DESCRIPTION:
# The list of USEflags required to be enabled on the chosen Python
# implementations, formed as a USE-dependency string. It should be valid
# for all implementations in PYTHON_COMPAT, so it may be necessary to
# use USE defaults.
#
# Example:
# @CODE
# PYTHON_REQ_USE="gdbm,ncurses(-)?"
# @CODE
#
# It will cause the Python dependencies to look like:
# @CODE
# python_targets_pythonX_Y? ( dev-lang/python:X.Y[gdbm,ncurses(-)?] )
# @CODE
# @ECLASS-VARIABLE: PYTHON_DEPS
# @DESCRIPTION:
# This is an eclass-generated Python dependency string for all
# implementations listed in PYTHON_COMPAT.
#
# Example use:
# @CODE
# RDEPEND="${PYTHON_DEPS}
# dev-foo/mydep"
# DEPEND="${RDEPEND}"
# @CODE
#
# Example value:
# @CODE
# dev-python/python-exec
# python_targets_python2_6? ( dev-lang/python:2.6[gdbm] )
# python_targets_python2_7? ( dev-lang/python:2.7[gdbm] )
# @CODE
# @ECLASS-VARIABLE: PYTHON_USEDEP
# @DESCRIPTION:
# This is an eclass-generated USE-dependency string which can be used to
# depend on another Python package being built for the same Python
# implementations.
#
# The generate USE-flag list is compatible with packages using python-r1
# and python-distutils-ng eclasses. It must not be used on packages
# using python.eclass.
#
# Example use:
# @CODE
# RDEPEND="dev-python/foo[${PYTHON_USEDEP}]"
# @CODE
#
# Example value:
# @CODE
# python_targets_python2_6?,python_targets_python2_7?
# @CODE
_python_set_globals() {
local flags=( "${PYTHON_COMPAT[@]/#/python_targets_}" )
local optflags=${flags[@]/%/?}
IUSE=${flags[*]}
REQUIRED_USE="|| ( ${flags[*]} )"
PYTHON_USEDEP=${optflags// /,}
local usestr
[[ ${PYTHON_REQ_USE} ]] && usestr="[${PYTHON_REQ_USE}]"
# 1) well, python-exec would suffice as an RDEP
# but no point in making this overcomplex, BDEP doesn't hurt anyone
# 2) python-exec should be built with all targets forced anyway
# but if new targets were added, we may need to force a rebuild
PYTHON_DEPS="dev-python/python-exec[${PYTHON_USEDEP}]"
local i
for i in "${PYTHON_COMPAT[@]}"; do
local d
case ${i} in
python*)
d='dev-lang/python';;
jython*)
d='dev-java/jython';;
pypy*)
d='dev-python/pypy';;
*)
die "Invalid implementation: ${i}"
esac
local v=${i##*[a-z]}
PYTHON_DEPS+=" python_targets_${i}? ( ${d}:${v/_/.}${usestr} )"
done
}
_python_set_globals
# @ECLASS-VARIABLE: BUILD_DIR
# @DESCRIPTION:
# The current build directory. In global scope, it is supposed to
# contain an initial build directory; if unset, it defaults to ${S}.
#
# In functions run by python_foreach_impl(), the BUILD_DIR is locally
# set to an implementation-specific build directory. That path is
# created through appending a hyphen and the implementation name
# to the final component of the initial BUILD_DIR.
#
# Example value:
# @CODE
# ${WORKDIR}/foo-1.3-python2_6
# @CODE
# @FUNCTION: python_copy_sources
# @DESCRIPTION:
# Create a single copy of the package sources (${S}) for each enabled
# Python implementation.
#
# The sources are always copied from S to implementation-specific build
# directories respecting BUILD_DIR.
python_copy_sources() {
debug-print-function ${FUNCNAME} "${@}"
local impl
local bdir=${BUILD_DIR:-${S}}
debug-print "${FUNCNAME}: bdir = ${bdir}"
einfo "Will copy sources from ${S}"
# the order is irrelevant here
for impl in "${PYTHON_COMPAT[@]}"; do
if use "python_targets_${impl}"
then
local BUILD_DIR=${bdir%%/}-${impl}
einfo "${impl}: copying to ${BUILD_DIR}"
debug-print "${FUNCNAME}: [${impl}] cp ${S} => ${BUILD_DIR}"
cp -pr "${S}" "${BUILD_DIR}" || die
fi
done
}
# @FUNCTION: _python_check_USE_PYTHON
# @INTERNAL
# @DESCRIPTION:
# Check whether USE_PYTHON and PYTHON_TARGETS are in sync. Output
# warnings if they are not.
_python_check_USE_PYTHON() {
debug-print-function ${FUNCNAME} "${@}"
if [[ ! ${_PYTHON_USE_PYTHON_CHECKED} ]]; then
_PYTHON_USE_PYTHON_CHECKED=1
# python-exec has profile-forced flags.
if [[ ${CATEGORY}/${PN} == dev-python/python-exec ]]; then
return
fi
_try_eselect() {
# The eselect solution will work only with one py2 & py3.
local impl py2 py3 dis_py2 dis_py3
for impl in "${PYTHON_COMPAT[@]}"; do
if use "python_targets_${impl}"; then
case "${impl}" in
python2_*)
if [[ ${py2+1} ]]; then
debug-print "${FUNCNAME}: -> more than one py2: ${py2} ${impl}"
return 1
fi
py2=${impl/_/.}
;;
python3_*)
if [[ ${py3+1} ]]; then
debug-print "${FUNCNAME}: -> more than one py3: ${py3} ${impl}"
return 1
fi
py3=${impl/_/.}
;;
*)
return 1
;;
esac
else
case "${impl}" in
python2_*)
dis_py2=1
;;
python3_*)
dis_py3=1
;;
esac
fi
done
# The eselect solution won't work if the disabled Python version
# is installed.
if [[ ! ${py2+1} && ${dis_py2} ]]; then
debug-print "${FUNCNAME}: -> all py2 versions disabled"
if has_version '=dev-lang/python-2*'; then
debug-print "${FUNCNAME}: ---> but =python-2* installed!"
return 1
fi
fi
if [[ ! ${py3+1} && ${dis_py3} ]]; then
debug-print "${FUNCNAME}: -> all py3 versions disabled"
if has_version '=dev-lang/python-3*'; then
debug-print "${FUNCNAME}: ---> but =python-3* installed!"
return 1
fi
fi
local warned
# Now check whether the correct implementations are active.
if [[ ${py2+1} ]]; then
local sel_py2=$(eselect python show --python2)
debug-print "${FUNCNAME}: -> py2 built: ${py2}, active: ${sel_py2}"
if [[ ${py2} != ${sel_py2} ]]; then
ewarn "Building package for ${py2} only while ${sel_py2} is active."
ewarn "Please consider switching the active Python 2 interpreter:"
ewarn
ewarn " eselect python set --python2 ${py2}"
warned=1
fi
fi
if [[ ${py3+1} ]]; then
local sel_py3=$(eselect python show --python3)
debug-print "${FUNCNAME}: -> py3 built: ${py3}, active: ${sel_py3}"
if [[ ${py3} != ${sel_py3} ]]; then
[[ ${warned} ]] && ewarn
ewarn "Building package for ${py3} only while ${sel_py3} is active."
ewarn "Please consider switching the active Python 3 interpreter:"
ewarn
ewarn " eselect python set --python3 ${py3}"
warned=1
fi
fi
if [[ ${warned} ]]; then
ewarn
ewarn "Please note that after switching the active Python interpreter,"
ewarn "you may need to run 'python-updater' to rebuild affected packages."
ewarn
ewarn "For more information on python.eclass compatibility, please see"
ewarn "the appropriate python-r1 User's Guide chapter [1]."
ewarn
ewarn "[1] http://www.gentoo.org/proj/en/Python/python-r1/user-guide.xml#doc_chap2"
fi
}
# If user has no USE_PYTHON, try to avoid it.
if [[ ! ${USE_PYTHON} ]]; then
debug-print "${FUNCNAME}: trying eselect solution ..."
_try_eselect && return
fi
debug-print "${FUNCNAME}: trying USE_PYTHON solution ..."
debug-print "${FUNCNAME}: -> USE_PYTHON=${USE_PYTHON}"
local impl old=${USE_PYTHON} new=() removed=()
for impl in "${PYTHON_COMPAT[@]}"; do
local abi
case "${impl}" in
python*)
abi=${impl#python}
;;
jython*)
abi=${impl#jython}-jython
;;
pypy*)
abi=2.7-pypy-${impl#pypy}
;;
*)
die "Unexpected Python implementation: ${impl}"
;;
esac
abi=${abi/_/.}
has "${abi}" ${USE_PYTHON}
local has_abi=${?}
use "python_targets_${impl}"
local has_impl=${?}
# 0 = has, 1 = does not have
if [[ ${has_abi} == 0 && ${has_impl} == 1 ]]; then
debug-print "${FUNCNAME}: ---> remove ${abi}"
# remove from USE_PYTHON
old=${old/${abi}/}
removed+=( ${abi} )
elif [[ ${has_abi} == 1 && ${has_impl} == 0 ]]; then
debug-print "${FUNCNAME}: ---> add ${abi}"
# add to USE_PYTHON
new+=( ${abi} )
fi
done
if [[ ${removed[@]} || ${new[@]} ]]; then
old=( ${old} )
debug-print "${FUNCNAME}: -> old: ${old[@]}"
debug-print "${FUNCNAME}: -> new: ${new[@]}"
debug-print "${FUNCNAME}: -> removed: ${removed[@]}"
if [[ ${USE_PYTHON} ]]; then
ewarn "It seems that your USE_PYTHON setting lists different Python"
ewarn "implementations than your PYTHON_TARGETS variable. Please consider"
ewarn "using the following value instead:"
ewarn
ewarn " USE_PYTHON='\033[35m${old[@]}${new[@]+ \033[1m${new[@]}}\033[0m'"
if [[ ${removed[@]} ]]; then
ewarn
ewarn "(removed \033[31m${removed[@]}\033[0m)"
fi
else
ewarn "It seems that you need to set USE_PYTHON to make sure that legacy"
ewarn "packages will be built with respect to PYTHON_TARGETS correctly:"
ewarn
ewarn " USE_PYTHON='\033[35;1m${new[@]}\033[0m'"
fi
ewarn
ewarn "Please note that after changing the USE_PYTHON variable, you may need"
ewarn "to run 'python-updater' to rebuild affected packages."
ewarn
ewarn "For more information on python.eclass compatibility, please see"
ewarn "the appropriate python-r1 User's Guide chapter [1]."
ewarn
ewarn "[1] http://www.gentoo.org/proj/en/Python/python-r1/user-guide.xml#doc_chap2"
fi
fi
}
# @FUNCTION: python_foreach_impl
# @USAGE: <command> [<args>...]
# @DESCRIPTION:
# Run the given command for each of the enabled Python implementations.
# If additional parameters are passed, they will be passed through
# to the command. If the command fails, python_foreach_impl dies.
# If necessary, use ':' to force a successful return.
#
# For each command being run, EPYTHON, PYTHON and BUILD_DIR are set
# locally, and the former two are exported to the command environment.
python_foreach_impl() {
debug-print-function ${FUNCNAME} "${@}"
_python_check_USE_PYTHON
local impl
local bdir=${BUILD_DIR:-${S}}
debug-print "${FUNCNAME}: bdir = ${bdir}"
for impl in "${_PYTHON_ALL_IMPLS[@]}"; do
if has "${impl}" "${PYTHON_COMPAT[@]}" && use "python_targets_${impl}"
then
local EPYTHON PYTHON
python_export "${impl}" EPYTHON PYTHON
local BUILD_DIR=${bdir%%/}-${impl}
export EPYTHON PYTHON
einfo "${EPYTHON}: running ${@}"
"${@}" || die "${EPYTHON}: ${1} failed"
fi
done
}
# @FUNCTION: python_export_best
# @USAGE: [<variable>...]
# @DESCRIPTION:
# Find the best (most preferred) Python implementation enabled
# and export given variables for it. If no variables are provided,
# EPYTHON & PYTHON will be exported.
python_export_best() {
debug-print-function ${FUNCNAME} "${@}"
[[ ${#} -gt 0 ]] || set -- EPYTHON PYTHON
local impl best
for impl in "${_PYTHON_ALL_IMPLS[@]}"; do
if has "${impl}" "${PYTHON_COMPAT[@]}" && use "python_targets_${impl}"
then
best=${impl}
fi
done
[[ ${best+1} ]] || die "python_export_best(): no implementation found!"
debug-print "${FUNCNAME}: Best implementation is: ${impl}"
python_export "${impl}" "${@}"
}
# @FUNCTION: python_replicate_script
# @USAGE: <path>...
# @DESCRIPTION:
# Copy the given script to variants for all enabled Python
# implementations, then replace it with a symlink to the wrapper.
#
# All specified files must start with a 'python' shebang. A file not
# having a matching shebang will be refused.
python_replicate_script() {
debug-print-function ${FUNCNAME} "${@}"
if [[ ${_PYTHON_SINGLE_R1} ]]; then
die "${FUNCNAME} must not be used with python-single-r1 eclass."
fi
local suffixes=()
_add_suffix() {
suffixes+=( "${EPYTHON}" )
}
python_foreach_impl _add_suffix
debug-print "${FUNCNAME}: suffixes = ( ${suffixes[@]} )"
local f suffix
for suffix in "${suffixes[@]}"; do
for f; do
local newf=${f}-${suffix}
debug-print "${FUNCNAME}: ${f} -> ${newf}"
cp "${f}" "${newf}" || die
done
_python_rewrite_shebang "${suffix}" "${@/%/-${suffix}}"
done
for f; do
_python_ln_rel "${ED}"/usr/bin/python-exec "${f}" || die
done
}
_PYTHON_R1=1
fi

View File

@ -0,0 +1,196 @@
# Copyright 1999-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/eclass/python-single-r1.eclass,v 1.6 2012/11/30 22:57:26 mgorny Exp $
# @ECLASS: python-single-r1
# @MAINTAINER:
# Michał Górny <mgorny@gentoo.org>
# Python herd <python@gentoo.org>
# @AUTHOR:
# Author: Michał Górny <mgorny@gentoo.org>
# Based on work of: Krzysztof Pawlik <nelchael@gentoo.org>
# @BLURB: An eclass for Python packages not installed for multiple implementations.
# @DESCRIPTION:
# An extension of the python-r1 eclass suite for packages which
# don't support being installed for multiple Python implementations.
# This mostly includes tools embedding Python.
#
# This eclass extends the IUSE and REQUIRED_USE set by python-r1
# to request correct PYTHON_SINGLE_TARGET. It also replaces
# PYTHON_USEDEP and PYTHON_DEPS with a more suitable form.
#
# Please note that packages support multiple Python implementations
# (using python-r1 eclass) can not depend on packages not supporting
# them (using this eclass).
#
# Please note that python-single-r1 will always inherit python-utils-r1
# as well. Thus, all the functions defined there can be used
# in the packages using python-single-r1, and there is no need ever
# to inherit both.
#
# For more information, please see the python-r1 Developer's Guide:
# http://www.gentoo.org/proj/en/Python/python-r1/dev-guide.xml
case "${EAPI:-0}" in
0|1|2|3)
die "Unsupported EAPI=${EAPI:-0} (too old) for ${ECLASS}"
;;
4|5)
# EAPI=4 needed by python-r1
;;
*)
die "Unsupported EAPI=${EAPI} (unknown) for ${ECLASS}"
;;
esac
if [[ ! ${_PYTHON_SINGLE_R1} ]]; then
if [[ ${_PYTHON_R1} ]]; then
die 'python-single-r1.eclass can not be used with python-r1.eclass.'
fi
inherit python-utils-r1
fi
EXPORT_FUNCTIONS pkg_setup
if [[ ! ${_PYTHON_SINGLE_R1} ]]; then
# @ECLASS-VARIABLE: PYTHON_COMPAT
# @REQUIRED
# @DESCRIPTION:
# This variable contains a list of Python implementations the package
# supports. It must be set before the `inherit' call. It has to be
# an array.
#
# Example:
# @CODE
# PYTHON_COMPAT=( python{2_5,2_6,2_7} )
# @CODE
if ! declare -p PYTHON_COMPAT &>/dev/null; then
die 'PYTHON_COMPAT not declared.'
fi
# @ECLASS-VARIABLE: PYTHON_REQ_USE
# @DEFAULT_UNSET
# @DESCRIPTION:
# The list of USEflags required to be enabled on the chosen Python
# implementations, formed as a USE-dependency string. It should be valid
# for all implementations in PYTHON_COMPAT, so it may be necessary to
# use USE defaults.
#
# Example:
# @CODE
# PYTHON_REQ_USE="gdbm,ncurses(-)?"
# @CODE
#
# It will cause the Python dependencies to look like:
# @CODE
# python_single_target_pythonX_Y? ( dev-lang/python:X.Y[gdbm,ncurses(-)?] )
# @CODE
# @ECLASS-VARIABLE: PYTHON_DEPS
# @DESCRIPTION:
# This is an eclass-generated Python dependency string for all
# implementations listed in PYTHON_COMPAT.
#
# The dependency string is conditional on PYTHON_SINGLE_TARGET.
#
# Example use:
# @CODE
# RDEPEND="${PYTHON_DEPS}
# dev-foo/mydep"
# DEPEND="${RDEPEND}"
# @CODE
#
# Example value:
# @CODE
# dev-python/python-exec
# python_single_target_python2_6? ( dev-lang/python:2.6[gdbm] )
# python_single_target_python2_7? ( dev-lang/python:2.7[gdbm] )
# @CODE
# @ECLASS-VARIABLE: PYTHON_USEDEP
# @DESCRIPTION:
# This is an eclass-generated USE-dependency string which can be used to
# depend on another Python package being built for the same Python
# implementations.
#
# The generate USE-flag list is compatible with packages using python-r1,
# python-single-r1 and python-distutils-ng eclasses. It must not be used
# on packages using python.eclass.
#
# Example use:
# @CODE
# RDEPEND="dev-python/foo[${PYTHON_USEDEP}]"
# @CODE
#
# Example value:
# @CODE
# python_targets_python2_7?,python_single_target_python2_7(+)?
# @CODE
_python_single_set_globals() {
local flags_mt=( "${PYTHON_COMPAT[@]/#/python_targets_}" )
local flags=( "${PYTHON_COMPAT[@]/#/python_single_target_}" )
local optflags=${flags_mt[@]/%/?}
optflags+=,${flags[@]/%/(+)?}
IUSE="${flags_mt[*]} ${flags[*]}"
REQUIRED_USE="|| ( ${flags_mt[*]} ) ^^ ( ${flags[*]} )"
PYTHON_USEDEP=${optflags// /,}
local usestr
[[ ${PYTHON_REQ_USE} ]] && usestr="[${PYTHON_REQ_USE}]"
# 1) well, python-exec would suffice as an RDEP
# but no point in making this overcomplex, BDEP doesn't hurt anyone
# 2) python-exec should be built with all targets forced anyway
# but if new targets were added, we may need to force a rebuild
PYTHON_DEPS="dev-python/python-exec[${PYTHON_USEDEP}]"
local i
for i in "${PYTHON_COMPAT[@]}"; do
# The chosen targets need to be in PYTHON_TARGETS as well.
# This is in order to enforce correct dependencies on packages
# supporting multiple implementations.
REQUIRED_USE+=" python_single_target_${i}? ( python_targets_${i} )"
local d
case ${i} in
python*)
d='dev-lang/python';;
jython*)
d='dev-java/jython';;
pypy*)
d='dev-python/pypy';;
*)
die "Invalid implementation: ${i}"
esac
local v=${i##*[a-z]}
PYTHON_DEPS+=" python_single_target_${i}? ( ${d}:${v/_/.}${usestr} )"
done
}
_python_single_set_globals
# @FUNCTION: python-single-r1_pkg_setup
# @DESCRIPTION:
# Determine what the selected Python implementation is and set EPYTHON
# and PYTHON accordingly.
python-single-r1_pkg_setup() {
debug-print-function ${FUNCNAME} "${@}"
local impl
for impl in "${_PYTHON_ALL_IMPLS[@]}"; do
if has "${impl}" "${PYTHON_COMPAT[@]}" \
&& use "python_single_target_${impl}"
then
python_export "${impl}" EPYTHON PYTHON
break
fi
done
}
_PYTHON_SINGLE_R1=1
fi

View File

@ -0,0 +1,494 @@
# Copyright 1999-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/eclass/python-utils-r1.eclass,v 1.5 2012/11/30 11:43:14 mgorny Exp $
# @ECLASS: python-utils-r1
# @MAINTAINER:
# Michał Górny <mgorny@gentoo.org>
# Python herd <python@gentoo.org>
# @AUTHOR:
# Author: Michał Górny <mgorny@gentoo.org>
# Based on work of: Krzysztof Pawlik <nelchael@gentoo.org>
# @BLURB: Utility functions for packages with Python parts.
# @DESCRIPTION:
# An utility eclass providing functions to query Python implementations,
# install Python modules and scripts.
#
# This eclass does not set any metadata variables nor export any phase
# functions. It can be inherited safely.
#
# For more information, please see the python-r1 Developer's Guide:
# http://www.gentoo.org/proj/en/Python/python-r1/dev-guide.xml
case "${EAPI:-0}" in
0|1|2|3|4|5)
# EAPI=4 makes die behavior clear
;;
*)
die "Unsupported EAPI=${EAPI} (unknown) for ${ECLASS}"
;;
esac
if [[ ${_PYTHON_ECLASS_INHERITED} ]]; then
die 'python-r1 suite eclasses can not be used with python.eclass.'
fi
if [[ ! ${_PYTHON_UTILS_R1} ]]; then
inherit multilib
# @ECLASS-VARIABLE: _PYTHON_ALL_IMPLS
# @INTERNAL
# @DESCRIPTION:
# All supported Python implementations, most preferred last.
_PYTHON_ALL_IMPLS=(
jython2_5
pypy1_8 pypy1_9
python3_1 python3_2 python3_3
python2_5 python2_6 python2_7
)
# @ECLASS-VARIABLE: PYTHON
# @DESCRIPTION:
# The absolute path to the current Python interpreter.
#
# Set and exported only in commands run by python_foreach_impl().
#
# Example value:
# @CODE
# /usr/bin/python2.6
# @CODE
# @ECLASS-VARIABLE: EPYTHON
# @DESCRIPTION:
# The executable name of the current Python interpreter.
#
# This variable is used consistently with python.eclass.
#
# Set and exported only in commands run by python_foreach_impl().
#
# Example value:
# @CODE
# python2.6
# @CODE
# @ECLASS-VARIABLE: PYTHON_SITEDIR
# @DESCRIPTION:
# The path to Python site-packages directory.
#
# Set and exported on request using python_export().
#
# Example value:
# @CODE
# /usr/lib64/python2.6/site-packages
# @CODE
# @FUNCTION: python_export
# @USAGE: [<impl>] <variables>...
# @DESCRIPTION:
# Set and export the Python implementation-relevant variables passed
# as parameters.
#
# The optional first parameter may specify the requested Python
# implementation (either as PYTHON_TARGETS value, e.g. python2_7,
# or an EPYTHON one, e.g. python2.7). If no implementation passed,
# the current one will be obtained from ${EPYTHON}.
#
# The variables which can be exported are: PYTHON, EPYTHON,
# PYTHON_SITEDIR. They are described more completely in the eclass
# variable documentation.
python_export() {
debug-print-function ${FUNCNAME} "${@}"
local impl var
case "${1}" in
python*|jython*)
impl=${1/_/.}
shift
;;
pypy-c*)
impl=${1}
shift
;;
pypy*)
local v=${1#pypy}
impl=pypy-c${v/_/.}
shift
;;
*)
impl=${EPYTHON}
[[ ${impl} ]] || die "python_export: no impl nor EPYTHON"
;;
esac
debug-print "${FUNCNAME}: implementation: ${impl}"
for var; do
case "${var}" in
EPYTHON)
export EPYTHON=${impl}
debug-print "${FUNCNAME}: EPYTHON = ${EPYTHON}"
;;
PYTHON)
export PYTHON=${EPREFIX}/usr/bin/${impl}
debug-print "${FUNCNAME}: PYTHON = ${PYTHON}"
;;
PYTHON_SITEDIR)
local dir
case "${impl}" in
python*)
dir=/usr/$(get_libdir)/${impl}
;;
jython*)
dir=/usr/share/${impl}/Lib
;;
pypy*)
dir=/usr/$(get_libdir)/${impl/-c/}
;;
esac
export PYTHON_SITEDIR=${EPREFIX}${dir}/site-packages
debug-print "${FUNCNAME}: PYTHON_SITEDIR = ${PYTHON_SITEDIR}"
;;
*)
die "python_export: unknown variable ${var}"
esac
done
}
# @FUNCTION: python_get_PYTHON
# @USAGE: [<impl>]
# @DESCRIPTION:
# Obtain and print the path to the Python interpreter for the given
# implementation. If no implementation is provided, ${EPYTHON} will
# be used.
#
# If you just need to have PYTHON set (and exported), then it is better
# to use python_export() directly instead.
python_get_PYTHON() {
debug-print-function ${FUNCNAME} "${@}"
python_export "${@}" PYTHON
echo "${PYTHON}"
}
# @FUNCTION: python_get_EPYTHON
# @USAGE: <impl>
# @DESCRIPTION:
# Obtain and print the EPYTHON value for the given implementation.
#
# If you just need to have EPYTHON set (and exported), then it is better
# to use python_export() directly instead.
python_get_EPYTHON() {
debug-print-function ${FUNCNAME} "${@}"
python_export "${@}" EPYTHON
echo "${EPYTHON}"
}
# @FUNCTION: python_get_sitedir
# @USAGE: [<impl>]
# @DESCRIPTION:
# Obtain and print the 'site-packages' path for the given
# implementation. If no implementation is provided, ${EPYTHON} will
# be used.
#
# If you just need to have PYTHON_SITEDIR set (and exported), then it is
# better to use python_export() directly instead.
python_get_sitedir() {
debug-print-function ${FUNCNAME} "${@}"
python_export "${@}" PYTHON_SITEDIR
echo "${PYTHON_SITEDIR}"
}
# @FUNCTION: _python_rewrite_shebang
# @INTERNAL
# @USAGE: [<EPYTHON>] <path>...
# @DESCRIPTION:
# Replaces 'python' executable in the shebang with the executable name
# of the specified interpreter. If no EPYTHON value (implementation) is
# used, the current ${EPYTHON} will be used.
#
# All specified files must start with a 'python' shebang. A file not
# having a matching shebang will be refused. The exact shebang style
# will be preserved in order not to break anything.
#
# Example conversions:
# @CODE
# From: #!/usr/bin/python -R
# To: #!/usr/bin/python2.7 -R
#
# From: #!/usr/bin/env FOO=bar python
# To: #!/usr/bin/env FOO=bar python2.7
# @CODE
_python_rewrite_shebang() {
debug-print-function ${FUNCNAME} "${@}"
local impl
case "${1}" in
python*|jython*|pypy-c*)
impl=${1}
shift
;;
*)
impl=${EPYTHON}
[[ ${impl} ]] || die "${FUNCNAME}: no impl nor EPYTHON"
;;
esac
debug-print "${FUNCNAME}: implementation: ${impl}"
local f
for f; do
local shebang=$(head -n 1 "${f}")
debug-print "${FUNCNAME}: path = ${f}"
debug-print "${FUNCNAME}: shebang = ${shebang}"
if [[ "${shebang} " != *'python '* ]]; then
eerror "A file does not seem to have a supported shebang:"
eerror " file: ${f}"
eerror " shebang: ${shebang}"
die "${FUNCNAME}: ${f} does not seem to have a valid shebang"
fi
sed -i -e "1s:python:${impl}:" "${f}" || die
done
}
# @FUNCTION: _python_ln_rel
# @INTERNAL
# @USAGE: <from> <to>
# @DESCRIPTION:
# Create a relative symlink.
_python_ln_rel() {
debug-print-function ${FUNCNAME} "${@}"
local from=${1}
local to=${2}
local frpath=${from%/*}/
local topath=${to%/*}/
local rel_path=
# remove double slashes
frpath=${frpath/\/\///}
topath=${topath/\/\///}
while [[ ${topath} ]]; do
local frseg=${frpath%%/*}
local toseg=${topath%%/*}
if [[ ${frseg} != ${toseg} ]]; then
rel_path=../${rel_path}${frseg:+${frseg}/}
fi
frpath=${frpath#${frseg}/}
topath=${topath#${toseg}/}
done
rel_path+=${frpath}${1##*/}
debug-print "${FUNCNAME}: ${from} -> ${to}"
debug-print "${FUNCNAME}: rel_path = ${rel_path}"
ln -fs "${rel_path}" "${to}"
}
# @FUNCTION: python_optimize
# @USAGE: [<directory>...]
# @DESCRIPTION:
# Compile and optimize Python modules in specified directories (absolute
# paths). If no directories are provided, the default system paths
# are used (prepended with ${D}).
python_optimize() {
debug-print-function ${FUNCNAME} "${@}"
[[ ${EPYTHON} ]] || die 'No Python implementation set (EPYTHON is null).'
local PYTHON=${PYTHON}
[[ ${PYTHON} ]] || python_export PYTHON
# Note: python2.6 can't handle passing files to compileall...
# default to sys.path
if [[ ${#} -eq 0 ]]; then
local f
while IFS= read -r -d '' f; do
# 1) accept only absolute paths
# (i.e. skip '', '.' or anything like that)
# 2) skip paths which do not exist
# (python2.6 complains about them verbosely)
if [[ ${f} == /* && -d ${D}${f} ]]; then
set -- "${D}${f}" "${@}"
fi
done < <("${PYTHON}" -c 'import sys; print("\0".join(sys.path))')
fi
local d
for d; do
# make sure to get a nice path without //
local instpath=${d#${D}}
instpath=/${instpath##/}
case "${EPYTHON}" in
python*)
"${PYTHON}" -m compileall -q -f -d "${instpath}" "${d}"
"${PYTHON}" -OO -m compileall -q -f -d "${instpath}" "${d}"
;;
*)
"${PYTHON}" -m compileall -q -f -d "${instpath}" "${@}"
;;
esac
done
}
# @ECLASS-VARIABLE: python_scriptroot
# @DEFAULT_UNSET
# @DESCRIPTION:
# The current script destination for python_doscript(). The path
# is relative to the installation root (${ED}).
#
# When unset, ${DESTTREE}/bin (/usr/bin by default) will be used.
#
# Can be set indirectly through the python_scriptinto() function.
#
# Example:
# @CODE
# src_install() {
# local python_scriptroot=${GAMES_BINDIR}
# python_foreach_impl python_doscript foo
# }
# @CODE
# @FUNCTION: python_scriptinto
# @USAGE: <new-path>
# @DESCRIPTION:
# Set the current scriptroot. The new value will be stored
# in the 'python_scriptroot' environment variable. The new value need
# be relative to the installation root (${ED}).
#
# Alternatively, you can set the variable directly.
python_scriptinto() {
debug-print-function ${FUNCNAME} "${@}"
python_scriptroot=${1}
}
# @FUNCTION: python_doscript
# @USAGE: <files>...
# @DESCRIPTION:
# Install the given scripts into current python_scriptroot,
# for the current Python implementation (${EPYTHON}).
#
# All specified files must start with a 'python' shebang. The shebang
# will be converted, the file will be renamed to be EPYTHON-suffixed
# and a wrapper will be installed in place of the original name.
#
# Example:
# @CODE
# src_install() {
# python_foreach_impl python_doscript ${PN}
# }
# @CODE
python_doscript() {
debug-print-function ${FUNCNAME} "${@}"
[[ ${EPYTHON} ]] || die 'No Python implementation set (EPYTHON is null).'
local d=${python_scriptroot:-${DESTTREE}/bin}
local INSDESTTREE INSOPTIONS
insinto "${d}"
insopts -m755
local f
for f; do
local oldfn=${f##*/}
local newfn=${oldfn}-${EPYTHON}
debug-print "${FUNCNAME}: ${oldfn} -> ${newfn}"
newins "${f}" "${newfn}" || die
_python_rewrite_shebang "${D}/${d}/${newfn}"
# install the wrapper
_python_ln_rel "${ED}"/usr/bin/python-exec "${D}/${d}/${oldfn}" || die
done
}
# @ECLASS-VARIABLE: python_moduleroot
# @DEFAULT_UNSET
# @DESCRIPTION:
# The current module root for python_domodule(). The path can be either
# an absolute system path (it must start with a slash, and ${D} will be
# prepended to it) or relative to the implementation's site-packages directory
# (then it must start with a non-slash character).
#
# When unset, the modules will be installed in the site-packages root.
#
# Can be set indirectly through the python_moduleinto() function.
#
# Example:
# @CODE
# src_install() {
# local python_moduleroot=bar
# # installs ${PYTHON_SITEDIR}/bar/baz.py
# python_foreach_impl python_domodule baz.py
# }
# @CODE
# @FUNCTION: python_moduleinto
# @USAGE: <new-path>
# @DESCRIPTION:
# Set the current module root. The new value will be stored
# in the 'python_moduleroot' environment variable. The new value need
# be relative to the site-packages root.
#
# Alternatively, you can set the variable directly.
python_moduleinto() {
debug-print-function ${FUNCNAME} "${@}"
python_moduleroot=${1}
}
# @FUNCTION: python_domodule
# @USAGE: <files>...
# @DESCRIPTION:
# Install the given modules (or packages) into the current
# python_moduleroot. The list can mention both modules (files)
# and packages (directories). All listed files will be installed
# for all enabled implementations, and compiled afterwards.
#
# Example:
# @CODE
# src_install() {
# # (${PN} being a directory)
# python_foreach_impl python_domodule ${PN}
# }
# @CODE
python_domodule() {
debug-print-function ${FUNCNAME} "${@}"
[[ ${EPYTHON} ]] || die 'No Python implementation set (EPYTHON is null).'
local d
if [[ ${python_moduleroot} == /* ]]; then
# absolute path
d=${python_moduleroot}
else
# relative to site-packages
local PYTHON_SITEDIR=${PYTHON_SITEDIR}
[[ ${PYTHON_SITEDIR} ]] || python_export PYTHON_SITEDIR
d=${PYTHON_SITEDIR}/${python_moduleroot}
fi
local INSDESTTREE
insinto "${d}"
doins -r "${@}" || die
python_optimize "${D}/${d}"
}
_PYTHON_UTILS_R1=1
fi

View File

@ -0,0 +1,29 @@
#!/bin/bash
source tests-common.sh
inherit autotools
test-it() {
tbegin "eaclocal_amflags $1: $2"
printf "ACLOCAL_AMFLAGS = %b\n" "$2" > Makefile.am
local flags=$(eaclocal_amflags) exp=${3:-$2}
[[ "${flags}" == "${exp}" ]]
if ! tend $? ; then
printf '### INPUT:\n%s\n' "$2"
printf '### FILE:\n%s\n' "$(<Makefile.am)"
printf '### EXPECTED:\n%s\n' "${exp}"
printf '### ACTUAL:\n%s\n' "${flags}"
fi
rm Makefile.am
}
test-it simple "-Im4"
test-it simple "-I m4 -I lakdjfladsfj /////"
test-it shell-exec '`echo hi`' "hi"
test-it shell-exec '`echo {0..3}`' "0 1 2 3"
test-it multiline '-I oneline \\\n\t-I twoline' "-I oneline -I twoline"
texit

View File

@ -0,0 +1,30 @@
#!/bin/bash
EAPI=4
PYTHON_COMPAT=( python2_7 )
source tests-common.sh
test-phase_name_free() {
local ph=${1}
if declare -f "${ph}"; then
die "${ph} function declared while name reserved for phase!"
fi
if declare -f "${ph}_all"; then
die "${ph}_all function declared while name reserved for phase!"
fi
}
inherit distutils-r1
tbegin "sane function names"
test-phase_name_free python_prepare
test-phase_name_free python_configure
test-phase_name_free python_compile
test-phase_name_free python_test
test-phase_name_free python_install
tend ${failed}
texit

View File

@ -0,0 +1,44 @@
#!/bin/bash
source tests-common.sh
inherit eutils
test-it() {
local s0 s1 s2
tbegin "push/pop '$*'"
s0=$(shopt -p)
t eshopts_push $*
s1=$(shopt -p)
t eshopts_pop
s2=$(shopt -p)
[[ ${s0} == "${s2}" ]] && \
[[ ${s1} == *"shopt $*"* ]]
tend $?
}
# should handle bug #395025
for arg in nullglob dotglob extglob ; do
for flag in s u ; do
test-it -${flag} ${arg}
done
done
tbegin "multi push/pop"
s0=$(shopt -p)
t eshopts_push -s dotglob
t eshopts_push -u dotglob
t eshopts_push -s extglob
t eshopts_push -u dotglob
t eshopts_push -s dotglob
t eshopts_pop
t eshopts_pop
t eshopts_pop
t eshopts_pop
t eshopts_pop
s1=$(shopt -p)
[[ ${s0} == "${s1}" ]]
tend $?
texit

View File

@ -0,0 +1,50 @@
#!/bin/bash
source tests-common.sh
inherit eutils
tbegin "initial stack state"
estack_pop teststack
# Should be empty and thus return 1
[[ $? -eq 1 ]]
tend $?
tbegin "simple push/pop"
estack_push ttt 1
pu=$?
estack_pop ttt
po=$?
[[ ${pu}${po} == "00" ]]
tend $?
tbegin "simple push/pop var"
estack_push xxx "boo ga boo"
pu=$?
estack_pop xxx i
po=$?
[[ ${pu}${po} == "00" ]] && [[ ${i} == "boo ga boo" ]]
tend $?
tbegin "multi push/pop"
estack_push yyy {1..10}
pu=$?
i=0
while estack_pop yyy ; do
: $(( i++ ))
done
[[ ${pu} -eq 0 && ${i} -eq 10 ]]
tend $?
tbegin "umask push/pop"
u0=$(umask)
eumask_push 0000
pu=$?
u1=$(umask)
eumask_pop
po=$?
u2=$(umask)
[[ ${pu}${po}:${u0}:${u1}:${u2} == "00:${u0}:0000:${u0}" ]]
tend $?
texit

View File

@ -0,0 +1,33 @@
#!/bin/bash
source tests-common.sh
inherit eutils
test-path_exists() {
local exp=$1; shift
tbegin "path_exists($*) == ${exp}"
path_exists "$@"
[[ ${exp} -eq $? ]]
tend $?
}
test-path_exists 1
test-path_exists 1 -a
test-path_exists 1 -o
good="/ . tests-common.sh /bin/bash"
test-path_exists 0 ${good}
test-path_exists 0 -a ${good}
test-path_exists 0 -o ${good}
bad="/asjdkfljasdlfkja jlakjdsflkasjdflkasdjflkasdjflaskdjf"
test-path_exists 1 ${bad}
test-path_exists 1 -a ${bad}
test-path_exists 1 -o ${bad}
test-path_exists 1 ${good} ${bad}
test-path_exists 1 -a ${good} ${bad}
test-path_exists 0 -o ${good} ${bad}
texit

View File

@ -0,0 +1,119 @@
#!/bin/bash
source tests-common.sh
inherit flag-o-matic
CFLAGS="-a -b -c=1"
CXXFLAGS="-x -y -z=2"
LDFLAGS="-l -m -n=3"
ftend() {
local ret=$?
local msg="Failed; flags are:"
local flag
for flag in $(all-flag-vars) ; do
msg+=$'\n\t'"${flag}=${!flag}"
done
tend ${ret} "${msg}"
}
tbegin "is-flag"
! (is-flag 1 2 3) 2>/dev/null
ftend
tbegin "is-ldflag"
! (is-ldflag 1 2 3) 2>/dev/null
ftend
while read exp flag ; do
[[ -z ${exp}${flag} ]] && continue
tbegin "is-flagq ${flag}"
is-flagq ${flag}
[[ ${exp} -eq $? ]]
ftend
done <<<"
1 -L
0 -a
0 -x
"
while read exp flag ; do
[[ -z ${exp}${flag} ]] && continue
tbegin "is-ldflagq ${flag}"
is-ldflagq "${flag}"
[[ ${exp} -eq $? ]]
ftend
done <<<"
1 -a
0 -n=*
1 -n
"
tbegin "strip-unsupported-flags"
strip-unsupported-flags
[[ ${CFLAGS} == "" ]] && [[ ${CXXFLAGS} == "-z=2" ]]
ftend
for var in $(all-flag-vars) ; do
eval ${var}=\"-filter -filter-glob -foo-${var%FLAGS}\"
done
tbegin "filter-flags basic"
filter-flags -filter
(
for var in $(all-flag-vars) ; do
val=${!var}
[[ ${val} == "-filter-glob -foo-${var%FLAGS}" ]] || exit 1
done
)
ftend
tbegin "filter-flags glob"
filter-flags '-filter-*'
(
for var in $(all-flag-vars) ; do
val=${!var}
[[ ${val} == "-foo-${var%FLAGS}" ]] || exit 1
done
)
ftend
tbegin "strip-flags basic"
CXXFLAGS+=" -O999 "
strip-flags
[[ -z ${CFLAGS}${LDFLAGS}${CPPFLAGS} && ${CXXFLAGS} == "-O2" ]]
ftend
tbegin "replace-flags basic"
CFLAGS="-O0 -foo"
replace-flags -O0 -O1
[[ ${CFLAGS} == "-O1 -foo" ]]
ftend
tbegin "replace-flags glob"
CXXFLAGS="-O0 -mcpu=bad -cow"
replace-flags '-mcpu=*' -mcpu=good
[[ ${CXXFLAGS} == "-O0 -mcpu=good -cow" ]]
ftend
tbegin "append-cflags basic"
CFLAGS=
append-cflags -O0
[[ ${CFLAGS} == "-O0" ]]
ftend
tbegin "append-cflags -DFOO='a b c'"
CFLAGS=
append-cflags '-DFOO="a b c"'
[[ ${CFLAGS} == '-DFOO="a b c"' ]]
ftend
tbegin "raw-ldflags"
LDFLAGS='-Wl,-O1 -Wl,--as-needed -Wl,-z,now -flto'
LDFLAGS=$(raw-ldflags)
[[ ${LDFLAGS} == '-O1 --as-needed -z now' ]]
ftend
texit

View File

@ -0,0 +1,40 @@
#!/bin/bash
source tests-common.sh
inherit multiprocessing
tbegin "simple"
MAKEOPTS="-j1" multijob_init
multijob_child_init ls -d / >/dev/null || die "fail!"
multijob_finish
tend $?
tbegin "less simple"
multijob_init -j3
multijob_child_init true || die "fail!"
multijob_child_init false || die "fail!"
multijob_child_init true || die "fail!"
multijob_finish
tend $(( $? == 1 ? 0 : 1 ))
tbegin "less less simple"
multijob_init -j1
multijob_child_init true || die "fail!"
multijob_child_init false || die "fail!"
multijob_child_init true && die "fail!"
multijob_finish
tend $?
tbegin "less less less simple"
multijob_init -j10
multijob_child_init true || die "fail!"
multijob_finish_one || die "fail!"
multijob_child_init false || die "fail!"
multijob_finish_one && die "fail!"
multijob_child_init true || die "fail!"
multijob_finish_one || die "fail!"
multijob_finish
tend $?
texit

View File

@ -0,0 +1,36 @@
#!/bin/bash
source tests-common.sh
inherit multiprocessing
test-makeopts_jobs() {
local exp=$1; shift
tbegin "makeopts_jobs($*) == ${exp}"
local act=$(makeopts_jobs "$@")
[[ ${act} == "${exp}" ]]
tend $? "Got back: ${act}"
}
tests=(
999 "-j"
999 "--jobs"
1 ""
1 "-l9 -w"
1 "-l9 -w-j4"
1 "-l9--jobs=3"
1 "-l9--jobs=8"
2 "-j2"
3 "-j 3"
4 "-l3 -j 4 -w"
5 "--jobs=5"
6 "--jobs 6"
7 "-l3 --jobs 7 -w"
4 "-j1 -j 2 --jobs 3 --jobs=4"
8 " -j 8 "
)
for (( i = 0; i < ${#tests[@]}; i += 2 )) ; do
test-makeopts_jobs "${tests[i]}" "${tests[i+1]}"
done
texit

View File

@ -0,0 +1,76 @@
#!/bin/bash
source tests-common.sh
inherit savedconfig
quiet() {
local out ret
out=$("$@" 2>&1)
ret=$?
[[ ${ret} -eq 0 ]] || echo "${out}"
return ${ret}
}
sc() { EBUILD_PHASE=install quiet save_config "$@" ; }
rc() { EBUILD_PHASE=prepare quiet restore_config "$@" ; }
cleanup() { rm -rf "${ED}"/* "${T}"/* "${WORKDIR}"/* ; }
test-it() {
local ret=0
tbegin "$@"
mkdir -p "${ED}"/etc/portage/savedconfig
: $(( ret |= $? ))
pushd "${WORKDIR}" >/dev/null
: $(( ret |= $? ))
test
: $(( ret |= $? ))
popd >/dev/null
: $(( ret |= $? ))
tend ${ret}
cleanup
}
test() {
touch f || return 1
sc f || return 1
[[ -f ${ED}/etc/portage/savedconfig/${CATEGORY}/${PF} ]]
}
test-it "simple save_config"
test() {
touch a b c || return 1
sc a b c || return 1
[[ -d ${ED}/etc/portage/savedconfig/${CATEGORY}/${PF} ]]
}
test-it "multi save_config"
test() {
mkdir dir || return 1
touch dir/{a,b,c} || return 1
sc dir || return 1
[[ -d ${ED}/etc/portage/savedconfig/${CATEGORY}/${PF} ]]
}
test-it "dir save_config"
PORTAGE_CONFIGROOT=${D}
test() {
echo "ggg" > f || return 1
rc f || return 1
[[ $(<f) == "ggg" ]]
}
test-it "simple restore_config"
test() {
echo "ggg" > f || return 1
rc f || return 1
[[ $(<f) == "ggg" ]] || return 1
sc f || return 1
echo "hhh" > f || return 1
rc f || return 1
[[ $(<f) == "ggg" ]]
}
test-it "simple restore+save config"
texit

View File

@ -0,0 +1,61 @@
#!/bin/bash
source tests-common.sh
inherit scons-utils
test-scons_clean_makeopts() {
local sconsopts=$(scons_clean_makeopts ${1})
if [[ ${sconsopts} != ${2-${1}} ]]; then
eerror "Self-test failed:"
eindent
eerror "MAKEOPTS: ${1}"
eerror "Expected: ${2-${1}}"
eerror "Actual: ${sconsopts}"
eoutdent
(( ++failed ))
return 1
fi
return 0
}
# jobcount expected for non-specified state
jc=5
# failed test counter
failed=0
tbegin "scons_clean_makeopts()"
# sane MAKEOPTS
test-scons_clean_makeopts '--jobs=14 -k'
test-scons_clean_makeopts '--jobs=14 -k'
test-scons_clean_makeopts '--jobs 15 -k'
test-scons_clean_makeopts '--jobs=16 --keep-going'
test-scons_clean_makeopts '-j17 --keep-going'
test-scons_clean_makeopts '-j 18 --keep-going'
# needing cleaning
test-scons_clean_makeopts '--jobs -k' "--jobs=${jc} -k"
test-scons_clean_makeopts '--jobs --keep-going' "--jobs=${jc} --keep-going"
test-scons_clean_makeopts '-kj' "-kj ${jc}"
# broken by definition (but passed as it breaks make as well)
test-scons_clean_makeopts '-jk'
test-scons_clean_makeopts '--jobs=randum'
test-scons_clean_makeopts '-kjrandum'
# needing stripping
test-scons_clean_makeopts '--load-average=25 -kj16' '-kj16'
test-scons_clean_makeopts '--load-average 25 -k -j17' '-k -j17'
test-scons_clean_makeopts '-j2 HOME=/tmp' '-j2'
test-scons_clean_makeopts '--jobs funnystuff -k' "--jobs=${jc} -k"
# bug #388961
test-scons_clean_makeopts '--jobs -l3' "--jobs=${jc}"
test-scons_clean_makeopts '-j -l3' "-j ${jc}"
tend ${failed}
texit

View File

@ -0,0 +1,133 @@
#!/bin/bash
if ! source /etc/init.d/functions.sh ; then
echo "Missing functions.sh. Please to install!" 1>&2
exit 1
fi
inherit() {
local e
for e in "$@" ; do
source ../${e}.eclass
done
}
EXPORT_FUNCTIONS() { :; }
debug-print() {
[[ ${#} -eq 0 ]] && return
if [[ ${ECLASS_DEBUG_OUTPUT} == on ]]; then
printf 'debug: %s\n' "${@}" >&2
elif [[ -n ${ECLASS_DEBUG_OUTPUT} ]]; then
printf 'debug: %s\n' "${@}" >> "${ECLASS_DEBUG_OUTPUT}"
fi
}
debug-print-function() {
debug-print "${1}, parameters: ${*:2}"
}
debug-print-section() {
debug-print "now in section ${*}"
}
has() {
local needle=$1
shift
local x
for x in "$@"; do
[ "${x}" = "${needle}" ] && return 0
done
return 1
}
use() { has "$1" ${IUSE} ; }
die() {
echo "die: $*" 1>&2
exit 1
}
has_version() {
portageq has_version / "$@"
}
KV_major() {
[[ -z $1 ]] && return 1
local KV=$@
echo "${KV%%.*}"
}
KV_minor() {
[[ -z $1 ]] && return 1
local KV=$@
KV=${KV#*.}
echo "${KV%%.*}"
}
KV_micro() {
[[ -z $1 ]] && return 1
local KV=$@
KV=${KV#*.*.}
echo "${KV%%[^[:digit:]]*}"
}
KV_to_int() {
[[ -z $1 ]] && return 1
local KV_MAJOR=$(KV_major "$1")
local KV_MINOR=$(KV_minor "$1")
local KV_MICRO=$(KV_micro "$1")
local KV_int=$(( KV_MAJOR * 65536 + KV_MINOR * 256 + KV_MICRO ))
# We make version 2.2.0 the minimum version we will handle as
# a sanity check ... if its less, we fail ...
if [[ ${KV_int} -ge 131584 ]] ; then
echo "${KV_int}"
return 0
fi
return 1
}
tret=0
tbegin() {
ebegin "Testing $*"
}
texit() {
rm -rf "${tmpdir}"
exit ${tret}
}
tend() {
t eend "$@"
}
t() {
"$@"
local ret=$?
: $(( tret |= ${ret} ))
return ${ret}
}
tmpdir="${PWD}/tmp"
pkg_root="${tmpdir}/$0/${RANDOM}"
T="${pkg_root}/temp"
D="${pkg_root}/image"
WORKDIR="${pkg_root}/work"
ED=${D}
mkdir -p "${D}" "${T}" "${WORKDIR}"
dodir() {
mkdir -p "${@/#/${ED}/}"
}
elog() { einfo "$@" ; }
IUSE=""
CATEGORY="dev-eclass"
PN="tests"
PV="0"
P="${PN}-${PV}"
PF=${P}

View File

@ -0,0 +1,59 @@
#!/bin/bash
source tests-common.sh
inherit toolchain-funcs
#
# TEST: tc-arch-kernel
#
test-tc-arch-kernel() {
local ret=0
KV=$1 ; shift
for CHOST in "$@" ; do
exp=${CHOST##*:}
CHOST=${CHOST%%:*}
actual=$(tc-arch-kernel)
if [[ ${actual} != ${exp:-${CHOST}} ]] ; then
eerror "Failure for CHOST: ${CHOST} Expected: ${exp} != Actual: ${actual}"
((++ret))
fi
done
return ${ret}
}
tbegin "tc-arch-kernel() (KV=2.6.0)"
test-tc-arch-kernel 2.6.0 \
alpha arm{,eb}:arm avr32 bfin:blackfin cris hppa:parisc \
i{3..6}86:i386 ia64 m68k mips{,eb}:mips nios2 powerpc:ppc powerpc64:ppc64 \
s390{,x}:s390 sh{1..4}{,eb}:sh sparc{,64} vax x86_64 \
i{3..6}86-gentoo-freebsd:i386
tend $?
tbegin "tc-arch-kernel() (KV=2.6.30)"
test-tc-arch-kernel 2.6.30 \
i{3..6}86:x86 x86_64:x86 \
powerpc{,64}:powerpc i{3..6}86-gentoo-freebsd:i386
tend $?
#
# TEST: tc-arch
#
tbegin "tc-arch"
ret=0
for CHOST in \
alpha arm{,eb}:arm avr32:avr bfin cris hppa i{3..6}86:x86 ia64 m68k \
mips{,eb}:mips nios2 powerpc:ppc powerpc64:ppc64 s390{,x}:s390 \
sh{1..4}{,eb}:sh sparc{,64}:sparc vax x86_64:amd64
do
exp=${CHOST##*:}
CHOST=${CHOST%%:*}
actual=$(tc-arch)
if [[ ${actual} != ${exp:-${CHOST}} ]] ; then
eerror "Failure for CHOST: ${CHOST} Expected: ${exp} != Actual: ${actual}"
((++ret))
fi
done
tend ${ret}
texit

View File

@ -0,0 +1,197 @@
#!/bin/bash
source tests-common.sh
inherit versionator
eshopts_push -s extglob
ver=( "" "lt" "eq" "gt" )
lt=1 eq=2 gt=3
test_version_compare() {
tbegin "version_compare ${1} -${ver[${2}]} ${3}"
version_compare "${1}" "${3}"
local r=$?
[[ ${r} -eq ${2} ]]
tend $? "FAIL: ${@} (got ${r} exp ${2})"
}
echo "
0 $lt 1
1 $lt 2
2 $gt 1
2 $eq 2
0 $eq 0
10 $lt 20
68 $eq 068
068 $gt 67
068 $lt 69
1.0 $lt 2.0
2.0 $eq 2.0
2.0 $gt 1.0
1.0 $gt 0.0
0.0 $eq 0.0
0.0 $lt 1.0
0.1 $lt 0.2
0.2 $eq 0.2
0.3 $gt 0.2
1.2 $lt 2.1
2.1 $gt 1.2
1.2.3 $lt 1.2.4
1.2.4 $gt 1.2.3
1.2.0 $gt 1.2
1.2.1 $gt 1.2
1.2 $lt 1.2.1
1.2b $eq 1.2b
1.2b $lt 1.2c
1.2b $gt 1.2a
1.2b $gt 1.2
1.2 $lt 1.2a
1.3 $gt 1.2a
1.3 $lt 1.3a
1.0_alpha7 $lt 1.0_beta7
1.0_beta $lt 1.0_pre
1.0_pre5 $lt 1.0_rc2
1.0_rc2 $lt 1.0
1.0_p1 $gt 1.0
1.0_p1-r1 $gt 1.0_p1
1.0_alpha6-r1 $gt 1.0_alpha6
1.0_beta6-r1 $gt 1.0_alpha6-r2
1.0_pre1 $lt 1.0_p1
1.0p $gt 1.0_p1
1.0r $gt 1.0-r1
1.6.15 $gt 1.6.10-r2
1.6.10-r2 $lt 1.6.15
" | while read a b c ; do
[[ -z "${a}${b}${c}" ]] && continue
test_version_compare "${a}" "${b}" "${c}"
done
for q in "alpha beta pre rc=${lt};${gt}" "p=${gt};${lt}" ; do
for p in ${q%%=*} ; do
c=${q##*=}
alt=${c%%;*} agt=${c##*;}
test_version_compare "1.0" $agt "1.0_${p}"
test_version_compare "1.0" $agt "1.0_${p}1"
test_version_compare "1.0" $agt "1.0_${p}068"
test_version_compare "2.0_${p}" $alt "2.0"
test_version_compare "2.0_${p}1" $alt "2.0"
test_version_compare "2.0_${p}068" $alt "2.0"
test_version_compare "1.0_${p}" $eq "1.0_${p}"
test_version_compare "0.0_${p}" $lt "0.0_${p}1"
test_version_compare "666_${p}3" $gt "666_${p}"
test_version_compare "1_${p}7" $lt "1_${p}8"
test_version_compare "1_${p}7" $eq "1_${p}7"
test_version_compare "1_${p}7" $gt "1_${p}6"
test_version_compare "1_${p}09" $eq "1_${p}9"
test_version_compare "1_${p}7-r0" $eq "1_${p}7"
test_version_compare "1_${p}7-r0" $lt "1_${p}7-r1"
test_version_compare "1_${p}7-r0" $lt "1_${p}7-r01"
test_version_compare "1_${p}7-r01" $eq "1_${p}7-r1"
test_version_compare "1_${p}8-r1" $gt "1_${p}7-r100"
test_version_compare "1_${p}_alpha" $lt "1_${p}_beta"
done
done
for p in "-r" "_p" ; do
test_version_compare "7.2${p}1" $lt "7.2${p}2"
test_version_compare "7.2${p}2" $gt "7.2${p}1"
test_version_compare "7.2${p}3" $gt "7.2${p}2"
test_version_compare "7.2${p}2" $lt "7.2${p}3"
done
# The following tests all come from portage's test cases:
test_version_compare "6.0" $gt "5.0"
test_version_compare "5.0" $gt "5"
test_version_compare "1.0-r1" $gt "1.0-r0"
test_version_compare "1.0-r1" $gt "1.0"
test_version_compare "999999999999999999999999999999" $gt "999999999999999999999999999998"
test_version_compare "1.0.0" $gt "1.0"
test_version_compare "1.0.0" $gt "1.0b"
test_version_compare "1b" $gt "1"
test_version_compare "1b_p1" $gt "1_p1"
test_version_compare "1.1b" $gt "1.1"
test_version_compare "12.2.5" $gt "12.2b"
test_version_compare "4.0" $lt "5.0"
test_version_compare "5" $lt "5.0"
test_version_compare "1.0_pre2" $lt "1.0_p2"
test_version_compare "1.0_alpha2" $lt "1.0_p2"
test_version_compare "1.0_alpha1" $lt "1.0_beta1"
test_version_compare "1.0_beta3" $lt "1.0_rc3"
test_version_compare "1.001000000000000000001" $lt "1.001000000000000000002"
test_version_compare "1.00100000000" $lt "1.0010000000000000001"
test_version_compare "999999999999999999999999999998" $lt "999999999999999999999999999999"
test_version_compare "1.01" $lt "1.1"
test_version_compare "1.0-r0" $lt "1.0-r1"
test_version_compare "1.0" $lt "1.0-r1"
test_version_compare "1.0" $lt "1.0.0"
test_version_compare "1.0b" $lt "1.0.0"
test_version_compare "1_p1" $lt "1b_p1"
test_version_compare "1" $lt "1b"
test_version_compare "1.1" $lt "1.1b"
test_version_compare "12.2b" $lt "12.2.5"
test_version_compare "4.0" $eq "4.0"
test_version_compare "1.0" $eq "1.0"
test_version_compare "1.0-r0" $eq "1.0"
test_version_compare "1.0" $eq "1.0-r0"
test_version_compare "1.0-r0" $eq "1.0-r0"
test_version_compare "1.0-r1" $eq "1.0-r1"
# The following were just tests for != in portage, we need something a bit
# more precise
test_version_compare "1" $lt "2"
test_version_compare "1.0_alpha" $lt "1.0_pre"
test_version_compare "1.0_beta" $gt "1.0_alpha"
test_version_compare "0" $lt "0.0"
test_version_compare "1.0-r0" $lt "1.0-r1"
test_version_compare "1.0-r1" $gt "1.0-r0"
test_version_compare "1.0" $lt "1.0-r1"
test_version_compare "1.0-r1" $gt "1.0"
test_version_compare "1_p1" $lt "1b_p1"
test_version_compare "1b" $gt "1"
test_version_compare "1.1b" $gt "1.1"
test_version_compare "12.2b" $gt "12.2"
# The following tests all come from paludis's test cases:
test_version_compare "1.0" $gt "1"
test_version_compare "1" $lt "1.0"
test_version_compare "1.0_alpha" $gt "1_alpha"
test_version_compare "1.0_alpha" $gt "1"
test_version_compare "1.0_alpha" $lt "1.0"
test_version_compare "1.2.0.0_alpha7-r4" $gt "1.2_alpha7-r4"
test_version_compare "0001" $eq "1"
test_version_compare "01" $eq "001"
test_version_compare "0001.1" $eq "1.1"
test_version_compare "01.01" $eq "1.01"
test_version_compare "1.010" $eq "1.01"
test_version_compare "1.00" $eq "1.0"
test_version_compare "1.0100" $eq "1.010"
test_version_compare "1" $eq "1-r0"
test_version_compare "1-r00" $eq "1-r0"
eshopts_pop
texit

View File

@ -0,0 +1,89 @@
# Copyright 1999-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/eclass/udev.eclass,v 1.6 2012/10/31 18:28:10 ssuominen Exp $
# @ECLASS: udev.eclass
# @MAINTAINER:
# udev-bugs@gentoo.org
# @BLURB: Default eclass for determining udev directories.
# @DESCRIPTION:
# Default eclass for determining udev directories.
# @EXAMPLE:
#
# @CODE
# inherit udev
#
# RDEPEND=">=sys-fs/udev-171-r6"
# DEPEND="${RDEPEND}"
#
# src_configure() {
# econf \
# --with-udevrulesdir="$(udev_get_udevdir)"/rules.d
# }
#
# src_install() {
# # udev_dorules contrib/99-foomatic
# udev_newrules contrib/98-foomatic 99-foomatic
# }
# @CODE
inherit toolchain-funcs
case ${EAPI:-0} in
0|1|2|3|4|5) ;;
*) die "${ECLASS}.eclass API in EAPI ${EAPI} not yet established."
esac
RDEPEND=""
DEPEND="virtual/pkgconfig"
# @FUNCTION: _udev_get_udevdir
# @INTERNAL
# @DESCRIPTION:
# Get unprefixed udevdir.
_udev_get_udevdir() {
if $($(tc-getPKG_CONFIG) --exists udev); then
echo "$($(tc-getPKG_CONFIG) --variable=udevdir udev)"
else
echo /lib/udev
fi
}
# @FUNCTION: udev_get_udevdir
# @DESCRIPTION:
# Output the path for the udev directory (not including ${D}).
# This function always succeeds, even if udev is not installed.
# The fallback value is set to /lib/udev
udev_get_udevdir() {
debug-print-function ${FUNCNAME} "${@}"
echo "$(_udev_get_udevdir)"
}
# @FUNCTION: udev_dorules
# @USAGE: rules [...]
# @DESCRIPTION:
# Install udev rule(s). Uses doins, thus it is fatal in EAPI 4
# and non-fatal in earlier EAPIs.
udev_dorules() {
debug-print-function ${FUNCNAME} "${@}"
(
insinto "$(_udev_get_udevdir)"/rules.d
doins "${@}"
)
}
# @FUNCTION: udev_newrules
# @USAGE: oldname newname
# @DESCRIPTION:
# Install udev rule with a new name. Uses newins, thus it is fatal
# in EAPI 4 and non-fatal in earlier EAPIs.
udev_newrules() {
debug-print-function ${FUNCNAME} "${@}"
(
insinto "$(_udev_get_udevdir)"/rules.d
newins "${@}"
)
}

View File

@ -0,0 +1,121 @@
# Copyright 1999-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/eclass/vala.eclass,v 1.4 2012/09/20 04:48:26 tetromino Exp $
# @ECLASS: vala.eclass
# @MAINTAINER:
# gnome@gentoo.org
# @AUTHOR:
# Alexandre Rostovtsev <tetromino@gentoo.org>
# @BLURB: Sets up the environment for using a specific version of vala.
# @DESCRIPTION:
# This eclass sets up commonly used environment variables for using a specific
# version of dev-lang/vala to configure and build a package. It is needed for
# packages whose build systems assume the existence of certain unversioned vala
# executables, pkgconfig files, etc., which Gentoo does not provide.
#
# This eclass provides one phase function: src_prepare.
inherit multilib
case "${EAPI:-0}" in
0) die "EAPI=0 is not supported" ;;
1) ;;
*) EXPORT_FUNCTIONS src_prepare ;;
esac
# @ECLASS-VARIABLE: VALA_MIN_API_VERSION
# @DESCRIPTION:
# Minimum vala API version (e.g. 0.16).
VALA_MIN_API_VERSION=${VALA_MIN_API_VERSION:-0.10}
# @ECLASS-VARIABLE: VALA_MAX_API_VERSION
# @DESCRIPTION:
# Maximum vala API version (e.g. 0.18).
VALA_MAX_API_VERSION=${VALA_MAX_API_VERSION:-0.18}
# @ECLASS-VARIABLE: VALA_USE_DEPEND
# @DEFAULT_UNSET
# @DESCRIPTION:
# USE dependencies that vala must be built with (e.g. vapigen).
# @FUNCTION: vala_api_versions
# @DESCRIPTION:
# Outputs a list of vala API versions from VALA_MAX_API_VERSION down to
# VALA_MIN_API_VERSION.
vala_api_versions() {
eval "echo 0.{${VALA_MAX_API_VERSION#0.}..${VALA_MIN_API_VERSION#0.}..2}"
}
# @FUNCTION: vala_depend
# @DESCRIPTION:
# Outputs a ||-dependency string on vala from VALA_MAX_API_VERSION down to
# VALA_MIN_API_VERSION
vala_depend() {
local u v versions=$(vala_api_versions)
[[ ${VALA_USE_DEPEND} ]] && u="[${VALA_USE_DEPEND}]"
echo -n "|| ("
for v in ${versions}; do
echo -n " dev-lang/vala:${v}${u}"
done
echo " )"
}
# @FUNCTION: vala_best_api_version
# @DESCRIPTION:
# Returns the highest installed vala API version satisfying
# VALA_MAX_API_VERSION, VALA_MIN_API_VERSION, and VALA_USE_DEPEND.
vala_best_api_version() {
local u v
[[ ${VALA_USE_DEPEND} ]] && u="[${VALA_USE_DEPEND}]"
for v in $(vala_api_versions); do
has_version "dev-lang/vala:${v}${u}" && echo "${v}" && return
done
}
# @FUNCTION: vala_src_prepare
# @USAGE: [--vala-api-version api_version]
# @DESCRIPTION:
# Sets up the environment variables and pkgconfig files for the
# specified API version, or, if no version is specified, for the
# highest installed vala API version satisfying
# VALA_MAX_API_VERSION, VALA_MIN_API_VERSION, and VALA_USE_DEPEND.
# Dies if called without --vala-api-version and no suitable vala
# version is found.
vala_src_prepare() {
local p d valafoo version
if [[ $1 = "--vala-api-version" ]]; then
version=$2
[[ ${version} ]] || die "'--vala-api-version' option requires API version parameter."
else
version=$(vala_best_api_version)
[[ ${version} ]] || die "No installed vala in $(vala_depend)"
fi
export VALAC=$(type -P valac-${version})
valafoo=$(type -P vala-gen-introspect-${version})
[[ ${valafoo} ]] && export VALA_GEN_INTROSPECT="${valafoo}"
valafoo=$(type -P vapigen-${version})
[[ ${valafoo} ]] && export VAPIGEN="${valafoo}"
valafoo="${EPREFIX}/usr/share/vala/Makefile.vapigen"
[[ -e ${valafoo} ]] && export VAPIGEN_MAKEFILE="${valafoo}"
export VAPIGEN_VAPIDIR="${EPREFIX}/usr/share/vala/vapi"
mkdir -p "${T}/pkgconfig" || die "mkdir failed"
for p in libvala vapigen; do
for d in "${EPREFIX}/usr/$(get_libdir)/pkgconfig" "${EPREFIX}/usr/share/pkgconfig"; do
if [[ -e ${d}/${p}-${version}.pc ]]; then
ln -s "${d}/${p}-${version}.pc" "${T}/pkgconfig/${p}.pc" || die "ln failed"
break
fi
done
done
: ${PKG_CONFIG_PATH:="${EPREFIX}/usr/$(get_libdir)/pkgconfig:${EPREFIX}/usr/share/pkgconfig"}
export PKG_CONFIG_PATH="${T}/pkgconfig:${PKG_CONFIG_PATH}"
}

View File

@ -0,0 +1,627 @@
# Copyright 1999-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/eclass/vdr-plugin-2.eclass,v 1.13 2012/09/29 19:38:56 hd_brummy Exp $
# @ECLASS: vdr-plugin-2.eclass
# @MAINTAINER:
# vdr@gentoo.org
# @BLURB: common vdr plugin ebuild functions
# @DESCRIPTION:
# Eclass for easing maitenance of vdr plugin ebuilds
# Authors:
# Matthias Schwarzott <zzam@gentoo.org>
# Joerg Bornkessel <hd_brummy@gentoo.org>
# Christian Ruppert <idl0r@gentoo.org>
# Plugin config file installation:
#
# A plugin config file can be specified through the $VDR_CONFD_FILE variable, it
# defaults to ${FILESDIR}/confd. Each config file will be installed as e.g.
# ${D}/etc/conf.d/vdr.${VDRPLUGIN}
# Installation of rc-addon files:
# NOTE: rc-addon files must be valid shell scripts!
#
# Installing rc-addon files is basically the same as for plugin config files
# (see above), it's just using the $VDR_RCADDON_FILE variable instead.
# The default value when $VDR_RCADDON_FILE is undefined is:
# ${FILESDIR}/rc-addon.sh and will be installed as
# ${VDR_RC_DIR}/plugin-${VDRPLUGIN}.sh
#
# The rc-addon files will be sourced by the startscript when the specific plugin
# has been enabled.
# rc-addon files may be used to prepare everything that is necessary for the
# plugin start/stop, like passing extra command line options and so on.
# Applying your own local/user patches:
# This is done by using the epatch_user() function of the eutils.eclass.
# Simply put your patches into one of these directories:
# /etc/portage/patches/<CATEGORY>/<PF|P|PN>/
# Quote: where the first of these three directories to exist will be the one to
# use, ignoring any more general directories which might exist as well.
#
# For more details about it please take a look at the eutils.class.
inherit base eutils flag-o-matic multilib toolchain-funcs
case ${EAPI:-0} in
4|5) ;;
*) die "EAPI ${EAPI} unsupported."
esac
EXPORT_FUNCTIONS pkg_setup src_unpack src_prepare src_compile src_install pkg_postinst pkg_postrm pkg_config
IUSE=""
# Name of the plugin stripped from all vdrplugin-, vdr- and -cvs pre- and postfixes
VDRPLUGIN="${PN/#vdrplugin-/}"
VDRPLUGIN="${VDRPLUGIN/#vdr-/}"
VDRPLUGIN="${VDRPLUGIN/%-cvs/}"
DESCRIPTION="vdr Plugin: ${VDRPLUGIN} (based on vdr-plugin-2.eclass)"
# Works in most cases
S="${WORKDIR}/${VDRPLUGIN}-${PV}"
# depend on headers for DVB-driver
COMMON_DEPEND=">=media-tv/gentoo-vdr-scripts-0.4.2"
DEPEND="${COMMON_DEPEND}
virtual/linuxtv-dvb-headers"
RDEPEND="${COMMON_DEPEND}
>=app-admin/eselect-vdr-0.0.2"
# This is a hack for ebuilds like vdr-xineliboutput that want to
# conditionally install a vdr-plugin
if [[ "${GENTOO_VDR_CONDITIONAL:-no}" = "yes" ]]; then
IUSE="${IUSE} vdr"
DEPEND="vdr? ( ${DEPEND} )"
RDEPEND="vdr? ( ${RDEPEND} )"
fi
# New method of storing plugindb
# Called from src_install
# file maintained by normal portage-methods
create_plugindb_file() {
local NEW_VDRPLUGINDB_DIR=/usr/share/vdr/vdrplugin-rebuild/
local DB_FILE="${NEW_VDRPLUGINDB_DIR}/${CATEGORY}-${PF}"
insinto "${NEW_VDRPLUGINDB_DIR}"
# BUG: portage-2.1.4_rc9 will delete the EBUILD= line, so we cannot use this code.
# cat <<-EOT > "${D}/${DB_FILE}"
# VDRPLUGIN_DB=1
# CREATOR=ECLASS
# EBUILD=${CATEGORY}/${PN}
# EBUILD_V=${PVR}
# EOT
{
echo "VDRPLUGIN_DB=1"
echo "CREATOR=ECLASS"
echo "EBUILD=${CATEGORY}/${PN}"
echo "EBUILD_V=${PVR}"
echo "PLUGINS=\"$@\""
} > "${D}/${DB_FILE}"
}
# Delete files created outside of vdr-plugin-2.eclass
# vdrplugin-rebuild.ebuild converted plugindb and files are
# not deleted by portage itself - should only be needed as
# long as not every system has switched over to
# vdrplugin-rebuild-0.2 / gentoo-vdr-scripts-0.4.2
delete_orphan_plugindb_file() {
#elog Testing for orphaned plugindb file
local NEW_VDRPLUGINDB_DIR=/usr/share/vdr/vdrplugin-rebuild/
local DB_FILE="${ROOT}/${NEW_VDRPLUGINDB_DIR}/${CATEGORY}-${PF}"
# file exists
[[ -f ${DB_FILE} ]] || return
# will portage handle the file itself
if grep -q CREATOR=ECLASS "${DB_FILE}"; then
#elog file owned by eclass - don't touch it
return
fi
elog "Removing orphaned plugindb-file."
elog "\t#rm ${DB_FILE}"
rm "${DB_FILE}"
}
create_header_checksum_file() {
# Danger: Not using $ROOT here, as compile will also not use it !!!
# If vdr in $ROOT and / differ, plugins will not run anyway
local CHKSUM="header-md5-vdr"
if [[ -f ${VDR_CHECKSUM_DIR}/header-md5-vdr ]]; then
cp "${VDR_CHECKSUM_DIR}/header-md5-vdr" "${CHKSUM}"
elif type -p md5sum >/dev/null 2>&1; then
(
cd "${VDR_INCLUDE_DIR}"
md5sum *.h libsi/*.h|LC_ALL=C sort --key=2
) > "${CHKSUM}"
else
die "Could not create md5 checksum of headers"
fi
insinto "${VDR_CHECKSUM_DIR}"
local p_name
for p_name; do
newins "${CHKSUM}" "header-md5-${p_name}"
done
}
fix_vdr_libsi_include() {
dev_check "Fixing include of libsi-headers"
local f
for f; do
sed -i "${f}" \
-e '/#include/s:"\(.*libsi.*\)":<\1>:' \
-e '/#include/s:<.*\(libsi/.*\)>:<vdr/\1>:'
done
}
vdr_patchmakefile() {
einfo "Patching Makefile"
[[ -e Makefile ]] || die "Makefile of plugin can not be found!"
cp Makefile "${WORKDIR}"/Makefile.before
# plugin makefiles use VDRDIR in strange ways
# assumptions:
# 1. $(VDRDIR) contains Make.config
# 2. $(VDRDIR) contains config.h
# 3. $(VDRDIR)/include/vdr contains the headers
# 4. $(VDRDIR) contains main vdr Makefile
# 5. $(VDRDIR)/locale exists
# 6. $(VDRDIR) allows to access vdr source files
#
# We only have one directory (for now /usr/include/vdr),
# that contains vdr-headers and Make.config.
# To satisfy 1-3 we do this:
# Set VDRDIR=/usr/include/vdr
# Set VDRINCDIR=/usr/include
# Change $(VDRDIR)/include to $(VDRINCDIR)
sed -i Makefile \
-e "s:^VDRDIR.*$:VDRDIR = ${VDR_INCLUDE_DIR}:" \
-e "/^VDRDIR/a VDRINCDIR = ${VDR_INCLUDE_DIR%/vdr}" \
-e '/VDRINCDIR.*=/!s:$(VDRDIR)/include:$(VDRINCDIR):' \
\
-e 's:-I$(DVBDIR)/include::' \
-e 's:-I$(DVBDIR)::'
# may be needed for multiproto:
#sed -i Makefile \
# -e "s:^DVBDIR.*$:DVBDIR = ${DVB_INCLUDE_DIR}:" \
# -e 's:-I$(DVBDIR)/include:-I$(DVBDIR):'
if ! grep -q APIVERSION Makefile; then
ebegin " Converting to APIVERSION"
sed -i Makefile \
-e 's:^APIVERSION = :APIVERSION ?= :' \
-e 's:$(LIBDIR)/$@.$(VDRVERSION):$(LIBDIR)/$@.$(APIVERSION):' \
-e '/VDRVERSION =/a\APIVERSION = $(shell sed -ne '"'"'/define APIVERSION/s/^.*"\\(.*\\)".*$$/\\1/p'"'"' $(VDRDIR)/config.h)'
eend $?
fi
# Correcting Compile-Flags
# Do not overwrite CXXFLAGS, add LDFLAGS if missing
sed -i Makefile \
-e '/^CXXFLAGS[[:space:]]*=/s/=/?=/' \
-e '/LDFLAGS/!s:-shared:$(LDFLAGS) -shared:'
# Disabling file stripping, the package manager takes care of it
sed -i Makefile \
-e '/@.*strip/d' \
-e '/strip \$(LIBDIR)\/\$@/d' \
-e 's/STRIP.*=.*$/STRIP = true/'
# Use a file instead of a variable as single-stepping via ebuild
# destroys environment.
touch "${WORKDIR}"/.vdr-plugin_makefile_patched
}
# Begin new vdr-plugin-2.eclass content
dev_check() {
# A lot useful debug infos
# set VDR_MAINTAINER_MODE="1" in /etc/make.conf
if [[ -n ${VDR_MAINTAINER_MODE} ]]; then
eerror "\t Maintainer Info: $@"
fi
}
gettext_missing() {
# plugins without converting to gettext
local GETTEXT_MISSING=$( grep xgettext Makefile )
if [[ -z ${GETTEXT_MISSING} ]]; then
dev_check "Plugin isn't converted to gettext handling \n"
fi
}
linguas_support() {
# Patching Makefile for linguas support.
# Only locales, enabled through the LINGUAS (make.conf) variable will be
# "compiled" and installed.
#
# Some plugins have po/ in a subdir
# set PO_SUBDIR in .ebuild
# i.e media-plugins/vdr-streamdev
# PO_SUBDIR="client server"
einfo "Patching for Linguas support"
einfo "available Languages for ${P} are:"
[[ -f po ]] && local po_dir="${S}"
local po_subdir=( ${S}/${PO_SUBDIR} )
local f
makefile_dir=( ${po_dir} ${po_subdir[*]} )
for f in ${makefile_dir[*]}; do
PLUGIN_LINGUAS=$( ls ${f}/po --ignore="*.pot" | sed -e "s:.po::g" | cut -d_ -f1 | tr \\\012 ' ' )
einfo "LINGUAS=\"${PLUGIN_LINGUAS}\""
sed -i ${f}/Makefile \
-e 's:\$(wildcard[[:space:]]*\$(PODIR)/\*.po):\$(foreach dir,\$(LINGUAS),\$(wildcard \$(PODIR)\/\$(dir)\*.po)):' \
|| die "sed failed for Linguas"
done
strip-linguas ${PLUGIN_LINGUAS} en
# maintainer check
if [[ ! -d po ]]; then
dev_check "po dir not found? May be in subdir? \n"
fi
}
vdr_i18n() {
# i18n handling was deprecated since >=media-video/vdr-1.5.9,
# finally with >=media-video/vdr-1.7.27 it has been dropped entirely and some
# plugins will fail to "compile" because they're still using the old variant.
# Simply remove the i18n.o object from Makefile (OBJECT) and
# remove "static const tI18nPhrase*" from i18n.h.
#
# Plugins that are still using the old method will be pmasked until they're
# fixed or in case of maintainer timeout they'll be masked for removal.
gettext_missing
local I18N_OBJECT=$( grep i18n.o Makefile )
if [[ -n ${I18N_OBJECT} ]]; then
if [[ "${KEEP_I18NOBJECT:-no}" = "yes" ]]; then
dev_check "Forced to keep i18n.o"
else
sed -i "s:i18n.o::g" Makefile
dev_check "OBJECT i18n.o found"
dev_check "removed per sed \n"
fi
else
dev_check "OBJECT i18n.o not found in Makefile"
dev_check "all fine or manual review needed? \n"
fi
local I18N_STRING=$( [[ -e i18n.h ]] && grep tI18nPhrase i18n.h )
if [[ -n ${I18N_STRING} ]]; then
sed -i "s:^extern[[:space:]]*const[[:space:]]*tI18nPhrase://static const tI18nPhrase:" i18n.h
dev_check "obsolete tI18nPhrase found"
dev_check "disabled per sed, please recheck \n"
else
dev_check "obsolete tI18nPhrase not found, fine..."
dev_check "please review, may be in subdir... \n"
fi
}
remove_i18n_include() {
# remove uneeded i18.n includes
# call 'remove_i18n_include bla foo'
local f
for f; do
sed -i "${f}" \
-e "s:^#include[[:space:]]*\"i18n.h\"://:"
done
dev_check "removed i18n.h for ${@}"
}
# end new vdr-plugin-2.eclass content
vdr-plugin-2_copy_source_tree() {
pushd . >/dev/null
cp -r "${S}" "${T}"/source-tree
cd "${T}"/source-tree
cp "${WORKDIR}"/Makefile.before Makefile
# TODO: Fix this, maybe no longer needed
sed -i Makefile \
-e "s:^DVBDIR.*$:DVBDIR = ${DVB_INCLUDE_DIR}:" \
-e 's:^CXXFLAGS:#CXXFLAGS:' \
-e 's:-I$(DVBDIR)/include:-I$(DVBDIR):' \
-e 's:-I$(VDRDIR) -I$(DVBDIR):-I$(DVBDIR) -I$(VDRDIR):'
popd >/dev/null
}
vdr-plugin-2_install_source_tree() {
einfo "Installing sources"
destdir="${VDRSOURCE_DIR}/vdr-${VDRVERSION}/PLUGINS/src/${VDRPLUGIN}"
insinto "${destdir}-${PV}"
doins -r "${T}"/source-tree/*
dosym "${VDRPLUGIN}-${PV}" "${destdir}"
}
vdr-plugin-2_print_enable_command() {
local p_name c=0 l=""
for p_name in ${vdr_plugin_list}; do
c=$(( c+1 ))
l="$l ${p_name#vdr-}"
done
elog
case $c in
1) elog "Installed plugin${l}" ;;
*) elog "Installed $c plugins:${l}" ;;
esac
elog "To activate a plugin execute this command:"
elog "\teselect vdr-plugin enable <plugin_name> ..."
elog
}
has_vdr() {
[[ -f "${VDR_INCLUDE_DIR}"/config.h ]]
}
## exported functions
vdr-plugin-2_pkg_setup() {
# -fPIC is needed for shared objects on some platforms (amd64 and others)
append-flags -fPIC
# Plugins need to be compiled with position independent code, otherwise linking
# VDR against it will fail
if has_version ">=media-video/vdr-1.7.13"; then
append-lfs-flags
fi
# missing ${chost}- tag
tc-export CC CXX
# Where should the plugins live in the filesystem
VDR_PLUGIN_DIR="/usr/$(get_libdir)/vdr/plugins"
VDR_CHECKSUM_DIR="${VDR_PLUGIN_DIR%/plugins}/checksums"
# was /usr/lib/... some time ago
# since gentoo-vdr-scripts-0.3.6 it works with /usr/share/...
VDR_RC_DIR="/usr/share/vdr/rcscript"
# Pathes to includes
VDR_INCLUDE_DIR="/usr/include/vdr"
DVB_INCLUDE_DIR="/usr/include"
TMP_LOCALE_DIR="${WORKDIR}/tmp-locale"
LOCDIR="/usr/share/locale"
if ! has_vdr; then
# set to invalid values to detect abuses
VDRVERSION="eclass_no_vdr_installed"
APIVERSION="eclass_no_vdr_installed"
if [[ "${GENTOO_VDR_CONDITIONAL:-no}" = "yes" ]] && ! use vdr; then
einfo "VDR not found!"
else
# if vdr is required
die "VDR not found!"
fi
return
fi
VDRVERSION=$(awk -F'"' '/define VDRVERSION/ {print $2}' "${VDR_INCLUDE_DIR}"/config.h)
APIVERSION=$(awk -F'"' '/define APIVERSION/ {print $2}' "${VDR_INCLUDE_DIR}"/config.h)
[[ -z ${APIVERSION} ]] && APIVERSION="${VDRVERSION}"
einfo "Compiling against"
einfo "\tvdr-${VDRVERSION} [API version ${APIVERSION}]"
if [[ -n "${VDR_LOCAL_PATCHES_DIR}" ]]; then
eerror "Using VDR_LOCAL_PATCHES_DIR is deprecated!"
eerror "Please move all your patches into"
eerror "${EROOT}/etc/portage/patches/${CATEGORY}/${P}"
eerror "and remove or unset the VDR_LOCAL_PATCHES_DIR variable."
die
fi
}
vdr-plugin-2_src_util() {
while [ "$1" ]; do
case "$1" in
all)
vdr-plugin-2_src_util unpack add_local_patch patchmakefile linguas_patch i18n
;;
prepare)
vdr-plugin-2_src_util add_local_patch patchmakefile linguas_patch i18n
;;
unpack)
base_src_unpack
;;
add_local_patch)
cd "${S}" || die "Could not change to plugin-source-directory!"
epatch_user
;;
patchmakefile)
cd "${S}" || die "Could not change to plugin-source-directory!"
vdr_patchmakefile
;;
i18n)
vdr_i18n
;;
linguas_patch)
linguas_support
;;
esac
shift
done
}
vdr-plugin-2_src_unpack() {
if [[ -z ${VDR_INCLUDE_DIR} ]]; then
eerror "Wrong use of vdr-plugin-2.eclass."
eerror "An ebuild for a vdr-plugin will not work without calling vdr-plugin-2_src_unpack."
echo
eerror "Please report this at bugs.gentoo.org."
die "vdr-plugin-2_src_unpack not called!"
fi
if [ -z "$1" ]; then
vdr-plugin-2_src_util unpack
else
vdr-plugin-2_src_util $@
fi
}
vdr-plugin-2_src_prepare() {
if [[ -z ${VDR_INCLUDE_DIR} ]]; then
eerror "Wrong use of vdr-plugin-2.eclass."
eerror "An ebuild for a vdr-plugin will not work without calling vdr-plugin-2_src_prepare."
echo
eerror "Please report this at bugs.gentoo.org."
die "vdr-plugin-2_src_prepare not called!"
fi
base_src_prepare
vdr-plugin-2_src_util prepare
}
vdr-plugin-2_src_compile() {
[ -z "$1" ] && vdr-plugin-2_src_compile copy_source compile
while [ "$1" ]; do
case "$1" in
copy_source)
[[ -n "${VDRSOURCE_DIR}" ]] && vdr-plugin-2_copy_source_tree
;;
compile)
if [[ ! -f ${WORKDIR}/.vdr-plugin_makefile_patched ]]; then
eerror "Wrong use of vdr-plugin-2.eclass."
eerror "An ebuild for a vdr-plugin will not work without"
eerror "calling vdr-plugin-2_src_compile to patch the Makefile."
echo
eerror "Please report this at bugs.gentoo.org."
die "vdr-plugin-2_src_compile not called!"
fi
cd "${S}"
BUILD_TARGETS=${BUILD_TARGETS:-${VDRPLUGIN_MAKE_TARGET:-all}}
emake ${BUILD_PARAMS} \
${BUILD_TARGETS} \
LOCALEDIR="${TMP_LOCALE_DIR}" \
LIBDIR="${S}" \
TMPDIR="${T}" \
|| die "emake failed"
;;
esac
shift
done
}
vdr-plugin-2_src_install() {
if [[ -z ${VDR_INCLUDE_DIR} ]]; then
eerror "Wrong use of vdr-plugin-2.eclass."
eerror "An ebuild for a vdr-plugin will not work without calling vdr-plugin-2_src_install."
echo
eerror "Please report this at bugs.gentoo.org."
die "vdr-plugin-2_src_install not called!"
fi
[[ -n "${VDRSOURCE_DIR}" ]] && vdr-plugin-2_install_source_tree
cd "${WORKDIR}"
if [[ -n ${VDR_MAINTAINER_MODE} ]]; then
local mname="${P}-Makefile"
cp "${S}"/Makefile "${mname}.patched"
cp Makefile.before "${mname}.before"
diff -u "${mname}.before" "${mname}.patched" > "${mname}.diff"
insinto "/usr/share/vdr/maintainer-data/makefile-changes"
doins "${mname}.diff"
insinto "/usr/share/vdr/maintainer-data/makefile-before"
doins "${mname}.before"
insinto "/usr/share/vdr/maintainer-data/makefile-patched"
doins "${mname}.patched"
fi
cd "${S}"
insinto "${VDR_PLUGIN_DIR}"
doins libvdr-*.so.*
# create list of all created plugin libs
vdr_plugin_list=""
local p_name
for p in libvdr-*.so.*; do
p_name="${p%.so*}"
p_name="${p_name#lib}"
vdr_plugin_list="${vdr_plugin_list} ${p_name}"
done
create_header_checksum_file ${vdr_plugin_list}
create_plugindb_file ${vdr_plugin_list}
if [[ -d ${TMP_LOCALE_DIR} ]]; then
einfo "Installing locales"
cd "${TMP_LOCALE_DIR}"
local linguas
for linguas in ${LINGUAS[*]}; do
insinto "${LOCDIR}"
cp -r --parents ${linguas}* ${D}/${LOCDIR}
done
fi
cd "${S}"
local docfile
for docfile in README* HISTORY CHANGELOG; do
[[ -f ${docfile} ]] && dodoc ${docfile}
done
# if VDR_CONFD_FILE is empty and ${FILESDIR}/confd exists take it
[[ -z ${VDR_CONFD_FILE} ]] && [[ -e ${FILESDIR}/confd ]] && VDR_CONFD_FILE=${FILESDIR}/confd
if [[ -n ${VDR_CONFD_FILE} ]]; then
newconfd "${VDR_CONFD_FILE}" vdr.${VDRPLUGIN}
fi
# if VDR_RCADDON_FILE is empty and ${FILESDIR}/rc-addon.sh exists take it
[[ -z ${VDR_RCADDON_FILE} ]] && [[ -e ${FILESDIR}/rc-addon.sh ]] && VDR_RCADDON_FILE=${FILESDIR}/rc-addon.sh
if [[ -n ${VDR_RCADDON_FILE} ]]; then
insinto "${VDR_RC_DIR}"
newins "${VDR_RCADDON_FILE}" plugin-${VDRPLUGIN}.sh
fi
}
vdr-plugin-2_pkg_postinst() {
vdr-plugin-2_print_enable_command
if [[ -n "${VDR_CONFD_FILE}" ]]; then
elog "Please have a look at the config-file"
elog "\t/etc/conf.d/vdr.${VDRPLUGIN}"
elog
fi
}
vdr-plugin-2_pkg_postrm() {
delete_orphan_plugindb_file
}
vdr-plugin-2_pkg_config() {
:
}

View File

@ -0,0 +1,83 @@
# Copyright 1999-2011 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/eclass/vmware-bundle.eclass,v 1.2 2011/08/22 04:46:32 vapier Exp $
# @ECLASS: vmware-bundle.eclass
# @MAINTAINER:
# vmware@gentoo.org
# @AUTHOR:
# Matt Whitlock <matt@whitlock.name>
# @BLURB: Provides extract functionality for vmware products bundles
DEPEND="dev-libs/libxslt"
vmware-bundle_extract-bundle-component() {
local bundle=${1:?} component=${2:?} dest=${3:-${2}}
cat > "${T}"/list-bundle-components.xsl <<-EOF
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes"/>
<xsl:template match="text()"/>
<xsl:template match="/bundle/components/component">
<xsl:value-of select="@offset"/>
<xsl:text> </xsl:text>
<xsl:value-of select="@size"/>
<xsl:text> </xsl:text>
<xsl:value-of select="@name"/>
<xsl:text>&#10;</xsl:text>
</xsl:template>
</xsl:stylesheet>
EOF
local -i bundle_size=$(stat -L -c'%s' "${bundle}")
local -i bundle_manifestOffset=$(od -An -j$((bundle_size-36)) -N4 -tu4 "${bundle}")
local -i bundle_manifestSize=$(od -An -j$((bundle_size-40)) -N4 -tu4 "${bundle}")
local -i bundle_dataOffset=$(od -An -j$((bundle_size-44)) -N4 -tu4 "${bundle}")
local -i bundle_dataSize=$(od -An -j$((bundle_size-52)) -N8 -tu8 "${bundle}")
tail -c+$((bundle_manifestOffset+1)) "${bundle}" 2> /dev/null | head -c$((bundle_manifestSize)) |
xsltproc "${T}"/list-bundle-components.xsl - |
while read -r component_offset component_size component_name ; do
if [[ ${component_name} == ${component} ]] ; then
ebegin "Extracting '${component_name}' component from '$(basename "${bundle}")'"
vmware-bundle_extract-component "${bundle}" "${dest}" $((bundle_dataOffset+component_offset))
eend
fi
done
}
vmware-bundle_extract-component() {
local component=${1:?} dest=${2:-.}
local -i offset=${3}
cat > "${T}"/list-component-files.xsl <<-EOF
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes"/>
<xsl:template match="text()"/>
<xsl:template match="/component/fileset/file">
<xsl:value-of select="@offset"/>
<xsl:text> </xsl:text>
<xsl:value-of select="@compressedSize"/>
<xsl:text> </xsl:text>
<xsl:value-of select="@uncompressedSize"/>
<xsl:text> </xsl:text>
<xsl:value-of select="@path"/>
<xsl:text>&#10;</xsl:text>
</xsl:template>
</xsl:stylesheet>
EOF
local -i component_manifestOffset=$(od -An -j$((offset+9)) -N4 -tu4 "${component}")
local -i component_manifestSize=$(od -An -j$((offset+13)) -N4 -tu4 "${component}")
local -i component_dataOffset=$(od -An -j$((offset+17)) -N4 -tu4 "${component}")
local -i component_dataSize=$(od -An -j$((offset+21)) -N8 -tu8 "${component}")
tail -c+$((offset+component_manifestOffset+1)) "${component}" 2> /dev/null |
head -c$((component_manifestSize)) | xsltproc "${T}"/list-component-files.xsl - |
while read -r file_offset file_compressedSize file_uncompressedSize file_path ; do
if [[ ${file_path} ]] ; then
echo -n '.'
file_path="${dest}/${file_path}"
mkdir -p "$(dirname "${file_path}")" || die
tail -c+$((offset+component_dataOffset+file_offset+1)) "${component}" 2> /dev/null |
head -c$((file_compressedSize)) | gzip -cd > "${file_path}" || die
fi
done
echo
}