From: Alexander Smirnov <asmirnov@ilbers.de>
To: isar-users@googlegroups.com
Cc: Alexander Smirnov <asmirnov@ilbers.de>
Subject: [PATCH 2/4] scripts: Update start_vm
Date: Tue, 8 Aug 2017 13:04:22 +0300 [thread overview]
Message-ID: <20170808100424.19607-3-asmirnov@ilbers.de> (raw)
In-Reply-To: <20170808100424.19607-1-asmirnov@ilbers.de>
Add support for user command line parameters which can specify:
- Target architecture
- Debian distribution
- Path to build folder
Signed-off-by: Alexander Smirnov <asmirnov@ilbers.de>
---
scripts/start_vm | 60 ++++++++++++++++++++++++++++++++++++++++++--------------
1 file changed, 45 insertions(+), 15 deletions(-)
diff --git a/scripts/start_vm b/scripts/start_vm
index a043a52..32d4864 100755
--- a/scripts/start_vm
+++ b/scripts/start_vm
@@ -8,10 +8,6 @@ set -e
ES_OK=0
ES_BUG=3
-# TODO: Get the target from the command line or from the build environment
-ARCH=arm
-DISTRO=stretch
-
# Convert bitbake assignments to shell ones
# a = b a=b
# a ?= b a=b
@@ -56,19 +52,53 @@ show_help() {
echo "is used."
echo
echo "Parameters:"
- echo " --help display this message and exit."
+ echo " -a, --arch ARCH set isar machine architecture."
+ echo " Supported: arm, i386, amd64."
+ echo " -b, --build BUILD set path to build directory."
+ echo " -d, --distro DISTRO set isar Debian distribution."
+ echo " Supported: jessie, stretch."
+ echo " --help display this message and exit."
+ echo
+ echo "Exit status:"
+ echo " 0 if OK,"
+ echo " 3 if invalid parameters are passed."
}
-if [ "$#" == "1" -a "$1" == "--help" ]; then
- show_help
- exit 0
-fi
-
-if [ "$#" == "0" ]; then
- BUILD_DIR=$PWD
-else
- BUILD_DIR=$1
-fi
+# Set default values, that can be overwritten from command line
+ARCH=arm
+DISTRO=stretch
+BUILD_DIR=$PWD
+
+# Parse command line to get user configuration
+while [[ $# -gt 0 ]]
+do
+ key="$1"
+
+ case $key in
+ -h|--help)
+ show_help
+ exit 0
+ ;;
+ -a|--arch)
+ ARCH=$2
+ shift
+ ;;
+ -b|--build)
+ BUILD_DIR=$2
+ shift
+ ;;
+ -d|--distro)
+ DISTRO=$2
+ shift
+ ;;
+ *)
+ echo "error: invalid parameter '$key', please try '--help' to get list of supported parameters"
+ exit $ES_BUG
+ ;;
+ esac
+
+ shift
+done
readonly IMAGE_DIR=$BUILD_DIR/tmp/deploy/images
--
2.1.4
next prev parent reply other threads:[~2017-08-08 10:15 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-08 10:04 [PATCH 0/4] Various fixes Alexander Smirnov
2017-08-08 10:04 ` [PATCH 1/4] isar: Fix mutli-distro builds in parallel Alexander Smirnov
2017-08-08 10:58 ` Henning Schild
2017-08-08 11:21 ` Alexander Smirnov
2017-08-08 11:56 ` Henning Schild
2017-08-21 21:11 ` Baurzhan Ismagulov
2017-08-08 10:04 ` Alexander Smirnov [this message]
2017-08-08 10:04 ` [PATCH 3/4] buildchroot: Fix dependency installation in buildchroot Alexander Smirnov
2017-08-21 21:28 ` Baurzhan Ismagulov
2017-08-08 10:04 ` [PATCH 4/4] buildchroot: Update build script Alexander Smirnov
2017-08-08 11:05 ` Henning Schild
2017-08-21 21:42 ` Baurzhan Ismagulov
2017-08-21 21:35 ` Baurzhan Ismagulov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170808100424.19607-3-asmirnov@ilbers.de \
--to=asmirnov@ilbers.de \
--cc=isar-users@googlegroups.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox