summaryrefslogtreecommitdiff
blob: 88bd55f9b576463cd252bf350209804f9a727a05 (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
# Copyright 1999-2007 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/media-video/motion/motion-3.2.9.ebuild,v 1.1 2007/11/19 21:09:03 aballier Exp $

inherit eutils

DESCRIPTION="Motion is a video motion detector with tracking-support for webcams."
HOMEPAGE="http://www.lavrsen.dk/twiki/bin/view/Motion/WebHome"
SRC_URI="mirror://sourceforge/${PN}/${P}.tar.gz"

LICENSE="GPL-2"
SLOT="0"
KEYWORDS="~alpha ~amd64 ~ppc ~x86"
IUSE="ffmpeg mysql postgres v4l"

DEPEND="sys-libs/zlib
	media-libs/jpeg
	media-video/mjpegtools
	ffmpeg? ( media-video/ffmpeg )
	mysql? ( virtual/mysql )
	postgres? ( dev-db/postgresql )"

pkg_setup() {
	enewuser motion -1 -1 -1 "video" || die "failed to create motion user"
}

src_unpack() {
	unpack ${A}
	cd "${S}"
	epatch "${FILESDIR}/${P}-asneeded.patch"
}

src_compile() {
	econf --without-optimizecpu \
		$(use_with v4l) \
		$(use_with mysql) \
		$(use_with postgres pgsql) \
		$(use_with ffmpeg)

	emake || die "emake failed."
}

src_install() {
	emake DESTDIR="${D}" install || die "emake install failed."

	# Install init script.
	newinitd "${FILESDIR}"/motion.init-r1 motion
	newconfd "${FILESDIR}"/motion.confd motion

	# Create correct dir for motion.pid
	dodir /var/run/motion
	fowners motion:video /var/run/motion
	fperms 750 /var/run/motion
	keepdir /var/run/motion

	# Rename configuration file.
	mv "${D}"/etc/motion-dist.conf "${D}"/etc/motion.conf

	# Tell it to use a pid file where motion user has the rights to write to
	sed -i -e "s:motion.pid:motion/\0:" "${D}/etc/motion.conf"

	# Remove dummy documentation and install it using ebuild functions.
	rm -rf "${D}"/usr/share/doc/${P}
	dodoc CHANGELOG CODE_STANDARD CREDITS FAQ README README.FreeBSD *.conf
	dohtml *.html
}

pkg_postinst() {
	elog "You need to setup /etc/motion.conf before running"
	elog "motion for the first time. You can install motion"
	elog "detection as a service, use:"
	elog "rc-update add motion default"
}