#!/bin/bash
#
-# selector is a simple shell command for selection of strings with a
-# dynamic pattern-matching.
+# selector is a simple command line utility for selection of strings
+# with a dynamic pattern-matching.
#
# Copyright (c) 2009 Francois Fleuret
-# Written by Francois Fleuret <francois.fleuret@idiap.ch>
+# Written by Francois Fleuret <francois@fleuret.org>
#
# This file is part of selector.
#
# along with selector. If not, see <http://www.gnu.org/licenses/>.
#
-VERSION=1.0
+# This script creates the Debian package. The way it does it is
+# probably not very conventional. I am open to suggestions.
+
+set -e
+
+VERSION=1.0-R$(cat REVISION_NUMBER)
+PACKAGE=/tmp/selector_${VERSION}_i386.deb
+
+BIN_PATH="usr/bin"
+MAN_PATH="usr/share/man/man1"
+
+make -j -k || exit 1
+
+strip selector
TMP=`mktemp -d /tmp/deb.XXXXXX`
-for d in DEBIAN usr/bin usr/man/man1; do
+for d in DEBIAN ${BIN_PATH} ${MAN_PATH}; do
mkdir -p ${TMP}/${d}
done
+mkdir -p debian/control
+
+LIB_DEPENDS=$(dpkg-shlibdeps -O ./selector | grep Depends | sed -e "s/^.*Depends=//")
+
cat > ${TMP}/DEBIAN/control <<EOF
Package: selector
Version: ${VERSION}
Maintainer: Francois Fleuret <francois@fleuret.org>
-Description: A command line dynamic string-matching
Architecture: i386
-Depends: libncurses5, libstdc++6, libc6, libgcc1
+Depends: ${LIB_DEPENDS}
+Description: A command line utility for dynamic string-matching
+ This is a command line utility for dynamic string selection. As you
+ type a list of substrings separated by ';', or a regexp, the display
+ is updated in real time to show only the matching lines. The main
+ usage of selector is as an efficient search in the shell command
+ history. With the correct option, it will inject the selected line
+ into the tty input buffer, allowing the user to edit the line and
+ execute it as a standard command.
EOF
-cp ./selector ${TMP}/usr/bin
-cp ./selector.1 ${TMP}/usr/man/man1
+cp ./selector ${TMP}/${BIN_PATH}
+cp ./selector.1 ${TMP}/${MAN_PATH}
+gzip ${TMP}/${MAN_PATH}/selector.1
+
+dpkg-deb --build ${TMP} ${PACKAGE}
-dpkg-deb --build ${TMP} selector_${VERSION}_i386.deb
+dpkg --contents ${PACKAGE}
rm -rf ${TMP}