wfa_dut: Modify the layout of wfa_dut project

Per comment in https://crrev.com/c/2486609,
we modify the layout of wfa_dut as:
* Binaries and start/stop scripts: /usr/local/bin
  wfa_dut, wfa_ca, start_wfa_*, stop_wfa_ca_dut

* Helper scripts: /usr/local/libexe/wfa:
  scripts/*

BUG=b:171276142
TEST=In chroot, after emerge-$BOARD net-wireless/wfa-test-suite-dut, run
  ./deploy/package.sh ~/trunk/chromite/ssh_keys/testing_rsa $BOARD
Then unzip wfa_ca.zip, then run:
  cd wfa_ca
  ./deploy/install.sh $DUT_HOST
to see if the wfa_ca binaries and scripts are installed.

Also run ./deploy/wfa_ca_dut.sh start $DUT_HOST
to see if the wfa_ca server is up and running.

Change-Id: I737bfab54bb9b7c1b8b2f140477a66aab3bd676b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/Wi-FiTestSuite-Linux-DUT/+/2501501
Reviewed-by: Shuo-Peng Liao <deanliao@chromium.org>
Tested-by: Shuo-Peng Liao <deanliao@chromium.org>
diff --git a/deploy/dut.sh b/deploy/dut.sh
index d17b60f..0da0fb9 100644
--- a/deploy/dut.sh
+++ b/deploy/dut.sh
@@ -21,7 +21,7 @@
   ssh -i $IDENTITY -F $SSH_CONFIG $DUT_HOST $@
 }
 
-# Copy source file(s) to $DUT_HOST:$WFA_DIR
-function deploy_dut {
-  scp -i $IDENTITY -F $SSH_CONFIG $@ $DUT_HOST:$WFA_DIR
+# Copy source file(s) to $DUT_HOST:${last_param}
+function deploy {
+  scp -i $IDENTITY -F $SSH_CONFIG ${@:1:$#-1} $DUT_HOST:${!#}
 }
diff --git a/deploy/install.sh b/deploy/install.sh
index 5798394..615b547 100755
--- a/deploy/install.sh
+++ b/deploy/install.sh
@@ -8,8 +8,9 @@
   exit 0
 fi
 
-WFA_DIR=/usr/local/bin/wfa
 DUT_HOST=$1
+WFA_BIN=/usr/local/bin
+WFA_LIBEXE=/usr/local/libexe/wfa
 
 # Load run_dut and deploy_dut functions.
 MY_DIR=$( dirname "${BASH_SOURCE[0]}" )
@@ -19,10 +20,12 @@
 cd $MY_DIR/..
 
 echo "Stopping existing wfa_ca and wfa_dut on $DUT_HOST"
-run_dut mkdir -p $WFA_DIR
-deploy_dut scripts/stop_wfa_ca_dut
-run_dut $WFA_DIR/stop_wfa_ca_dut
+deploy bin/stop_wfa_ca_dut $WFA_BIN
+run_dut stop_wfa_ca_dut
 
-echo "Deploying wfa_ca, wfa_dut and scripts to $DUT_HOST:$WFA_DIR"
-deploy_dut ca/wfa_ca dut/wfa_dut
-deploy_dut scripts/*
+echo "Deploying wfa_ca, wfa_dut and start/stop scripts to $DUT_HOST:$WFA_BIN"
+deploy bin/* $WFA_BIN
+
+echo "Deploying helper scripts to $DUT_HOST:$WFA_LIBEXE"
+run_dut mkdir -p $WFA_LIBEXE
+deploy scripts/* $WFA_LIBEXE
diff --git a/deploy/package.sh b/deploy/package.sh
index 6b7cad1..80fc1eb 100755
--- a/deploy/package.sh
+++ b/deploy/package.sh
@@ -1,10 +1,23 @@
 #!/bin/bash
 
+# Package WFA Test Suite's content to a zip file for deployment.
+# It grabs the compiled binaries, helper scripts and DUT's SSH keys to
+# pack in a zip file.
+#
+# Parameters: <testing_rsa_path> <board name to access /build/$board>
+#
+# Layout:
+#   bin/: wfa_ca, wfa_dut and scripts in shbin/*
+#   deploy/: deploy scripts in deploy/*
+#   scripts: helper scripts in scripts/*
+
+
+
 PKGNAME=wfa_ca
 PKGFILE=$PKGNAME.zip
 
-if [ $# -ne 1 ]; then
-  echo "Usage: ./package.sh <path to identity file (testing_rsa)>"
+if [ $# -ne 2 ]; then
+  echo "Usage: ./package.sh <path to identity file (testing_rsa)> <board name>"
   exit 1
 fi
 IDENTITY_SRC=$1
@@ -13,6 +26,13 @@
   exit 1
 fi
 
+BOARD=$2
+BUILT_BIN=/build/$BOARD/usr/local/bin
+if [ ! -f $BUILT_BIN/wfa_dut ]; then
+  echo "File not found: $BUILT_BIN/wfa_dut. Are you in chroot? Please run emerge first"
+  exit 1
+fi
+
 MYDIR=$( dirname "${BASH_SOURCE[0]}" )
 cd $MYDIR/..
 BASE=$( pwd )
@@ -20,14 +40,13 @@
 TMPD=$( mktemp -d )
 PKGDIR=$TMPD/$PKGNAME
 echo "Copying files to $PKGDIR"
-mkdir -p $PKGDIR/ca
-cp ca/wfa_ca $PKGDIR/ca
-
-mkdir -p $PKGDIR/dut
-cp dut/wfa_dut $PKGDIR/dut
+mkdir -p $PKGDIR/bin
+cp $BUILT_BIN/wfa_ca $PKGDIR/bin
+cp $BUILT_BIN/wfa_dut $PKGDIR/bin
 
 cp -a deploy $PKGDIR
 cp -a scripts $PKGDIR
+cp -a shbin/* $PKGDIR/bin
 
 IDENTITY_DEST=$PKGDIR/deploy/testing_rsa
 cp $IDENTITY_SRC $IDENTITY_DEST
diff --git a/deploy/wfa_ca_dut.sh b/deploy/wfa_ca_dut.sh
index 17cfbcd..1ffbebe 100755
--- a/deploy/wfa_ca_dut.sh
+++ b/deploy/wfa_ca_dut.sh
@@ -6,19 +6,17 @@
 START_STOP=$1
 DUT_HOST=$2
 
-WFA_DIR=/usr/local/bin/wfa
-
 # Load run_dut and deploy_dut functions.
 MY_DIR=$( dirname "${BASH_SOURCE[0]}" )
 source $MY_DIR/dut.sh
 
 case $START_STOP in
   start)
-    run_dut $WFA_DIR/start_wfa_ca_dut &
+    run_dut start_wfa_ca_dut &
     echo "wfa_ca / wfa_dut started on $DUT_HOST"
     ;;
   stop)
-    run_dut $WFA_DIR/stop_wfa_ca_dut
+    run_dut stop_wfa_ca_dut
     echo "wfa_ca / wfa_dut stopped on $DUT_HOST"
     ;;
   *)
diff --git a/scripts/start_wfa_ca b/scripts/start_wfa_ca
deleted file mode 100755
index 7164ffb..0000000
--- a/scripts/start_wfa_ca
+++ /dev/null
@@ -1,11 +0,0 @@
-#!/bin/bash
-#
-# Starts wfa_ca on default port and bind to default wfa_dut server.
-
-DUT_IP=$( ifconfig eth0 | grep "inet " | awk '{ print $2 }' )
-WFA_DIR=/usr/local/bin/wfa
-
-echo "Starting wfa_ca on $DUT_IP:8888"
-
-# Append $WFA_DIR to $PATH so that wfa_ca can run the scripts in it.
-PATH="$PATH:$WFA_DIR" $WFA_DIR/wfa_ca eth0 8888 $DUT_IP 9999 &
diff --git a/scripts/start_wfa_ca_dut b/scripts/start_wfa_ca_dut
deleted file mode 100755
index f7201d0..0000000
--- a/scripts/start_wfa_ca_dut
+++ /dev/null
@@ -1,11 +0,0 @@
-#!/bin/bash
-#
-# Starts wfa_dut and wfa_ca in sequence.
-
-WFA_DIR=/usr/local/bin/wfa
-
-$WFA_DIR/stop_wfa_ca_dut
-
-$WFA_DIR/start_wfa_dut &
-sleep 1
-$WFA_DIR/start_wfa_ca &
diff --git a/scripts/start_wfa_dut b/scripts/start_wfa_dut
deleted file mode 100755
index f08c647..0000000
--- a/scripts/start_wfa_dut
+++ /dev/null
@@ -1,13 +0,0 @@
-#!/bin/bash
-#
-# Starts wfa_dut on default port.
-
-WFA_DIR=/usr/local/bin/wfa
-
-echo "shill: giving up managing WiFi devices"
-$WFA_DIR/shill_disable_wifi
-
-echo "Starting wfa_dut on localhost:9999"
-
-# Append $WFA_DIR to $PATH so that wfa_dut can run the scripts in it.
-PATH="$PATH:$WFA_DIR" $WFA_DIR/wfa_dut eth0 9999 &
diff --git a/shbin/start_wfa_ca b/shbin/start_wfa_ca
new file mode 100755
index 0000000..46ff97a
--- /dev/null
+++ b/shbin/start_wfa_ca
@@ -0,0 +1,11 @@
+#!/bin/bash
+#
+# Starts wfa_ca on default port and bind to default wfa_dut server.
+
+DUT_IP=$( ifconfig eth0 | grep "inet " | awk '{ print $2 }' )
+WFA_LIB=/usr/local/libexe/wfa
+
+echo "Starting wfa_ca on $DUT_IP:8888"
+
+# Append $WFA_LIB to $PATH so that wfa_ca can run the scripts in it.
+PATH="$PATH:$WFA_LIB" wfa_ca eth0 8888 $DUT_IP 9999 &
diff --git a/shbin/start_wfa_ca_dut b/shbin/start_wfa_ca_dut
new file mode 100755
index 0000000..88167cd
--- /dev/null
+++ b/shbin/start_wfa_ca_dut
@@ -0,0 +1,9 @@
+#!/bin/bash
+#
+# Starts wfa_dut and wfa_ca in sequence.
+
+stop_wfa_ca_dut
+
+start_wfa_dut &
+sleep 1
+start_wfa_ca &
diff --git a/shbin/start_wfa_dut b/shbin/start_wfa_dut
new file mode 100755
index 0000000..16f9663
--- /dev/null
+++ b/shbin/start_wfa_dut
@@ -0,0 +1,13 @@
+#!/bin/bash
+#
+# Starts wfa_dut on default port.
+
+WFA_LIB=/usr/local/libexe/wfa
+
+echo "shill: giving up managing WiFi devices"
+$WFA_LIB/shill_disable_wifi
+
+echo "Starting wfa_dut on localhost:9999"
+
+# Append $WFA_LIB to $PATH so that wfa_dut can run the scripts in it.
+PATH="$PATH:$WFA_LIB" wfa_dut eth0 9999 &
diff --git a/scripts/stop_wfa_ca_dut b/shbin/stop_wfa_ca_dut
similarity index 72%
rename from scripts/stop_wfa_ca_dut
rename to shbin/stop_wfa_ca_dut
index 8543255..77ef310 100755
--- a/scripts/stop_wfa_ca_dut
+++ b/shbin/stop_wfa_ca_dut
@@ -2,11 +2,11 @@
 #
 # Stops wfa_ca and wfa_dut servers.
 
-WFA_DIR=/usr/local/bin/wfa
+WFA_LIB=/usr/local/libexe/wfa
 
 echo "kill wfa_ca & wfa_dut"
 killall wfa_ca
 killall wfa_dut
 
 echo "shill: managing WiFi devices"
-$WFA_DIR/shill_enable_wifi
+$WFA_LIB/shill_enable_wifi