From d9b244d8a3c83b39f67444f36b21a88cbaf4547b Mon Sep 17 00:00:00 2001 From: James Knight Date: Fri, 7 Apr 2023 01:21:06 -0400 Subject: [PATCH] board/qemu: define start qemu script outside of post-image script The following moves the definition of the QEMU board's `start-qemu.sh` helper script from being inlined in the post-image script into its own file. This should, in theory, make it easier to maintain the script in the future. Signed-off-by: James Knight [yann.morin.1998@free.fr: - don't sub-shell in the script - merge all 3 sed calls into one - create dest file with the sed, don't cp first - also substitute HOST_DIR - fix shellcheck ] Signed-off-by: Yann E. MORIN --- board/qemu/post-image.sh | 23 ++++++----------------- board/qemu/start-qemu.sh.in | 14 ++++++++++++++ 2 files changed, 20 insertions(+), 17 deletions(-) create mode 100644 board/qemu/start-qemu.sh.in diff --git a/board/qemu/post-image.sh b/board/qemu/post-image.sh index 88f0413496..57306dd546 100755 --- a/board/qemu/post-image.sh +++ b/board/qemu/post-image.sh @@ -41,21 +41,10 @@ case ${DEFCONFIG_NAME} in ;; esac -cat <<-_EOF_ > "${START_QEMU_SCRIPT}" - #!/bin/sh - ( - BINARIES_DIR="\${0%/*}/" - cd \${BINARIES_DIR} - - if [ "\${1}" = "serial-only" ]; then - EXTRA_ARGS='${SERIAL_ARGS}' - else - EXTRA_ARGS='${DEFAULT_ARGS}' - fi - - export PATH="${HOST_DIR}/bin:\${PATH}" - exec ${QEMU_CMD_LINE} \${EXTRA_ARGS} - ) -_EOF_ - +sed "s|@SERIAL_ARGS@|${SERIAL_ARGS}|g" \ + "s|@DEFAULT_ARGS@|${DEFAULT_ARGS}|g" \ + "s|@QEMU_CMD_LINE@|${QEMU_CMD_LINE}|g" \ + "s|@HOST_DIR@|${HOST_DIR}|g" \ + <"${QEMU_BOARD_DIR}/start-qemu.sh.in" \ + >"${START_QEMU_SCRIPT}" chmod +x "${START_QEMU_SCRIPT}" diff --git a/board/qemu/start-qemu.sh.in b/board/qemu/start-qemu.sh.in new file mode 100644 index 0000000000..4dc9bfbb0d --- /dev/null +++ b/board/qemu/start-qemu.sh.in @@ -0,0 +1,14 @@ +#!/bin/sh + +BINARIES_DIR="${0%/*}/" +# shellcheck disable=SC2164 +cd "${BINARIES_DIR}" + +if [ "${1}" = "serial-only" ]; then + EXTRA_ARGS='@SERIAL_ARGS@' +else + EXTRA_ARGS='@DEFAULT_ARGS@' +fi + +export PATH="@HOST_DIR@/bin:${PATH}" +exec @QEMU_CMD_LINE@ ${EXTRA_ARGS}