forked from Mirror/pmbootstrap
helpers: run: stop handling Arch in PathString (MR 2463)
This was always a hack, and it looks like there (hopefully) aren't any placs where we still need to handle this. Possibly expecting regressions... But then we have something to write a test for. Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
This commit is contained in:
parent
41c8413fda
commit
500b0908f8
2 changed files with 3 additions and 14 deletions
|
@ -3,7 +3,6 @@
|
||||||
import os
|
import os
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
import subprocess
|
import subprocess
|
||||||
from pmb.core.arch import Arch
|
|
||||||
import pmb.helpers.run_core
|
import pmb.helpers.run_core
|
||||||
from collections.abc import Sequence
|
from collections.abc import Sequence
|
||||||
from typing import overload, Literal
|
from typing import overload, Literal
|
||||||
|
@ -35,13 +34,8 @@ def user(
|
||||||
See pmb.helpers.run_core.core() for a detailed description of all other
|
See pmb.helpers.run_core.core() for a detailed description of all other
|
||||||
arguments and the return value.
|
arguments and the return value.
|
||||||
"""
|
"""
|
||||||
cmd_parts = []
|
cmd_parts = [os.fspath(c) for c in cmd]
|
||||||
for c in cmd:
|
|
||||||
if isinstance(c, Arch):
|
|
||||||
c = str(c)
|
|
||||||
else:
|
|
||||||
c = os.fspath(c)
|
|
||||||
cmd_parts.append(c)
|
|
||||||
# Readable log message (without all the escaping)
|
# Readable log message (without all the escaping)
|
||||||
msg = "% "
|
msg = "% "
|
||||||
for key, value in env.items():
|
for key, value in env.items():
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
import fcntl
|
import fcntl
|
||||||
from pmb.core.context import get_context
|
from pmb.core.context import get_context
|
||||||
from pmb.core.arch import Arch
|
|
||||||
from pmb.types import PathString, Env, RunOutputType
|
from pmb.types import PathString, Env, RunOutputType
|
||||||
from pmb.helpers import logging
|
from pmb.helpers import logging
|
||||||
import os
|
import os
|
||||||
|
@ -37,11 +36,7 @@ def flat_cmd(
|
||||||
cd /home/pmos;echo 'string with spaces'
|
cd /home/pmos;echo 'string with spaces'
|
||||||
"""
|
"""
|
||||||
# Merge env and cmd into escaped list
|
# Merge env and cmd into escaped list
|
||||||
escaped = []
|
escaped = [f"{key}={shlex.quote(os.fspath(value))}" for key, value in env.items()]
|
||||||
for key, value in env.items():
|
|
||||||
if isinstance(value, Arch):
|
|
||||||
value = str(value)
|
|
||||||
escaped.append(key + "=" + shlex.quote(os.fspath(value)))
|
|
||||||
for cmd in cmds:
|
for cmd in cmds:
|
||||||
for i in range(len(cmd)):
|
for i in range(len(cmd)):
|
||||||
escaped.append(shlex.quote(os.fspath(cmd[i])))
|
escaped.append(shlex.quote(os.fspath(cmd[i])))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue