From 6c0d73acf48425acb2f3aab58a5097aa460db4cf Mon Sep 17 00:00:00 2001 From: CHTEKK Date: Sat, 13 Jan 2007 18:21:42 +0000 Subject: Experiment with stuff... svn path=/; revision=15 --- apache1-removal/eclass/apache-module.eclass | 323 ++++++++++++++++++++++++++++ apache1-removal/eclass/depend.apache.eclass | 254 ++++++++++++++++++++++ 2 files changed, 577 insertions(+) create mode 100644 apache1-removal/eclass/apache-module.eclass create mode 100644 apache1-removal/eclass/depend.apache.eclass diff --git a/apache1-removal/eclass/apache-module.eclass b/apache1-removal/eclass/apache-module.eclass new file mode 100644 index 0000000..19ecfa8 --- /dev/null +++ b/apache1-removal/eclass/apache-module.eclass @@ -0,0 +1,323 @@ +# Copyright 1999-2007 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: $ + +inherit depend.apache + +# This eclass provides a common set of functions for Apache modules. + +# NOTE: If you use this, be sure you use the need_* call after you have +# defined DEPEND and RDEPEND. Also note that you can not rely on the +# automatic RDEPEND=DEPEND that Portage does if you use this eclass. +# See bug 107127 for more information. + +###### +## Common ebuild variables +###### + +#### +## APXS2_S +## +## Paths to temporary build directories +#### +APXS2_S="" + +#### +## APXS2_ARGS +## +## Arguments to pass to the apxs tool +#### +APXS2_ARGS="" + +#### +## APACHE2_MOD_FILE +## +## Name of the module that src_install installs (only, minus the .so) +#### +APACHE2_MOD_FILE="" + +#### +## APACHE2_MOD_CONF +## +## Configuration file installed by src_install +#### +APACHE2_MOD_CONF="" + +#### +## APACHE2_MOD_DEFINE +## +## Name of define (eg FOO) to use in conditional loading of the installed +## module/it's config file, multiple defines should be space separated +#### +APACHE2_MOD_DEFINE="" + +#### +## DOCFILES +## +## If the exported src_install() is being used, and ${DOCFILES} is non-zero, +## some sed-fu is applied to split out html documentation (if any) from normal +## documentation, and dodoc'd or dohtml'd +#### +DOCFILES="" + +###### +## Utility functions +###### + +#### +## apache_cd_dir +## +## Return the path to our temporary build dir +#### +apache_cd_dir() { + debug-print-function $FUNCNAME $* + + [[ -n "${APXS2_S}" ]] && CD_DIR="${APXS2_S}" + + # XXX - Is this really needed? Can't we just return ${S}? + if [[ -z "${CD_DIR}" ]] ; then + if [[ -d "${S}/src" ]] ; then + CD_DIR="${S}/src" + else + CD_DIR="${S}" + fi + fi + + debug-print apache_cd_dir: "CD_DIR=${CD_DIR}" + echo "${CD_DIR}" +} + +#### +## apache_mod_file +## +## Return the path to the module file +#### +apache_mod_file() { + debug-print-function $FUNCNAME $* + + [[ -n "${APACHE2_MOD_FILE}" ]] && MOD_FILE="${APACHE2_MOD_FILE}" + [[ -z "${MOD_FILE}" ]] && MOD_FILE="$(apache_cd_dir)/.libs/${PN}.so" + + debug-print apache_mod_file: "MOD_FILE=${MOD_FILE}" + echo "${MOD_FILE}" +} + +#### +## apache_doc_magic +## +## Some magic for picking out html files from ${DOCFILES}. It takes +## an optional first argument `html'; if the first argument is equals +## `html', only html files are returned, otherwise normal (non-html) +## docs are returned. +#### +apache_doc_magic() { + debug-print-function $FUNCNAME $* + + if [[ -n "${DOCFILES}" ]] ; then + if [[ "x$1" == "xhtml" ]] ; then + DOCS="`echo ${DOCFILES} | sed -e 's/ /\n/g' | sed -e '/^[^ ]*.html$/ !d'`" + else + DOCS="`echo ${DOCFILES} | sed 's, *[^ ]*\+.html, ,g'`" + fi + + debug-print apache_doc_magic: "DOCS=${DOCS}" + echo "${DOCS}" + fi +} + +###### +## Apache 1.x ebuild functions - !!! DEPRECATED !!! +###### + +#### +## apache1_src_compile - !!! DEPRECATED !!! +#### +apache1_src_compile() { + debug-print-function $FUNCNAME $* + + echo "Apache 1.X support is deprecated! Please migrate to Apache 2.X!" +} + +#### +## apache1_src_install - !!! DEPRECATED !!! +#### +apache1_src_install() { + debug-print-function $FUNCNAME $* + + echo "Apache 1.X support is deprecated! Please migrate to Apache 2.X!" +} + +#### +## apache1_pkg_postinst - !!! DEPRECATED !!! +#### +apache1_pkg_postinst() { + debug-print-function $FUNCNAME $* + + echo "Apache 1.X support is deprecated! Please migrate to Apache 2.X!" +} + +###### +## Apache 2.x ebuild functions +###### + +#### +## apache2_pkg_setup +## +## Checks to see if APACHE2_MT_UNSAFE is set to anything other than "no". If it is, then +## we check what the MPM style used by Apache is, if it isnt prefork, we let the user +## know they need prefork, and then exit the build. +#### +apache2_pkg_setup() { + debug-print-function $FUNCNAME $* + + if [[ -n "${APACHE2_SAFE_MPMS}" ]] ; then + INSTALLED_MPM="$(${ROOT}/usr/sbin/apxs2 -q MPM_NAME)" + + if hasq ${INSTALLED_MPM} ${APACHE2_SAFE_MPMS} ; then + INSTALLED_MPM_SAFE="yes" + fi + + if [[ -z "${INSTALLED_MPM_SAFE}" ]] ; then + eerror "The module you are trying to install (${PN})" + eerror "will only work with one of the following MPMs:" + eerror " ${APACHE2_SAFE_MPMS}" + eerror "You do not currently have any of these MPMs installed." + eerror "Please re-install apache with the correct mpm-* USE flag set." + die "No safe MPM installed." + fi + fi +} + +#### +## apache2_src_compile +## +## The default action is to call ${APXS2} with the value of +## ${APXS2_ARGS}. If a module requires a different build setup +## than this, use ${APXS2} in your own src_compile routine. +#### +apache2_src_compile() { + debug-print-function $FUNCNAME $* + + CD_DIR=$(apache_cd_dir) + cd "${CD_DIR}" || die "cd ${CD_DIR} failed" + APXS2_ARGS="${APXS2_ARGS:--c ${PN}.c}" + ${APXS2} ${APXS2_ARGS} || die "${APXS2} ${APXS2_ARGS} failed" +} + +#### +## apache2_src_install +## +## This installs the files into apache's directories. The module is installed +## from a directory chosen as above (APXS2_S or ${S}/src). In addition, +## this function can also set the executable permission on files listed in EXECFILES. +## The configuration file name is listed in CONFFILE without the .conf extensions, +## so if you configuration is 55_mod_foo.conf, CONFFILE would be 55_mod_foo. +## DOCFILES contains the list of files you want filed as documentation. +#### +apache2_src_install() { + debug-print-function $FUNCNAME $* + + CD_DIR=$(apache_cd_dir) + cd "${CD_DIR}" || die "cd ${CD_DIR} failed" + + MOD_FILE=$(apache_mod_file) + + exeinto "${APACHE2_MODULESDIR}" + doexe ${MOD_FILE} || die "internal ebuild error: '${MOD_FILE}' not found" + [[ -n "${APACHE2_EXECFILES}" ]] && doexe ${APACHE2_EXECFILES} + + if [[ -n "${APACHE2_MOD_CONF}" ]] ; then + insinto "${APACHE2_MODULES_CONFDIR}" + doins "${FILESDIR}/${APACHE2_MOD_CONF}.conf" || die "internal ebuild error: '${FILESDIR}/${APACHE2_MOD_CONF}.conf' not found." + fi + + if [[ -n "${APACHE2_VHOSTFILE}" ]] ; then + insinto "${APACHE2_VHOSTDIR}" + doins "${FILESDIR}/${APACHE2_VHOSTFILE}.conf" + fi + + cd "${S}" + + if [[ -n "${DOCFILES}" ]] ; then + OTHER_DOCS=$(apache_doc_magic) + HTML_DOCS=$(apache_doc_magic html) + + [[ -n "${OTHER_DOCS}" ]] && dodoc ${OTHER_DOCS} + [[ -n "${HTML_DOCS}" ]] && dohtml ${HTML_DOCS} + fi +} + +apache2_pkg_postinst() { + debug-print-function $FUNCNAME $* + + if [[ -n "${APACHE2_MOD_DEFINE}" ]] ; then + local my_opts="-D ${APACHE2_MOD_DEFINE// / -D }" + + einfo + einfo "To enable ${PN}, you need to edit your /etc/conf.d/apache2 file and" + einfo "add '${my_opts}' to APACHE2_OPTS." + einfo + fi + + if [[ -n "${APACHE2_MOD_CONF}" ]] ; then + einfo + einfo "Configuration file installed as" + einfo " ${APACHE2_MODULES_CONFDIR}/$(basename ${APACHE2_MOD_CONF}).conf" + einfo "You may want to edit it before turning the module on in /etc/conf.d/apache2" + einfo + fi + + if [[ -n "${APACHE2_SAFE_MPMS}" ]] ; then + INSTALLED_MPM="$(${ROOT}/usr/sbin/apxs2 -q MPM_NAME)" + + if ! hasq ${INSTALLED_MPM} ${APACHE2_SAFE_MPMS} ; then + INSTALLED_MPM_UNSAFE="${INSTALLED_MPM_UNSAFE} ${mpm}" + else + INSTALLED_MPM_SAFE="${INSTALLED_MPM_SAFE} ${mpm}" + fi + + if [[ -n "${INSTALLED_MPM_UNSAFE}" ]] ; then + ewarn "You have one or more MPMs installed that will not work with" + ewarn "this module (${PN}). Please make sure that you only enable" + ewarn "this module if you are using one of the following MPMs:" + ewarn " ${INSTALLED_MPM_SAFE}" + fi + fi +} + +###### +## Apache dual (1.x or 2.x) ebuild functions - Apache 1.X DEPRECATED! +## +## This is where the magic happens. We provide dummy routines of all of the functions +## provided by all of the specifics. We use APACHE_ECLASS_VER_* to see which versions +## to call. If a function is provided by a given section (ie pkg_postinst in Apache 2.x) +## the exported routine simply does nothing. +###### + +apache-module_pkg_setup() { + debug-print-function $FUNCNAME $* + + apache2_pkg_setup +} + +apache-module_src_compile() { + debug-print-function $FUNCNAME $* + + apache2_src_compile +} + +apache-module_src_install() { + debug-print-function $FUNCNAME $* + + apache2_src_install +} + +apache-module_pkg_postinst() { + debug-print-function $FUNCNAME $* + + apache2_pkg_postinst +} + +EXPORT_FUNCTIONS pkg_setup src_compile src_install pkg_postinst + +# vim:ts=4 diff --git a/apache1-removal/eclass/depend.apache.eclass b/apache1-removal/eclass/depend.apache.eclass new file mode 100644 index 0000000..5380be3 --- /dev/null +++ b/apache1-removal/eclass/depend.apache.eclass @@ -0,0 +1,254 @@ +# Copyright 1999-2007 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: $ + +inherit multilib + +# This eclass handles depending on apache in a sane way and providing +# information about where certain interfaces are located. + +# NOTE: If you use this, be sure you use the need_* call after you have +# defined DEPEND and RDEPEND. Also note that you can not rely on the +# automatic RDEPEND=DEPEND that portage does if you use this eclass. +# See bug 107127 for more information. + +###### +## Apache Common Variables +## +## These are internal variables used by this, and other apache-related eclasses, +## and thus should not need to be used by the ebuilds themselves (the ebuilds +## should know what version of Apache they are building against). +###### + +#### +## APACHE_VERSION +## +## Stores the version of apache we are going to be ebuilding. This variable is +## set by the need_apache{|1|2} functions. +## +#### +#APACHE_VERSION="2" + +#### +## APXS2 +## +## Paths to the apxs tools +#### +APXS2="/usr/sbin/apxs2" + +#### +## APACHECTL2 +## +## Paths to the apachectl tools +#### +APACHECTL2="/usr/sbin/apache2ctl" + +#### +## APACHE2_BASEDIR +## +## Paths to the server root directories +#### +APACHE2_BASEDIR="/usr/$(get_libdir)/apache2" + +#### +## APACHE2_CONFDIR +## +## Paths to the configuration file directories +#### +APACHE2_CONFDIR="/etc/apache2" + +#### +## APACHE2_MODULES_CONFDIR +## +## Paths where module configuration files are kept +#### +APACHE2_MODULES_CONFDIR="${APACHE2_CONFDIR}/modules.d" + +#### +## APACHE2_VHOSTDIR +## +## Paths where virtual host configuration files are kept +#### +APACHE2_VHOSTDIR="${APACHE2_CONFDIR}/vhosts.d" + +#### +## APACHE2_MODULESDIR +## +## Paths where we install modules +#### +APACHE2_MODULESDIR="${APACHE2_BASEDIR}/modules" + +#### +## APACHE2_DEPEND, APACHE2_0_DEPEND, APACHE2_2_DEPEND +## +## Dependencies for Apache 2.x +#### +APACHE2_DEPEND="=net-www/apache-2*" +APACHE2_0_DEPEND="=net-www/apache-2.0*" +APACHE2_2_DEPEND="=net-www/apache-2.2*" + +#### +## NEED_APACHE_DEPEND +## +## Dependency magic based on useflags to use the right DEPEND +## If you change this, please check the DEPENDS in need_apache() +#### + +NEED_APACHE_DEPEND="${APACHE2_DEPEND}" +WANT_APACHE_DEPEND="apache2? ( ${APACHE2_DEPEND} )" + +#### +# uses_apache1() - !!! DEPRECATED !!! +#### + +uses_apache1() { + debug-print-function $FUNCNAME $* + + echo "Apache 1.X support is deprecated! Please migrate to Apache 2.X!" +} + +#### +# uses_apache2() +# +# sets up all of the environment variables required by an apache2 module +#### + +uses_apache2() { + debug-print-function $FUNCNAME $* + # WARNING: Do not use these variables with anything that is put + # into the dependency cache (DEPEND/RDEPEND/etc) + APACHE_VERSION="2" + USE_APACHE2="2" + APXS="${APXS2}" + APACHECTL="${APACHECTL2}" + APACHE_BASEDIR="${APACHE2_BASEDIR}" + APACHE_CONFDIR="${APACHE2_CONFDIR}" + APACHE_MODULES_CONFDIR="${APACHE2_MODULES_CONFDIR}" + APACHE_VHOSTSDIR="${APACHE2_VHOSTSDIR}" + APACHE_MODULESDIR="${APACHE2_MODULESDIR}" +} + +doesnt_use_apache() { + debug-print-function $FUNCNAME $* + APACHE_VERSION="0" + USE_APACHE="" +} + +#### +## need_apache1 - !!! DEPRECATED !!! +#### +need_apache1() { + debug-print-function $FUNCNAME $* + + echo "Apache 1.X support is deprecated! Please migrate to Apache 2.X!" +} + +#### +## need_apache2 +## +## An ebuild calls this to get the dependency information +## for apache-2.x. An ebuild should use this in order for +## future changes to the build infrastructure to happen +## seamlessly. All an ebuild needs to do is include the +## line need_apache2 somewhere. +#### +need_apache2() { + debug-print-function $FUNCNAME $* + + DEPEND="${DEPEND} ${APACHE2_DEPEND}" + RDEPEND="${RDEPEND} ${APACHE2_DEPEND}" + APACHE_VERSION="2" +} + +#### +## need_apache2_0 +## +## Works like need_apache2 above, but its used by modules +## that only support apache 2.0 and do not work with +## higher versions. +## +#### +need_apache2_0() { + debug-print-function $FUNCNAME $* + + DEPEND="${DEPEND} ${APACHE2_0_DEPEND}" + RDEPEND="${RDEPEND} ${APACHE2_0_DEPEND}" + APACHE_VERSION="2" +} + +#### +## need_apache2_2 +## +## Works like need_apache2 above, but its used by modules +## that only support apache 2.2 and do not work with +## lower versions. +## +#### +need_apache2_2() { + debug-print-function $FUNCNAME $* + + DEPEND="${DEPEND} ${APACHE2_2_DEPEND}" + RDEPEND="${RDEPEND} ${APACHE2_2_DEPEND}" + APACHE_VERSION="2" +} + +#### +## DO NOT CHANGE THIS FUNCTION UNLESS YOU UNDERSTAND THE CONSEQUENCES IT +## WILL HAVE ON THE CACHE! +## +## This function can take a variable amount of arguments specifying the +## versions of apache the ebuild supports +## +## If no arguments are specified, then all versions are assumed to be supported +## +## If both 1.3 and 2.x are specified, the apache2 USE-flag will be used in +## DEPEND/RDEPEND to determine which version to use. +## +## Currently supported versions: 1.3 2.0 2.2 2.x +need_apache() { + debug-print-function $FUNCNAME $* + + local supports20 supports22 supports2x + + if [[ $# -eq 0 ]] ; then + supports2x="yes" + else + while [[ $# -gt 0 ]] ; do + case "$1" in + 2.0) supports20="yes"; shift;; + 2.2) supports22="yes"; shift;; + 2.x) supports2x="yes"; shift;; + *) die "Unknown version specifier: $1";; + esac + done + fi + + if [[ "${supports20}" == "yes" ]] && [[ "${supports22}" == "yes" ]] ; then + supports2x="yes"; + fi + + debug-print "supports20: ${supports20}" + debug-print "supports22: ${supports22}" + debug-print "supports2x: ${supports2x}" + + if [[ "${supports2x}" == "yes" ]] ; then + need_apache2 + elif [[ "${supports20}" == "yes" ]] ; then + need_apache2_0 + elif [[ "${supports22}" == "yes" ]] ; then + need_apache2_2 + fi +} + +want_apache() { + debug-print-function $FUNCNAME $* + + IUSE="${IUSE} apache2" + DEPEND="${DEPEND} ${WANT_APACHE_DEPEND}" + RDEPEND="${RDEPEND} ${WANT_APACHE_DEPEND}" + if useq apache2 ; then + uses_apache2 + else + doesnt_use_apache + fi +} -- cgit v1.2.3-65-gdbad