fix(./make): chdir before signing for Android (#339)

More cleanup after https://github.com/ooni/probe/issues/1466
This commit is contained in:
Simone Basso 2021-05-07 12:18:40 +02:00 committed by GitHub
parent 2c0cef4b1a
commit ad73fef757
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

26
make
View File

@ -256,7 +256,7 @@ The third form of the command prints this help screen.
def _print_target(self, target: Target, indent: int) -> None:
sys.stdout.write(
'{}{}{}\n'.format(
"{}{}{}\n".format(
" " * indent, target.name(), ":" if target.deps() else ""
)
)
@ -468,6 +468,23 @@ class AugmentedPath(Environ):
super().__init__(engine, "PATH", value)
class WorkingDir:
"""WorkingDir is a context manager that enters into a given working
directory and returns to the previous directory when done."""
def __init__(self, dirpath: str) -> None:
self._dirpath = dirpath
self._prev: str = ""
def __enter__(self) -> None:
self._prev = os.getcwd()
os.chdir(self._dirpath)
def __exit__(self, type: Any, value: Any, traceback: Any) -> bool:
os.chdir(self._prev)
return False # propagate exc
class Target(Protocol):
"""Target is a target to build."""
@ -853,9 +870,10 @@ class BundleJAR(BaseTarget):
"oonimkall-{}.pom".format(version),
)
allnames: List[str] = []
for name in names:
allnames.append(name)
allnames.append(sign(engine, name))
with WorkingDir(os.path.join(".", "MOBILE", "android")):
for name in names:
allnames.append(name)
allnames.append(sign(engine, name))
engine.run(
[
"jar",