Author: ks156
Date: 2008-12-15 10:16:47 +0100 (Mon, 15 Dec 2008)
New Revision: 3122
Modified:
software_suite_v2/software/development_tools/gadget_packer/trunk/tux_gadget_packer
Log:
* Added verifictations for all the XML sections.
Modified:
software_suite_v2/software/development_tools/gadget_packer/trunk/tux_gadget_packer
===================================================================
---
software_suite_v2/software/development_tools/gadget_packer/trunk/tux_gadget_packer
2008-12-15 09:13:17 UTC (rev 3121)
+++
software_suite_v2/software/development_tools/gadget_packer/trunk/tux_gadget_packer
2008-12-15 09:16:47 UTC (rev 3122)
@@ -1,108 +1,155 @@
#!/bin/bash
# Constants
-OPTIONAL="\033[80D\033[71C\033[33mOPTIONAL \033[00m\n"
-WARNING="\033[80D\033[72C\033[33mWARNING \033[00m\n"
-DETECTED="\033[80D\033[71C\033[32mDETECTED \033[00m\n"
-PASSED="\033[80D\033[73C\033[32mPASSED \033[00m\n"
-NOTFOUND="\033[80D\033[70C\033[31mNOT FOUND \033[00m\n"
-FAILED="\033[80D\033[73C\033[31mFAILED \033[00m\n"
+WARNING="\033[80D\033[72C\033[33mWARNING\033[00m\n"
+PASSED="\033[80D\033[73C\033[32mPASSED\033[00m\n"
+NOTFOUND="\033[80D\033[70C\033[31mNOT FOUND\033[00m\n"
+FAILED="\033[80D\033[73C\033[31mFAILED\033[00m\n"
+log_report () {
+ LOG="$LOG $1"
+}
+
# Scan the <description></description> section
scan_description () {
echo $line |grep "<name>" > /dev/null
if [ $? == 0 ]; then
- printf "> Name : "
- NAME=`echo $line |cut -f 2 -d '>' | cut -f 1 -d "<"`
- echo $NAME
+ DESC_NAME=`echo $line |cut -f 2 -d '>' | cut -f 1 -d "<"`
fi
echo $line |grep "<description>" >/dev/null
if [ $? == 0 ]; then
- printf "> Desc : "
- echo $line |cut -f 2 -d '>' |cut -f 1 -d '<'
+ DESC_DESC=`echo $line |cut -f 2 -d '>' |cut -f 1 -d '<'`
fi
echo $line |grep "<author>" >/dev/null
if [ $? == 0 ]; then
- printf "> Author : "
- echo $line |cut -f 2 -d '>' |cut -f 1 -d '<'
+ DESC_AUTHOR=`echo $line |cut -f 2 -d '>' |cut -f 1 -d '<'`
fi
echo $line |grep "<version>" >/dev/null
if [ $? == 0 ]; then
- printf "> Version : "
- echo $line |cut -f 2 -d '>' |cut -f 1 -d '<'
+ DESC_VERSION=`echo $line |cut -f 2 -d '>' |cut -f 1 -d '<'`
fi
}
# Scan the <parameters></parameters> section
+PARAM_COUNT=0
scan_parameters () {
echo $line |grep "<parameter" >/dev/null
if [ $? == 0 ]; then
- printf "\n Parameter :\n"
+ let PARAM_COUNT=$PARAM_COUNT+1
fi
echo $line |grep "name" > /dev/null
if [ $? == 0 ]; then
- printf "> Name : "
- echo $line |cut -f 2 -d '"'
+ PARAM_NAME=`echo $line |cut -f 2 -d '"'`
fi
echo $line |grep "description" >/dev/null
if [ $? == 0 ]; then
- printf "> Desc : "
- echo $line |cut -f 2 -d '"'
+ PARAM_DESC=`echo $line |cut -f 2 -d '"'`
fi
echo $line |grep "type" >/dev/null
if [ $? == 0 ]; then
- printf "> Type : "
- echo $line |cut -f 2 -d '"'
+ PARAM_TYPE=`echo $line |cut -f 2 -d '"'`
fi
echo $line |grep "defaultValue" >/dev/null
if [ $? == 0 ]; then
- printf "> Default : "
- echo $line |cut -f 2 -d '"'
+ PARAM_VALUE=`echo $line |cut -f 2 -d '"'`
fi
}
# Scan the <commands></commands> section
+CMD_COUNT=0
scan_commands () {
echo $line |grep "<command" >/dev/null
if [ $? == 0 ]; then
- printf "\n Command :\n"
+ let CMD_COUNT=$CMD_COUNT+1
fi
echo $line |grep "name" > /dev/null
if [ $? == 0 ]; then
- printf "> Name : "
- echo $line |cut -f 2 -d '"'
+ CMD_NAME=`echo $line |cut -f 2 -d '"'`
fi
echo $line |grep "description" >/dev/null
if [ $? == 0 ]; then
- printf "> Desc : "
- echo $line |cut -f 2 -d '"'
+ CMD_DESC=`echo $line |cut -f 2 -d '"'`
fi
}
+verify_xml () {
+ log_report "\n Description section :\n"
+ if [[ ! -z $DESC_NAME ]] && [[ ! -z $DESC_DESC ]] && \
+ [[ ! -z $DESC_AUTHOR ]] && [[ ! -z $DESC_VERSION ]]; then
+ log_report "> Found description $PASSED"
+ else
+ if [[ -z $DESC_NAME ]]; then
+ log_report "> No gadget's name found $WARNING"
+ fi
+ if [[ -z $DESC_DESC ]]; then
+ log_report "> No gadget's description found $WARNING"
+ fi
+ if [[ -z $DESC_AUTHOR ]]; then
+ log_report "> No gadget's author found $WARNING"
+ fi
+ if [[ -z $DESC_VERSION ]]; then
+ log_report "> No gadget's version found $WARNING"
+ fi
+ fi
+ log_report "\n Parameters section :\n"
+ if [[ ! -z $PARAM_NAME ]] && [[ ! -z $PARAM_DESC ]] && \
+ [[ ! -z $PARAM_TYPE ]] && [[ ! -z $PARAM_VALUE ]]; then
+ log_report "> Found parameters $PASSED"
+ log_report ">> Number of parameters found : $PARAM_COUNT\n"
+ else
+ if [[ -z $PARAM_NAME ]]; then
+ log_report "> No parameter's name found $WARNING"
+ fi
+ if [[ -z $PARAM_DESC ]]; then
+ log_report "> No parameter's description found $WARNING"
+ fi
+ if [[ -z $PARAM_TYPE ]]; then
+ log_report "> No parameter's type found $WARNING"
+ fi
+ if [[ -z $PARAM_VALUE ]]; then
+ log_report "> No parameter's value found $WARNING"
+ fi
+ fi
+ log_report "\n Commands section :\n"
+ if [[ ! -z $CMD_NAME ]] && [[ ! -z $CMD_DESC ]]; then
+ log_report "> Found commands $PASSED"
+ log_report ">> Number of commands found : $PARAM_COUNT\n"
+ else
+ log_report "Number of commands found : $CMD_COUNT\n"
+ if [[ -z $CMD_NAME ]]; then
+ log_report "> No command's name found $WARNING"
+ fi
+ if [[ -z $CMD_DESC ]]; then
+ log_report "> No command's description found $WARNING"
+ fi
+ fi
+}
+
detect_po () {
for i in `find $DIR/resources/*.po`; do
FILE=`echo ${i%%.po} |sed 's/^.*\///g'`
- printf "$FILE "
+ log_report "$FILE "
done
}
detect_help () {
for i in `find $DIR/resources/help_*.html`; do
FILE=`echo ${i%%.html} |sed 's/^.*\///g' |sed 's/help_//g'`
- printf "$FILE "
+ log_report "$FILE "
done
}
#### Start of the script
#>>> Header
+echo
"--------------------------------------------------------------------------------"
echo "TuxDroid gadgets compiler"
echo
"--------------------------------------------------------------------------------"
#<<< Check if the path is correct >>>
DIR=$1
-if [ ! -d $DIR ]; then
+if [[ -z $1 ]] || [ ! -d $DIR ]; then
echo "Couldn't find the folder to pack"
echo "Please specify the complete path to the folder"
- exit 0
+ exit 1
fi
#<<< Check the file architecture integrity >>>
printf "Verifying the architecture integrity"
@@ -118,53 +165,43 @@
#<<< Verify the files >>>
# gadget.xml
-echo "Verifying the files"
+log_report "Informations on gadget.xml\n"
if [ ! -e $DIR/resources/gadget.xml ]; then
- printf "> gadget.xml $NOTFOUND"
+ printf "> gadget.xml not found $NOTFOUND"
exit 1
else
- INT=`grep "kind" $DIR/resources/gadget.xml | sed 's/kind=//g' |sed
's/>//g' |sed 's/\"//g'`
- case $INT in
- *java*) EXT="jar" ;;
- *python*) EXT="py" ;;
- perl) EXT="pl" ;;
- ruby) EXT="rb" ;;
- bash) EXT="sh" ;;
- *) echo $INT
- esac
- printf "> gadget.xml $DETECTED"
+ log_report "> gadget.xml found $PASSED"
fi
# icon
ICN=`grep "iconFile" $DIR/resources/gadget.xml |cut -f 2 -d ">" |cut -f 1 -d
"<"`
if [ ! -e "$DIR/$ICN" ]; then
- printf "> no icon file found $WARNING"
+ log_report "> no icon file found $WARNING"
else
- printf "> icon file found $DETECTED"
+ log_report "> icon file found $PASSED"
fi
# translation files
if [ ! -e $DIR/resources/gadget.pot ]; then
- printf "> no translation file found $WARNING"
+ log_report "> no translation file found $WARNING"
else
- printf "> translation file found $DETECTED"
- printf ">> extra languages : "
+ log_report "> translation file found $PASSED"
+ log_report ">> extra languages : "
detect_po
- printf "\n"
+ log_report "\n"
fi
# help files
if [ ! -e $DIR/resources/help.html ]; then
- printf "> no help file found $WARNING"
+ log_report "> no help file found $WARNING"
else
- printf "> help file found $DETECTED"
- printf ">> extra languages : "
+ log_report "> help file found $PASSED"
+ log_report ">> extra languages : "
detect_help
- printf "\n"
+ log_report "\n"
fi
echo ""
# <<< Parse the XML file >>>
-echo "Retrieving informations from gadget.xml"
DESC=False
PARAM=False
COM=False
@@ -200,13 +237,16 @@
COM=True
fi
done < $DIR/resources/gadget.xml
+verify_xml
# <<< Creating the TGF file >>>
-echo ""
-printf "Creating TGF file"
-NAME=`echo $NAME |sed 's/ /_/g'`
+NAME=`echo $DESC_NAME |sed 's/ /_/g'`
+if [[ -z $NAME ]]; then
+ NAME=tuxdroid-gadget
+fi
cd $DIR
zip -r -q $NAME.zip *
-cd -
+cd - >/dev/null
mv $DIR/$NAME.zip ./$NAME.tgf
-printf "$PASSED"
+printf "$LOG"
+exit 0
------------------------------------------------------------------------------
SF.Net email is Sponsored by MIX09, March 18-20, 2009 in Las Vegas, Nevada.
The future of the web can't happen without you. Join us at MIX09 to help
pave the way to the Next Web now. Learn more and register at
http://ad.doubleclick.net/clk;208669438;13503038;i?http://2009.visitmix.com/
_______________________________________________
Tux-droid-svn mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tux-droid-svn