Lines Matching +full:is +full:- +full:path +full:- +full:inside
2 # Use of this source code is governed by a BSD-style license that can be
10 from pathlib import Path
19 Command = List[Union[str, Path]]
24 cwd: Optional[Path] = None, argument
29 ) -> subprocess.CompletedProcess:
39 dir_extra = f" in {cwd}" if cwd is not None else ""
47 encoding="utf-8",
54 def installed_llvm_has_pgo_generate_enabled() -> bool:
55 """Returns whether the currently-installed LLVM has USE=pgo_generate."""
57 ["equery", "--no-color", "--no-pipe", "u", "sys-devel/llvm"],
61 # The output of `equery` is in the format:
64 # The relevant bit is the second.
65 r = re.compile(r"^ [+-] ([+-]) llvm_pgo_generate\s", re.MULTILINE)
69 "No llvm_pgo_generate line found in USE for sys-devel/llvm"
74 "Multiple llvm_pgo_generate line found in USE for sys-devel/llvm"
80 def quickpkg_llvm() -> Path:
88 # sudo rm -rf /var/lib/portage/pkgs/sys-devel/llvm*tbz2 && \
89 # sudo emerge -G sys-devel/llvm
92 "Base LLVM version has pgo_generate enabled; this is "
94 "quickly restore to a non-pgo_generate LLVM by "
95 "running `sudo emerge -G sys-devel/llvm`."
98 logging.info("Building binpackage for existing sys-devel/llvm installation")
100 ["quickpkg", "sys-devel/llvm"], stdout=subprocess.PIPE
102 # We have to scrape for the package's name, since the package generated is
106 r"Building package for sys-devel/(llvm-[^ ]+) ", quickpkg_result
115 pkg = Path("/var/lib/portage/pkgs/sys-devel", llvm_ver + ".tbz2")
120 def generate_quickpkg_restoration_command(quickpkg_path: Path) -> Command: argument
124 return ["sudo", "emerge", "--usepkgonly", f"={category}/{package_ver}"]
127 def is_in_chroot() -> bool:
128 """Returns whether this script was invoked inside of the chroot."""
129 return Path("/etc/cros_chroot_version").exists()
133 """Calls sys.exit if this script was not run inside of the chroot."""
135 sys.exit("Run me inside of the chroot.")
139 """Calls sys.exit if this script was run inside of the chroot."""
145 def temporary_file(prefix: Optional[str] = None) -> Generator[Path, None, None]:
149 the file open. This is useful if the temporary file is intended to be
152 File-like aspects of NamedTemporaryFile.
155 tmp_path = Path(tmp)