create-nokia-widget2 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #!/bin/bash
  2. # Create a WRT Widget
  3. # Uses the yuicompressor library to compress the javascript and css files
  4. #
  5. # Usage:
  6. #
  7. # ./create-wrt-widget homedir widget
  8. #
  9. # where homedir is the widget code parent directory
  10. # widget is the complete name of the widget, including path
  11. #
  12. # 2010 (c) Samuel kobelkowsky - yalla ya!
  13. # samuel@yalla-ya.com
  14. HOMEDIR=$1
  15. TARGET=$2
  16. TMPDIR=/tmp/`basename $TARGET.$$`
  17. # Validate arguments
  18. if [ -z "$HOMEDIR" -o -z "$TARGET" -o $# -ne 2 ]
  19. then
  20. echo "Usage: $0 homedir widget"
  21. exit
  22. fi
  23. # Check that homedir exists
  24. if [ ! -d $HOMEDIR ]
  25. then
  26. echo $HOMEDIR "doesn't exist"
  27. exit
  28. fi
  29. # Copy homedir to a temporary directory
  30. mkdir -p $TMPDIR
  31. cp -r $HOMEDIR/ $TMPDIR/`basename $TARGET .wgz`/
  32. # Obfuscate and compress the code using yuicompressor
  33. find $TMPDIR -type f -a \( -name '*.js' -o -name '*.css' \) -exec sh -c "/usr/bin/java -jar /usr/local/yuicompressor-2.4.2/build/yuicompressor-2.4.2.jar -o {}.mini {} ; mv {}.mini {}" \;
  34. # Create the wgz file (filter the .svn files)
  35. cd $TMPDIR
  36. rm -f $TARGET
  37. find . -path '*/.svn' -prune -o -type f -print | zip $TARGET -@ > /dev/null
  38. # Clean the temp dir
  39. cd /tmp
  40. rm -rf $TMPDIR
  41. echo
  42. echo "Built the JavaScript and CSS compressed $TARGET widget"