make: revamp
* rewrite it in a single, more standard makefile * forward most commands to npm * support parallel use * get rid of load-time auth check and trust user * rework targets * `prep_commit` -> `format`, `lint` * `dev`, `beta`, `release` -> `build-dev`, `build-prod`, `build-tests` * `prep_staging`, `package`: rm * update devguide accordingly Fixes: #1401
This commit is contained in:
parent
92dc3b8acb
commit
377827c8d9
132
Makefile
132
Makefile
|
@ -1,28 +1,120 @@
|
|||
|
||||
#########################################################################
|
||||
# Makefile Usage:
|
||||
#
|
||||
# 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) and set up the ROKU_DEV_PASSWORD environment variable, too
|
||||
##########################################################################
|
||||
# Need curl and npm in your $PATH
|
||||
# If you want to get_images, you'll also need convert from ImageMagick
|
||||
##########################################################################
|
||||
|
||||
APPNAME = Jellyfin_Roku
|
||||
VERSION = 1.6.6
|
||||
VERSION := 1.6.6
|
||||
|
||||
ZIP_EXCLUDE= -x xml/* -x artwork/* -x \*.pkg -x storeassets\* -x keys\* -x \*/.\* -x *.git* -x *.DS* -x *.pkg* -x dist/**\* -x out/**\*
|
||||
## usage
|
||||
|
||||
include app.mk
|
||||
.PHONY: help
|
||||
help:
|
||||
@echo "targets"
|
||||
@echo " build-dev build development package"
|
||||
@echo " build-prod build production package"
|
||||
@echo " build-tests build tests package"
|
||||
@echo " format format brighscripts"
|
||||
@echo " lint lint code and documentation"
|
||||
@echo " get_images update official jellyfin images"
|
||||
@echo "targets needing ROKU_DEV_TARGET"
|
||||
@echo " home press the home button on device"
|
||||
@echo " launch launch installed"
|
||||
@echo "targets needing ROKU_DEV_TARGET and ROKU_DEV_PASSWORD"
|
||||
@echo " install install on device"
|
||||
@echo " remove remove installed from device"
|
||||
@echo " screenshot take a screenshot"
|
||||
@echo " deploy lint, remove, install"
|
||||
@echo "environment"
|
||||
@echo " ROKU_DEV_TARGET with device's IP"
|
||||
@echo " ROKU_DEV_PASSWORD with device's password"
|
||||
|
||||
dev:
|
||||
$(MAKE) BUILD='dev' package
|
||||
## development
|
||||
|
||||
beta:
|
||||
$(MAKE) BUILD='beta' package
|
||||
BUILT_PKG := out/$(notdir $(CURDIR)).zip
|
||||
|
||||
release:
|
||||
$(MAKE) BUILD='release' package
|
||||
node_modules/: package-lock.json; npm ci
|
||||
|
||||
deploy: prep_staging remove install
|
||||
.PHONY: build-dev build-prod build-tests
|
||||
.NOTPARALLEL: build-dev build-prod build-tests # output to the same file
|
||||
build-dev: node_modules/; npm run build
|
||||
build-prod: node_modules/; npm run build-prod
|
||||
build-tests: node_modules/; npm run build-tests
|
||||
|
||||
# default to build-dev if file doesn't exist
|
||||
$(BUILT_PKG):; $(MAKE) build-dev
|
||||
|
||||
.PHONY: format
|
||||
format: node_modules/; npm run format
|
||||
|
||||
.PHONY: lint
|
||||
lint: node_modules/
|
||||
npm run check-formatting
|
||||
npm run lint
|
||||
npm run lint-json
|
||||
npm run lint-markdown
|
||||
npm run lint-spelling
|
||||
npm run validate
|
||||
|
||||
## roku box
|
||||
|
||||
CURL_CMD ?= curl --show-error
|
||||
|
||||
ifdef ROKU_DEV_TARGET
|
||||
|
||||
.PHONY: home launch
|
||||
home:
|
||||
$(CURL_CMD) -XPOST http://$(ROKU_DEV_TARGET):8060/keypress/home
|
||||
sleep 2 # wait for device reaction
|
||||
launch:
|
||||
$(CURL_CMD) -XPOST http://$(ROKU_DEV_TARGET):8060/launch/dev
|
||||
|
||||
ifdef ROKU_DEV_PASSWORD
|
||||
|
||||
CURL_LOGGED_CMD := $(CURL_CMD) --user rokudev:$(ROKU_DEV_PASSWORD) --digest
|
||||
|
||||
EXTRACT_ERROR_CMD := grep "<font color" | sed "s/<font color=\"red\">//" | sed "s[</font>[["
|
||||
.PHONY: install remove
|
||||
install: $(BUILT_PKG) home
|
||||
$(CURL_LOGGED_CMD) -F "mysubmit=Install" -F "archive=@$<" -F "passwd=" http://$(ROKU_DEV_TARGET)/plugin_install | $(EXTRACT_ERROR_CMD)
|
||||
$(MAKE) launch
|
||||
remove:
|
||||
$(CURL_LOGGED_CMD) -F "mysubmit=Delete" -F "archive=" -F "passwd=" http://$(ROKU_DEV_TARGET)/plugin_install | $(EXTRACT_ERROR_CMD)
|
||||
|
||||
.PHONY: screenshot
|
||||
screenshot:
|
||||
$(CURL_LOGGED_CMD) -o screenshot.jpg "http://$(ROKU_DEV_TARGET)/pkgs/dev.jpg"
|
||||
|
||||
.PHONY: deploy
|
||||
.NOTPARALLEL: deploy
|
||||
deploy: lint remove install
|
||||
|
||||
endif # ROKU_DEV_PASSWORD
|
||||
|
||||
endif # ROKU_DEV_TARGET
|
||||
|
||||
## sync branding
|
||||
|
||||
CONVERT_CMD ?= convert -gravity center
|
||||
CONVERT_BLUEBG_CMD := $(CONVERT_CMD) -background "\#000b25"
|
||||
BANNER := images/banner-dark.svg
|
||||
ICON := images/icon-transparent.svg
|
||||
|
||||
images/:; mkdir $@
|
||||
|
||||
.PHONY: redo # force rerun
|
||||
$(BANNER) $(ICON): images/ redo
|
||||
$(CURL_CMD) https://raw.githubusercontent.com/jellyfin/jellyfin-ux/master/branding/SVG/$(@F) > $@
|
||||
|
||||
images/logo.png: $(BANNER); $(CONVERT_CMD) -background none -scale 1000x48 -extent 180x48 $< $@
|
||||
images/channel-poster_fhd.png: $(BANNER); $(CONVERT_BLUEBG_CMD) -scale 535x400 -extent 540x405 $< $@
|
||||
images/channel-poster_hd.png: $(BANNER); $(CONVERT_BLUEBG_CMD) -scale 275x205 -extent 336x210 $< $@
|
||||
images/channel-poster_sd.png: $(BANNER); $(CONVERT_BLUEBG_CMD) -scale 182x135 -extent 246x140 $< $@
|
||||
images/splash-screen_fhd.jpg: $(BANNER); $(CONVERT_BLUEBG_CMD) -scale 540x540 -extent 1920x1080 $< $@
|
||||
images/splash-screen_hd.jpg: $(BANNER); $(CONVERT_BLUEBG_CMD) -scale 360x360 -extent 1280x720 $< $@
|
||||
images/splash-screen_sd.jpg: $(BANNER); $(CONVERT_BLUEBG_CMD) -scale 240x240 -extent 720x480 $< $@
|
||||
|
||||
.PHONY: get_images
|
||||
get_images: $(ICON)
|
||||
get_images: images/logo.png
|
||||
get_images: images/channel-poster_fhd.png images/channel-poster_hd.png images/channel-poster_sd.png
|
||||
get_images: images/splash-screen_fhd.jpg images/splash-screen_hd.jpg images/splash-screen_sd.jpg
|
||||
|
|
215
app.mk
215
app.mk
|
@ -1,215 +0,0 @@
|
|||
#########################################################################
|
||||
# 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.
|
||||
##########################################################################
|
||||
|
||||
BUILD = dev
|
||||
|
||||
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 }')
|
||||
|
||||
BRANDING_ROOT = https://raw.githubusercontent.com/jellyfin/jellyfin-ux/master/branding/SVG
|
||||
ICON_SOURCE = icon-transparent.svg
|
||||
BANNER_SOURCE = banner-dark.svg
|
||||
OUTPUT_DIR = ./images
|
||||
|
||||
# Locales supported by Roku
|
||||
SUPPORTED_LOCALES = en_US en_GB fr_CA es_ES de_DE it_IT pt_BR
|
||||
|
||||
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 --tcp-fastopen --connect-timeout 2 --max-time 30 --retry 5
|
||||
else
|
||||
CURLCMD = curl -S --tcp-fastopen --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 $(SOURCEREL)/manifest $(STAGINGREL)/manifest
|
||||
cp -r $(SOURCEREL)/source $(STAGINGREL)
|
||||
cp -r $(SOURCEREL)/components $(STAGINGREL)
|
||||
cp -r $(SOURCEREL)/images $(STAGINGREL)
|
||||
cp -r $(SOURCEREL)/settings $(STAGINGREL)
|
||||
|
||||
# Copy only supported languages over to staging
|
||||
mkdir $(STAGINGREL)/locale
|
||||
cp -r $(foreach f,$(SUPPORTED_LOCALES),$(SOURCEREL)/locale/$f) $(STAGINGREL)/locale
|
||||
|
||||
ifneq ($(BUILD), dev)
|
||||
echo "COPYING $(BUILD)"
|
||||
cp $(SOURCEREL)/resources/branding/$(BUILD)/* $(STAGINGREL)/images
|
||||
endif
|
||||
|
||||
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 " >> 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)-$(BUILD).zip"
|
||||
@if [ -d $(STAGINGREL) ]; \
|
||||
then \
|
||||
cd $(STAGINGREL); \
|
||||
(zip -0 -r "../apps/$(APPNAME)-$(BUILD).zip" . -i \*.png $(ZIP_EXCLUDE)); \
|
||||
(zip -9 -r "../apps/$(APPNAME)-$(BUILD).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)-$(BUILD) complete ***"
|
||||
|
||||
prep_commit:
|
||||
npm run format
|
||||
npm ci
|
||||
npm run validate
|
||||
npm run check-formatting
|
||||
|
||||
install: prep_staging package home
|
||||
@echo "Installing $(APPNAME)-$(BUILD) to host $(ROKU_DEV_TARGET)"
|
||||
@$(CURLCMD) --user $(USERPASS) --digest -F "mysubmit=Install" -F "archive=@$(ZIPREL)/$(APPNAME)-$(BUILD).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
|
||||
|
||||
get_images:
|
||||
@if [ ! -d $(OUTPUT_DIR) ]; \
|
||||
then \
|
||||
mkdir -p $(OUTPUT_DIR); \
|
||||
echo "Creating images folder"; \
|
||||
fi
|
||||
|
||||
echo "Downloading SVG source files from $(BRANDING_ROOT)"
|
||||
@wget $(BRANDING_ROOT)/$(ICON_SOURCE) > /dev/null
|
||||
@wget $(BRANDING_ROOT)/$(BANNER_SOURCE) > /dev/null
|
||||
echo "Finished downloading SVG files"
|
||||
|
||||
echo "Creating image files"
|
||||
@convert -background "#000b25" -gravity center -scale 535x400 -extent 540x405 $(BANNER_SOURCE) $(OUTPUT_DIR)/channel-poster_fhd.png
|
||||
@convert -background "#000b25" -gravity center -scale 275x205 -extent 336x210 $(BANNER_SOURCE) $(OUTPUT_DIR)/channel-poster_hd.png
|
||||
@convert -background "#000b25" -gravity center -scale 182x135 -extent 246x140 $(BANNER_SOURCE) $(OUTPUT_DIR)/channel-poster_sd.png
|
||||
|
||||
@convert -background none -gravity center -scale 1000x48 -extent 180x48 $(BANNER_SOURCE) $(OUTPUT_DIR)/logo.png
|
||||
|
||||
@convert -background "#000b25" -gravity center -scale 540x540 -extent 1920x1080 $(BANNER_SOURCE) $(OUTPUT_DIR)/splash-screen_fhd.jpg
|
||||
@convert -background "#000b25" -gravity center -scale 360x360 -extent 1280x720 $(BANNER_SOURCE) $(OUTPUT_DIR)/splash-screen_hd.jpg
|
||||
@convert -background "#000b25" -gravity center -scale 240x240 -extent 720x480 $(BANNER_SOURCE) $(OUTPUT_DIR)/splash-screen_sd.jpg
|
||||
echo "Finished creating image files"
|
||||
|
||||
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'
|
||||
|
||||
|
||||
|
||||
|
|
@ -46,6 +46,7 @@ cd jellyfin-roku
|
|||
Install Dependencies:
|
||||
|
||||
```bash
|
||||
sudo apt-get install npm
|
||||
npm install
|
||||
```
|
||||
|
||||
|
@ -86,16 +87,16 @@ Example:
|
|||
Install Necessary Packages
|
||||
|
||||
```bash
|
||||
sudo apt-get install wget make zip
|
||||
sudo apt-get install make
|
||||
```
|
||||
|
||||
Build the package
|
||||
|
||||
```bash
|
||||
make dev
|
||||
make build-dev
|
||||
```
|
||||
|
||||
This will create a zip in `out/apps/Jellyfin_Roku-dev.zip`. Login to your Roku's device in your browser and upload the zip file then run install.
|
||||
This will create a zip in `out/jellyfin-roku.zip`. Login to your Roku's device in your browser and upload the zip file then run install.
|
||||
|
||||
## Method 3: Direct load to Roku Device
|
||||
|
||||
|
@ -113,7 +114,7 @@ Normally you would have to open up your browser and upload a .zip file containin
|
|||
### Install Necessary Packages
|
||||
|
||||
```bash
|
||||
sudo apt-get install wget make zip
|
||||
sudo apt-get install make curl
|
||||
```
|
||||
|
||||
### Deploy
|
||||
|
@ -121,7 +122,7 @@ sudo apt-get install wget make zip
|
|||
Package up the application, send it to your Roku, and launch the channel:
|
||||
|
||||
```bash
|
||||
make install
|
||||
make build-dev install
|
||||
```
|
||||
|
||||
Note: You only have to run this command once if you are not a developer. The Jellyfin channel will still be installed after rebooting your Roku device.
|
||||
|
@ -147,7 +148,7 @@ git pull
|
|||
Deploy the app:
|
||||
|
||||
```bash
|
||||
make install
|
||||
make build-dev install
|
||||
```
|
||||
|
||||
## Command Line Workflow
|
||||
|
@ -167,7 +168,7 @@ sudo apt-get install nodejs npm
|
|||
Before committing your code, please run:
|
||||
|
||||
```bash
|
||||
make prep_commit
|
||||
make format lint
|
||||
```
|
||||
|
||||
This will format your code and run the CI checks locally to ensure you will pass the CI tests.
|
||||
|
@ -179,7 +180,7 @@ This repo already contains all necessary images for the app. This script only ne
|
|||
Install necessary packages:
|
||||
|
||||
```bash
|
||||
sudo apt-get install imagemagick
|
||||
sudo apt-get install curl imagemagick
|
||||
```
|
||||
|
||||
Download and convert images:
|
||||
|
|
Loading…
Reference in New Issue
Block a user