Skip to contentSkip to conversation

genimage.sh: fix calling from BR2_ROOTFS_POST_IMAGE_SCRIPT

PATCH New Abhimanyu Vishwakarma 2 participants 2 messages Apr 24, 2017 – Apr 27, 2017

lore
Share & tools
lore
#0 lore raw

PATCH v10 1/2 genimage.sh: fix calling from BR2_ROOTFS_POST_IMAGE_SCRIPT

From: Abhimanyu Vishwakarma <[email protected]>

When called from BR2_ROOTFS_POST_IMAGE_SCRIPT, this script ends up with following error:

Error: Missing argument

This is because, an extra positional argument is also passed along with BR2_ROOTFS_POST_SCRIPT_ARGS. genimage.sh didn't have support to parse positional and optional arguments together.

---
Changes v7->v8
- New file
Changes v8->v9
- Fix indentation
- Use bash basename as script name instead hardcoding (by arnout)
Changes v9->v10 (Suggested by Arnout)
- Remove tab indentation (use existing 2 space indent)
- Fix commit message grammer
- add reviewed-by tag
- keep tested-by tag as no code change just indentation

 support/scripts/genimage.sh | 19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)
support/scripts/genimage.sh +14 -5
index 0ed0e8bcc..6c8d9e5ad 100755
@@ -5,13 +5,22 @@ die() {
   exit 1
 }
 
+# Parse arguments and put into argument list of the script
+opts="$(getopt -n "${0##*/}" -o c: -- "$@")" || exit $?
+eval set -- "$opts"
+
 GENIMAGE_TMP="${BUILD_DIR}/genimage.tmp"
 
-while getopts c: OPT ; do
-	case "${OPT}" in
-	c) GENIMAGE_CFG="${OPTARG}";;
-	:) die "option '${OPTARG}' expects a mandatory argument\n";;
-	\?) die "unknown option '${OPTARG}'\n";;
+while true ; do
+	case "$1" in
+	-c)
+	  GENIMAGE_CFG="${2}";
+	  shift 2 ;;
+	--) # Discard all non-option parameters
+	  shift 1;
+	  break ;;
+	*)
+	  die "unknown option '${1}'" ;;
 	esac
 done
 
Signature · 1 line
2.11.0
#1 lore raw

PATCH v10 1/2 genimage.sh: fix calling from BR2_ROOTFS_POST_IMAGE_SCRIPT

Quoted 29 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Abhimanyu" == Abhimanyu Vishwakarma <[email protected]> writes:

From: Abhimanyu Vishwakarma <[email protected]> When called from BR2_ROOTFS_POST_IMAGE_SCRIPT, this script ends up with following error:

Error: Missing argument

This is because, an extra positional argument is also passed along with BR2_ROOTFS_POST_SCRIPT_ARGS. genimage.sh didn't have support to parse positional and optional arguments together.

---
Changes v7->v8
- New file
Changes v8->v9
- Fix indentation
- Use bash basename as script name instead hardcoding (by arnout)
Changes v9->v10 (Suggested by Arnout)
- Remove tab indentation (use existing 2 space indent)
- Fix commit message grammer
- add reviewed-by tag
- keep tested-by tag as no code change just indentation

Quoted 2 lines
 support/scripts/genimage.sh | 19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)

Committed, thanks.

Signature · 1 line
Bye, Peter Korsgaard