varnish / libvmod-example Goto Github PK
View Code? Open in Web Editor NEWAn example vmod for Varnish Cache
Home Page: https://varnish-cache.org/vmods/
An example vmod for Varnish Cache
Home Page: https://varnish-cache.org/vmods/
With current git master for vmod example, the source tree is always rebuilt when running make.
Expected: No files rebuilt since no source files have been modified between invocations.
(=3a37e) lkarsten@IMMER ~/work/libvmod-example> make
make all-recursive
make[1]: Entering directory '/home/lkarsten/work/libvmod-example'
Making all in src
make[2]: Entering directory '/home/lkarsten/work/libvmod-example/src'
/usr/share/varnish-plus/vmodtool.py ../src/vmod_example.vcc
/bin/bash ../libtool --tag=CC --mode=compile gcc -std=gnu99 -DHAVE_CONFIG_H -I. -I.. -I/usr/include/varnish-plus -Wall -Werror -g -O2 -MT vmod_example.lo -MD -MP -MF .deps/vmod_example.Tpo -c -o vmod_example.lo vmod_example.c
libtool: compile: gcc -std=gnu99 -DHAVE_CONFIG_H -I. -I.. -I/usr/include/varnish-plus -Wall -Werror -g -O2 -MT vmod_example.lo -MD -MP -MF .deps/vmod_example.Tpo -c vmod_example.c -fPIC -DPIC -o .libs/vmod_example.o
mv -f .deps/vmod_example.Tpo .deps/vmod_example.Plo
/bin/bash ../libtool --tag=CC --mode=link gcc -std=gnu99 -g -O2 -module -export-dynamic -avoid-version -shared -o libvmod_example.la -rpath /usr/lib/varnish-plus/vmods vmod_example.lo vcc_if.lo
libtool: link: rm -fr .libs/libvmod_example.la .libs/libvmod_example.lai .libs/libvmod_example.so
libtool: link: gcc -std=gnu99 -shared -fPIC -DPIC .libs/vmod_example.o .libs/vcc_if.o -O2 -Wl,-soname -Wl,libvmod_example.so -o .libs/libvmod_example.so
libtool: link: ( cd ".libs" && rm -f "libvmod_example.la" && ln -s "../libvmod_example.la" "libvmod_example.la" )
make[2]: Leaving directory '/home/lkarsten/work/libvmod-example/src'
make[2]: Entering directory '/home/lkarsten/work/libvmod-example'
make[2]: Leaving directory '/home/lkarsten/work/libvmod-example'
make[1]: Leaving directory '/home/lkarsten/work/libvmod-example'
# Rerunning without modifying/touching any files:
(=3a37e) lkarsten@IMMER ~/work/libvmod-example> make
make all-recursive
make[1]: Entering directory '/home/lkarsten/work/libvmod-example'
Making all in src
make[2]: Entering directory '/home/lkarsten/work/libvmod-example/src'
/usr/share/varnish-plus/vmodtool.py ../src/vmod_example.vcc
/bin/bash ../libtool --tag=CC --mode=compile gcc -std=gnu99 -DHAVE_CONFIG_H -I. -I.. -I/usr/include/varnish-plus -Wall -Werror -g -O2 -MT vcc_if.lo -MD -MP -MF .deps/vcc_if.Tpo -c -o vcc_if.lo vcc_if.c
libtool: compile: gcc -std=gnu99 -DHAVE_CONFIG_H -I. -I.. -I/usr/include/varnish-plus -Wall -Werror -g -O2 -MT vcc_if.lo -MD -MP -MF .deps/vcc_if.Tpo -c vcc_if.c -fPIC -DPIC -o .libs/vcc_if.o
mv -f .deps/vcc_if.Tpo .deps/vcc_if.Plo
/bin/bash ../libtool --tag=CC --mode=compile gcc -std=gnu99 -DHAVE_CONFIG_H -I. -I.. -I/usr/include/varnish-plus -Wall -Werror -g -O2 -MT vmod_example.lo -MD -MP -MF .deps/vmod_example.Tpo -c -o vmod_example.lo vmod_example.c
rst2man vmod_example.man.rst vmod_example.3
libtool: compile: gcc -std=gnu99 -DHAVE_CONFIG_H -I. -I.. -I/usr/include/varnish-plus -Wall -Werror -g -O2 -MT vmod_example.lo -MD -MP -MF .deps/vmod_example.Tpo -c vmod_example.c -fPIC -DPIC -o .libs/vmod_example.o
mv -f .deps/vmod_example.Tpo .deps/vmod_example.Plo
/bin/bash ../libtool --tag=CC --mode=link gcc -std=gnu99 -g -O2 -module -export-dynamic -avoid-version -shared -o libvmod_example.la -rpath /usr/lib/varnish-plus/vmods vmod_example.lo vcc_if.lo
libtool: link: rm -fr .libs/libvmod_example.la .libs/libvmod_example.lai .libs/libvmod_example.so
libtool: link: gcc -std=gnu99 -shared -fPIC -DPIC .libs/vmod_example.o .libs/vcc_if.o -O2 -Wl,-soname -Wl,libvmod_example.so -o .libs/libvmod_example.so
libtool: link: ( cd ".libs" && rm -f "libvmod_example.la" && ln -s "../libvmod_example.la" "libvmod_example.la" )
make[2]: Leaving directory '/home/lkarsten/work/libvmod-example/src'
make[2]: Entering directory '/home/lkarsten/work/libvmod-example'
make[2]: Leaving directory '/home/lkarsten/work/libvmod-example'
The installation path comes from pkg-config, and does not take DESTDIR into account.
$ ~/work/libvmod-example> LC_ALL=C make distcheck
make dist-gzip am__post_remove_distdir='@:'
[..]
make[3]: Entering directory '/home/lkarsten/work/libvmod-example/libvmod-example-trunk/_build/src'
make[3]: Nothing to be done for 'install-exec-am'.
/bin/mkdir -p '/usr/lib/x86_64-linux-gnu/varnish/vmods'
/bin/mkdir: cannot create directory '/usr/lib/x86_64-linux-gnu/varnish': Permission denied
Makefile:372: recipe for target 'install-vmodLTLIBRARIES' failed
make[3]: *** [install-vmodLTLIBRARIES] Error 1
make[3]: Leaving directory '/home/lkarsten/work/libvmod-example/libvmod-example-trunk/_build/src'
Makefile:540: recipe for target 'install-am' failed
make[2]: *** [install-am] Error 2
make[2]: Leaving directory '/home/lkarsten/work/libvmod-example/libvmod-example-trunk/_build/src'
Makefile:473: recipe for target 'install-recursive' failed
make[1]: *** [install-recursive] Error 1
make[1]: Leaving directory '/home/lkarsten/work/libvmod-example/libvmod-example-trunk/_build'
Makefile:679: recipe for target 'distcheck' failed
make: *** [distcheck] Error 1
configure prefers varnishd/varnishtest from $PATH over those from directories from the pkg-config, so libvmod-example may end up building against a different installation than the one used for make check
$ PATH=/usr/sbin:$PATH
$ PKG_CONFIG_PATH=/tmp/lib/pkgconfig ./configure
...
checking for varnishtest... /usr/bin/varnishtest
checking for varnishd... /usr/sbin/varnishd
but:
$ PKG_CONFIG_PATH=/tmp/lib/pkgconfig pkg-config --variable=sbindir varnishapi
/tmp/sbin
$ PKG_CONFIG_PATH=/tmp/lib/pkgconfig pkg-config --variable=bindir varnishapi
/tmp/bin
$ ls -als /tmp/sbin/varnishd /tmp/bin/varnishtest
360 -rwxr-xr-x 1 slink slink 366600 Mar 3 17:45 /tmp/bin/varnishtest
2632 -rwxr-xr-x 1 slink slink 2692576 Mar 3 17:45 /tmp/sbin/varnishd
this can be worked around by passing the VARNISHD
and VARNISHTEST
variables to configure
pointing to the right paths.
I will prepare a fix and issue a pull request.
The PKG_CHECK_VAR macro was added to pkg.m4 with commit 5b463c927b6caeb332bb147572ea82b1650ceb7d of git://anongit.freedesktop.org/pkg-config, which went into pkg-config-0.28
Thus, on systems with pkg-config <= 0.27, PKG_CHECK_VAR is not available and autoconf fails.
The phony make target "vcc" was introduced in c7087eb doesn't seem to handle fresh builds with -j set:
(=3a37e) lkarsten@IMMER ~/work/libvmod-example> make
make all-recursive
make[1]: Entering directory '/home/lkarsten/work/libvmod-example'
Making all in src
make[2]: Entering directory '/home/lkarsten/work/libvmod-example/src'
/usr/share/varnish-plus/vmodtool.py ../src/vmod_example.vcc
make[2]: *** No rule to make target 'vcc_if.c', needed by 'vcc_if.lo'. Stop.
make[2]: *** Waiting for unfinished jobs....
make[2]: Leaving directory '/home/lkarsten/work/libvmod-example/src'
Makefile:456: recipe for target 'all-recursive' failed
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory '/home/lkarsten/work/libvmod-example'
Makefile:366: recipe for target 'all' failed
make: *** [all] Error 2
2 (=3a37e) lkarsten@IMMER ~/work/libvmod-example>
Rerunning make yields working results. MAKEFLAGS=-j10
Hi! I'm trying to install libvmods with Varnish 4.0 and I encountered below error:
ubuntu@ip-10-166-38-236:~/libvmod-example-master$ make
make all-recursive
make[1]: Entering directory `/home/ubuntu/libvmod-example-master'
Making all in src
make[2]: Entering directory `/home/ubuntu/libvmod-example-master/src'
make[2]: *** No rule to make target `@VMODTOOL@', needed by `vcc_if.c'. Stop.
make[2]: Leaving directory `/home/ubuntu/libvmod-example-master/src'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/ubuntu/libvmod-example-master'
make: *** [all] Error 2
Environment: Ubuntu 14.04 64bit
Full log includes previous steps: https://gist.github.com/yoloseem/e41c2a2681080b4ecf53
make dist when successfully run, produces a configure that unnecessarily requires rst2man, as the manpage is prebuilt by make dist. This makes the release tarball difficult to build on platforms that misses rst2man, like rhel5 and clones.
Workaround: export RST2MAN=/bin/true before calling configure.
See toreanderson/libvmod-rfc6052#2 . vmod-rfc6052 is based on this example vmod, and the bug originates here.
Ingvar
[lkarsten@el6 libvmod-example]$ ./autogen.sh
++ pkg-config --variable=datarootdir varnishapi
+ dataroot=/usr/share
+ aclocal -I m4 -I /usr/share/aclocal
configure.ac:1: error: Autoconf version 2.64 or higher is required
configure.ac:1: the top level
autom4te: /usr/bin/m4 failed with exit status: 63
aclocal: autom4te failed with exit status: 63
Since we no longer require the source to be available, and now use pkg-config to figure out the various paths.
just a reminder -- as discussed on IRC, I think relaxing the license of libvmod-example (for instance to stating that it is in the public domain) would help VMOD authors with doubts of their legal departments
irc
(12:56:23) scn: i don't think we have anything to gain by mandating a license on it
(12:57:32) slink: scn: yeah. How about "libvmod-example is in the public domain"?
(12:57:35) scn: and copyright .. they get their own when they make a derivative work, don't they?
(12:58:05) slink: scn: yes, but in the strict sense one had to keep the copyright for any code stemming from libvmod-example
(12:58:45) scn: i don't know why we have all of that stuff in there in the first place. before my time. i'm ok with simplifying it.
Hi,
I try to build this module under Ubuntu
cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=14.04
DISTRIB_CODENAME=trusty
DISTRIB_DESCRIPTION="Ubuntu 14.04.1 LTS"
I use Varnish 4.01 that I successfully build on my machine
flebris@server1:~/code/varnish-cache$ git status
HEAD detached at 4d461ea
Changes not staged for commit:
(use "git add ..." to update what will be committed)
(use "git checkout -- ..." to discard changes in working directory)
modified: etc/example.vcl
no changes added to commit (use "git add" and/or "git commit -a")
flebris@server1:/code/varnish-cache/bin/varnishd$ ./varnishd -V/code/varnish-cache/bin/varnishd$
varnishd (varnish-4.0.1 revision 4d461ea)
Copyright (c) 2006 Verdens Gang AS
Copyright (c) 2006-2011 Varnish Software AS
flebris@server1:
I use the master branch of libvmod_example (supposed it's the v4 branch)
It build and 'make check' is OK
When I try to use this vmod in Varnishd I have an error version
flebris@server1:~/code/varnish-cache/bin/varnishd$ ./varnishd -C -f ../../etc/example.vcl
Message from VCC-compiler:
Not running as root, no priv-sep
Incompatible VMOD example
File name: /usr/local/lib/varnish/vmods/libvmod_example.so
VMOD version 1.2
varnishd version 2.0
('input' Line 15 Pos 8)
import example;
-------#######-
I have this in Varnish-cache code
But in VMOD I only found
const struct vmod_data Vmod_example_Data = {
.vrt_major = VRT_MAJOR_VERSION,
.vrt_minor = VRT_MINOR_VERSION,
.name = "example",
.func = &Vmod_Func,
.func_len = sizeof(Vmod_Func),
.proto = Vmod_Proto,
.spec = Vmod_Spec,
.abi = VMOD_ABI_Version,
.file_id = "GYCHCHIHQCGAHFDPAEYD@@QXTXKYGVXC",
};
So I don't understand where come from 1.2 why this build don't work ....
Thanks,
Fred
We should consider adding FPM configuration.
Ramin K from SnappyTV provided the following example, perhaps it can be built on:
rkhatibi/libvmod-digest@4d3a28a
Would you guys consider a disclaimer of copyright or a copyright exception clause for a template vmod upon which others should be based?
If I can directly fork this repo to begin work on my own vmod, using this one as a template for the autogen / configure / m4 / src tree layout, I'd like apply my own copyright rather than inherit from the Varnish copyright.
Looking at some of the downstream forks of this repo, others are treating the LICENSE file as a template where Varnish Software AS can be replaced with Other Org. I think that's the right direction to go in, but it isn't explicitly permitted.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.