-
-
Notifications
You must be signed in to change notification settings - Fork 14.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
libfprint-2-tod1-broadcom: init at 5.12.018
- Loading branch information
Showing
2 changed files
with
108 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
{ | ||
autoPatchelfHook, | ||
fetchzip, | ||
lib, | ||
libfprint-tod, | ||
openssl, | ||
patchelfUnstable, # have to use patchelfUnstable to support --rename-dynamic-symbols | ||
stdenv, | ||
}: | ||
|
||
# Based on ideas from (using a wrapper library to redirect fopen() calls to firmware files): | ||
# * https://tapesoftware.net/replace-symbol/ | ||
# * https://github.com/NixOS/nixpkgs/pull/260715 | ||
let | ||
pname = "libfprint-2-tod1-broadcom"; | ||
version = "5.12.018"; | ||
|
||
src = fetchzip { | ||
url = "http://dell.archive.canonical.com/updates/pool/public/libf/${pname}/${pname}_${version}.orig.tar.gz"; | ||
hash = "sha256-0C2PpYpEJNrU+8NT95w4QV0J5nHQisMY94Czw3jQOzw="; | ||
pname = "${pname}-unpacked"; | ||
inherit version; | ||
}; | ||
|
||
# wraps `fopen()` for finding firmware files | ||
wrapperLibName = "wrapper-lib.so"; | ||
wrapperLib = stdenv.mkDerivation { | ||
pname = "${pname}-wrapper-lib"; | ||
inherit version; | ||
|
||
src = ./.; | ||
|
||
postPatch = '' | ||
substitute wrapper-lib.c lib.c \ | ||
--subst-var-by to "${src}/var/lib/fprint/fw" | ||
cc -fPIC -shared lib.c -o ${wrapperLibName} | ||
''; | ||
|
||
installPhase = '' | ||
runHook preInstall | ||
install -D -t $out/lib ${wrapperLibName} | ||
runHook postInstall | ||
''; | ||
}; | ||
in | ||
stdenv.mkDerivation { | ||
inherit src pname version; | ||
|
||
buildInputs = [ | ||
libfprint-tod | ||
openssl | ||
wrapperLib | ||
]; | ||
|
||
nativeBuildInputs = [ | ||
autoPatchelfHook | ||
patchelfUnstable | ||
]; | ||
|
||
installPhase = '' | ||
runHook preInstall | ||
install -D -t "$out/lib/libfprint-2/tod-1/" -m 644 -v usr/lib/x86_64-linux-gnu/libfprint-2/tod-1/libfprint-2-tod-1-broadcom.so | ||
install -D -t "$out/lib/udev/rules.d/" -m 644 -v lib/udev/rules.d/60-libfprint-2-device-broadcom.rules | ||
runHook postInstall | ||
''; | ||
|
||
postFixup = '' | ||
echo fopen64 fopen_wrapper > fopen_name_map | ||
patchelf \ | ||
--rename-dynamic-symbols fopen_name_map \ | ||
--add-needed ${wrapperLibName} \ | ||
"$out/lib/libfprint-2/tod-1/libfprint-2-tod-1-broadcom.so" | ||
''; | ||
|
||
passthru.driverPath = "/lib/libfprint-2/tod-1"; | ||
|
||
meta = with lib; { | ||
description = "Broadcom driver module for libfprint-2-tod Touch OEM Driver (from Dell)"; | ||
homepage = "http://dell.archive.canonical.com/updates/pool/public/libf/libfprint-2-tod1-broadcom/"; | ||
license = licenses.unfree; | ||
maintainers = with maintainers; [ pitkling ]; | ||
platforms = [ "x86_64-linux" ]; | ||
sourceProvenance = with sourceTypes; [ binaryNativeCode ]; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include <string.h> | ||
|
||
static const char from[] = "/var/lib/fprint/fw"; | ||
static const char to[] = "@to@"; | ||
|
||
FILE* fopen_wrapper(const char* fn, const char* mode) { | ||
size_t fn_len = strlen(fn); | ||
size_t from_len = strlen(from); | ||
if (fn_len > from_len && memcmp(fn, from, from_len) == 0) { | ||
size_t to_len = strlen(to); | ||
char* rewritten = calloc(fn_len + (to_len - from_len) + 1, 1); | ||
memcpy(rewritten, to, to_len); | ||
memcpy(rewritten + to_len, fn + from_len, fn_len - from_len); | ||
|
||
printf("fopen_wrapper.c: Replacing path '%s' with '%s'\n", fn, rewritten); | ||
FILE* result = fopen(rewritten, mode); | ||
free(rewritten); | ||
return result; | ||
} | ||
return fopen(fn, mode); | ||
} |
25e042c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pitkling the current
libfprint-2-tod1-broadcom
doesn't work from a Dell 7300 (typing it on one right now), even on NixOS-unstable. Reading this AUR post it seems an older upstream commit needs to be pulled in for it work correctly.25e042c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the heads up, @ahydronous! Can you open an issue for this?
In the meantime: I was actually not aware that Dell uses a git repository on launchpad for their fingerprint drivers but thought that http://dell.archive.canonical.com/updates/pool/public/libf/libfprint-2-tod1-broadcom/ is the official driver source. But from what I can see in the launchpad repository, there is a new driver version (6.1.26, on the
upstream
branch) that adds support for some new devices. I assume your Dell 7300 uses a fingerprint sensor with one of the new model numbers0a5c:5864
,0a5c:5865
,0a5c:5866
, or0a5c:5867
? (You can check withlsusb | grep Broadcom
.)I did a quick update of the driver package on my fork under the branch libfprint-2-tod1-broadcom-update to pull in the new drivers. They added a new dynamic library for the new drivers, which I patched with my wrapper (not yet sure whether that's actually needed).
I cannot test it myself, since I don't have one of the new devices at hand. Could you give it a try and let me know whether it works?
25e042c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My device is
Bus 001 Device 003: ID 0a5c:5842 Broadcom Corp. 58200.
However, with the current package with
fprintd-verify
I getImpossible to verify: GDBus.Error:net.reactivated.Fprint.Error.NoSuchDevice: No devices available
, even if rebooted after arebuild
.This is the full piece of code I use in my
configuration.nix
I'll test your branch and see if that fixes it!
25e042c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's strange,
0a5c:5842
should actually work, it's not one of the new devices. Your config looks fine, although you can omit thepackage = …
part, since it's default value takesservices.fprintd.tod.enable
into account and adjusts accordingly.Please test the branch anyway, just to be sure. But I suspect it won't work either.
25e042c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps its because I have secure boot turned off or something, I'll dig in my BIOs settings. Checking
dmesg
I getI must admit I'm still a bit of a nixos neophyte, seems I can't get your package to work with an override..
I tried doing
along with the config I did earlier, but it breaks down with the error
I understand if this is getting too much of a bother for you haha..
25e042c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No worries. If it turns out to be a general issue with the package I'll fix it, but right now I'm not sure whether the problem lies somewhere else. The
overrideAttrs
-Method you're using won't work here. Thesrc
attribute your overwriting is actually referring to the driver package, it's not the source of my package. If you're using a flake-based configuration, you should be able to use my fork as an input and import the package. Otherwise, the easiest road might be to download the whole package directorynixpkgs/pkgs/by-name/li/libfprint-2-tod1-broadcom
and add the derivation yourself via an appropriatecallPackage ./<path-to-downloaded-dir>/pacakge.nix { }
call.Anyway, given that the fork adds only drivers for new devices (not your
0a5c:5842
) it's probably not worth the hassle. I think it's better to first check for some other potential problems. Anything else indmesg
that might be related? What aboutlsusb -v -d 0a5c:5842
andjournalctl -u fprintd
(maybe after a manualfprintd-list
/fprintd-enroll
)?