[meta-freescale] [Documentation][PATCH 01/14] scripts/output-machine-list: add commands interface

Mario Domenech Goulart mario at ossystems.com.br
Wed Apr 30 05:56:36 PDT 2014


Now output-machine-list accepts two commands: one to list machine
names (list) and another one to print a formatted table of machines
and their corresponding attributes (tabularize).

The script output is now printed to the standard output.

Signed-off-by: Mario Domenech Goulart <mario at ossystems.com.br>
---
 scripts/output-machine-list |   94 +++++++++++++++++++++++++++++++++----------
 1 file changed, 73 insertions(+), 21 deletions(-)

diff --git a/scripts/output-machine-list b/scripts/output-machine-list
index 0ced9ab..807332a 100755
--- a/scripts/output-machine-list
+++ b/scripts/output-machine-list
@@ -1,31 +1,83 @@
 #!/bin/sh
 
+usage() {
+    local exit_code
+    local output
+    [ -n $1 ] && exit_code=$1
+    if [ -n "$exit_code" ] && [ "$exit_code" != "0" ]; then
+        output=2
+    else
+        output=1
+    fi
+    cat <<EOF >&$output
+Usage: `basename $0` <yocto directory> [<command>]
+
+Commands:
+
+tabularize
+   Print tabular data for machines
+
+list
+   List machine names
+
+If <command> is omitted, list is used by default.
+EOF
+    [ -n "$exit_code" ] && exit $exit_code
+}
+
+
+[ -z "$1" ] && usage 1
+
+if [ "$1" = "-h" ] || [ "$1" = "-help" ] || [ "$1" = "--help" ]; then
+    usage 0
+fi
+
 REPO=$1
+COMMAND=$2
 
 TMP=`mktemp`
 MACHINE_LAYERS="meta-fsl-arm meta-fsl-arm-extra"
-DST=`dirname $0`/../release-notes/source/machine-list.inc
-
-for l in $MACHINE_LAYERS; do
-	MACHINES=`cd $REPO; repo forall $l -c 'find -wholename "*/conf/machine/*.conf" | sed "s,./\(.*\),$REPO_PATH/\1,g"'`
-	for m in $MACHINES; do
-		machine=`basename $m | sed 's,\.conf$,,g'`
-		name=`sed -n 's,#@NAME:\s*\(.*\),\1,p' $REPO/$m`
-		soc=`sed -n 's,#@SOC:\s*\(.*\),\1,p' $REPO/$m`
-
-		printf "%-25s  %-50s  %-12s  %-10s\n" "$machine" "$name" "$soc" "$l" >> $TMP
-	done
-done
-
-cat > $DST <<EOF
-=========================  ==================================================  ============  ==========
-         Machine             Name                                                 SoC          Layer
-=========================  ==================================================  ============  ==========
+
+list_machine_files() {
+    for l in $MACHINE_LAYERS; do
+        cd $REPO; repo forall $l -c 'find -wholename "*/conf/machine/*.conf" | sed "s,./\(.*\),$REPO_PATH/\1,g"'
+    done
+}
+
+list_machines() {
+    for m in `list_machine_files`; do
+        basename $m | sed 's,\.conf$,,g'
+    done | sort
+}
+
+tabularize_machines() {
+    for l in $MACHINE_LAYERS; do
+        MACHINES=`cd $REPO; repo forall $l -c 'find -wholename "*/conf/machine/*.conf" | sed "s,./\(.*\),$REPO_PATH/\1,g"'`
+        for m in $MACHINES; do
+            machine=`basename $m | sed 's,\.conf$,,g'`
+            name=`sed -n 's,#@NAME:\s*\(.*\),\1,p' $REPO/$m`
+            soc=`sed -n 's,#@SOC:\s*\(.*\),\1,p' $REPO/$m`
+
+            printf "%-25s  %-50s  %-20s  %-10s\n" "$machine" "$name" "$soc" "$l" >> $TMP
+        done
+    done
+
+    cat <<EOF
+=========================  ==================================================  ====================  ==========
+         Machine             Name                                                      SoC             Layer
+=========================  ==================================================  ====================  ==========
 EOF
 
-sort -u -k 1 $TMP >> $DST
+    sort -u -k 1 $TMP
 
-cat >> $DST <<EOF
-=========================  ==================================================  ============  ==========
+    cat <<EOF
+=========================  ==================================================  ====================  ==========
 EOF
-rm $TMP
+    rm $TMP
+}
+
+case "$COMMAND" in
+    "tabularize") tabularize_machines ;;
+    "list" | "") list_machines ;;
+    *) echo "Invalid command: $COMMAND" >&2
+esac
-- 
1.7.10.4



More information about the meta-freescale mailing list