Pārlūkot izejas kodu

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 <james.d.knight@live.com>
[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 <yann.morin.1998@free.fr>
James Knight 2 gadi atpakaļ
vecāks
revīzija
d9b244d8a3
2 mainītis faili ar 20 papildinājumiem un 17 dzēšanām
  1. 6 17
      board/qemu/post-image.sh
  2. 14 0
      board/qemu/start-qemu.sh.in

+ 6 - 17
board/qemu/post-image.sh

@@ -41,21 +41,10 @@ case ${DEFCONFIG_NAME} in
     ;;
     ;;
 esac
 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}"
 chmod +x "${START_QEMU_SCRIPT}"

+ 14 - 0
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}