-
Notifications
You must be signed in to change notification settings - Fork 4
/
app.mk
181 lines (157 loc) · 6.63 KB
/
app.mk
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
# SPDX-FileCopyrightText: 2020 Jellyfin Project https://github.com/jellyfin/jellyfin-roku
# SPDX-FileCopyrightText: 2020 Tod Fitch <tod@fitchfamily.org>
#
# SPDX-License-Identifier: GPL-2.0-only
#########################################################################
# common include file for application Makefiles
#
# Makefile Common Usage:
# > make
# > make install
# > make remove
#
# By default, ZIP_EXCLUDE will exclude -x \*.pkg -x storeassets\* -x keys\* -x .\*
# If you define ZIP_EXCLUDE in your Makefile, it will override the default setting.
#
# To exclude different files from being added to the zipfile during packaging
# include a line like this:ZIP_EXCLUDE= -x keys\*
# that will exclude any file who's name begins with 'keys'
# to exclude using more than one pattern use additional '-x <pattern>' arguments
# ZIP_EXCLUDE= -x \*.pkg -x storeassets\*
#
# Important Notes:
# To use the "install" and "remove" targets to install your
# application directly from the shell, you must do the following:
#
# 1) Make sure that you have the curl command line executable in your path
# 2) Set the variable ROKU_DEV_TARGET in your environment to the IP
# address of your Roku box. (e.g. export ROKU_DEV_TARGET=192.168.1.1.
# Set in your this variable in your shell startup (e.g. .bashrc)
# 3) Set the variable ROKU_DEV_PASSWORD in your environment for the password
# associated with the rokudev account.
##########################################################################
DISTREL = $(shell pwd)/out
COMMONREL ?= $(shell pwd)/common
SOURCEREL = $(shell pwd)
ZIPREL = $(DISTREL)/apps
STAGINGREL = $(DISTREL)/staging
PKGREL = $(DISTREL)/packages
APPSOURCEDIR = source
IMPORTFILES = $(foreach f,$(IMPORTS),$(COMMONREL)/$f.brs)
IMPORTCLEANUP = $(foreach f,$(IMPORTS),$(APPSOURCEDIR)/$f.brs)
GITCOMMIT = $(shell git rev-parse --short HEAD)
BUILDDATE = $(shell date -u | awk '{ print $$2,$$3,$$6,$$4 }')
BUILD_NUMBER_FILE=build-number.txt
ifdef ROKU_DEV_PASSWORD
USERPASS = rokudev:$(ROKU_DEV_PASSWORD)
else
USERPASS = rokudev
endif
ifndef ZIP_EXCLUDE
ZIP_EXCLUDE= -x \*.pkg -x storeassets\* -x keys\* -x \*/.\*
endif
HTTPSTATUS = $(shell curl --silent --write-out "\n%{http_code}\n" $(ROKU_DEV_TARGET))
ifeq "$(HTTPSTATUS)" " 401"
CURLCMD = curl -S --connect-timeout 2 --max-time 30 --retry 5
else
CURLCMD = curl -S --connect-timeout 2 --max-time 30 --retry 5 --user $(USERPASS) --digest
endif
home:
@echo "Forcing roku to main menu screen $(ROKU_DEV_TARGET)..."
curl -s -S -d '' http://$(ROKU_DEV_TARGET):8060/keypress/home
sleep 2
prep_staging:
@echo "*** Preparing Staging Area ***"
@echo " >> removing old application zip $(ZIPREL)/$(APPNAME).zip"
@if [ -e "$(ZIPREL)/$(APPNAME).zip" ]; \
then \
rm $(ZIPREL)/$(APPNAME).zip; \
fi
@echo " >> creating destination directory $(ZIPREL)"
@if [ ! -d $(ZIPREL) ]; \
then \
mkdir -p $(ZIPREL); \
fi
@echo " >> setting directory permissions for $(ZIPREL)"
@if [ ! -w $(ZIPREL) ]; \
then \
chmod 755 $(ZIPREL); \
fi
@echo " >> creating destination directory $(STAGINGREL)"
@if [ -d $(STAGINGREL) ]; \
then \
find $(STAGINGREL) -delete; \
fi; \
mkdir -p $(STAGINGREL); \
chmod -R 755 $(STAGINGREL); \
echo " >> moving application to $(STAGINGREL)"
cp -r $(SOURCEREL)/source $(STAGINGREL)
cp -r $(SOURCEREL)/components $(STAGINGREL)
cp -r $(SOURCEREL)/images $(STAGINGREL)
cp -r $(SOURCEREL)/resources $(STAGINGREL)
cp -r $(SOURCEREL)/locale $(STAGINGREL)
cp -r $(SOURCEREL)/fonts $(STAGINGREL)
cp $(SOURCEREL)/manifest $(STAGINGREL)/manifest
package: prep_staging
@echo "*** Creating $(APPNAME).zip ***"
@echo " >> copying imports"
@if [ "$(IMPORTFILES)" ]; \
then \
mkdir $(APPSOURCEDIR)/common; \
cp -f -p -v $(IMPORTFILES) $(APPSOURCEDIR)/common/; \
fi \
@echo " >> bumping build number"
@if ! test -f $(BUILD_NUMBER_FILE); then echo 0 > $(BUILD_NUMBER_FILE); fi
@echo $$(($$(cat $(BUILD_NUMBER_FILE)) + 1)) > $(BUILD_NUMBER_FILE)
echo "build_version=$$(cat $(BUILD_NUMBER_FILE))" >> $(STAGINGREL)/manifest
@echo " >> generating build info file"
mkdir -p $(STAGINGREL)/$(APPSOURCEDIR)
@if [ -e "$(STAGINGREL)/$(APPSOURCEDIR)/buildinfo.brs" ]; \
then \
rm $(STAGINGREL)/$(APPSOURCEDIR)/buildinfo.brs; \
fi
echo " >> generating build info file";\
echo "Function BuildDate()" >> $(STAGINGREL)/$(APPSOURCEDIR)/buildinfo.brs
echo " return \"${BUILDDATE}\"" >> $(STAGINGREL)/$(APPSOURCEDIR)/buildinfo.brs
echo "End Function" >> $(STAGINGREL)/$(APPSOURCEDIR)/buildinfo.brs
echo "Function BuildCommit()" >> $(STAGINGREL)/$(APPSOURCEDIR)/buildinfo.brs
echo " return \"${GITCOMMIT}\"" >> $(STAGINGREL)/$(APPSOURCEDIR)/buildinfo.brs
echo "End Function" >> $(STAGINGREL)/$(APPSOURCEDIR)/buildinfo.brs
# zip .png files without compression
# do not zip up any files ending with '~'
@echo " >> creating application zip $(STAGINGREL)/../apps/$(APPNAME).zip"
@if [ -d $(STAGINGREL) ]; \
then \
cd $(STAGINGREL); \
(zip -0 -r "../apps/$(APPNAME).zip" . -i \*.png $(ZIP_EXCLUDE)); \
(zip -9 -r "../apps/$(APPNAME).zip" . -x \*~ -x \*.png $(ZIP_EXCLUDE)); \
cd $(SOURCEREL);\
else \
echo "Source for $(APPNAME) not found at $(STAGINGREL)"; \
fi
@if [ "$(IMPORTCLEANUP)" ]; \
then \
echo " >> deleting imports";\
rm -r -f $(APPSOURCEDIR)/common; \
fi \
@echo "*** packaging $(APPNAME) complete ***"
prep_tests:
@mkdir -p $(STAGINGREL)/components/tests/; \
mkdir -p $(STAGINGREL)/source/tests/; \
cp -r $(SOURCEREL)/tests/components/* $(STAGINGREL)/components/tests/;\
cp -r $(SOURCEREL)/tests/source/* $(STAGINGREL)/source/tests/;\
./node_modules/.bin/rooibos-cli i tests/.rooibosrc.json
install: prep_staging package home
@echo "Installing $(APPNAME) to host $(ROKU_DEV_TARGET)"
@$(CURLCMD) --user $(USERPASS) --digest -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>[["
remove:
@echo "Removing $(APPNAME) from host $(ROKU_DEV_TARGET)"
@if [ "$(HTTPSTATUS)" == " 401" ]; \
then \
$(CURLCMD) --user $(USERPASS) --digest -F "mysubmit=Delete" -F "archive=" -F "passwd=" http://$(ROKU_DEV_TARGET)/plugin_install | grep "<font color" | sed "s/<font color=\"red\">//" | sed "s[</font>[[" ; \
else \
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>[[" ; \
fi
screenshot:
SCREENSHOT_TIME=`date "+%s"`; \
curl -m 1 -o screenshot.jpg --user $(USERPASS) --digest "http://$(ROKU_DEV_TARGET)/pkgs/dev.jpg?time=$$SCREENSHOT_TIME" -H 'Accept: image/png,image/*;q=0.8,*/*;q=0.5' -H 'Accept-Language: en-US,en;q=0.5' -H 'Accept-Encoding: gzip, deflate'