[MediaWiki-commits] [Gerrit] New upstream version. Port to Varnish 4. - change (operations...libvmod-netmapper)

2016-02-02 Thread Ema (Code Review)
Ema has submitted this change and it was merged.

Change subject: New upstream version. Port to Varnish 4.
..


New upstream version. Port to Varnish 4.

Version 1.3 of libvmod-netmapper features some autotools-related changes
because of the way vmods are built in Varnish 4. It is now possible to
build vmods out-of-tree.

Further, architectural changes in Varnish 4 required minor modifcations
to the module itself.

Change-Id: I1a3facbd96b875c9f88e066092d59fc09bee2c37
---
M Makefile.am
M NEWS
M autogen.sh
M configure.ac
M src/Makefile.am
M src/vmod_netmapper.c
M src/vmod_netmapper.vcc
M src/vnm.c
8 files changed, 74 insertions(+), 50 deletions(-)

Approvals:
  Ema: Verified; Looks good to me, approved
  BBlack: Looks good to me, but someone else must approve



diff --git a/Makefile.am b/Makefile.am
index d7dcb2b..5b581e7 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -2,6 +2,9 @@
 
 SUBDIRS = src
 
+DISTCHECK_CONFIGURE_FLAGS = \
+   VMOD_DIR='$${libdir}/varnish/vmods'
+
 EXTRA_DIST = README.rst
 
 dist_man_MANS = vmod_netmapper.3
diff --git a/NEWS b/NEWS
index 2039f67..e64a29c 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,8 @@
+1.3 - 2016-02-02
+   Use vrt_ctx pointers instead of a sess pointers in VMOD functions.
+   Use VSLb instead of WSP for logging.
+   Autotools-related changes because of the way vmods are built in Varnish 4.
+
 1.2 - 2013-09-12
Added vnm_validate cmdline tool.  Exit status indicates JSON parse-ability.
  Accepts IP addr as extra argument for manual results debugging.
diff --git a/autogen.sh b/autogen.sh
index 9a12ef5..08d225b 100755
--- a/autogen.sh
+++ b/autogen.sh
@@ -35,8 +35,19 @@
esac
 fi
 
-set -ex
+# check for varnishapi.m4 in custom paths
+dataroot=$(pkg-config --variable=datarootdir varnishapi 2>/dev/null)
+if [ -z "$dataroot" ] ; then
+cat >&2 <<'EOF'
+Package varnishapi was not found in the pkg-config search path.
+Perhaps you should add the directory containing `varnishapi.pc'
+to the PKG_CONFIG_PATH environment variable
+EOF
+exit 1
+fi
 
+set -ex
+[ -d m4 ] || mkdir m4
 aclocal -I m4
 $LIBTOOLIZE --copy --force
 autoheader
diff --git a/configure.ac b/configure.ac
index aa0a8fd..c763247 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,7 +1,8 @@
 AC_PREREQ(2.59)
-AC_COPYRIGHT([Copyright (c) 2013 Brandon Black ])
-AC_INIT([libvmod-netmapper],[1.2],[bbl...@wikimedia.org],[libvmod-netmapper],[https://git.wikimedia.org/summary/operations%2Fsoftware%2Fvarnish%2Flibvmod-netmapper])
+AC_COPYRIGHT([Copyright (c) 2013-2016 Brandon Black ])
+AC_INIT([libvmod-netmapper],[1.3],[bbl...@wikimedia.org],[libvmod-netmapper],[https://git.wikimedia.org/summary/operations%2Fsoftware%2Fvarnish%2Flibvmod-netmapper])
 AC_CONFIG_MACRO_DIR([m4])
+m4_ifndef([VARNISH_VMOD_INCLUDES], AC_MSG_ERROR([Need varnish.m4]))
 AC_CONFIG_AUX_DIR([acaux])
 AC_CONFIG_SRCDIR(src/vmod_netmapper.vcc)
 AM_CONFIG_HEADER(config.h)
@@ -41,36 +42,35 @@
 # Check for python
 AC_CHECK_PROGS(PYTHON, [python3 python3.1 python3.2 python2.7 python2.6 
python2.5 python2 python], [AC_MSG_ERROR([Python is needed to build this vmod, 
please install python.])])
 
-# Varnish source tree
-AC_ARG_VAR([VARNISHSRC], [path to Varnish source tree (mandatory)])
-if test "x$VARNISHSRC" = x; then
-   AC_MSG_ERROR([No Varnish source tree specified])
-fi
-VARNISHSRC=`cd $VARNISHSRC && pwd`
-AC_CHECK_FILE([$VARNISHSRC/include/varnishapi.h],
-   [],
-   [AC_MSG_FAILURE(["$VARNISHSRC" is not a Varnish source directory])]
-)
+PKG_CHECK_MODULES([libvarnishapi], [varnishapi])
+PKG_CHECK_VAR([LIBVARNISHAPI_PREFIX], [varnishapi], [prefix])
+PKG_CHECK_VAR([LIBVARNISHAPI_DATAROOTDIR], [varnishapi], [datarootdir])
+PKG_CHECK_VAR([LIBVARNISHAPI_BINDIR], [varnishapi], [bindir])
+PKG_CHECK_VAR([LIBVARNISHAPI_SBINDIR], [varnishapi], [sbindir])
+AC_SUBST([LIBVARNISHAPI_DATAROOTDIR])
 
-# varnishd and varnishtest locations (default from source tree)
+# Varnish include files tree
+VARNISH_VMOD_INCLUDES
+VARNISH_VMOD_DIR
+VARNISH_VMODTOOL
+# AC_PREFIX_DEFAULT acts too early in the configure run,
+# so we can't use it
+ac_default_prefix=$LIBVARNISHAPI_PREFIX
 
-AC_ARG_VAR([VARNISHD], [path to varnishd binary (default: used built copy in 
VARNISHSRC)])
-if test "x$VARNISHD" = x; then
-VARNISHD="$VARNISHSRC/bin/varnishd/varnishd"
-fi
-AC_CHECK_FILE([$VARNISHD],
-   [],
-[AC_MSG_FAILURE([varnishd binary "$VARNISHD" does not exist])]
-)
+AC_PATH_PROG([VARNISHTEST], [varnishtest], [],
+[$LIBVARNISHAPI_BINDIR:$LIBVARNISHAPI_SBINDIR:$PATH])
+AC_PATH_PROG([VARNISHD], [varnishd], [],
+[$LIBVARNISHAPI_SBINDIR:$LIBVARNISHAPI_BINDIR:$PATH])
 
-AC_ARG_VAR([VARNISHTEST], [path to varnishtest binary (default: used built 
copy in VARNISHSRC)])
-if test "x$VARNISHTEST" = x; then
-VARNISHTEST="$VARNISHSRC/bin/varnishtest/varnishtest"
-fi
-AC_CHECK_FILE([$VARNISHTEST],
-   [],
-

[MediaWiki-commits] [Gerrit] New upstream version. Port to Varnish 4. - change (operations...libvmod-netmapper)

2016-02-02 Thread Ema (Code Review)
Ema has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/267885

Change subject: New upstream version. Port to Varnish 4.
..

New upstream version. Port to Varnish 4.

Version 1.3 of libvmod-netmapper features some autotools-related changes
because of the way vmods are built in Varnish 4. It is now possible to
build vmods out-of-tree.

Further, architectural changes in Varnish 4 required minor modifcations
to the module itself.

Change-Id: I1a3facbd96b875c9f88e066092d59fc09bee2c37
---
M Makefile.am
M NEWS
M autogen.sh
M configure.ac
M src/Makefile.am
M src/vmod_netmapper.c
M src/vmod_netmapper.vcc
M src/vnm.c
8 files changed, 74 insertions(+), 50 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/operations/software/varnish/libvmod-netmapper 
refs/changes/85/267885/1

diff --git a/Makefile.am b/Makefile.am
index d7dcb2b..5b581e7 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -2,6 +2,9 @@
 
 SUBDIRS = src
 
+DISTCHECK_CONFIGURE_FLAGS = \
+   VMOD_DIR='$${libdir}/varnish/vmods'
+
 EXTRA_DIST = README.rst
 
 dist_man_MANS = vmod_netmapper.3
diff --git a/NEWS b/NEWS
index 2039f67..e64a29c 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,8 @@
+1.3 - 2016-02-02
+   Use vrt_ctx pointers instead of a sess pointers in VMOD functions.
+   Use VSLb instead of WSP for logging.
+   Autotools-related changes because of the way vmods are built in Varnish 4.
+
 1.2 - 2013-09-12
Added vnm_validate cmdline tool.  Exit status indicates JSON parse-ability.
  Accepts IP addr as extra argument for manual results debugging.
diff --git a/autogen.sh b/autogen.sh
index 9a12ef5..08d225b 100755
--- a/autogen.sh
+++ b/autogen.sh
@@ -35,8 +35,19 @@
esac
 fi
 
-set -ex
+# check for varnishapi.m4 in custom paths
+dataroot=$(pkg-config --variable=datarootdir varnishapi 2>/dev/null)
+if [ -z "$dataroot" ] ; then
+cat >&2 <<'EOF'
+Package varnishapi was not found in the pkg-config search path.
+Perhaps you should add the directory containing `varnishapi.pc'
+to the PKG_CONFIG_PATH environment variable
+EOF
+exit 1
+fi
 
+set -ex
+[ -d m4 ] || mkdir m4
 aclocal -I m4
 $LIBTOOLIZE --copy --force
 autoheader
diff --git a/configure.ac b/configure.ac
index aa0a8fd..c763247 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,7 +1,8 @@
 AC_PREREQ(2.59)
-AC_COPYRIGHT([Copyright (c) 2013 Brandon Black ])
-AC_INIT([libvmod-netmapper],[1.2],[bbl...@wikimedia.org],[libvmod-netmapper],[https://git.wikimedia.org/summary/operations%2Fsoftware%2Fvarnish%2Flibvmod-netmapper])
+AC_COPYRIGHT([Copyright (c) 2013-2016 Brandon Black ])
+AC_INIT([libvmod-netmapper],[1.3],[bbl...@wikimedia.org],[libvmod-netmapper],[https://git.wikimedia.org/summary/operations%2Fsoftware%2Fvarnish%2Flibvmod-netmapper])
 AC_CONFIG_MACRO_DIR([m4])
+m4_ifndef([VARNISH_VMOD_INCLUDES], AC_MSG_ERROR([Need varnish.m4]))
 AC_CONFIG_AUX_DIR([acaux])
 AC_CONFIG_SRCDIR(src/vmod_netmapper.vcc)
 AM_CONFIG_HEADER(config.h)
@@ -41,36 +42,35 @@
 # Check for python
 AC_CHECK_PROGS(PYTHON, [python3 python3.1 python3.2 python2.7 python2.6 
python2.5 python2 python], [AC_MSG_ERROR([Python is needed to build this vmod, 
please install python.])])
 
-# Varnish source tree
-AC_ARG_VAR([VARNISHSRC], [path to Varnish source tree (mandatory)])
-if test "x$VARNISHSRC" = x; then
-   AC_MSG_ERROR([No Varnish source tree specified])
-fi
-VARNISHSRC=`cd $VARNISHSRC && pwd`
-AC_CHECK_FILE([$VARNISHSRC/include/varnishapi.h],
-   [],
-   [AC_MSG_FAILURE(["$VARNISHSRC" is not a Varnish source directory])]
-)
+PKG_CHECK_MODULES([libvarnishapi], [varnishapi])
+PKG_CHECK_VAR([LIBVARNISHAPI_PREFIX], [varnishapi], [prefix])
+PKG_CHECK_VAR([LIBVARNISHAPI_DATAROOTDIR], [varnishapi], [datarootdir])
+PKG_CHECK_VAR([LIBVARNISHAPI_BINDIR], [varnishapi], [bindir])
+PKG_CHECK_VAR([LIBVARNISHAPI_SBINDIR], [varnishapi], [sbindir])
+AC_SUBST([LIBVARNISHAPI_DATAROOTDIR])
 
-# varnishd and varnishtest locations (default from source tree)
+# Varnish include files tree
+VARNISH_VMOD_INCLUDES
+VARNISH_VMOD_DIR
+VARNISH_VMODTOOL
+# AC_PREFIX_DEFAULT acts too early in the configure run,
+# so we can't use it
+ac_default_prefix=$LIBVARNISHAPI_PREFIX
 
-AC_ARG_VAR([VARNISHD], [path to varnishd binary (default: used built copy in 
VARNISHSRC)])
-if test "x$VARNISHD" = x; then
-VARNISHD="$VARNISHSRC/bin/varnishd/varnishd"
-fi
-AC_CHECK_FILE([$VARNISHD],
-   [],
-[AC_MSG_FAILURE([varnishd binary "$VARNISHD" does not exist])]
-)
+AC_PATH_PROG([VARNISHTEST], [varnishtest], [],
+[$LIBVARNISHAPI_BINDIR:$LIBVARNISHAPI_SBINDIR:$PATH])
+AC_PATH_PROG([VARNISHD], [varnishd], [],
+[$LIBVARNISHAPI_SBINDIR:$LIBVARNISHAPI_BINDIR:$PATH])
 
-AC_ARG_VAR([VARNISHTEST], [path to varnishtest binary (default: used built 
copy in VARNISHSRC)])
-if test "x$VARNISHTEST" = x; then
-VARNISHTEST="$VARNISHSRC/bin/varnishtest/varnishtest"
-fi
-AC_CHECK_FILE([$VARNISHTEST],
-