ndn-tools: Initial packaging

Change-Id: Ic1e722903cdc146095dccb410999c36303d5233d
diff --git a/ndn-tools/Makefile b/ndn-tools/Makefile
new file mode 100644
index 0000000..8392438
--- /dev/null
+++ b/ndn-tools/Makefile
@@ -0,0 +1,16 @@
+# URL for git clone
+GIT_URL=https://github.com/named-data/ndn-tools
+
+# Tag name or commit hash for checkout
+GIT_VERSION=4bd28fc8394a53a49fc283ead2bdc6a77893da4c
+
+# Package name
+NAME=ndn-tools
+
+# Package version
+VERSION=0.0.0-1-g4bd28fc
+
+# PPA version
+PPA_VERSION=1
+
+include ../packaging.mk
diff --git a/ndn-tools/debian/changelog b/ndn-tools/debian/changelog
new file mode 100644
index 0000000..24a6e0f
--- /dev/null
+++ b/ndn-tools/debian/changelog
@@ -0,0 +1,5 @@
+ndn-tools (0.0.0~ppa0~DISTRO) DISTRO; urgency=low
+
+  * Initial release
+
+ -- Alexander Afanasyev <alexander.afanasyev@ucla.edu>  Wed, 22 Jul 2015 15:58:30 -0800
diff --git a/ndn-tools/debian/compat b/ndn-tools/debian/compat
new file mode 100644
index 0000000..45a4fb7
--- /dev/null
+++ b/ndn-tools/debian/compat
@@ -0,0 +1 @@
+8
diff --git a/ndn-tools/debian/control b/ndn-tools/debian/control
new file mode 100644
index 0000000..32797d6
--- /dev/null
+++ b/ndn-tools/debian/control
@@ -0,0 +1,43 @@
+Source: ndn-tools
+Priority: extra
+Maintainer: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
+Build-Depends: debhelper (>= 8.0.0),
+ dh-systemd (>= 1.5),
+ python (>= 2.7.0),
+ pkg-config (>= 0.26),
+ libpcap-dev,
+ ndn-cxx-dev (>= 0.3.3)
+Standards-Version: 3.9.2
+Section: net
+Homepage: http://github.com/named-data/ndn-tools
+Vcs-Git: git://github.com/named-data/ndn-tools.git
+Vcs-Browser: http://github.com/named-data/ndn-tools
+
+Package: ndn-tools
+Architecture: i386 amd64
+Depends: ndndump, ndnping, ndnpeek, ndn-dissect
+
+Package: ndndump
+Architecture: i386 amd64
+Depends: ${shlibs:Depends}, ${misc:Depends}, ndn-cxx
+Description: A traffic analysis tool that captures Interest and Data packets
+ on the wire, and displays brief information about captured packets.
+
+Package: ndnping
+Architecture: i386 amd64
+Depends: ${shlibs:Depends}, ${misc:Depends}, ndn-cxx, nfd
+Description: Reachability testing tools for Named Data Networking.
+
+Package: ndnpeek
+Architecture: i386 amd64
+Depends: ${shlibs:Depends}, ${misc:Depends}, ndn-cxx
+Description: ndnpeek and ndnpoke are a pair of programs to request and make available
+ for retrieval of a single Data packet.
+
+Package: ndn-dissect
+Architecture: i386 amd64
+Depends: ${shlibs:Depends}, ${misc:Depends}, ndn-cxx
+Description: An NDN packet format inspector. It reads zero or more NDN packets from either
+ an input file or the standard input, and displays the Type-Length-Value (TLV) structure
+ of those packets on the standard output.
+
diff --git a/ndn-tools/debian/copyright b/ndn-tools/debian/copyright
new file mode 100644
index 0000000..b511787
--- /dev/null
+++ b/ndn-tools/debian/copyright
@@ -0,0 +1,43 @@
+Format: http://dep.debian.net/deps/dep5
+Upstream-Name: ndndump
+Source: http://github.com/named-data/ndndump
+
+Files: *
+Copyright: Copyright (c) 2011-2014, Regents of the University of California.
+License: GPL-3+
+ ndndump is free software: you can redistribute it and/or modify it under the terms
+ of the GNU General Public License as published by the Free Software Foundation,
+ either version 3 of the License, or (at your option) any later version.
+ .
+ ndndump 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 General Public License for more details.
+ .
+ You should have received a copy of the GNU General Public License along with
+ ndndump, e.g., in COPYING file.  If not, see <http://www.gnu.org/licenses/>.
+
+Files: debian/*
+Copyright: Copyright (c) 2013-2015, Alexander Afanasyev <alexander.afanasyev@ucla.edu>
+License: BSD
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+     * Redistributions of source code must retain the above copyright
+       notice, this list of conditions and the following disclaimer.
+     * Redistributions in binary form must reproduce the above copyright
+       notice, this list of conditions and the following disclaimer in the
+       documentation and/or other materials provided with the distribution.
+     * Neither the name of the Regents of the University of California nor
+       the names of its contributors may be used to endorse or promote
+       products derived from this software without specific prior written
+       permission.
+ .
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ ARE DISCLAIMED. IN NO EVENT SHALL REGENTS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/ndn-tools/debian/ndn-dissect.install b/ndn-tools/debian/ndn-dissect.install
new file mode 100644
index 0000000..e1cf36f
--- /dev/null
+++ b/ndn-tools/debian/ndn-dissect.install
@@ -0,0 +1,3 @@
+usr/bin/ndn-dissect
+usr/share/man/man1/ndn-dissect.1
+
diff --git a/ndn-tools/debian/ndndump.install b/ndn-tools/debian/ndndump.install
new file mode 100644
index 0000000..a66c852
--- /dev/null
+++ b/ndn-tools/debian/ndndump.install
@@ -0,0 +1,2 @@
+usr/bin/ndndump
+usr/share/man/man8/ndndump.8
diff --git a/ndn-tools/debian/ndnpeek.install b/ndn-tools/debian/ndnpeek.install
new file mode 100644
index 0000000..98ef4a8
--- /dev/null
+++ b/ndn-tools/debian/ndnpeek.install
@@ -0,0 +1,5 @@
+usr/bin/ndnpeek
+usr/bin/ndnpoke
+usr/share/man/man1/ndnpeek.1
+usr/share/man/man1/ndnpoke.1
+
diff --git a/ndn-tools/debian/ndnping.default b/ndn-tools/debian/ndnping.default
new file mode 100644
index 0000000..d5a1b5b
--- /dev/null
+++ b/ndn-tools/debian/ndnping.default
@@ -0,0 +1,6 @@
+# defaults for ndnping server
+
+# Prefix should be set to a valid value
+PREFIX="/localhost/ndnpingserver"
+
+FLAGS=""
diff --git a/ndn-tools/debian/ndnping.install b/ndn-tools/debian/ndnping.install
new file mode 100644
index 0000000..a0307d9
--- /dev/null
+++ b/ndn-tools/debian/ndnping.install
@@ -0,0 +1,5 @@
+usr/bin/ndnping
+usr/bin/ndnpingserver
+usr/share/man/man1/ndnping.1
+usr/share/man/man1/ndnpingserver.1
+
diff --git a/ndn-tools/debian/ndnping.postinst b/ndn-tools/debian/ndnping.postinst
new file mode 100644
index 0000000..09502a5
--- /dev/null
+++ b/ndn-tools/debian/ndnping.postinst
@@ -0,0 +1,19 @@
+#!/bin/sh -e
+
+if [ "$1" != "configure" ]; then
+        exit 0
+fi
+
+APP=ndnping
+
+if [ ! -f /var/lib/ndn/$APP/.ndn/ndnsec-public-info.db ]; then
+    # Create HOME and generate self-signed NDN certificate
+    sudo mkdir -p /var/lib/ndn/$APP/.ndn
+    sudo chown -R ndn:ndn /var/lib/ndn/$APP
+    sudo -u ndn -g ndn HOME=/var/lib/ndn/$APP ndnsec-keygen /localhost/daemons/$APP | \
+      sudo -u ndn -g ndn HOME=/var/lib/ndn/$APP ndnsec-install-cert -
+fi
+
+#DEBHELPER#
+
+exit 0
diff --git a/ndn-tools/debian/ndnping.service b/ndn-tools/debian/ndnping.service
new file mode 100644
index 0000000..fc2ce8f
--- /dev/null
+++ b/ndn-tools/debian/ndnping.service
@@ -0,0 +1,24 @@
+# Authors:
+# - Eric Newberry <enewberry@email.arizona.edu>
+# - Alexander Afanasyev <http://lasr.cs.ucla.edu/afanasyev/index.html>
+
+[Unit]
+Description=Reachability testing server for Named Data Networking.
+Documentation=man:ndnpingserver
+Requires=nfd.service
+After=nfd.service
+
+[Service]
+Environment=HOME=/var/lib/ndn/ndnping
+EnvironmentFile=-/etc/default/ndnping
+User=ndn
+Group=ndn
+ExecStart=/usr/bin/ndnpingserver "$PREFIX" $FLAGS
+Restart=on-failure
+ProtectSystem=full
+PrivateTmp=yes
+PrivateDevices=yes
+ProtectHome=yes
+
+[Install]
+WantedBy=multi-user.target
diff --git a/ndn-tools/debian/ndnping.upstart b/ndn-tools/debian/ndnping.upstart
new file mode 100644
index 0000000..75d9cc4
--- /dev/null
+++ b/ndn-tools/debian/ndnping.upstart
@@ -0,0 +1,21 @@
+description "NDN TLV ping server"
+author      "Alexander Afanasyev <alexander.afanasyev@ucla.edu>"
+
+start on started  nfd
+stop  on stopping nfd
+
+respawn
+respawn limit unlimited
+
+setuid ndn
+setgid ndn
+
+script
+    FLAGS=""
+    PREFIX="/localhost/ndnpingserver"
+    if [ -f /etc/default/ndnping ]; then
+        . /etc/default/ndnping
+    fi
+    export HOME=/var/lib/ndn/ndnping
+    exec /usr/bin/ndnpingserver "$PREFIX" $FLAGS
+end script
diff --git a/ndn-tools/debian/rules b/ndn-tools/debian/rules
new file mode 100755
index 0000000..a4d748a
--- /dev/null
+++ b/ndn-tools/debian/rules
@@ -0,0 +1,38 @@
+#!/usr/bin/make -f
+# -*- makefile -*-
+# Sample debian/rules that uses debhelper.
+# This file was originally written by Joey Hess and Craig Small.
+# As a special exception, when this file is copied by dh-make into a
+# dh-make output file, you may use that output file without restriction.
+# This special exception was added by Craig Small in version 0.37 of dh-make.
+
+# Uncomment this to turn on verbose mode.
+# export DH_VERBOSE=1
+
+LDFLAGS := $(shell dpkg-buildflags --get LDFLAGS)
+CXXFLAGS := $(shell dpkg-buildflags --get CXXFLAGS)
+
+%:
+	dh $@ --parallel --with=systemd
+
+override_dh_auto_configure:
+	CXXFLAGS="$(CXXFLAGS)" LINKFLAGS="$(LDFLAGS)" ./waf configure --prefix=/usr
+
+override_dh_auto_build:
+	./waf build
+
+override_dh_auto_install:
+	./waf install --destdir=debian/tmp
+
+override_dh_auto_clean:
+	./waf distclean
+
+override_dh_clean:
+	dh_clean
+	./waf distclean
+	rm -rf .waf-1*
+	rm -rf .waf3-1*
+	rm -f .waf-tools/*.pyc
+	rm -Rf manpages/*.pyc
+
+override_dh_auto_test:
diff --git a/ndn-tools/debian/source/format b/ndn-tools/debian/source/format
new file mode 100644
index 0000000..163aaf8
--- /dev/null
+++ b/ndn-tools/debian/source/format
@@ -0,0 +1 @@
+3.0 (quilt)