Merge pull request #255080 from dani0854/python/manuf/init

python3Packages.manuf: init at 1.1.5
This commit is contained in:
OTABI Tomoya 2023-09-21 13:22:39 +09:00 committed by GitHub
commit 28c306a5ce
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 107 additions and 0 deletions

View File

@ -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 ];
};
}

View File

@ -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):

View File

@ -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:

View File

@ -6429,6 +6429,8 @@ self: super: with self; {
manuel = callPackage ../development/python-modules/manuel { };
manuf = callPackage ../development/python-modules/manuf { };
mapbox = callPackage ../development/python-modules/mapbox { };
mapbox-earcut = callPackage ../development/python-modules/mapbox-earcut { };