about summary refs log tree commit diff
path: root/pkgs/by-name
diff options
context:
space:
mode:
authorAdam C. Stephens <2071575+adamcstephens@users.noreply.github.com>2024-04-26 16:29:51 -0400
committerGitHub <noreply@github.com>2024-04-26 16:29:51 -0400
commit0b868df4ced96400774414f5baf30b696215b98f (patch)
tree278313b5e8db365537f267db9dd56c818697629c /pkgs/by-name
parent2a899c07e422b6b2be8fad2d6a7c4e7eea99af2c (diff)
parent6f0a1a198810dd152c322c355395c7810d08c4d3 (diff)
Merge pull request #306277 from adamcstephens/ovs/fix-python313
openvswitch*: fix 3.13 compatibility, apply RFCs, add self
Diffstat (limited to 'pkgs/by-name')
-rw-r--r--pkgs/by-name/op/openvswitch/generic.nix143
-rw-r--r--pkgs/by-name/op/openvswitch/lts.nix5
-rw-r--r--pkgs/by-name/op/openvswitch/package.nix4
-rw-r--r--pkgs/by-name/op/openvswitch/patches/disable-bash-arg-completion-test.patch12
-rw-r--r--pkgs/by-name/op/openvswitch/patches/fix-python313.patch12
-rwxr-xr-xpkgs/by-name/op/openvswitch/update.nu19
6 files changed, 195 insertions, 0 deletions
diff --git a/pkgs/by-name/op/openvswitch/generic.nix b/pkgs/by-name/op/openvswitch/generic.nix
new file mode 100644
index 0000000000000..dadccc1c39473
--- /dev/null
+++ b/pkgs/by-name/op/openvswitch/generic.nix
@@ -0,0 +1,143 @@
+{
+  version,
+  hash,
+  updateScriptArgs ? "",
+}:
+
+{
+  lib,
+  stdenv,
+  fetchurl,
+  autoconf,
+  automake,
+  installShellFiles,
+  iproute2,
+  kernel ? null,
+  libcap_ng,
+  libtool,
+  openssl,
+  perl,
+  pkg-config,
+  procps,
+  python3,
+  sphinxHook,
+  util-linux,
+  which,
+  writeScript,
+}:
+
+let
+  _kernel = kernel;
+in
+stdenv.mkDerivation rec {
+  pname = "openvswitch";
+  inherit version;
+
+  kernel = lib.optional (_kernel != null) _kernel.dev;
+
+  src = fetchurl {
+    url = "https://www.openvswitch.org/releases/${pname}-${version}.tar.gz";
+    inherit hash;
+  };
+
+  outputs = [
+    "out"
+    "man"
+  ];
+
+  patches = [
+    # 8: vsctl-bashcomp - argument completion FAILED (completion.at:664)
+    ./patches/disable-bash-arg-completion-test.patch
+
+    # https://github.com/openvswitch/ovs/commit/9185793e75435d890f18d391eaaeab0ade6f1415
+    ./patches/fix-python313.patch
+  ];
+
+  nativeBuildInputs = [
+    autoconf
+    automake
+    installShellFiles
+    libtool
+    pkg-config
+    sphinxHook
+  ];
+
+  sphinxBuilders = [ "man" ];
+
+  sphinxRoot = "./Documentation";
+
+  buildInputs = [
+    libcap_ng
+    openssl
+    perl
+    procps
+    python3
+    util-linux
+    which
+  ];
+
+  preConfigure = "./boot.sh";
+
+  configureFlags = [
+    "--localstatedir=/var"
+    "--sharedstatedir=/var"
+    "--sbindir=$(out)/bin"
+  ] ++ (lib.optionals (_kernel != null) [ "--with-linux" ]);
+
+  # Leave /var out of this!
+  installFlags = [
+    "LOGDIR=$(TMPDIR)/dummy"
+    "RUNDIR=$(TMPDIR)/dummy"
+    "PKIDIR=$(TMPDIR)/dummy"
+  ];
+
+  enableParallelBuilding = true;
+
+  postInstall = ''
+    installShellCompletion --bash utilities/ovs-appctl-bashcomp.bash
+    installShellCompletion --bash utilities/ovs-vsctl-bashcomp.bash
+  '';
+
+  doCheck = true;
+  preCheck = ''
+    export TESTSUITEFLAGS="-j$NIX_BUILD_CORES"
+    export RECHECK=yes
+
+    patchShebangs tests/
+  '';
+
+  nativeCheckInputs =
+    [ iproute2 ]
+    ++ (with python3.pkgs; [
+      netaddr
+      pyparsing
+      pytest
+    ]);
+
+  passthru.updateScript = writeScript "ovs-update.nu" ''
+    ${./update.nu} ${updateScriptArgs}
+  '';
+
+  meta = with lib; {
+    changelog = "https://www.openvswitch.org/releases/NEWS-${version}.txt";
+    description = "A multilayer virtual switch";
+    longDescription = ''
+      Open vSwitch is a production quality, multilayer virtual switch
+      licensed under the open source Apache 2.0 license. It is
+      designed to enable massive network automation through
+      programmatic extension, while still supporting standard
+      management interfaces and protocols (e.g. NetFlow, sFlow, SPAN,
+      RSPAN, CLI, LACP, 802.1ag). In addition, it is designed to
+      support distribution across multiple physical servers similar
+      to VMware's vNetwork distributed vswitch or Cisco's Nexus 1000V.
+    '';
+    homepage = "https://www.openvswitch.org/";
+    license = licenses.asl20;
+    maintainers = with maintainers; [
+      adamcstephens
+      kmcopper
+      netixx
+    ];
+    platforms = platforms.linux;
+  };
+}
diff --git a/pkgs/by-name/op/openvswitch/lts.nix b/pkgs/by-name/op/openvswitch/lts.nix
new file mode 100644
index 0000000000000..93ccbfcee95d6
--- /dev/null
+++ b/pkgs/by-name/op/openvswitch/lts.nix
@@ -0,0 +1,5 @@
+import ./generic.nix {
+  version = "2.17.9";
+  hash = "sha256-4bP6RyZ2YmhT8i1j+VnlrQYeG/V+G71ETQ7Yj5R++LE=";
+  updateScriptArgs = "--lts=true --regex '2\.17.*'";
+}
diff --git a/pkgs/by-name/op/openvswitch/package.nix b/pkgs/by-name/op/openvswitch/package.nix
new file mode 100644
index 0000000000000..0ea5b6391605a
--- /dev/null
+++ b/pkgs/by-name/op/openvswitch/package.nix
@@ -0,0 +1,4 @@
+import ./generic.nix {
+  version = "3.3.0";
+  hash = "sha256-Gvy4H7lHwL6IWGaZXWwIjmHfQ1YRFXiSBqKzP3vBsF8=";
+}
diff --git a/pkgs/by-name/op/openvswitch/patches/disable-bash-arg-completion-test.patch b/pkgs/by-name/op/openvswitch/patches/disable-bash-arg-completion-test.patch
new file mode 100644
index 0000000000000..2b45427417632
--- /dev/null
+++ b/pkgs/by-name/op/openvswitch/patches/disable-bash-arg-completion-test.patch
@@ -0,0 +1,12 @@
+diff --git a/tests/completion.at b/tests/completion.at
+index b6155af25..6367cb545 100644
+--- a/tests/completion.at
++++ b/tests/completion.at
+@@ -425,6 +425,7 @@ AT_CLEANUP
+ 
+ 
+ AT_SETUP([vsctl-bashcomp - argument completion])
++AT_SKIP_IF([true])
+ AT_SKIP_IF([test -z ${BASH_VERSION+x}])
+ AT_SKIP_IF([eval 'test ${BASH_VERSINFO[[0]]} -lt 4'])
+ OVS_VSWITCHD_START(
diff --git a/pkgs/by-name/op/openvswitch/patches/fix-python313.patch b/pkgs/by-name/op/openvswitch/patches/fix-python313.patch
new file mode 100644
index 0000000000000..0b68c0560d51e
--- /dev/null
+++ b/pkgs/by-name/op/openvswitch/patches/fix-python313.patch
@@ -0,0 +1,12 @@
+diff --git a/tests/vlog.at b/tests/vlog.at
+index 785014956e7..efe91479a63 100644
+--- a/tests/vlog.at
++++ b/tests/vlog.at
+@@ -8,6 +8,7 @@ AT_CHECK([$PYTHON3 $srcdir/test-vlog.py --log-file log_file \
+ 
+ AT_CHECK([sed -e 's/.*-.*-.*T..:..:..Z |//' \
+ -e 's/File ".*", line [[0-9]][[0-9]]*,/File <name>, line <number>,/' \
++-e '/\^\+/d' \
+ stderr_log], [0], [dnl
+   0  | module_0 | EMER | emergency
+   1  | module_0 | ERR | error
diff --git a/pkgs/by-name/op/openvswitch/update.nu b/pkgs/by-name/op/openvswitch/update.nu
new file mode 100755
index 0000000000000..60e462f4625ed
--- /dev/null
+++ b/pkgs/by-name/op/openvswitch/update.nu
@@ -0,0 +1,19 @@
+#!/usr/bin/env nix-shell
+#!nix-shell -i nu -p nushell common-updater-scripts
+
+def main [--lts = false, --regex: string] {
+  let tags = list-git-tags --url=https://github.com/openvswitch/ovs | lines | sort --natural | str replace v ''
+
+  let latest_tag = if $regex == null { $tags } else { $tags | find --regex $regex } | last
+  let current_version = nix eval --raw -f default.nix $"openvswitch(if $lts {"-lts"}).version" | str trim
+
+  if $latest_tag != $current_version {
+    if $lts {
+      update-source-version openvswitch-lts $latest_tag $"--file=(pwd)/pkgs/by-name/op/openvswitch/lts.nix"
+    } else {
+      update-source-version openvswitch $latest_tag $"--file=(pwd)/pkgs/by-name/op/openvswitch/default.nix"
+    }
+  }
+
+  {"lts?": $lts, before: $current_version, after: $latest_tag}
+}