8000 Add LD_LIBRARY_PATH to JavaInstallerMixin by viren-nadkarni · Pull Request #11667 · localstack/localstack · GitHub
[go: up one dir, main page]

Skip to content

Add LD_LIBRARY_PATH to JavaInstallerMixin #11667

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions localstack-core/localstack/packages/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,20 +86,24 @@ def install(self, target: Optional[InstallTarget] = None) -> None:
with self.install_lock:
# Skip the installation if it's already installed
if not self.is_installed():
LOG.debug("Starting installation of %s...", self.name)
LOG.debug("Starting installation of %s %s...", self.name, self.version)
self._prepare_installation(target)
self._install(target)
self._post_process(target)
LOG.debug("Installation of %s finished.", self.name)
LOG.debug("Installation of %s %s finished.", self.name, self.version)
else:
LOG.debug("Installation of %s skipped (already installed).", self.name)
LOG.debug(
"Installation of %s %s skipped (already installed).",
self.name,
self.version,
)
if not self._setup_for_target[target]:
LOG.debug("Performing runtime setup for already installed package.")
self._setup_existing_installation(target)
except PackageException as e:
raise e
except Exception as e:
raise PackageException(f"Installation of {self.name} failed.") from e
raise PackageException(f"Installation of {self.name} {self.version} failed.") from e

def is_installed(self) -> bool:
"""
Expand Down
11 changes: 10 additions & 1 deletion localstack-core/localstack/packages/java.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,13 @@ def get_java_home(self) -> str | None:
"""
return java_package.get_installer().get_java_home()

def get_java_env_vars(self, path: str = None) -> dict[str, str]:
def get_java_env_vars(self, path: str = None, ld_library_path: str = None) -> dict[str, str]:
"""
Returns environment variables pointing to the Java installation. This is useful to build the environment where
the application will run.

:param path: If not specified, the value of PATH will be obtained from the environment
:param ld_library_path: If not specified, the value of LD_LIBRARY_PATH will be obtained from the environment
:return: dict consisting of two items:
- JAVA_HOME: path to JRE installation
- PATH: the env path variable updated with JRE bin path
Expand All @@ -54,8 +55,16 @@ def get_java_env_vars(self, path: str = None) -> dict[str, str]:

path = path or os.environ["PATH"]

ld_library_path = ld_library_path or os.environ.get("LD_LIBRARY_PATH")
# null paths (e.g. `:/foo`) have a special meaning according to the manpages
if ld_library_path is None:
ld_library_path = f"{java_home}/lib:{java_home}/lib/server"
else:
ld_library_path = f"{java_home}/lib:{java_home}/lib/server:{ld_library_path}"

return {
"JAVA_HOME": java_home,
"LD_LIBRARY_PATH": ld_library_path,
"PATH": f"{java_bin}:{path}",
}

Expand Down
Loading
0