radare2: fix update script to handle invocation from elsewhere

It looks like `with Path:` is supposed to be a context-manager
for changing directory but it doesn't seem to work and the only
way I've found to make that work is if we made our own and annotated it.

Instead just use nix search path to tell the expression where
to find the file it looks for.

Also re-use SCRIPT_DIR elsewhere instead of re-"computing" it.
This commit is contained in:
Will Dietz 2018-10-16 14:01:08 -05:00
parent 6fdc165564
commit 26dfc0c533

View File

@ -38,10 +38,9 @@ def get_radare2_rev() -> str:
def get_cutter_version() -> str: def get_cutter_version() -> str:
version_expr = """ version_expr = """
(with import <nixpkgs> {}; (builtins.parseDrvName (qt5.callPackage ./cutter.nix {}).name).version) (with import <nixpkgs> {}; (builtins.parseDrvName (qt5.callPackage <radare2/cutter.nix> {}).name).version)
""" """
with SCRIPT_DIR: return sh("nix", "eval", "--raw", version_expr.strip(), "-I", "radare2={0}".format(SCRIPT_DIR))
return sh("nix", "eval", "--raw", version_expr.strip())
def get_r2_cutter_rev() -> str: def get_r2_cutter_rev() -> str:
@ -109,7 +108,7 @@ def main() -> None:
"https://github.com/radare/radare2", "https://github.com/radare/radare2",
".", ".",
) )
nix_file = str(Path(__file__).parent.joinpath("default.nix")) nix_file = str(SCRIPT_DIR.joinpath("default.nix"))
radare2_info = get_repo_info(dirname, radare2_rev) radare2_info = get_repo_info(dirname, radare2_rev)