summaryrefslogtreecommitdiff
path: root/pkgs/athena-bccr
diff options
context:
space:
mode:
authorAlejandro Soto <alejandro@34project.org>2026-03-09 02:33:10 -0600
committerAlejandro Soto <alejandro@34project.org>2026-03-09 02:33:10 -0600
commitca6ac0d5cb77b1328be42e36582bfcc970512ed9 (patch)
treee50538a6175501f8964926efe057ca2d51ca59f7 /pkgs/athena-bccr
parent2edfc79f2d21c876091eb1115324a4b96e5da8a5 (diff)
trivionomicon: athena-bccr: patch hard-coded FHS paths in idopte driver
Diffstat (limited to 'pkgs/athena-bccr')
-rw-r--r--pkgs/athena-bccr/unwrapped.nix27
1 files changed, 24 insertions, 3 deletions
diff --git a/pkgs/athena-bccr/unwrapped.nix b/pkgs/athena-bccr/unwrapped.nix
index c7781e4..3a70144 100644
--- a/pkgs/athena-bccr/unwrapped.nix
+++ b/pkgs/athena-bccr/unwrapped.nix
@@ -102,6 +102,7 @@
libnotify,
openssl,
pcsclite,
+ python3,
stdenv,
unzip,
webkitgtk_4_1,
@@ -124,6 +125,7 @@
nativeBuildInputs = [
autoPatchelfHook
+ python3
];
outputs = ["out" "lib"];
@@ -132,15 +134,34 @@
runHook preInstall
install -m755 -d $out/bin $lib/{etc,lib/SCMiddleware}
- install -m755 usr/lib/SCMiddleware/{idocachesrv,SCManager} $out/bin
- install -m755 usr/lib/SCMiddleware/*.so $lib/lib/SCMiddleware
+ install -m755 usr/lib/SCMiddleware/SCManager $out/bin
+ install -m755 usr/lib/SCMiddleware/{*.so,idocachesrv} $lib/lib/SCMiddleware
cp -r etc/id* $lib/etc
runHook postInstall
'';
preFixup = ''
- patchelf --set-rpath $lib/lib/SCMiddleware $lib/lib/SCMiddleware/* $out/bin/*
+ for elf in $lib/lib/SCMiddleware/* $out/bin/*; do
+ python3 /dev/fd/3 <$elf >$elf.patched 3<<EOF
+ import sys
+ contents = sys.stdin.buffer.read()
+
+ def bin_replace(s, a, b):
+ assert len(a) >= len(b)
+ return s.replace(a, b + b'\0' * (len(a) - len(b)))
+
+ contents = bin_replace(contents, b'/usr/lib/SCMiddleware', b'/etc/SCMiddleware')
+ contents = bin_replace(contents, b'/tmp/.idoss_socket', b'/run/idoss/socket')
+
+ sys.stdout.buffer.write(contents)
+ EOF
+
+ chmod --reference=$elf $elf.patched
+ mv $elf.patched $elf
+
+ patchelf --set-rpath $lib/lib/SCMiddleware $elf
+ done
'';
passthru.pkcs11-path = "lib/SCMiddleware/libidop11.so";