-
Notifications
You must be signed in to change notification settings - Fork 11
/
Makefile
93 lines (79 loc) · 3.07 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
APPNAME = roku-libs
DEVICEIP ?= 192.168.1.2
VERSION ?= 0.18.0
ROKU ?= rokudev
ROKUPASS ?= password
ZIPEXCLUDE = -x \*.pkg -x keys\* -x LICENSE\* -x \*.md -x \*/.\* -x .\* -x build\* -x package\*
PKGREL = ./package
ZIPREL = ./build
SOURCEREL = ..
.PHONY: zip install remove tests package
zip:
# Remove old application zip
@if [ -e "$(ZIPREL)/$(APPNAME).zip" ]; \
then \
rm $(ZIPREL)/$(APPNAME).zip; \
fi
# Create destination directory
@if [ ! -d $(ZIPREL) ]; \
then \
mkdir -p $(ZIPREL); \
fi
# Set directory permissions
@if [ ! -w $(ZIPREL) ]; \
then \
chmod 755 $(ZIPREL); \
fi
# Zip .png files without compression do not zip Makefiles or any files ending with '~'
@echo " Creating application zip: $(ZIPREL)/$(APPNAME).zip"
@if [ -d $(SOURCEREL)/$(APPNAME) ]; \
then \
(zip -q -0 -r "$(ZIPREL)/$(APPNAME).zip" . -i \*.png $(ZIPEXCLUDE)); \
(zip -q -9 -r "$(ZIPREL)/$(APPNAME).zip" . -x \*~ -x \*.png -x Makefile $(ZIPEXCLUDE)); \
else \
echo " Source for $(APPNAME) not found at $(SOURCEREL)/$(APPNAME)"; \
fi
install: zip
# Close current app to avoid crashes
@curl -d "" "http://$(DEVICEIP):8060/keypress/home"
@sleep 1
@echo " Installing $(APPNAME).zip to host $(DEVICEIP)"
@curl --user $(ROKU):$(ROKUPASS) --digest -s -S -F "mysubmit=Install" -F "archive=@$(ZIPREL)/$(APPNAME).zip" -F "passwd=" http://$(DEVICEIP)/plugin_install | grep "<font color" | sed "s/<font color=\"red\">//" | sed "s[</font>[[" ; \
remove:
# Close current app to avoid crashes
@curl -d "" "http://$(DEVICEIP):8060/keypress/home"
@sleep 1
@echo " Removing $(APPNAME) from host $(DEVICEIP)"
@curl --user $(ROKU):$(ROKUPASS) --digest -s -S -F "mysubmit=Delete" -F "archive=" -F "passwd=" http://$(DEVICEIP)/plugin_install | grep "<font color" | sed "s/<font color=\"red\">//" | sed "s[</font>[[" ; \
tests: install
@echo " Running tests at $(DEVICEIP):8085"
@curl -d '' "http://${DEVICEIP}:8060/launch/dev?RunTests=true"
package: DEVIDPASS ?= "$(shell read -p " Developer ID password: " REPLY; echo $$REPLY)"
package: install
# Create destination directory
@if [ ! -d $(PKGREL) ]; \
then \
mkdir -p $(PKGREL); \
fi
# Set directory permissions
@if [ ! -w $(PKGREL) ]; \
then \
chmod 755 $(PKGREL); \
fi
# Package application on remote device
@echo " Packaging $(APPNAME) to host $(DEVICEIP)"
$(eval PKGFILE := $(shell curl --anyauth -u $(ROKU):$(ROKUPASS) -s -S -Fmysubmit=Package -Fapp_name=$(APPNAME)/$(VERSION) -Fpasswd=$(DEVIDPASS) -Fpkg_time=`date +%s` "http://$(DEVICEIP)/plugin_package" | grep 'pkgs' | sed 's/.*href=\"\([^\"]*\)\".*/\1/' | sed 's#pkgs//##'))
@if [ -z $(PKGFILE) ]; \
then \
echo " Package creation failed! Check if your device has been rekeyed"; \
exit 1; \
fi
# Dowload package from device
$(eval PKGFULLPATH := $(PKGREL)/$(APPNAME)-$(VERSION)_$(PKGFILE))
@curl --user $(ROKU):$(ROKUPASS) --digest -s -S -o $(PKGFULLPATH) http://$(DEVICEIP)/pkgs/$(PKGFILE)
@if [ ! -f ""$(PKGFULLPATH)"" ]; \
then \
echo " Package download failed! File does not exist: $(PKGFULLPATH)"; \
exit 2; \
fi
@echo " Package downloaded to: $(PKGFULLPATH)"