From: Alexander Popov Date: Fri, 2 Sep 2022 11:50:39 +0000 (+0300) Subject: Move get-nix-kconfig.py to kconfig_hardened_check/config_files/distros X-Git-Tag: v0.6.1~96 X-Git-Url: https://jxself.org/git/?a=commitdiff_plain;h=bb9f28659ac237d20198f32e964127b575e45cdc;hp=b9d4e55550339a8f5c3c43f4c412f3b5422d0df7;p=kconfig-hardened-check.git Move get-nix-kconfig.py to kconfig_hardened_check/config_files/distros This script is still waiting for fixes from NixOS folks: Issue #63 PR #64 --- diff --git a/contrib/get-nix-kconfig.py b/contrib/get-nix-kconfig.py deleted file mode 100644 index f8c49d1..0000000 --- a/contrib/get-nix-kconfig.py +++ /dev/null @@ -1,30 +0,0 @@ -#! /usr/bin/env nix-shell -#! nix-shell -i python3 -p python3 - -import json -import os -import shutil -import subprocess -import sys -from tempfile import TemporaryDirectory - - -def main() -> None: - proc = subprocess.run( - ["nix", "search", "-u", "--json", "^nixpkgs.linux_"], capture_output=True - ) - data = json.loads(proc.stdout) - with TemporaryDirectory() as temp: - for pkg in data.keys(): - symlink = os.path.join(temp, pkg) - res = subprocess.run(["nix", "build", f"{pkg}.configfile", "-o", symlink]) - if res.returncode != 0: - print(f"failed to get configuration for {pkg}", file=sys.stderr) - continue - name = f"{pkg.replace('.', '-')}-config" - with open(name, "w") as dst, open(symlink) as src: - shutil.copyfileobj(src, dst) - - -if __name__ == "__main__": - main() diff --git a/kconfig_hardened_check/config_files/distros/get-nix-kconfig.py b/kconfig_hardened_check/config_files/distros/get-nix-kconfig.py new file mode 100644 index 0000000..f8c49d1 --- /dev/null +++ b/kconfig_hardened_check/config_files/distros/get-nix-kconfig.py @@ -0,0 +1,30 @@ +#! /usr/bin/env nix-shell +#! nix-shell -i python3 -p python3 + +import json +import os +import shutil +import subprocess +import sys +from tempfile import TemporaryDirectory + + +def main() -> None: + proc = subprocess.run( + ["nix", "search", "-u", "--json", "^nixpkgs.linux_"], capture_output=True + ) + data = json.loads(proc.stdout) + with TemporaryDirectory() as temp: + for pkg in data.keys(): + symlink = os.path.join(temp, pkg) + res = subprocess.run(["nix", "build", f"{pkg}.configfile", "-o", symlink]) + if res.returncode != 0: + print(f"failed to get configuration for {pkg}", file=sys.stderr) + continue + name = f"{pkg.replace('.', '-')}-config" + with open(name, "w") as dst, open(symlink) as src: + shutil.copyfileobj(src, dst) + + +if __name__ == "__main__": + main()