Subject: [alpine-devel] [PATCH] testing/motion: new aport

From: Mika Havela <[email-masked]>
Date: Wed, 7 Nov 2012 17:04:52 +0000

---
 testing/motion/APKBUILD                  |  56 ++++++++++
 testing/motion/motion-dist.conf.in.patch | 170 +++++++++++++++++++++++++++++++
 testing/motion/motion.confd              |  17 ++++
 testing/motion/motion.initd              |  27 +++++
 testing/motion/motion.pre-install        |   6 ++
 5 files changed, 276 insertions(+)
 create mode 100644 testing/motion/APKBUILD
 create mode 100644 testing/motion/motion-dist.conf.in.patch
 create mode 100644 testing/motion/motion.confd
 create mode 100644 testing/motion/motion.initd
 create mode 100644 testing/motion/motion.pre-install

diff --git a/testing/motion/APKBUILD b/testing/motion/APKBUILD
new file mode 100644
index 0000000..731ae5a
--- /dev/null
+++ b/testing/motion/APKBUILD
@@ -0,0 +1,56 @@
+# Contributor: Mika Havela <[email-masked]>
+# Maintainer: Mika Havela <[email-masked]>
+pkgname=motion
+pkgver=3.2.12
+pkgrel=0
+pkgdesc="Detect if a significant part of the picture has changed (e.g. from a webcam)."
+url="http://www.lavrsen.dk/foswiki/bin/view/Motion/WebHome"
+arch="all"
+license="GPL2"
+pkgusers="motion"
+pkggroups="motion"
+depends="jpeg v4l-utils"   # Add ffmpeg (when motion is patched/fixed for this)
+depends_dev=""
+makedepends="$depends_dev bash jpeg-dev v4l-utils-dev"  # Add ffmpeg-dev (when motion is patched/fixed for this)
+install="$pkgname.pre-install"
+subpackages="$pkgname-doc"
+source="http://downloads.sourceforge.net/$pkgname/$pkgname-$pkgver.tar.gz
+motion.confd
+motion.initd
+motion-dist.conf.in.patch"
+
+_builddir="$srcdir"/$pkgname-$pkgver
+prepare() {
+	local i
+	cd "$_builddir"
+	for i in $source; do
+		case $i in
+		*.patch) msg $i; patch -p1 -i "$srcdir"/$i || return 1;;
+		esac
+	done
+	sed -i 's@<linux/videodev.h>@<libv4l1.h>\n#include <linux/videodev2.h>@' *.c *.h
+}
+
+build() {
+	cd "$_builddir"
+	./configure \
+	  --prefix=/usr \
+	  --sysconfdir=/etc/motion
+
+	make || return 1
+}
+
+package() {
+	cd "$_builddir"
+	make DESTDIR="$pkgdir" install || return 1
+	install -d -o "$pkgusers" -g "$pkggroups" "$pkgdir"/var/run/motion
+	install -d -o "$pkgusers" -g "$pkggroups" "$pkgdir"/home/motion/motion_captures    # Default config is configured to store captures here
+	install -Dm644 "$srcdir"/"$pkgname".confd "$pkgdir"/etc/conf.d/"$pkgname"
+	install -Dm755 "$srcdir"/"$pkgname".initd "$pkgdir"/etc/init.d/"$pkgname"
+	install -Dm644 COPYING "$pkgdir"/usr/share/licenses/$pkgname/COPYING
+}
+
+md5sums="1ba0065ed50509aaffb171594c689f46  motion-3.2.12.tar.gz
+c444bfd48ac8d6272d5191836ceb544a  motion.confd
+3acfe162df3fec28c88c1688e7385189  motion.initd
+2ee4fa214987e7643025732f016e9296  motion-dist.conf.in.patch"
diff --git a/testing/motion/motion-dist.conf.in.patch b/testing/motion/motion-dist.conf.in.patch
new file mode 100644
index 0000000..9d6d82d
--- /dev/null
+++ b/testing/motion/motion-dist.conf.in.patch
@@ -0,0 +1,170 @@
+--- motion-3.2.12/motion-dist.conf.in
++++ ./motion-dist.conf.in
+@@ -1,6 +1,6 @@
+ # Rename this distribution example file to motion.conf
+ #
+-# This config file was generated by @PACKAGE_NAME@ @PACKAGE_VERSION@
++# This config file was generated by motion 3.2.12
+ 
+ 
+ ############################################################
+@@ -237,57 +237,6 @@
+ 
+ 
+ ############################################################
+-# FFMPEG related options
+-# Film (mpeg) file output, and deinterlacing of the video input
+-# The options movie_filename and timelapse_filename are also used
+-# by the ffmpeg feature
+-############################################################
+-
+-# Use ffmpeg to encode mpeg movies in realtime (default: off)
+-ffmpeg_cap_new on
+-
+-# Use ffmpeg to make movies with only the pixels moving
+-# object (ghost images) (default: off)
+-ffmpeg_cap_motion off
+-
+-# Use ffmpeg to encode a timelapse movie 
+-# Default value 0 = off - else save frame every Nth second
+-ffmpeg_timelapse 0
+-
+-# The file rollover mode of the timelapse video
+-# Valid values: hourly, daily (default), weekly-sunday, weekly-monday, monthly, manual
+-ffmpeg_timelapse_mode daily
+-
+-# Bitrate to be used by the ffmpeg encoder (default: 400000)
+-# This option is ignored if ffmpeg_variable_bitrate is not 0 (disabled)
+-ffmpeg_bps 500000
+-
+-# Enables and defines variable bitrate for the ffmpeg encoder.
+-# ffmpeg_bps is ignored if variable bitrate is enabled.
+-# Valid values: 0 (default) = fixed bitrate defined by ffmpeg_bps,
+-# or the range 2 - 31 where 2 means best quality and 31 is worst.
+-ffmpeg_variable_bitrate 0
+-
+-# Codec to used by ffmpeg for the video compression.
+-# Timelapse mpegs are always made in mpeg1 format independent from this option.
+-# Supported formats are: mpeg1 (ffmpeg-0.4.8 only), mpeg4 (default), and msmpeg4.
+-# mpeg1 - gives you files with extension .mpg
+-# mpeg4 or msmpeg4 - gives you files with extension .avi
+-# msmpeg4 is recommended for use with Windows Media Player because
+-# it requires no installation of codec on the Windows client.
+-# swf - gives you a flash film with extension .swf
+-# flv - gives you a flash video with extension .flv
+-# ffv1 - FF video codec 1 for Lossless Encoding ( experimental )
+-# mov - QuickTime ( testing )
+-ffmpeg_video_codec mpeg4
+-
+-# Use ffmpeg to deinterlace video. Necessary if you use an analog camera
+-# and see horizontal combing on moving objects in video or pictures.
+-# (default: off)
+-ffmpeg_deinterlace off
+-
+-
+-############################################################
+ # Snapshots (Traditional Periodic Webcam File Output)
+ ############################################################
+ 
+@@ -356,7 +305,7 @@
+ 
+ # Target base directory for pictures and films
+ # Recommended to use absolute path. (Default: current working directory)
+-target_dir /usr/local/apache2/htdocs/cam1
++target_dir /home/motion/motion_captures
+ 
+ # File path for snapshots (jpeg or ppm) relative to target_dir
+ # Default: %v-%Y%m%d%H%M%S-snapshot
+@@ -376,22 +325,7 @@
+ # convention for preview shots. See motion guide for details
+ jpeg_filename %v-%Y%m%d%H%M%S-%q
+ 
+-# File path for motion triggered ffmpeg films (mpeg) relative to target_dir
+-# Default: %v-%Y%m%d%H%M%S
+-# Default value is equivalent to legacy oldlayout option
+-# For Motion 3.0 compatible mode choose: %Y/%m/%d/%H%M%S
+-# File extension .mpg or .avi is automatically added so do not include this
+-# This option was previously called ffmpeg_filename
+-movie_filename %v-%Y%m%d%H%M%S
+ 
+-# File path for timelapse mpegs relative to target_dir
+-# Default: %Y%m%d-timelapse
+-# Default value is near equivalent to legacy oldlayout option
+-# For Motion 3.0 compatible mode choose: %Y/%m/%d-timelapse
+-# File extension .mpg is automatically added so do not include this
+-timelapse_filename %Y%m%d-timelapse
+-
+-
+ ############################################################
+ # Live Webcam Server
+ ############################################################
+@@ -540,69 +474,6 @@
+ # It depends on the driver, some drivers don't detect a lost camera at all
+ # Some hang the motion thread. Some even hang the PC! (default: none)
+ ; on_camera_lost value
+-
+-############################################################
+-# Common Options For MySQL and PostgreSQL database features.
+-# Options require the MySQL/PostgreSQL options to be active also.
+-############################################################
+-
+-# Log to the database when creating motion triggered image file  (default: on)
+-sql_log_image on
+-
+-# Log to the database when creating a snapshot image file (default: on)
+-sql_log_snapshot on
+-
+-# Log to the database when creating motion triggered mpeg file (default: off)
+-sql_log_mpeg off
+-
+-# Log to the database when creating timelapse mpeg file (default: off)
+-sql_log_timelapse off
+-
+-# SQL query string that is sent to the database
+-# Use same conversion specifiers has for text features
+-# Additional special conversion specifiers are
+-# %n = the number representing the file_type
+-# %f = filename with full path
+-# Default value:
+-# insert into security(camera, filename, frame, file_type, time_stamp, text_event) values('%t', '%f', '%q', '%n', '%Y-%m-%d %T', '%C')
+-sql_query insert into security(camera, filename, frame, file_type, time_stamp, event_time_stamp) values('%t', '%f', '%q', '%n', '%Y-%m-%d %T', '%C')
+-
+-
+-############################################################
+-# Database Options For MySQL
+-############################################################
+-
+-# Mysql database to log to (default: not defined)
+-; mysql_db value
+-
+-# The host on which the database is located (default: localhost)
+-; mysql_host value
+-
+-# User account name for MySQL database (default: not defined)
+-; mysql_user value
+-
+-# User password for MySQL database (default: not defined)
+-; mysql_password value
+-
+-
+-############################################################
+-# Database Options For PostgreSQL
+-############################################################
+-
+-# PostgreSQL database to log to (default: not defined)
+-; pgsql_db value
+-
+-# The host on which the database is located (default: localhost)
+-; pgsql_host value
+-
+-# User account name for PostgreSQL database (default: not defined)
+-; pgsql_user value
+-
+-# User password for PostgreSQL database (default: not defined)
+-; pgsql_password value
+-
+-# Port on which the PostgreSQL database is located (default: 5432)
+-; pgsql_port 5432
+ 
+ 
+ ############################################################
diff --git a/testing/motion/motion.confd b/testing/motion/motion.confd
new file mode 100644
index 0000000..ff24e5c
--- /dev/null
+++ b/testing/motion/motion.confd
@@ -0,0 +1,17 @@
+# /etc/conf.d/motion
+## -c     Full path and filename of config file. E.g. /home/kurt/motion.conf. 
+##        Default is /usr/local/etc unless specified differently when building 
+##        Motion. Many RPMs and debian packages will most likely use /etc or 
+##        /etc/motion as default.
+##
+## -n     Run in non-daemon mode.
+##
+## -s     Run in setup mode. Also forces non-daemon mode
+##
+## -d level Run in debug mode, level 1-9.
+##
+##
+## See the motion(1) manpage for more info.
+
+MOTION_OPTS="-c /etc/motion/motion-dist.conf"
+
diff --git a/testing/motion/motion.initd b/testing/motion/motion.initd
new file mode 100644
index 0000000..78493c3
--- /dev/null
+++ b/testing/motion/motion.initd
@@ -0,0 +1,27 @@
+#!/sbin/runscript
+# Copyright 1999-2004 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/net-misc/rsync/files/rsyncd.init.d,v 1.5 2007/02/23 11:33:59 uberlord Exp $
+
+description="motion daemon"
+user="motion"
+command="/usr/bin/motion"
+pidfile="/var/run/${RC_SVCNAME}/${RC_SVCNAME}.pid"
+
+start() {
+	ebegin "Starting ${RC_SVCNAME}"
+	start-stop-daemon --start \
+	    --exec ${command} \
+	    --user ${user} \
+	    --pidfile ${pidfile} \
+	    -- ${MOTION_OPTS}
+	eend $?
+}
+
+stop() {
+	ebegin "Stopping ${RC_SVCNAME}"
+	start-stop-daemon --stop \
+	    --exec ${command} \
+	    --pidfile ${pidfile}
+	eend $?
+}
diff --git a/testing/motion/motion.pre-install b/testing/motion/motion.pre-install
new file mode 100644
index 0000000..f4ff0d9
--- /dev/null
+++ b/testing/motion/motion.pre-install
@@ -0,0 +1,6 @@
+#!/bin/sh
+addgroup -S motion 2>/dev/null
+adduser -S -h /home/motion -s /bin/false -G motion -D motion 2>/dev/null
+addgroup motion video
+exit 0
+
-- 
1.7.12.3

---
Unsubscribe:  [email-masked]
Help:         [email-masked]
---