MCPcopy
hub / github.com/saltstack/salt / _refresh_macos_binary_paths

Method _refresh_macos_binary_paths

tests/support/pkg.py:590–690  ·  view source on GitHub ↗

Re-resolve ``install_dir`` / ``binary_paths`` after a ``.pkg`` install. ``__attrs_post_init__`` runs before installers populate ``/opt/...``, so upgrade/downgrade sessions need a second pass once files exist.

(self)

Source from the content-addressed store, hash-verified

588 log.debug("install_dir: %s", self.install_dir)
589
590 def _refresh_macos_binary_paths(self):
591 """
592 Re-resolve ``install_dir`` / ``binary_paths`` after a ``.pkg`` install.
593
594 ``__attrs_post_init__`` runs before installers populate ``/opt/...``,
595 so upgrade/downgrade sessions need a second pass once files exist.
596 """
597 if not platform.is_darwin():
598 return
599 # Prepends so :func:`shutil.which` inside prefix detection can see
600 # ``/opt`` layouts before a stale default ``/opt/salt`` mis-seeds
601 # ``$PATH`` from :meth:`update_process_path`.
602 opt_first = [
603 p
604 for p in (
605 "/opt/saltstack/salt/bin",
606 "/opt/saltstack/salt",
607 "/opt/salt/bin",
608 "/opt/salt",
609 )
610 if pathlib.Path(p).exists()
611 ]
612 _old = os.environ.get("PATH", "")
613 if opt_first:
614 os.environ["PATH"] = os.pathsep.join(opt_first) + os.pathsep + _old
615 try:
616 found = _macos_salt_onedir_prefix()
617 finally:
618 os.environ["PATH"] = _old
619 if found is None:
620 return
621 self.install_dir = found
622 self.bin_dir = found / "bin"
623 self.run_root = self.bin_dir / "run"
624 python_bin = self.install_dir / "bin" / "python3"
625 if os.path.exists(self.install_dir / "bin" / "salt"):
626 install_dir = self.install_dir / "bin"
627 else:
628 install_dir = self.install_dir
629 if self.relenv:
630 self.binary_paths = {
631 "salt": [install_dir / "salt"],
632 "api": [install_dir / "salt-api"],
633 "call": [install_dir / "salt-call"],
634 "cloud": [install_dir / "salt-cloud"],
635 "cp": [install_dir / "salt-cp"],
636 "key": [install_dir / "salt-key"],
637 "master": [install_dir / "salt-master"],
638 "minion": [install_dir / "salt-minion"],
639 "proxy": [install_dir / "salt-proxy"],
640 "run": [install_dir / "salt-run"],
641 "ssh": [install_dir / "salt-ssh"],
642 "syndic": [install_dir / "salt-syndic"],
643 "spm": [install_dir / "spm"],
644 "pip": [install_dir / "salt-pip"],
645 "python": [python_bin],
646 }
647 else:

Callers 4

_install_pkgsMethod · 0.95
installMethod · 0.95
install_previousMethod · 0.95
__enter__Method · 0.95

Calls 4

debugMethod · 0.80
existsMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected