Advertisement
chren

app.mk

Jul 30th, 2015
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Make 7.04 KB | None | 0 0
  1. #########################################################################
  2. # common include file for application Makefiles
  3. #
  4. # Makefile Common Usage:
  5. # > make
  6. # > make install
  7. # > make remove
  8. #
  9. # Makefile Less Common Usage:
  10. # > make art-opt
  11. # > make pkg
  12. # > make install_native
  13. # > make remove_native
  14. # > make tr
  15. #
  16. # By default, ZIP_EXCLUDE will exclude -x \*.pkg -x storeassets\* -x keys\* -x .\*
  17. # If you define ZIP_EXCLUDE in your Makefile, it will override the default setting.
  18. #
  19. # To exclude different files from being added to the zipfile during packaging
  20. # include a line like this:ZIP_EXCLUDE= -x keys\*
  21. # that will exclude any file who's name begins with 'keys'
  22. # to exclude using more than one pattern use additional '-x <pattern>' arguments
  23. # ZIP_EXCLUDE= -x \*.pkg -x storeassets\*
  24. #
  25. # Important Notes:
  26. # To use the "install" and "remove" targets to install your
  27. # application directly from the shell, you must do the following:
  28. #
  29. # 1) Make sure that you have the curl command line executable in your path
  30. # 2) Set the variable ROKU_DEV_TARGET in your environment to the IP
  31. #    address of your Roku box. (e.g. export ROKU_DEV_TARGET=192.168.1.1.
  32. #    Set in your this variable in your shell startup (e.g. .bashrc)
  33. ##########################################################################  
  34. DISTREL = ..
  35. COMMONREL = ../common
  36. SOURCEREL = ..
  37. DEVPASSWORD = rokudev
  38.  
  39. ZIPREL = $(DISTREL)/apps
  40. PKGREL = $(DISTREL)/packages
  41.  
  42. APPSOURCEDIR = source
  43. IMPORTFILES = $(foreach f,$(IMPORTS),$(COMMONREL)/$f.brs)
  44. IMPORTCLEANUP = $(foreach f,$(IMPORTS),$(APPSOURCEDIR)/$f.brs)
  45.  
  46. NATIVEDEVREL  = $(DISTREL)/rootfs/Linux86_dev.OBJ/root/nvram/incoming
  47. NATIVEDEVPKG  = $(NATIVEDEVREL)/dev.zip
  48. NATIVETICKLER = $(DISTREL)/application/Linux86_dev.OBJ/root/bin/plethora  tickle-plugin-installer
  49.  
  50. ifdef DEVPASSWORD
  51.     USERPASS = rokudev:$(DEVPASSWORD)
  52. else
  53.     USERPASS = rokudev
  54. endif
  55.  
  56. ifndef ZIP_EXCLUDE
  57.   ZIP_EXCLUDE= -x \*.pkg -x storeassets\* -x keys\* -x \*/.\*
  58. endif
  59.  
  60. HTTPSTATUS = $(shell curl --silent --write-out "\n%{http_code}\n" $(ROKU_DEV_TARGET))
  61.  
  62. .PHONY: all $(APPNAME)
  63.  
  64. $(APPNAME): manifest
  65.     @echo "*** Creating $(APPNAME).zip ***"
  66.  
  67.     @echo "  >> removing old application zip $(ZIPREL)/$(APPNAME).zip"
  68.     @if [ -e "$(ZIPREL)/$(APPNAME).zip" ]; \
  69.     then \
  70.         rm  $(ZIPREL)/$(APPNAME).zip; \
  71.     fi
  72.  
  73.     @echo "  >> creating destination directory $(ZIPREL)"  
  74.     @if [ ! -d $(ZIPREL) ]; \
  75.     then \
  76.         mkdir -p $(ZIPREL); \
  77.     fi
  78.  
  79.     @echo "  >> setting directory permissions for $(ZIPREL)"
  80.     @if [ ! -w $(ZIPREL) ]; \
  81.     then \
  82.         chmod 755 $(ZIPREL); \
  83.     fi
  84.  
  85.     @echo "  >> copying imports"
  86.     @if [ "$(IMPORTFILES)" ]; \
  87.     then \
  88.         mkdir $(APPSOURCEDIR)/common; \
  89.         cp -f --preserve=ownership,timestamps --no-preserve=mode -v $(IMPORTFILES) $(APPSOURCEDIR)/common/; \
  90.     fi \
  91.  
  92. # zip .png files without compression
  93. # do not zip up Makefiles, or any files ending with '~'
  94.     @echo "  >> creating application zip $(ZIPREL)/$(APPNAME).zip" 
  95.     @if [ -d $(SOURCEREL)/$(APPNAME) ]; \
  96.     then \
  97.         (zip -0 -r "$(ZIPREL)/$(APPNAME).zip" . -i \*.png $(ZIP_EXCLUDE)); \
  98.         (zip -9 -r "$(ZIPREL)/$(APPNAME).zip" . -x \*~ -x \*.png -x Makefile $(ZIP_EXCLUDE)); \
  99.     else \
  100.         echo "Source for $(APPNAME) not found at $(SOURCEREL)/$(APPNAME)"; \
  101.     fi
  102.  
  103.     @if [ "$(IMPORTCLEANUP)" ]; \
  104.     then \
  105.         echo "  >> deleting imports";\
  106.         rm -r -f $(APPSOURCEDIR)/common; \
  107.     fi \
  108.  
  109.     @echo "*** packaging $(APPNAME) complete ***"
  110.  
  111. #if DISTDIR is not empty then copy the zip package to the DISTDIR.
  112.     @if [ $(DISTDIR) ];\
  113.     then \
  114.         rm -f $(DISTDIR)/$(DISTZIP).zip; \
  115.         mkdir -p $(DISTDIR); \
  116.         cp -f --preserve=ownership,timestamps --no-preserve=mode $(ZIPREL)/$(APPNAME).zip $(DISTDIR)/$(DISTZIP).zip; \
  117.     fi \
  118.  
  119. install: $(APPNAME)
  120.     @echo "Installing $(APPNAME) to host $(ROKU_DEV_TARGET)"
  121.     @if [ "$(HTTPSTATUS)" = " 401" ]; \
  122.     then \
  123.         curl --user $(USERPASS) --digest -s -S -F "mysubmit=Install" -F "archive=@$(ZIPREL)/$(APPNAME).zip" -F "passwd=" http://$(ROKU_DEV_TARGET)/plugin_install | grep "<font color" | sed "s/<font color=\"red\">//" | sed "s[</font>[[" ; \
  124.     else \
  125.         curl -s -S -F "mysubmit=Install" -F "archive=@$(ZIPREL)/$(APPNAME).zip" -F "passwd=" http://$(ROKU_DEV_TARGET)/plugin_install | grep "<font color" | sed "s/<font color=\"red\">//" | sed "s[</font>[[" ; \
  126.     fi
  127.  
  128.  
  129. pkg: install
  130.     @echo "*** Creating Package ***"
  131.  
  132.     @echo "  >> creating destination directory $(PKGREL)"  
  133.     @if [ ! -d $(PKGREL) ]; \
  134.     then \
  135.         mkdir -p $(PKGREL); \
  136.     fi
  137.  
  138.     @echo "  >> setting directory permissions for $(PKGREL)"
  139.     @if [ ! -w $(PKGREL) ]; \
  140.     then \
  141.         chmod 755 $(PKGREL); \
  142.     fi
  143.  
  144.     @echo "Packaging  $(APPSRC)/$(APPNAME) on host $(ROKU_DEV_TARGET)"
  145.     @if [ "$(HTTPSTATUS)" == " 401" ]; \
  146.     then \
  147.         read -p "Password: " REPLY ; echo $$REPLY | xargs -i curl --user $(USERPASS) --digest -s -S -Fmysubmit=Package -Fapp_name=$(APPNAME)/$(VERSION) -Fpasswd={} -Fpkg_time=`expr \`date +%s\` \* 1000` "http://$(ROKU_DEV_TARGET)/plugin_package" | grep '^<tr><td><font face="Courier"><a' | sed 's/.*href=\"\([^\"]*\)\".*/\1/' | sed 's#pkgs//##' | xargs -i curl --user $(USERPASS) --digest -s -S -o $(PKGREL)/$(APPNAME)_`date +%F-%T`.pkg http://$(ROKU_DEV_TARGET)/pkgs/{} ; \
  148.     else \
  149.         read -p "Password: " REPLY ; echo $$REPLY | xargs -i curl -s -S -Fmysubmit=Package -Fapp_name=$(APPNAME)/$(VERSION) -Fpasswd={} -Fpkg_time=`expr \`date +%s\` \* 1000` "http://$(ROKU_DEV_TARGET)/plugin_package" | grep '^<tr><td><font face="Courier"><a' | sed 's/.*href=\"\([^\"]*\)\".*/\1/' | sed 's#pkgs//##' | xargs -i curl -s -S -o $(PKGREL)/$(APPNAME)_`date +%F-%T`.pkg http://$(ROKU_DEV_TARGET)/pkgs/{} ; \
  150.     fi
  151.  
  152.     @echo "*** Package  $(APPNAME) complete ***"
  153.  
  154. remove:
  155.     @echo "Removing $(APPNAME) from host $(ROKU_DEV_TARGET)"
  156.     @if [ "$(HTTPSTATUS)" == " 401" ]; \
  157.     then \
  158.         curl --user $(USERPASS) --digest -s -S -F "mysubmit=Delete" -F "archive=" -F "passwd=" http://$(ROKU_DEV_TARGET)/plugin_install | grep "<font color" | sed "s/<font color=\"red\">//" | sed "s[</font>[[" ; \
  159.     else \
  160.         curl -s -S -F "mysubmit=Delete" -F "archive=" -F "passwd=" http://$(ROKU_DEV_TARGET)/plugin_install | grep "<font color" | sed "s/<font color=\"red\">//" | sed "s[</font>[[" ; \
  161.     fi
  162.  
  163. install_native: $(APPNAME)
  164.     @echo "Installing $(APPNAME) to native."
  165.     @mkdir -p $(NATIVEDEVREL)
  166.     @cp $(ZIPREL)/$(APPNAME).zip  $(NATIVEDEVPKG)
  167.     @$(NATIVETICKLER)
  168.  
  169. remove_native:
  170.     @echo "Removing $(APPNAME) from native."
  171.     @rm $(NATIVEDEVPKG)
  172.     @$(NATIVETICKLER)
  173.  
  174. APPS_JPG_ART=`\find . -name "*.jpg"`
  175.  
  176. art-jpg-opt:
  177.     p4 edit $(APPS_JPG_ART)
  178.     for i in $(APPS_JPG_ART); \
  179.     do \
  180.         TMPJ=`mktemp` || return 1; \
  181.         echo "optimizing $$i"; \
  182.         (jpegtran -copy none -optimize -outfile $$TMPJ $$i && mv -f $$TMPJ $$i &); \
  183.     done
  184.     wait
  185.     p4 revert -a $(APPS_JPG_ART)
  186.  
  187. APPS_PNG_ART=`\find . -name "*.png"`
  188.  
  189. art-png-opt:
  190.     p4 edit $(APPS_PNG_ART)
  191.     for i in $(APPS_PNG_ART); \
  192.     do \
  193.         (optipng -o7 $$i &); \
  194.     done
  195.     wait
  196.     p4 revert -a $(APPS_PNG_ART)
  197.  
  198. art-opt: art-png-opt art-jpg-opt
  199.  
  200. tr:
  201.     p4 edit locale/.../translations.xml
  202.     ../../rdk/rokudev/utilities/linux/bin/maketr
  203.     rm locale/en_US/translations.xml
  204.     p4 revert -a locale/.../translations.xml
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement