summaryrefslogtreecommitdiff
blob: b2127a43fd265466261333cafd0f17280c840ce4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
# Copyright 2002-2003 Gentoo Technologies, Inc.
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/net-zope/zope/zope-2.6.0-r2.ebuild,v 1.2 2003/09/07 00:21:34 msterret Exp $

S="${WORKDIR}/Zope-${PV}-src"

DESCRIPTION="Zope is a web application platform used for building high-performance, dynamic web sites."
HOMEPAGE="http://www.zope.org"
SRC_URI="http://www.zope.org/Products/Zope/${PV}/Zope-${PV}-src.tgz"
LICENSE="ZPL"
SLOT="0"

KEYWORDS="~x86 ~sparc"

RDEPEND="=dev-lang/python-2.1.3*"
DEPEND="virtual/glibc
		>=sys-apps/sed-4.0.5
		app-admin/zope-config
	   ${RDEPEND}"

ZUID=zope
ZGID=$(echo ${P} |sed -e "s:\.:_:g")
ZSERVDIR="${DESTTREE}/share/zope/${PF}/"
ZINSTDIR=$"/var/lib/zope/${ZGID}"
CONFDIR="/etc/conf.d/"

# Narrow the scope of ownership/permissions.
# Security plan:
# * ZUID is the superuser for all zope instances.
# * ZGID is for a single instance's administration.
# * Other's should not have any access to ${ZSERVDIR},
#   because they can work through the Zope web interface.
#   This should protect our code/data better.

#Parameters:
# $1 = instance directory
# $2 = group

setup_security()
{
    chown -R ${ZUID}:${2} ${1}
    chmod -R g+u ${1}
    chmod -R o-rwx ${1}
}

install_help()
{
	einfo "Need to setup an inituser (admin) before executing zope:"
	einfo "\tzope-config --zpasswd"
    einfo "To execute default Zope instance:"
	einfo "\t/etc/init.d/${ZGID} start"
}

pkg_setup() {
    if ! groupmod ${ZGID} > /dev/null 2>&1 ; then
		groupadd ${ZGID} || die "Can not add ${ZGID} group!"
    fi
    if ! id ${ZUID} > /dev/null 2>&1 ; then
		useradd -d ${ZSERVDIR} -c "Zope dedicatedr-user" ${ZUID} \
	|| die "Can not add ${ZUID} user!"
    fi
}

src_unpack()
{
	unpack ${A}
	# DateTime 2.6.0(only) rfc822 fix
	einfo "Applying patches..."
	bzcat ${FILESDIR}/${PV}/DateTime.py.bz2 \
		> ${S}/lib/python/DateTime/DateTime.py	|| die "Patch failed"
}

src_compile() {
    python2.1 wo_pcgi.py || die "Failed to compile."
}

src_install() {
	dodoc LICENSE.txt README.txt
	docinto doc ; dodoc doc/*.txt
	docinto doc/PLATFORMS ; dodoc doc/PLATFORMS/*
	docinto doc/changenotes ; dodoc doc/changenotes/*

    # using '/etc/init.d/zope'
	rm -Rf start stop LICENSE.txt README.txt doc/

	# Need to rip out the zinstance stuff out
    # but save as templates
	mkdir .templates
	mv -f Extensions/ .templates/
	mv -f import/ .templates/
	mv -f var/ .templates/

    # Add conf.d script.
    dodir /etc/conf.d
    echo "ZOPE_OPTS=\"-u zope\"" | \
    cat - ${FILESDIR}/${PV}/zope.envd > .templates/zope.confd

    # Fill in environmental variables
    sed -i -e "/ZOPE_HOME=/ c\\ZOPE_HOME=${ZSERVDIR}\\ " \
        -e "/SOFTWARE_HOME=/ c\\SOFTWARE_HOME=${ZSERVDIR}/lib/python\\ " \
	.templates/zope.confd

    # Add rc-script.
    cp ${FILESDIR}/${PV}/zope-r1.initd .templates/zope.initd

    # Copy the remaining contents of ${S} into the ${D}.
    dodir ${ZSERVDIR}
    cp -a . ${D}${ZSERVDIR}

	setup_security ${D}${ZSERVDIR} ${ZGID}
}

pkg_postinst()
{
	# Here we add our default zope instance.
	/usr/sbin/zope-config --zserv=${ZSERVDIR} --zinst=${ZINSTDIR} \
		--zgid=${ZGID}
	install_help
}

pkg_config()
{
	install_help
}