libfprint-2-tod1-broadcom: init at 5.12.018
This commit is contained in:
@@ -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 ];
|
||||
};
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
Reference in New Issue
Block a user