mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
feat(rsax931): Use mac_brew_pkg.homebrew_prefix
Uses the homebrew_prefix method to get the Homebrew's prefix if Homebrew is installed on the machine
This commit is contained in:
parent
f04e3ff248
commit
21d80bfa3a
2 changed files with 16 additions and 11 deletions
|
@ -44,13 +44,17 @@ def _find_libcrypto():
|
|||
lib = lib or glob.glob("lib/libcrypto.dylib")
|
||||
|
||||
# Find library symlinks in Homebrew locations.
|
||||
brew_prefix = os.getenv("HOMEBREW_PREFIX", "/usr/local")
|
||||
lib = lib or glob.glob(
|
||||
os.path.join(brew_prefix, "opt/openssl/lib/libcrypto.dylib")
|
||||
)
|
||||
lib = lib or glob.glob(
|
||||
os.path.join(brew_prefix, "opt/openssl@*/lib/libcrypto.dylib")
|
||||
)
|
||||
import salt.modules.mac_brew_pkg as mac_brew
|
||||
|
||||
brew_prefix = mac_brew.homebrew_prefix(quiet=True)
|
||||
if brew_prefix is not None:
|
||||
lib = lib or glob.glob(
|
||||
os.path.join(brew_prefix, "opt/openssl/lib/libcrypto.dylib")
|
||||
)
|
||||
lib = lib or glob.glob(
|
||||
os.path.join(brew_prefix, "opt/openssl@*/lib/libcrypto.dylib")
|
||||
)
|
||||
|
||||
# look in macports.
|
||||
lib = lib or glob.glob("/opt/local/lib/libcrypto.dylib")
|
||||
# check if 10.15, regular libcrypto.dylib is just a false pointer.
|
||||
|
|
|
@ -247,11 +247,12 @@ def test_find_libcrypto_darwin_bigsur_packaged():
|
|||
platform, "mac_ver", lambda: ("11.2.2", (), "")
|
||||
), patch.object(sys, "platform", "macosx"):
|
||||
for package_manager, expected_lib in managed_paths.items():
|
||||
mock_env = os.environ.copy()
|
||||
if package_manager == "brew":
|
||||
env = {"HOMEBREW_PREFIX": "/test/homebrew/prefix"}
|
||||
else:
|
||||
env = {"HOMEBREW_PREFIX": ""}
|
||||
with patch.object(os, "getenv", mock_getenv(env)):
|
||||
mock_env["HOMEBREW_PREFIX"] = "/test/homebrew/prefix"
|
||||
elif "HOMEBREW_PREFIX" in mock_env:
|
||||
del mock_env["HOMEBREW_PREFIX"]
|
||||
with patch.dict(os.environ, mock_env):
|
||||
with patch.object(glob, "glob", mock_glob(expected_lib)):
|
||||
lib_path = _find_libcrypto()
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue