Bug#518235: [PATCH] SOCKS, "socksify irssi" vs linking

Christoph Fritz <[email protected]> Mon, 29 Mar 2010 02:13:58 +0200
Newsgroups gmane.linux.debian.devel.bugs.general,gmane.network.irc.irssi.devel
Message-ID <1269821638.11061.10.camel@lovely>
$ socksify irssi
-!- Irssi: Unable to connect server irc.freenode.net port 6667 [No route to host]

So I brought lenny's dante up to date and did some small changes to
configure.in:

1. apt-get source irssi
2. apply patch
3. autoreconf -i
4. dpkg-buildpackage 2>&1 | tee /tmp/irssi_buil.log
5. dpkg -i irssi_0.8.12-8_i386.deb

$ irssi
-!- Welcome to the freenode Internet Relay Chat Network

Why doesn't "socksify irssi" work but linking?

[PATCH] Proxy enhancements (incl. native SOCKS5 support) 
at http://bugs.irssi.org/index.php?do=details&task_id=691
looks nice, why isn't this in trunk?

---
 configure.in     |   43 +++++++++++++++++++++++++++++++------------
 debian/changelog |    7 +++++++
 debian/control   |    4 +++-
 debian/rules     |    2 +-
 4 files changed, 42 insertions(+), 14 deletions(-)

diff --git a/configure.in b/configure.in
index a864415..3cfb484 100644
--- a/configure.in
+++ b/configure.in
@@ -282,18 +282,37 @@ dnl ** check for socks
 dnl **
 
 if test "x$want_socks" = "xyes"; then
-	AC_CHECK_LIB(socks, connect, [
-		AC_DEFINE(HAVE_SOCKS,, Build with socks support)
-		LIBS="$LIBS -lsocks"
-		AC_CHECK_HEADER(socks.h, [
-			AC_DEFINE(HAVE_SOCKS_H)
-			CFLAGS="$CFLAGS -DSOCKS"
-			AC_MSG_RESULT(["socks5 library found, building with it"])
-		], [
-			AC_MSG_RESULT(["socks4 library found, building with it"])
-			CFLAGS="$CFLAGS -Dconnect=Rconnect -Dgetsockname=Rgetsockname -Dgetpeername=Rgetpeername -Dbind=Rbind -Daccept=Raccept -Dlisten=Rlisten -Dselect=Rselect"
-		])
-	])
+		AC_MSG_CHECKING([for socks])
+		oldLIBS=$LIBS
+		LIBS="-lsocks $LIBS"
+		AC_TRY_LINK([void check() { }],
+			[connect();],
+				SOCKS_LIB="-lsocks",
+			SOCKS_LIB="")
+		LIBS=$oldLIBS
+		dnl Debian uses libsocksd
+		if test -z "$SOCKS_LIB"; then
+			oldLIBS=$LIBS
+			LIBS="-lsocksd $LIBS"
+			AC_TRY_LINK([void check() { }],
+				[Rconnect();],
+					SOCKS_LIB="-lsocksd",
+			SOCKS_LIB="")
+			LIBS=$oldLIBS
+		fi
+		if test "$SOCKS_LIB"; then
+			AC_MSG_RESULT(["$SOCKS_LIB found"])
+			AC_DEFINE(HAVE_SOCKS,, Build with socks support)
+			LIBS="$LIBS $SOCKS_LIB"
+			AC_CHECK_HEADER(socks.h, [
+				AC_DEFINE(HAVE_SOCKS_H)
+				CFLAGS="$CFLAGS -DSOCKS"
+				AC_MSG_RESULT(["socks5 library found, building with it"])
+			], [
+				AC_MSG_RESULT(["socks4 library found, building with it"])
+				CFLAGS="$CFLAGS -Dconnect=Rconnect -Dgetsockname=Rgetsockname -Dgetpeername=Rgetpeername -Dbind=Rbind -Daccept=Raccept -Dlisten=Rlisten -Dselect=Rselect"
+			])
+		fi
 fi
 
 dnl **
diff --git a/debian/changelog b/debian/changelog
index 74df6db..9e3d965 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,10 @@
+irssi (0.8.12-8) unstable; urgency=low
+
+  * add SOCKS support
+    (closes: #518235)
+
+ -- Christoph Fritz <[email protected]>  Sun, 28 Mar 2010 18:43:23 +0200
+
 irssi (0.8.12-7) stable; urgency=medium
 
   * Fetch patch wallops-fix to fix CVE-2009-1959 off-by-one in event_wallops
diff --git a/debian/control b/debian/control
index fa1197f..bbf929a 100644
--- a/debian/control
+++ b/debian/control
@@ -3,7 +3,7 @@ Section: net
 Priority: optional
 Maintainer: David Pashley <[email protected]>
 Uploaders: Gerfried Fuchs <[email protected]>
-Build-Depends: debhelper (>= 5), autotools-dev, libglib2.0-dev, perl (>= 5.8.1), libperl-dev (>= 5.8.1), libncurses5-dev, libssl-dev, openssl, quilt
+Build-Depends: debhelper (>= 5), autotools-dev, libglib2.0-dev, perl (>= 5.8.1), libperl-dev (>= 5.8.1), libncurses5-dev, libsocksd0-dev, libssl-dev, openssl, quilt
 Standards-Version: 3.8.0
 Homepage: http://irssi.org/
 Vcs-Git: git://git.debian.org/git/users/alfie/irssi.git
@@ -26,6 +26,7 @@ Description: terminal based IRC client
   * Irssi-proxy
   * Transparent upgrading
   * Recode support
+  * SOCKS support
 
 Package: irssi-dev
 Architecture: any
@@ -43,5 +44,6 @@ Description: text-mode version of the irssi IRC client development files
   * Irssi-proxy
   * Transparent upgrading
   * Recode support
+  * SOCKS support
  .
  This package includes the development files for the irssi client.
diff --git a/debian/rules b/debian/rules
index d5841ad..174ae4d 100755
--- a/debian/rules
+++ b/debian/rules
@@ -31,7 +31,7 @@ config.status: patch configure
 	CFLAGS="$(CFLAGS)" ./configure --host=$(DEB_HOST_GNU_TYPE) --build=$(DEB_BUILD_GNU_TYPE) \
 			 --prefix=/usr --mandir=\$${prefix}/share/man --infodir=\$${prefix}/share/info \
 			 --sysconfdir=/etc \
-	--without-servertest --enable-ipv6 --with-bot --with-proxy \
+	--without-servertest --enable-ipv6 --with-bot --with-proxy --with-socks \
 	--enable-perl --with-perl-lib=vendor
 
 
-- 
1.5.6.5