From a082d38b97bef781c116e0520397f9d049737e0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Andr=C3=A9?= Date: Thu, 2 Jul 2015 10:26:20 +0900 Subject: [PATCH] Make tools/min-env.sh portable We had different issues here. First, sort command used to sort variables and services names is dependent on the local, so fix it to C to have consistent results. C local is available on all systems. Second, awk doesn't recognize \s escape char for space on OSX. This resulted in indented check_required_vars calls being ignored. In fact, all variables checked via indented check_required_vars calls (i.e. in a fuction or conditional block) are actually *optional* variables, so I changed the behavior to ignore those. Change-Id: I6fc4cca9567cb712609d0fe0a20dfe21ed6df151 Closes-Bug: #1470683 --- tools/min-env.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tools/min-env.sh b/tools/min-env.sh index 403a43c34c..f5fecec454 100755 --- a/tools/min-env.sh +++ b/tools/min-env.sh @@ -6,6 +6,9 @@ REAL_PATH=$(python -c "import os,sys;print os.path.realpath('$0')") cd "$(dirname "$REAL_PATH")/.." +# Make sure sort produces the same output on all systems +export LC_ALL=C + DOC=docs/minimal-environment-vars.md DOCKERDIR="docker" # BASE and TYPE can be hard coded to centos and rdo since the required vars will always be the same @@ -35,7 +38,7 @@ function find_vars { scripts=$(find ${img_location} -name *.sh | sort -t / -k 4) for script in $scripts; do - local vars=$(awk '/^\s*check_required_vars/,/([^\\]\s*$)/' $script) + local vars=$(awk '/^check_required_vars/,/([^\\] *$)/' $script) vars=$(echo "$vars" | sed 's/check_required_vars//' | sed 's/\\//g') if [ ! -z "$vars" ]; then