aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Rocard <kevinx.rocard@intel.com>2013-02-22 16:53:25 +0100
committerDavid Wagner <david.wagner@intel.com>2014-02-12 17:03:51 +0100
commitcf092eea28b080b65854848be6548a2760af04cd (patch)
tree83d7c102a5a638d9b981389a39150b354ff06197
parent4d26284850243549d4177768030e58d984b05c37 (diff)
downloadexternal_parameter-framework-cf092eea28b080b65854848be6548a2760af04cd.zip
external_parameter-framework-cf092eea28b080b65854848be6548a2760af04cd.tar.gz
external_parameter-framework-cf092eea28b080b65854848be6548a2760af04cd.tar.bz2
PFW: [xml generation] Change send command method
BZ: 97960 The lightRoutingUpdate.sh script had bugs using adb shell commands. Push the generated script of board, then execute it remotly. Remove support for environement define pfw file and add support for multiple argument files. Change-Id: Ie43e1e2a4d3bc207a8704e7ca1a254dad74c9139 Signed-off-by: Kevin Rocard <kevinx.rocard@intel.com> Reviewed-on: http://android.intel.com:8080/93371 Reviewed-by: cactus <cactus@intel.com> Reviewed-by: Wagner, David <david.wagner@intel.com> Reviewed-by: De Chivre, Renaud <renaud.de.chivre@intel.com> Tested-by: Dixon, CharlesX <charlesx.dixon@intel.com> Reviewed-by: buildbot <buildbot@intel.com> Tested-by: buildbot <buildbot@intel.com>
-rwxr-xr-xtools/xmlGenerator/lightRoutingUpdate.sh105
1 files changed, 57 insertions, 48 deletions
diff --git a/tools/xmlGenerator/lightRoutingUpdate.sh b/tools/xmlGenerator/lightRoutingUpdate.sh
index 646bdf5..dd16362 100755
--- a/tools/xmlGenerator/lightRoutingUpdate.sh
+++ b/tools/xmlGenerator/lightRoutingUpdate.sh
@@ -28,26 +28,24 @@
set -eu -o pipefail
adbShell="adb shell"
-parameterCommandAccess="eval parameter"
+parameterCommandAccess="eval remote-process localhost 5000"
parameter="$adbShell $parameterCommandAccess"
tmpfile="/tmp/pfw_commands"
+target_tmpfile="/data/pfw_commands"
adbShellForward () {
+
+ echo 'echo $?; exit' >> "$1"
+
# Send commands
- (
- echo 'PS1="# "'
- echo 'set -xeu'
- cat "$1"
- echo 'echo $?'
- echo 'exit'
- )|
- # adb shell can not handle a too fast input, create artificial delay :(
- while read line; do echo "$line"; sleep 0.04; done |
- $adbShell |
- # keep only the -3line, the output of "echo $?"
- tee /dev/stderr | tail -3 | sed '1{s/\r//;q}' |
+ adb push "$1" "$target_tmpfile"
+ $adbShell chmod 700 "$target_tmpfile"
+
+ $adbShell "$target_tmpfile" |
+ # keep only the -2 line, the output of "echo $?"
+ tee /dev/stderr | tail -2 | sed '1{s/\r//;q}' |
# stop if $? != 0 (as of set -e)
xargs test 0 -eq 2> /dev/null
@@ -65,77 +63,88 @@ function parameterExecute ()
return 0
}
-# Clean tmp file
-rm "$tmpfile" || true
+function log ()
+{
+ echo "$@" >&2
+}
-if test $# -eq 0
-then
- domainFile="$(realpath "$PFWtest_DomainFile")"
-else
- domainFile="$1"
-fi
+# Clean tmp file
+echo > "${tmpfile}"
#################
# Configure PFW #
#################
-parameterExecute setTuningMode on
-parameterExecute setAutoSync off
+echo "setTuningMode on" >> "${tmpfile}"
+echo "setAutoSync off" >> "${tmpfile}"
-echo "Delete routing domains"
+log "Delete routing domains"
for domain in $(parameterExecute listDomains |grep -io '^Routing.[^ ]*')
do
- echo "Will delete domain $domain"
- echo "deleteDomain $domain" >> "$tmpfile"
+ log "Will delete domain $domain"
+ echo "deleteDomain $domain" >> "${tmpfile}"
done
#########################
# Generate PFW commands #
#########################
-echo "Generate domain commands from file $(realpath $domainFile)"
-m4 "$domainFile" | $(dirname $0)/PFWScriptGenerator.py --pfw >> "$tmpfile"
+log "Generate domain commands from file(s): $*"
+m4 "$@" \
+ | $(dirname $0)/PFWScriptGenerator.py --pfw >> "${tmpfile}"
-sed -i -e':a' \
- -e '# look for line finishing wih \
+echo "setAutoSync off" >> "${tmpfile}"
+echo "setTuningMode off" >> "${tmpfile}"
+
+sed -i -e':a
+ # look for line finishing with \
/\\$/{
# Delete the last char (\)
s/\\$//;
# Append the next line and delete the \n separator
N;
s/\n/ /;
- # Jump back to the expression begining
+ # Jump back to the expression beginning
ta;
- };' \
- -e '/^$/d;# delete empty lines' \
- -e 's/^ *//;# delete leading space' \
- -e 's/ */ /g;# delete multiple spaces' \
- -e 's/^.*$/'"$parameterCommandAccess"' "\0"\;/;# Add a prefix ($parameterCommandAccess) on each line' "$tmpfile"
+ };
+ # delete empty lines;
+ /^$/d
+ # delete leading space
+ s/^ *//
+ # delete multiple spaces
+ s/ */ /g;
+ # Prefix each line with "$parameterCommandAccess
+ '"s/^/$parameterCommandAccess /" \
+ "${tmpfile}"
-echo "Execute commands"
-adbShellForward "$tmpfile"
+echo "set -xeu" > "${tmpfile}2"
+cat "${tmpfile}" >> "${tmpfile}2"
+log "Execute commands"
+adbShellForward "${tmpfile}2"
-parameterExecute setAutoSync off
-parameterExecute setTuningMode off
#####################
# Generate xml file #
#####################
-# Output file is the input file with the xml extension
-outputFile="$(echo "$domainFile" | sed 's#\.pfw$#.xml#')"
+outputFilePath="domains.xml"
-# Test if diferent from .pfw file (we do not whant to overwrite it)
-if test "$outputFile" == "$domainFile"
+if test $# -ne 0
then
- outputFile="${outputFile}.xml"
+ # Output file is the input file with the xml extension
+ outputFilePath="${1%.*}.xml"
+ if test "$outputFilePath" == "$1"
+ then
+ # There is a conflict
+ outputFilePath="${1}.xml"
+ fi
fi
-echo "Output file: $outputFile"
-$parameter getDomainsXML |sed 's/\r//' > "$outputFile"
+log "Output file: $outputFilePath"
+$parameter getDomainsXML |sed 's/\r//' > "$outputFilePath"
-echo "The media serveur PFW domains have been change, please restart it to restore old domains"
+log "The media server PFW domains have been change, please restart it to restore old domains"