From 6a97f907a6f20b1a834a840221f7001279ecd3f4 Mon Sep 17 00:00:00 2001 From: Emmanuel Papin Date: Sun, 14 Dec 2014 20:47:56 +0100 Subject: [PATCH] Provide a debian folder to allow build of upstream package --- distros/debian/README.source | 12 ++ distros/debian/changelog | 9 + distros/debian/compat | 1 + distros/debian/control | 58 ++++++ distros/debian/copyright | 19 ++ distros/debian/docs | 2 + distros/debian/libopenalpr-dev.install | 3 + distros/debian/libopenalpr1.install | 2 + distros/debian/openalpr-daemon.default | 22 +++ distros/debian/openalpr-daemon.init | 175 ++++++++++++++++++ distros/debian/openalpr-daemon.install | 2 + distros/debian/openalpr-data.install | 1 + distros/debian/openalpr-utils.install | 6 + distros/debian/openalpr-utils.manpages | 1 + distros/debian/patches/enable_utilities.diff | 67 +++++++ .../patches/install_static_library.diff | 10 + ...make_alpr_dependent_to_shared_library.diff | 11 ++ distros/debian/patches/series | 3 + distros/debian/rules | 78 ++++++++ distros/debian/source/format | 1 + 20 files changed, 483 insertions(+) create mode 100644 distros/debian/README.source create mode 100644 distros/debian/changelog create mode 100644 distros/debian/compat create mode 100644 distros/debian/control create mode 100644 distros/debian/copyright create mode 100644 distros/debian/docs create mode 100644 distros/debian/libopenalpr-dev.install create mode 100644 distros/debian/libopenalpr1.install create mode 100644 distros/debian/openalpr-daemon.default create mode 100644 distros/debian/openalpr-daemon.init create mode 100644 distros/debian/openalpr-daemon.install create mode 100644 distros/debian/openalpr-data.install create mode 100644 distros/debian/openalpr-utils.install create mode 100644 distros/debian/openalpr-utils.manpages create mode 100644 distros/debian/patches/enable_utilities.diff create mode 100644 distros/debian/patches/install_static_library.diff create mode 100644 distros/debian/patches/make_alpr_dependent_to_shared_library.diff create mode 100644 distros/debian/patches/series create mode 100755 distros/debian/rules create mode 100644 distros/debian/source/format diff --git a/distros/debian/README.source b/distros/debian/README.source new file mode 100644 index 0000000..b546508 --- /dev/null +++ b/distros/debian/README.source @@ -0,0 +1,12 @@ +This package uses quilt to manage all modifications to the upstream source. +Changes are stored in the source package as diffs in debian/patches and applied +during the build. + +See /usr/share/doc/quilt/README.source for a detailed explanation. + + +This package uses the version 3.0 of the debian source package; An upstream +tarball is required to build it. This tarball can be generated automagically by +downloading the sources from the github repository with the following command: + +fakeroot debian/rules get-orig-source diff --git a/distros/debian/changelog b/distros/debian/changelog new file mode 100644 index 0000000..f44b35a --- /dev/null +++ b/distros/debian/changelog @@ -0,0 +1,9 @@ +openalpr (2.0.0-0.1) experimental; urgency=low + + * Non maintainer upload. + * Upstream release with several fixes: + - Compilation of utilities enabled + - installation of static library + - alpr build against shared library + + -- Emmanuel Papin Sun, 14 Dec 2014 19:39:07 +0200 diff --git a/distros/debian/compat b/distros/debian/compat new file mode 100644 index 0000000..ec63514 --- /dev/null +++ b/distros/debian/compat @@ -0,0 +1 @@ +9 diff --git a/distros/debian/control b/distros/debian/control new file mode 100644 index 0000000..65dd9ec --- /dev/null +++ b/distros/debian/control @@ -0,0 +1,58 @@ +Source: openalpr +Section: video +Priority: optional +Maintainer: Matt Hill +Build-Depends: debhelper (>= 9), libopencv-dev, libtesseract-dev, git, cmake, + build-essential, libtesseract-dev, libleptonica-dev, liblog4cplus-dev, + libcurl3-dev, uuid-dev +Standards-Version: 3.9.5 +Homepage: https://github.com/openalpr/openalpr + +Package: libopenalpr1 +Section: libs +Architecture: amd64 +Depends: openalpr-data (= ${source:Version}), ${shlibs:Depends}, ${misc:Depends} +Description: Automated License Plate Recognition library (OpenALPR) + OpenALPR is an open source Automatic License Plate Recognition library written + in C++. The library analyzes images and identifies license plates. The output + is the text representation of any license plate characters found in the image. + +Package: libopenalpr-dev +Section: libdevel +Architecture: amd64 +Depends: libopenalpr1 (= ${binary:Version}), ${misc:Depends} +Description: Development files for OpenALPR library + OpenALPR is an open source Automatic License Plate Recognition library written + in C++. The library analyzes images and identifies license plates. The output + is the text representation of any license plate characters found in the image. + +Package: openalpr-data +Section: misc +Architecture: all +Depends: ${misc:Depends} +Description: Runtime data for OpenALPR library + OpenALPR is an open source Automatic License Plate Recognition library written + in C++. The library analyzes images and identifies license plates. The output + is the text representation of any license plate characters found in the image. + +Package: openalpr-daemon +Section: video +Architecture: amd64 +Depends: openalpr-data (= ${source:Version}), ${shlibs:Depends}, ${misc:Depends} +Description: Daemon to run OpenALPR in the background + OpenALPR is an open source Automatic License Plate Recognition library written + in C++. The library analyzes images and identifies license plates. The output + is the text representation of any license plate characters found in the image. + The OpenALPR daemon allows you to monitor a camera stream for license plate + numbers in the background. Alprd runs as a daemon process on Linux. + The plate numbers can be streamed to another server (via HTTP posts) or can be + consumed programmatically via a beanstalkd queue. + +Package: openalpr-utils +Section: utils +Architecture: amd64 +Depends: openalpr-data (= ${source:Version}), ${shlibs:Depends}, ${misc:Depends} +Description: Utilities for the OpenALPR library + OpenALPR is an open source Automatic License Plate Recognition library written + in C++. The library analyzes images and identifies license plates. The output + is the text representation of any license plate characters found in the image. diff --git a/distros/debian/copyright b/distros/debian/copyright new file mode 100644 index 0000000..4bdd803 --- /dev/null +++ b/distros/debian/copyright @@ -0,0 +1,19 @@ +Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Upstream-Name: openalpr +Source: https://github.com/openalpr/openalpr + +Files: * +Copyright: 2013-2015 Matt Hill +License: AGPL-3.0 + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as + published by the Free Software Foundation, either version 3 of the + License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . diff --git a/distros/debian/docs b/distros/debian/docs new file mode 100644 index 0000000..f678bec --- /dev/null +++ b/distros/debian/docs @@ -0,0 +1,2 @@ +cla.txt +README.md diff --git a/distros/debian/libopenalpr-dev.install b/distros/debian/libopenalpr-dev.install new file mode 100644 index 0000000..877c682 --- /dev/null +++ b/distros/debian/libopenalpr-dev.install @@ -0,0 +1,3 @@ +usr/include/alpr.h +usr/lib/lib*.a +usr/lib/lib*so diff --git a/distros/debian/libopenalpr1.install b/distros/debian/libopenalpr1.install new file mode 100644 index 0000000..ac4ae8a --- /dev/null +++ b/distros/debian/libopenalpr1.install @@ -0,0 +1,2 @@ +usr/lib/lib*.so.* +usr/etc/openalpr/openalpr.conf etc/openalpr diff --git a/distros/debian/openalpr-daemon.default b/distros/debian/openalpr-daemon.default new file mode 100644 index 0000000..0cc67ed --- /dev/null +++ b/distros/debian/openalpr-daemon.default @@ -0,0 +1,22 @@ +# Defaults for alprd initscript +# sourced by /etc/init.d/openalpr-daemon +# installed at /etc/default/openalpr-daemon by the maintainer scripts +# +# This is a POSIX shell fragment +# +# These options can be set to modify the behavior of the openalr-daemon init script. +# The options commented out show the default values. + +# Start the daemon if set to "yes" +START_DAEMON="yes" + +# Path to the log file +#LOGFILE="/var/log/alpr.log" + +# User and group the daemon should run as +#USER="www-data" +#GROUP="www-data" + +# Additional options that are passed to the daemon +#DAEMON_OPTS="-n 20" + diff --git a/distros/debian/openalpr-daemon.init b/distros/debian/openalpr-daemon.init new file mode 100644 index 0000000..aaeb934 --- /dev/null +++ b/distros/debian/openalpr-daemon.init @@ -0,0 +1,175 @@ +#!/bin/sh +### BEGIN INIT INFO +# Provides: openalpr-daemon +# Required-Start: $local_fs $network $remote_fs $syslog +# Required-Stop: $local_fs $network $remote_fs $syslog +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: OpenALPR daemon for license plate recognition +# Description: OpenALPR daemon detects license plate in the background +### END INIT INFO + +# Author: lokidor + +unset USER + +# PATH should only include /usr/* if it runs after the mountnfs.sh script +PATH=/sbin:/usr/sbin:/bin:/usr/bin +DESC="OpenALPR daemon" +NAME=openalpr-daemon +DAEMON=/usr/bin/alprd +PIDFILE=/var/run/alprd.pid +SCRIPTNAME=/etc/init.d/$NAME +DEFAULT=/etc/default/$NAME + +# Exit if the package is not installed +[ -x "$DAEMON" ] || exit 0 + +# Read configuration variable file if it is present +[ -r $DEFAULT ] && . $DEFAULT + +# Load the VERBOSE setting and other rcS variables +. /lib/init/vars.sh + +# Define LSB log_* functions. +# Depend on lsb-base (>= 3.2-14) to ensure that this file is present +# and status_of_proc is working. +. /lib/lsb/init-functions + +# Do not start the daemon if NO_START is enabled in DEFAULT +if [ "$START_DAEMON" != "yes" ] && [ "$1" != "stop" ]; then + log_warning_msg "$NAME: Not starting $DESC." + log_warning_msg "$NAME: Disabled in $DEFAULT." + exit 0 +fi + +# Set the default log file +if [ -z $LOGFILE ]; then + LOGFILE=/var/log/alpr.log +fi + +# Set the default daemon options +if [ -z $DAEMON_OPTS ]; then + DAEMON_OPTS="-n 20" +fi + +# Run as `www-data' if USER is not specified or is `root' +if [ -z $USER ]; then + USER=www-data +fi + +# If no group is specified, use USER +if [ -z $GROUP ]; then + GROUP=$USER +fi + +DAEMON_ARGS="-l $LOGFILE $DAEMON_OPTS" + +# +# Function that starts the daemon/service +# +do_start() +{ + # Return + # 0 if daemon has been started + # 1 if daemon was already running + # 2 if daemon could not be started + [ ! -f $LOGFILE ] && touch $LOGFILE && chown $USER:$GROUP $LOGFILE \ + || return 2 + start-stop-daemon --start --quiet --pidfile $PIDFILE \ + --chuid $USER:$GROUP --exec $DAEMON --test > /dev/null \ + || return 1 + start-stop-daemon --start --quiet --pidfile $PIDFILE \ + --chuid $USER:$GROUP --exec $DAEMON -- \ + $DAEMON_ARGS \ + || return 2 +} + +# +# Function that stops the daemon/service +# +do_stop() +{ + # Return + # 0 if daemon has been stopped + # 1 if daemon was already stopped + # 2 if daemon could not be stopped + # other if a failure occurred + start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE --name $NAME + RETVAL="$?" + [ "$RETVAL" = 2 ] && return 2 + # Wait for children to finish too if this is a daemon that forks + # and if the daemon is only ever run from this initscript. + # If the above conditions are not satisfied then add some other code + # that waits for the process to drop all resources that could be + # needed by services started subsequently. A last resort is to + # sleep for some time. + start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON + [ "$?" = 2 ] && return 2 + # Many daemons don't delete their pidfiles when they exit. + rm -f $PIDFILE + return "$RETVAL" +} + +# +# Function that sends a SIGHUP to the daemon/service +# +do_reload() { + # + # If the daemon can reload its configuration without + # restarting (for example, when it is sent a SIGHUP), + # then implement that here. + # + start-stop-daemon --stop --signal 1 --quiet --pidfile $PIDFILE --name $NAME + return 0 +} + +case "$1" in + start) + [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME" + do_start + case "$?" in + 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; + 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; + esac + ;; + stop) + [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME" + do_stop + case "$?" in + 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; + 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; + esac + ;; + status) + status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $? + ;; + restart|force-reload) + # + # If the "reload" option is implemented then remove the + # 'force-reload' alias + # + log_daemon_msg "Restarting $DESC" "$NAME" + do_stop + case "$?" in + 0|1) + do_start + case "$?" in + 0) log_end_msg 0 ;; + 1) log_end_msg 1 ;; # Old process is still running + *) log_end_msg 1 ;; # Failed to start + esac + ;; + *) + # Failed to stop + log_end_msg 1 + ;; + esac + ;; + *) + echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2 + exit 3 + ;; +esac + +: diff --git a/distros/debian/openalpr-daemon.install b/distros/debian/openalpr-daemon.install new file mode 100644 index 0000000..f14b7ee --- /dev/null +++ b/distros/debian/openalpr-daemon.install @@ -0,0 +1,2 @@ +usr/bin/alprd +usr/etc/openalpr/alprd.conf etc/openalpr diff --git a/distros/debian/openalpr-data.install b/distros/debian/openalpr-data.install new file mode 100644 index 0000000..91594f9 --- /dev/null +++ b/distros/debian/openalpr-data.install @@ -0,0 +1 @@ +usr/share/openalpr/runtime_data diff --git a/distros/debian/openalpr-utils.install b/distros/debian/openalpr-utils.install new file mode 100644 index 0000000..9822d40 --- /dev/null +++ b/distros/debian/openalpr-utils.install @@ -0,0 +1,6 @@ +usr/bin/alpr +usr/bin/sortstate-openalpr-utils +usr/bin/classifychars-openalpr-utils +usr/bin/benchmark-openalpr-utils +usr/bin/prepcharsfortraining-openalpr-utils +usr/bin/tagplates-openalpr-utils diff --git a/distros/debian/openalpr-utils.manpages b/distros/debian/openalpr-utils.manpages new file mode 100644 index 0000000..3587728 --- /dev/null +++ b/distros/debian/openalpr-utils.manpages @@ -0,0 +1 @@ +doc/man/alpr.1 diff --git a/distros/debian/patches/enable_utilities.diff b/distros/debian/patches/enable_utilities.diff new file mode 100644 index 0000000..2c00974 --- /dev/null +++ b/distros/debian/patches/enable_utilities.diff @@ -0,0 +1,67 @@ +--- a/src/misc_utilities/CMakeLists.txt ++++ b/src/misc_utilities/CMakeLists.txt +@@ -1,28 +1,28 @@ + +-ADD_EXECUTABLE( sortstate EXCLUDE_FROM_ALL sortstate.cpp ) +-TARGET_LINK_LIBRARIES(sortstate +- openalpr-static ++ADD_EXECUTABLE( sortstate-openalpr-utils sortstate.cpp ) ++TARGET_LINK_LIBRARIES(sortstate-openalpr-utils ++ openalpr + support + ${OpenCV_LIBS} + ${Tesseract_LIBRARIES} + ) + +-ADD_EXECUTABLE( classifychars EXCLUDE_FROM_ALL classifychars.cpp ) +-TARGET_LINK_LIBRARIES(classifychars +- openalpr-static ++ADD_EXECUTABLE( classifychars-openalpr-utils classifychars.cpp ) ++TARGET_LINK_LIBRARIES(classifychars-openalpr-utils ++ openalpr + support + ${OpenCV_LIBS} + ${Tesseract_LIBRARIES} + ) + + +-ADD_EXECUTABLE(benchmark EXCLUDE_FROM_ALL ++ADD_EXECUTABLE(benchmark-openalpr-utils + benchmarks/benchmark.cpp + benchmarks/benchmark_utils.cpp + benchmarks/endtoendtest.cpp + ) +-TARGET_LINK_LIBRARIES(benchmark +- openalpr-static ++TARGET_LINK_LIBRARIES(benchmark-openalpr-utils ++ openalpr + support + pthread + ${OpenCV_LIBS} +@@ -30,16 +30,22 @@ + ) + + +-ADD_EXECUTABLE( prepcharsfortraining EXCLUDE_FROM_ALL prepcharsfortraining.cpp ) +-TARGET_LINK_LIBRARIES(prepcharsfortraining ++ADD_EXECUTABLE( prepcharsfortraining-openalpr-utils prepcharsfortraining.cpp ) ++TARGET_LINK_LIBRARIES(prepcharsfortraining-openalpr-utils + support + ${OpenCV_LIBS} + ) + + +-ADD_EXECUTABLE( tagplates EXCLUDE_FROM_ALL tagplates.cpp ) +-TARGET_LINK_LIBRARIES(tagplates ++ADD_EXECUTABLE( tagplates-openalpr-utils tagplates.cpp ) ++TARGET_LINK_LIBRARIES(tagplates-openalpr-utils + support + ${OpenCV_LIBS} + ) + ++install (TARGETS sortstate-openalpr-utils DESTINATION bin) ++install (TARGETS classifychars-openalpr-utils DESTINATION bin) ++install (TARGETS benchmark-openalpr-utils DESTINATION bin) ++install (TARGETS prepcharsfortraining-openalpr-utils DESTINATION bin) ++install (TARGETS tagplates-openalpr-utils DESTINATION bin) ++ diff --git a/distros/debian/patches/install_static_library.diff b/distros/debian/patches/install_static_library.diff new file mode 100644 index 0000000..46f4c6e --- /dev/null +++ b/distros/debian/patches/install_static_library.diff @@ -0,0 +1,10 @@ +--- a/src/openalpr/CMakeLists.txt ++++ b/src/openalpr/CMakeLists.txt +@@ -47,6 +47,7 @@ + + + install (FILES alpr.h DESTINATION ${CMAKE_INSTALL_PREFIX}/include) ++install (TARGETS openalpr-static DESTINATION ${CMAKE_INSTALL_PREFIX}/lib) + install (TARGETS openalpr DESTINATION ${CMAKE_INSTALL_PREFIX}/lib) + + # Add definition for default config file diff --git a/distros/debian/patches/make_alpr_dependent_to_shared_library.diff b/distros/debian/patches/make_alpr_dependent_to_shared_library.diff new file mode 100644 index 0000000..6775715 --- /dev/null +++ b/distros/debian/patches/make_alpr_dependent_to_shared_library.diff @@ -0,0 +1,11 @@ +--- a/src/CMakeLists.txt ++++ b/src/CMakeLists.txt +@@ -55,7 +55,7 @@ + ADD_EXECUTABLE( alpr main.cpp ) + + TARGET_LINK_LIBRARIES(alpr +- openalpr-static ++ openalpr + support + video + ${OpenCV_LIBS} diff --git a/distros/debian/patches/series b/distros/debian/patches/series new file mode 100644 index 0000000..e87ab72 --- /dev/null +++ b/distros/debian/patches/series @@ -0,0 +1,3 @@ +install_static_library.diff +make_alpr_dependent_to_shared_library.diff +enable_utilities.diff diff --git a/distros/debian/rules b/distros/debian/rules new file mode 100755 index 0000000..d9cedb0 --- /dev/null +++ b/distros/debian/rules @@ -0,0 +1,78 @@ +#!/usr/bin/make -f +# See debhelper(7) (uncomment to enable) +# output every command that modifies files on the build system. +#DH_VERBOSE = 1 + +# see EXAMPLES in dpkg-buildflags(1) and read /usr/share/dpkg/* +# DPKG_EXPORT_BUILDFLAGS = 1 +include /usr/share/dpkg/default.mk +# + +# These are used to get the most recent version of the original sources from github +UURL = $(shell git config --get remote.origin.url) +BRANCH = $(shell git rev-parse --abbrev-ref HEAD) +HEAD = $(shell git rev-parse HEAD) +PKD = $(shell pwd)/debian +PKG = $(word 2,$(shell dpkg-parsechangelog -l$(PKD)/changelog | grep ^Source)) +VER ?= $(shell dpkg-parsechangelog -l$(PKD)/changelog | perl -ne 'print $$1 if m{^Version:\s+(?:\d+:)?(\d.*)(?:\-\d+.*)};') +DTYPE = +TARBALL = ../$(PKG)_$(VER)$(DTYPE).orig.tar.xz + +# see FEATURE AREAS in dpkg-buildflags(1) +#export DEB_BUILD_MAINT_OPTIONS = hardening=+all + +# see ENVIRONMENT in dpkg-buildflags(1) +# package maintainers to append CFLAGS +#export DEB_CFLAGS_MAINT_APPEND = -Wall -pedantic +# package maintainers to append LDFLAGS +#export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed + +# main packaging script based on dh7 syntax +%: + dh $@ --sourcedirectory=src --with quilt + +# debmake generated override targets +# This is example for Cmake (See http://bugs.debian.org/641051 ) +#override_dh_auto_configure: +# dh_auto_configure -- \ +# -DCMAKE_BUILD_TYPE:STRING=Debug + +# Inspired by https://wiki.debian.org/onlyjob/get-orig-source +.PHONY: get-orig-source +get-orig-source: $(TARBALL) $(info I: $(PKG)_$(VER)$(DTYPE)) + @ + +$(TARBALL): + $(if $(wildcard $(PKG)-$(VER)),$(error folder '$(PKG)-$(VER)' exists, aborting...)) + @echo "# Cloning origin repository..."; \ + if ! git clone $(UURL) $(PKG)-$(VER); then \ + $(RM) -r $(PKG)-$(VER); \ + echo "failed to clone repository, aborting..."; \ + false; \ + fi + @if [ $(BRANCH) != "master" ]; then \ + cd $(PKG)-$(VER); \ + echo "# Not on master branch, fetching origin branch '$(BRANCH)'..."; \ + git fetch origin $(BRANCH):$(BRANCH) || false; \ + echo "# Switching to branch '$(BRANCH)'..."; \ + git checkout $(BRANCH) || false; \ + fi + @echo "# Checking local source..." + @if [ $$(cd $(PKG)-$(VER) && git rev-parse HEAD) = $(HEAD) ]; then \ + echo "even with origin, ok"; \ + true; \ + else \ + echo "not even with origin, aborting..."; \ + false; \ + fi + @echo "# Setting times..." + @cd $(PKG)-$(VER) \ + && for F in $$(git ls-tree -r --name-only HEAD | sed -e "s/\s/\*/g"); do \ + touch --no-dereference -d "$$(git log -1 --format="%ai" -- $$F)" "$$F"; \ + done + @echo "# Cleaning-up..." + cd $(PKG)-$(VER) && $(RM) -r .git + @echo "# Packing file '$(TARBALL)'..." + @find -L "$(PKG)-$(VER)" -xdev -type f -print | sort \ + | XZ_OPT="-6v" tar -caf "$(TARBALL)" -T- --owner=root --group=root --mode=a+rX \ + && $(RM) -r "$(PKG)-$(VER)" diff --git a/distros/debian/source/format b/distros/debian/source/format new file mode 100644 index 0000000..163aaf8 --- /dev/null +++ b/distros/debian/source/format @@ -0,0 +1 @@ +3.0 (quilt)