summary refs log tree commit diff
path: root/pkgs/development/python-modules/manuf
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/development/python-modules/manuf')
-rw-r--r--pkgs/development/python-modules/manuf/default.nix60
-rw-r--r--pkgs/development/python-modules/manuf/fix_manuf_url.patch14
-rw-r--r--pkgs/development/python-modules/manuf/internal_db_update_nix.patch31
3 files changed, 105 insertions, 0 deletions
diff --git a/pkgs/development/python-modules/manuf/default.nix b/pkgs/development/python-modules/manuf/default.nix
new file mode 100644
index 00000000000..6d237ab396f
--- /dev/null
+++ b/pkgs/development/python-modules/manuf/default.nix
@@ -0,0 +1,60 @@
+{ lib
+, buildPythonPackage
+, fetchFromGitHub
+, runCommand
+, python3
+, wireshark-cli
+, pytestCheckHook
+}:
+
+buildPythonPackage rec {
+  pname = "manuf";
+  version = "1.1.5";
+  format = "setuptools";
+
+  src = fetchFromGitHub {
+    owner = "coolbho3k";
+    repo = "manuf";
+    rev = "${version}";
+    hash = "sha256-3CFs3aqwE8rZPwU1QBqAGxNHT5jg7ymG12yBD56gTNI=";
+  };
+
+  nativeBuildInputs = [ wireshark-cli ];
+
+  patches = [
+    # Do update while building package from wireshark-cli
+    ./internal_db_update_nix.patch
+    # Fix MANUF_URL for external db update functionality (https://github.com/coolbho3k/manuf/issues/34)
+    ./fix_manuf_url.patch
+  ];
+
+  postPatch = ''
+    cat ${wireshark-cli}/share/wireshark/{manuf,wka} > manuf/manuf
+  '';
+
+  nativeCheckInputs = [
+    pytestCheckHook
+  ];
+
+  disabledTests = [
+    "test_update_update"
+  ];
+
+  pythonImportsCheck = [ "manuf" ];
+
+  passthru.tests = {
+    testMacAddress = runCommand "${pname}-test" {} ''
+      ${python3.pkgs.manuf}/bin/manuf BC:EE:7B:00:00:00 > $out
+      [ "$(cat $out | tr -d '\n')" = "Vendor(manuf='ASUSTekC', manuf_long='ASUSTek COMPUTER INC.', comment=None)" ]
+    '';
+  };
+
+  meta = with lib; {
+    homepage = "https://github.com/coolbho3k/manuf";
+    description = " Parser library for Wireshark's OUI database";
+    mainProgram = "manuf";
+    platforms = platforms.linux;
+    license = with licenses; [ lgpl3Plus asl20 ];
+    maintainers = with maintainers; [ dsuetin ];
+  };
+}
diff --git a/pkgs/development/python-modules/manuf/fix_manuf_url.patch b/pkgs/development/python-modules/manuf/fix_manuf_url.patch
new file mode 100644
index 00000000000..e858649b90f
--- /dev/null
+++ b/pkgs/development/python-modules/manuf/fix_manuf_url.patch
@@ -0,0 +1,14 @@
+diff --git a/manuf/manuf.py b/manuf/manuf.py
+index 09e9687..0ac9296 100755
+--- a/manuf/manuf.py
++++ b/manuf/manuf.py
+@@ -61,7 +61,8 @@ class MacParser(object):
+         IOError: If manuf file could not be found.
+ 
+     """
+-    MANUF_URL = "https://gitlab.com/wireshark/wireshark/raw/master/manuf"
++    # https://github.com/coolbho3k/manuf/issues/34
++    MANUF_URL = "https://www.wireshark.org/download/automated/data/manuf"
+     WFA_URL = "https://gitlab.com/wireshark/wireshark/raw/master/wka"
+ 
+     def  __init__(self, manuf_name=None, update=False):
diff --git a/pkgs/development/python-modules/manuf/internal_db_update_nix.patch b/pkgs/development/python-modules/manuf/internal_db_update_nix.patch
new file mode 100644
index 00000000000..174c71e4692
--- /dev/null
+++ b/pkgs/development/python-modules/manuf/internal_db_update_nix.patch
@@ -0,0 +1,31 @@
+diff --git a/manuf/manuf.py b/manuf/manuf.py
+index e5e9193..09e9687 100755
+--- a/manuf/manuf.py
++++ b/manuf/manuf.py
+@@ -65,8 +65,14 @@ class MacParser(object):
+     WFA_URL = "https://gitlab.com/wireshark/wireshark/raw/master/wka"
+ 
+     def  __init__(self, manuf_name=None, update=False):
+-        self._manuf_name = manuf_name or self.get_packaged_manuf_file_path()
+-        if update:
++        if manuf_name is not None:
++            self._manuf_name = manuf_name
++            self.external_db = True
++        else:
++            self._manuf_name = self.get_packaged_manuf_file_path()
++            self.external_db = False
++
++        if update and self.external_db:
+             self.update()
+         else:
+             self.refresh()
+@@ -134,6 +140,9 @@ class MacParser(object):
+             URLError: If the download fails
+ 
+         """
++        if manuf_url is None and not self.external_db:
++            return
++
+         if not manuf_url:
+             manuf_url = self.MANUF_URL
+         if not manuf_name: