summaryrefslogtreecommitdiff
blob: 0a429c54e2a4d961a83c336725d0d0a191c9693f (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
# Copyright 1999-2004 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/net-irc/oer-mysql/oer-mysql-1.0.42.ebuild,v 1.6 2004/07/01 22:23:02 eradicator Exp $

IUSE=""
MY_P=N"oer+MySQL"
S=${WORKDIR}/${MY_P}-dist

DESCRIPTION="Free to use GPL'd IRC bot"
HOMEPAGE="http://oer.equnet.org/"
SRC_URI="http://oer.equnet.org/testing/${MY_P}-1.0-42.tar.gz"
LICENSE="GPL-2"
SLOT="0"
KEYWORDS="x86 ~ppc"

DEPEND="virtual/libc
	 >=dev-db/mysql-3.23.52-r1
	 >=sys-apps/sed-3.02.80-r4"

src_compile() {

	CFLAGS=${CFLAGS} \
	./configure --host=${CHOST} \
		    --with-mysql=/usr || die "configure failed"

	cp Makefile Makefile.orig
	sed -e "s:-O2:${CFLAGS}:" < Makefile.orig > Makefile

	emake mycrypt || die
	emake || die "make failed"

	# Make ebuild config work properly. 
	cp ${S}/pre_install.sh ${S}/pre_install.sh.orig
	sed -e "s:LOGTO=\"pre_install.log\":LOGTO=\"\/etc\/oer\/pre_install.log\":" \
	    -e "s:CRYPT=\`.\/mycrypt:CRYPT=\`\/usr\/share\/tools\/mycrypt:" \
	    -e "s:sample-configuration\/oer+MySQL.conf:\/etc\/oer\/oer+MySQL.conf:" \
		< ${S}/pre_install.sh.orig > ${S}/pre_install.sh

}

src_install() {

	dodir /usr/bin \
	      /etc/oer \
	      /usr/share/oer

	cp ${S}/oer+MySQL ${D}/usr/bin
	cp -r ${S}/tools ${S}/scripts ${D}/usr/share/oer
	cp ${S}/mycrypt ${S}/pre_install.sh ${D}/usr/share/oer/tools

}

pkg_postinst() {

	if ! groupmod oer
	then
		einfo "Creating oer group (gid=74)."
		groupadd oer -g 74 || die "failed to create oer group (gid=74)"
	fi
	if ! id oer
	then
		einfo "Creating oer user (uid=74)."
		useradd -d /usr/share/oer -g oer -s /bin/false -u 74 oer \
			|| die "failed to create oer user (uid=74)"
	fi

	chown -R oer:oer /etc/oer
	chmod 0700 /etc/oer
	chown oer:oer /usr/bin/oer+MySQL
	einfo "Setting /usr/bin/oer+MySQL suid oer."
	chmod 6755 /usr/bin/oer+MySQL

	echo

	einfo
	einfo "To create MySQL database and simple config for your bot execute:"
	einfo
	einfo "# ebuild /var/db/pkg/net-irc/${P}/${P}.ebuild config"
	einfo
	einfo "NOTICE: Your mysql server must be running when executing the command above."
	einfo
}

pkg_config() {

	cd /usr/share/oer
	tools/pre_install.sh /usr/bin
	chown oer:oer /etc/oer/oer+MySQL.conf
	chmod 0600 /etc/oer/oer+MySQL.conf /etc/oer/pre_install.log

	einfo
	einfo "If all went well, you can start you bot by typing:"
	einfo
	einfo "# oer+MySQL -f /etc/oer/oer+MySQL.conf"
	einfo

}