pmb.helpers.run_core: move flat_cmd here

Move pmb.helpers.run.flat_cmd to run_core, as it will be used by
pmb.helpers.run_core.core in the next patch.

Link: https://lists.sr.ht/~postmarketos/pmbootstrap-devel/%3C20230713182337.6185-2-ollieparanoid@postmarketos.org%3E
This commit is contained in:
Oliver Smith 2023-07-13 20:19:47 +02:00
parent 46789ccee8
commit 20a0ccf36f
No known key found for this signature in database
GPG key ID: 5AE7F5513E0885CB
8 changed files with 54 additions and 48 deletions

View file

@ -5,6 +5,7 @@ import os
import logging
import pmb.helpers.run
import pmb.helpers.run_core
import pmb.parse.apkindex
import pmb.config.pmaports
import pmb.build
@ -29,7 +30,7 @@ def scp_abuild_key(args, user, host, port):
keyname = os.path.join("/tmp", os.path.basename(key))
remote_cmd = ['sudo', '-p', pmb.config.sideload_sudo_prompt,
'-S', 'mv', '-n', keyname, "/etc/apk/keys/"]
remote_cmd = pmb.helpers.run.flat_cmd(remote_cmd)
remote_cmd = pmb.helpers.run_core.flat_cmd(remote_cmd)
command = ['ssh', '-t', '-p', port, f'{user}@{host}', remote_cmd]
pmb.helpers.run.user(args, command, output="tui")
@ -53,8 +54,8 @@ def ssh_install_apks(args, user, host, port, paths):
logging.info(f"Installing packages at {user}@{host}")
add_cmd = ['sudo', '-p', pmb.config.sideload_sudo_prompt,
'-S', 'apk', '--wait', '30', 'add'] + remote_paths
add_cmd = pmb.helpers.run.flat_cmd(add_cmd)
clean_cmd = pmb.helpers.run.flat_cmd(['rm'] + remote_paths)
add_cmd = pmb.helpers.run_core.flat_cmd(add_cmd)
clean_cmd = pmb.helpers.run_core.flat_cmd(['rm'] + remote_paths)
command = ['ssh', '-t', '-p', port, f'{user}@{host}',
f'{add_cmd}; rc=$?; {clean_cmd}; exit $rc']
pmb.helpers.run.user(args, command, output="tui")