2
0
mirror of https://github.com/xcat2/confluent.git synced 2026-12-01 23:02:22 +00:00

Run remote imgutil scripts with sh

This commit is contained in:
Markus Hilger
2026-11-30 21:57:48 +01:00
parent f2e18689a8
commit f943e73a27
+4 -3
View File
@@ -527,8 +527,8 @@ def remote_env(host, files=()):
on host, and files below its pkglists subdirectory with their full path,
yield the path of the copied imgutil"""
rdir = subprocess.check_output(
['ssh', host, 'mkdir -p /run/imgutil && mktemp -d -p /run/imgutil remote.XXXXXX'],
stdin=subprocess.DEVNULL).decode('utf8').strip()
['ssh', '-T', host, '/bin/sh -s'],
input=b'mkdir -p /run/imgutil && mktemp -d -p /run/imgutil remote.XXXXXX\n').decode('utf8').strip()
# the last line, a shell startup file of the host may print more
rdir = rdir.split('\n')[-1].strip()
if not re.match(r'^/run/imgutil/remote\.[A-Za-z0-9]+$', rdir):
@@ -621,7 +621,8 @@ def prepare_remote_target(host, rpath):
script = ('if [ -L {0} ] || {{ [ -e {0} ] && ! {{ [ -d {0} ] && [ -z "$(ls -A {0})" ]; }}; }}; '
'then exit 3; fi; mkdir -p {1}').format(
shlex.quote(rpath), shlex.quote(os.path.dirname(rpath)))
rc = subprocess.call(['ssh', host, script], stdin=subprocess.DEVNULL)
rc = subprocess.run(['ssh', '-T', host, '/bin/sh -s'],
input=os.fsencode(script + '\n')).returncode
if rc == 3:
sys.stderr.write('{0}:{1} exists and is not an empty directory\n'.format(host, rpath))
sys.exit(1)