File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 66, nasm
77, python3
88, withDriver ? false
9+ , makeWrapper
910,
1011} :
1112
@@ -29,6 +30,7 @@ python3.pkgs.buildPythonApplication rec {
2930
3031 nativeBuildInputs = [
3132 nasm
33+ makeWrapper
3234 ]
3335 ++ lib . optionals ( lib . meta . availableOn stdenv . buildPlatform elfutils ) [
3436 elfutils
@@ -45,6 +47,32 @@ python3.pkgs.buildPythonApplication rec {
4547 touch README.NO_KERNEL_DRIVER
4648 '' ;
4749
50+ # Replace module_ids.json with a symlink to a writable location
51+ postInstall =
52+ let
53+ module_ids = "/var/lib/chipsec/module_ids.json" ;
54+ module_ids_default = "${ placeholder "out" } /${ python3 . pkgs . python . sitePackages } /chipsec/library/module_ids_default.json" ;
55+ createModuleIdsFile = ''
56+ if [ ! -e ${ module_ids } ]; then
57+ mkdir -p $(dirname ${ module_ids } )
58+ cp ${ module_ids_default } ${ module_ids }
59+ fi
60+ '' ;
61+ in
62+ ''
63+ # Rename original module_ids.json to module_ids_default.json
64+ mv $out/${ python3 . pkgs . python . sitePackages } /chipsec/library/module_ids.json \
65+ $out/${ python3 . pkgs . python . sitePackages } /chipsec/library/module_ids_default.json
66+
67+ # Create symlink to writable location
68+ ln -s ${ module_ids } $out/${ python3 . pkgs . python . sitePackages } /chipsec/library/module_ids.json
69+
70+ # Wrap chipsec_main to ensure the writable file exists
71+ mv $out/bin/chipsec_main $out/bin/.chipsec_main-wrapped
72+ makeWrapper $out/bin/.chipsec_main-wrapped $out/bin/chipsec_main \
73+ --run '${ createModuleIdsFile } '
74+ '' ;
75+
4876 nativeCheckInputs = with python3 . pkgs ; [
4977 distro
5078 pytestCheckHook
You can’t perform that action at this time.
0 commit comments