@@ -0,0 +1,77 @@
1+{ stdenv, fetchurl, makeWrapper, pkgconfig, utillinux, which
2+, procps, libcap_ng, openssl, python27, iproute , perl
3+, kernel ? null }:
4+
5+with stdenv.lib;
6+
7+let
8+ _kernel = kernel;
9+in stdenv.mkDerivation rec {
10+ version = "2.5.6";
11+ pname = "openvswitch";
12+
13+ src = fetchurl {
14+ url = "http://openvswitch.org/releases/${pname}-${version}.tar.gz";
15+ sha256 = "14zjcd0ddjv90rwb24l3cac6psd34a9r04jjghn1av0kf6b76zj4";
16+ };
17+
18+ kernel = optional (_kernel != null) _kernel.dev;
19+
20+ nativeBuildInputs = [ pkgconfig ];
21+ buildInputs = [ makeWrapper utillinux openssl libcap_ng python27
22+ perl procps which ];
23+
24+ configureFlags = [
25+ "--localstatedir=/var"
26+ "--sharedstatedir=/var"
27+ "--sbindir=$(out)/bin"
28+ ] ++ (optionals (_kernel != null) ["--with-linux"]);
29+
30+ # Leave /var out of this!
31+ installFlags = [
32+ "LOGDIR=$(TMPDIR)/dummy"
33+ "RUNDIR=$(TMPDIR)/dummy"
34+ "PKIDIR=$(TMPDIR)/dummy"
35+ ];
36+
37+ postBuild = ''
38+ # fix tests
39+ substituteInPlace xenserver/opt_xensource_libexec_interface-reconfigure --replace '/usr/bin/env python' '${python27.interpreter}'
40+ substituteInPlace vtep/ovs-vtep --replace '/usr/bin/env python' '${python27.interpreter}'
41+ '';
42+
43+ enableParallelBuilding = true;
44+ doCheck = false; # bash-completion test fails with "compgen: command not found"
45+
46+ postInstall = ''
47+ cp debian/ovs-monitor-ipsec $out/share/openvswitch/scripts
48+ makeWrapper \
49+ $out/share/openvswitch/scripts/ovs-monitor-ipsec \
50+ $out/bin/ovs-monitor-ipsec \
51+ --prefix PYTHONPATH : "$out/share/openvswitch/python"
52+ substituteInPlace $out/share/openvswitch/scripts/ovs-monitor-ipsec \
53+ --replace "UnixctlServer.create(None)" "UnixctlServer.create(os.environ['UNIXCTLPATH'])"
54+ substituteInPlace $out/share/openvswitch/scripts/ovs-monitor-ipsec \
55+ --replace "self.psk_file" "root_prefix + self.psk_file"
56+ substituteInPlace $out/share/openvswitch/scripts/ovs-monitor-ipsec \
57+ --replace "self.cert_dir" "root_prefix + self.cert_dir"
58+ '';
59+
60+ meta = with stdenv.lib; {
61+ platforms = platforms.linux;
62+ description = "A multilayer virtual switch";
63+ longDescription =
64+ ''
65+ Open vSwitch is a production quality, multilayer virtual switch
66+ licensed under the open source Apache 2.0 license. It is
67+ designed to enable massive network automation through
68+ programmatic extension, while still supporting standard
69+ management interfaces and protocols (e.g. NetFlow, sFlow, SPAN,
70+ RSPAN, CLI, LACP, 802.1ag). In addition, it is designed to
71+ support distribution across multiple physical servers similar
72+ to VMware's vNetwork distributed vswitch or Cisco's Nexus 1000V.
73+ '';
74+ homepage = http://openvswitch.org/;
75+ license = licenses.asl20;
76+ };
77+}