Try to fix prefix in post-install script for OSX pkg installer.

The pkg installer does not have any environment variables (like $PREFIX)
defined, but by inspection the other scripts that it executes set
the PREFIX as $2/{installer_name}. So we do that when $PREFIX is not
defined, which should cover all of the installers.
This commit is contained in:
Ryan Volz 2021-05-19 15:53:41 -04:00
parent 41c8754126
commit 73b77ae44d

View File

@ -105,10 +105,20 @@ def render_constructor_specs(
# write the post_install scripts referenced in the construct dict
if platform.startswith("win"):
with (constructor_dir / "post_install.bat").open("w") as f:
f.write("\n".join((r"del /q %PREFIX%\pkgs\*.tar.bz2", "")))
f.write("\n".join((r"del /q %PREFIX%\pkgs\*.tar.bz2", "exit 0", "")))
else:
with (constructor_dir / "post_install.sh").open("w") as f:
f.write("\n".join((r"rm -f $PREFIX/pkgs/*.tar.bz2", "")))
f.write(
"\n".join(
(
"#!/bin/sh",
f'PREFIX="${{PREFIX:-$2/{installer_name}}}"',
r"rm -f $PREFIX/pkgs/*.tar.bz2",
"exit 0",
"",
)
)
)
construct_yaml_path = constructor_dir / "construct.yaml"
with construct_yaml_path.open("w") as f: