public inbox for gentoo-dev@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-dev] apache.eclass proposed
@ 2003-06-08 10:12 Ned Ludd
  2003-06-08 19:45 ` Robin H.Johnson
  2003-06-12  0:13 ` Stewart
  0 siblings, 2 replies; 10+ messages in thread
From: Ned Ludd @ 2003-06-08 10:12 UTC (permalink / raw
  To: gentoo-dev

[-- Attachment #1: Type: text/plain, Size: 842 bytes --]

After writing a net-www/ ebuild it seemed apparent to me that we are
going to need an apache.eclass. A quick find in portage reveals quite a
few independent ebuilds all needing the basic functionality that could
be provided by an apache.eclass

syntactically perfect the idea is what matters..
I have attached an apache.eclass that I welcome your input/feedback on.
While it may not be syntactically perfect for the apache2 part its the
idea that we get this out there and start talking about one that
matters.

my portage # find . -name '*.ebuild' | xargs grep HTTPD_USER= | wc
     22      96    1904
my portage # find . -name '*.ebuild' | xargs grep HTTPD_GROUP= | wc
     21     123    2081
my portage # find . -name '*.ebuild' | xargs grep HTTPD_ROOT= | wc
     50     299    5154
-- 
Ned Ludd <solar@gentoo.org>
Gentoo Linux (Hardened)

[-- Attachment #2: apache.eclass --]
[-- Type: text/plain, Size: 2326 bytes --]

# Copyright 1999-2003 Gentoo Technologies, Inc.
# Distributed under the terms of the GNU General Public License v2
# $Header: $

#
# Author: Ned Ludd <solar@gentoo.org>
#
# This eclass is designed to allow easier installation of web applications,
# modules, and their counterparts incorporation into the Gentoo Linux system.
# 

#set -x

ECLASS=apache
INHERITED="${INHERITED} ${ECLASS}"
IUSE="apache2 ${IUSE}"
DESCRIPTION="Based on the ${ECLASS} eclass"

newdepend virtual/glibc sys-apps/gawk sys-apps/grep 
#	apache2? ( >=net-www/apache-2.0.43-r1 ) \
#	!apache2? ( !<net-www/apache-1.3.26-r2 <net-www/apache-2 )"
#

EXPORT_FUNCTIONS has_apache2 httpd_getvar httpd_user httpd_group httpd_root

# Return the string 2 on success, nothing otherwise
has_apache2() {
	ret="";
	# The use flag overrides all.
	if [ `use apache2` ]; then
		ret=2
	else
		if [ `has_version '>=net-www/apache-2'` ]; then
			# If user has apache 1 & 2 installed and use  
			# `use apache2` was not set then we should pref apache1
			if [ `has_version '<net-www/apache-2'` ]; then
				ret=""
			else
				ret=2
			fi
		fi
	fi
	echo -n "${ret}"
}

# Wrapper function to grep for string from file. 
httpd_getvar() {
	name=$1
	conf=$2
	[ ! -f "${conf}" ] && die "$conf: No such file or directory"
	v=$(grep ^${name} ${conf} | gawk '{print $2}' | head -1)
	echo -n "${v}";
}

# Get apache User / should return apache
httpd_user() {
	ap=$(has_apache2)
	conf="/etc/apache${ap}/conf/commonapache${ap}.conf"
	httpd_getvar User ${conf}
}

# Get apache Group / should return apache
httpd_group() {
	ap=$(has_apache2)
	conf="/etc/apache${ap}/conf/commonapache${ap}.conf"
	httpd_getvar Group ${conf}	
}

# Get apache DocumentRoot
httpd_root() {
	ap=$(has_apache2)
	conf=/etc/apache${ap}/conf/apache${ap}.conf
	httpd_getvar DocumentRoot ${conf}
}

httpd_user=`httpd_user`
httpd_group=`httpd_group`
httpd_root=`httpd_root`

# fallbacks
[ -z "${httpd_user}" ] && httpd_user="apache"
[ -z "${httpd_group}" ] && httpd_group="apache"
[ -z "${httpd_root}" ] && httpd_root="/home/httpd/htdocs"

# Mark readonly so other ebuilds dont override.
declare -r HTTPD_USER=${httpd_user};
declare -r HTTPD_GROUP=${httpd_group};
declare -r HTTPD_ROOT=${httpd_root}

export HTTPD_USER
export HTTPD_GROUP 
export HTTPD_ROOT

unset httpd_user
unset httpd_group
unset httpd_root

#set +x


[-- Attachment #3: Type: text/plain, Size: 37 bytes --]

--
gentoo-dev@gentoo.org mailing list

^ permalink raw reply	[flat|nested] 10+ messages in thread
* Re: [gentoo-dev] apache.eclass proposed
@ 2003-06-08 14:32 Joshua Brindle
  0 siblings, 0 replies; 10+ messages in thread
From: Joshua Brindle @ 2003-06-08 14:32 UTC (permalink / raw
  To: gentoo-dev, Ludd, Ned

This is very good, I've seen many apache related ebuilds that do 
not do the right thing about determining what apache/which configs
which directories, etc to use, I think that all apache related ebuilds
should use this, it's an easy and central way to manage the logic
of apache configs

Good job solar :)


>After writing a net-www/ ebuild it seemed apparent to me that we are
>going to need an apache.eclass. A quick find in portage reveals quite a
>few independent ebuilds all needing the basic functionality that could
>be provided by an apache.eclass
>
>syntactically perfect the idea is what matters..
>I have attached an apache.eclass that I welcome your input/feedback on.
>While it may not be syntactically perfect for the apache2 part its the
>idea that we get this out there and start talking about one that
>matters.
>
>my portage # find . -name '*.ebuild' | xargs grep HTTPD_USER= | wc
>     22      96    1904
>my portage # find . -name '*.ebuild' | xargs grep HTTPD_GROUP= | wc
>     21     123    2081
>my portage # find . -name '*.ebuild' | xargs grep HTTPD_ROOT= | wc
>     50     299    5154
>-- 
>Ned Ludd <solar@gentoo.org>
>Gentoo Linux (Hardened)


--
gentoo-dev@gentoo.org mailing list


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2003-06-12  0:13 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-06-08 10:12 [gentoo-dev] apache.eclass proposed Ned Ludd
2003-06-08 19:45 ` Robin H.Johnson
2003-06-08 19:50   ` Paul de Vrieze
2003-06-09  3:07     ` Ned Ludd
2003-06-09  6:01       ` Robin H.Johnson
2003-06-09 17:23         ` Brad Laue
2003-06-10  3:02           ` Donny Davies
2003-06-10  5:43             ` Robin H.Johnson
2003-06-12  0:13 ` Stewart
  -- strict thread matches above, loose matches on Subject: below --
2003-06-08 14:32 Joshua Brindle

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox