The following commit has been merged in the master branch:
commit 0e130ee1ab1f2e43ac24b8867dfabd66563a4e6b
Author: Eric Cooper <e...@cmu.edu>
Date:   Tue Mar 10 16:43:02 2009 -0400

    determine approx port using debconf

diff --git a/debian/approx.config b/debian/approx.config
new file mode 100644
index 0000000..d28379f
--- /dev/null
+++ b/debian/approx.config
@@ -0,0 +1,17 @@
+#!/bin/sh -e
+
+. /usr/share/debconf/confmodule
+
+db_set approx/port 9999
+numeric=no
+while [ $numeric = no ]; do
+    db_input medium approx/port || true
+    db_go || true
+    db_get approx/port
+    if echo "$RET" | grep -q '^[0-9][0-9]*$'; then
+        numeric=yes
+    else
+        db_input medium approx/numeric_port || true
+        db_go || true
+    fi
+done
diff --git a/debian/approx.postinst b/debian/approx.postinst
index fc5c9bb..987a177 100644
--- a/debian/approx.postinst
+++ b/debian/approx.postinst
@@ -1,8 +1,11 @@
 #!/bin/sh -e
 
-if [ "$1" != "configure" ]; then
-    exit 0
-fi
+. /usr/share/debconf/confmodule
+
+case "$1" in
+    configure|reconfigure) ;;
+    *) exit 0 ;;
+esac
 
 # add the approx user
 adduser --quiet --system --group --no-create-home --home /var/cache/approx 
approx
@@ -14,17 +17,18 @@ if [ ! -d /var/cache/approx ]; then
 fi
 
 # add entry to /etc/inetd.conf
-update-inetd --add "9999\t\tstream\ttcp\tnowait\tapprox\t/usr/sbin/approx"
-
-# remove unused defaults file
-if [ -f /etc/default/approx ]; then
-    rm -f /etc/default/approx
-fi
+db_get approx/port
+port="$RET"
+update-inetd --add "$port\t\tstream\ttcp\tnowait\tapprox\t/usr/sbin/approx"
 
-# remove unused init script
-if [ -f /etc/init.d/approx ]; then
-    rm -f /etc/init.d/approx
-    update-rc.d approx remove >/dev/null
+if dpkg --compare-versions "$2" lt "4.0"; then
+    if [ -f /etc/default/approx ]; then
+        rm -f /etc/default/approx
+    fi
+    if [ -f /etc/init.d/approx ]; then
+        rm -f /etc/init.d/approx
+        update-rc.d approx remove >/dev/null
+    fi
 fi
 
 #DEBHELPER#
diff --git a/debian/approx.templates b/debian/approx.templates
new file mode 100644
index 0000000..4207aa2
--- /dev/null
+++ b/debian/approx.templates
@@ -0,0 +1,11 @@
+Template: approx/port
+Type: string
+Default: 9999
+Description: TCP port for approx service:
+ Please enter the numeric TCP port on which approx should listen for requests.
+ The default is 9999 (for compatibility with apt-proxy).
+
+Template: approx/numeric_port
+Type: error
+Description: Port must be numeric
+  The port must be specified as a decimal number.

-- 
approx upstream and debian packaging

_______________________________________________
Pkg-ocaml-maint-commits mailing list
Pkg-ocaml-maint-commits@lists.alioth.debian.org
http://lists.alioth.debian.org/mailman/listinfo/pkg-ocaml-maint-commits

Reply via email to