Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH v2 1/3] board/qemu: define start qemu script outside of post-image script
@ 2023-04-07  5:21 James Knight
  2023-04-10 21:11 ` Yann E. MORIN
  0 siblings, 1 reply; 3+ messages in thread
From: James Knight @ 2023-04-07  5:21 UTC (permalink / raw)
  To: buildroot; +Cc: James Knight, Romain Naour

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>
---
Changes v1 -> v2:
  - Split original into three patches (suggested by Arnout).
  - This patch moves cat script into a new 'start-qemu.sh.in'
    file (suggested by Arnout).
  - Script template dropped escape characters; uses VAR_ prefixes.
---
 board/qemu/post-image.sh    | 21 ++++-----------------
 board/qemu/start-qemu.sh.in | 14 ++++++++++++++
 2 files changed, 18 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 88f04134961ea7a105e506045ca16a0d9b810925..c9043a1364e8e03dbfa9ff3370d4e4a34357bef5 100755
--- a/board/qemu/post-image.sh
+++ b/board/qemu/post-image.sh
@@ -41,21 +41,8 @@ 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_
-
+cp "${QEMU_BOARD_DIR}/start-qemu.sh.in" "${START_QEMU_SCRIPT}"
+sed -i "s|VAR_DEFAULT_ARGS|${DEFAULT_ARGS}|g" "${START_QEMU_SCRIPT}"
+sed -i "s|VAR_QEMU_CMD_LINE|${QEMU_CMD_LINE}|g" "${START_QEMU_SCRIPT}"
+sed -i "s|VAR_SERIAL_ARGS|${SERIAL_ARGS}|g" "${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 0000000000000000000000000000000000000000..c2d77734c7a6b318a5f7adedfd9b0b5875e84f59
--- /dev/null
+++ b/board/qemu/start-qemu.sh.in
@@ -0,0 +1,14 @@
+#!/bin/sh
+(
+BINARIES_DIR="${0%/*}/"
+cd ${BINARIES_DIR}
+
+if [ "${1}" = "serial-only" ]; then
+    EXTRA_ARGS='VAR_SERIAL_ARGS'
+else
+    EXTRA_ARGS='VAR_DEFAULT_ARGS'
+fi
+
+export PATH="${HOST_DIR}/bin:${PATH}"
+exec VAR_QEMU_CMD_LINE ${EXTRA_ARGS}
+)
-- 
2.39.1.windows.1

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-04-11  7:06 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-04-07  5:21 [Buildroot] [PATCH v2 1/3] board/qemu: define start qemu script outside of post-image script James Knight
2023-04-10 21:11 ` Yann E. MORIN
2023-04-11  7:05   ` Arnout Vandecappelle

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox