Skip to content

Commit

Permalink
New config format and rebrand (#124)
Browse files Browse the repository at this point in the history
* Move to new TOML config file

* Fix defaults and add mode checks

* Update service readers to use new config

* Rename platform folders

* Rename TapTo references

* Rename TapTo reference in GH action

* Rename binary in build script

* Refactor directory handling and cleanup platform APIs

* Rename LiveModeEnabled to CartModeEnabled and add wildcard checks

* Update config handling to use platform-specific directories

* Update socket file name to core.sock in configuration

* Remove any old tapto startup entries on mister

* Migrate old config DB and refactor platform setup order

* Log config values on service start

* Initial ini migrate function

* Add migration from INI to TOML configuration files

* Enable logging for config loading

* Fix config file env loading path

* Split platform start methods

* Make legacy mappings file error clearer

* Hide useless mister socket error

* Move audio feedback setting

* Cart mode -> hold mode

* Add new config values and restructure file

* Update settings api endpoint to match config

* Introduce api versioning and move endpoint

* Upgrade go version, mister image and switch to go-toml

* Check schema version on load

* Rename launcher module to zapscript

* Move data files to assets dir

* Allow specifying custom log outputs per platform

* Output certain config arrays as multiline
  • Loading branch information
wizzomafizzo authored Dec 23, 2024
1 parent 571ef83 commit 4699e9e
Show file tree
Hide file tree
Showing 71 changed files with 1,373 additions and 757 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/mister_repo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ jobs:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
steps:
- uses: actions/checkout@v2
- name: Get latest TapTo release
id: taptoreleaseinfo
- name: Get latest Zaparoo release
id: zaparooreleaseinfo
uses: cardinalby/git-get-release-action@v1
with:
latest: true
repo: wizzomafizzo/tapto
repo: ZaparooProject/zaparoo-core
- name: Create repo database
run: |
python3 scripts/mister/repo/generate.py ${{ steps.taptoreleaseinfo.outputs.tag_name }}
python3 scripts/mister/repo/generate.py ${{ steps.zaparooreleaseinfo.outputs.tag_name }}
- name: Commit repo database
uses: EndBug/add-and-commit@v9
with:
Expand Down
92 changes: 46 additions & 46 deletions Taskfile.dist.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,32 +11,32 @@ dotenv: [".env"]
tasks:
build:
cmds:
- go build --ldflags "-linkmode external -extldflags -static -s -w" -o _build/${PLATFORM}_{{ARCH}}/${TAPTO_BIN} ./cmd/$PLATFORM
- go build --ldflags "-linkmode external -extldflags -static -s -w" -o _build/${PLATFORM}_{{ARCH}}/${APP_BIN} ./cmd/$PLATFORM

build-image-mister:
vars:
IMAGE_NAME: tapto/mister-build
IMAGE_NAME: zaparoo/mister-build
DOCKERFILE: "./scripts/mister/build"
cmds:
- docker build --platform linux/arm/v7 -t {{.IMAGE_NAME}} {{.DOCKERFILE}}

build-image-mistex:
vars:
IMAGE_NAME: tapto/mistex-build
IMAGE_NAME: zaparoo/mistex-build
DOCKERFILE: "./scripts/linux_arm64/build"
cmds:
- docker build --platform linux/arm/v8 -t {{.IMAGE_NAME}} {{.DOCKERFILE}}

build-image-batocera-arm64:
vars:
IMAGE_NAME: tapto/batocera-arm64-build
IMAGE_NAME: zaparoo/batocera-arm64-build
DOCKERFILE: "./scripts/linux_arm64/build"
cmds:
- docker build --platform linux/arm/v8 -t {{.IMAGE_NAME}} {{.DOCKERFILE}}

build-image-batocera-amd64:
vars:
IMAGE_NAME: tapto/batocera-amd64-build
IMAGE_NAME: zaparoo/batocera-amd64-build
DOCKERFILE: "./scripts/linux_amd64/build"
cmds:
- docker build --platform linux/amd64 -t {{.IMAGE_NAME}} {{.DOCKERFILE}}
Expand All @@ -52,116 +52,116 @@ tasks:
vars:
BUILD_DIR: "./_build/mister_arm"
BUILDCACHE: "{{.BUILD_DIR}}/.go-buildcache"
MODCACHE: "{{.BUILD_DIR}}/.go-modcache"
IMAGE_NAME: tapto/mister-build
GOCACHE: "{{.BUILD_DIR}}/.go-cache"
IMAGE_NAME: zaparoo/mister-build
IMG_BUILDCACHE: /home/build/.cache/go-build
IMG_MODCACHE: /home/build/go/pkg/mod
IMG_GOCACHE: /home/build/go
cmds:
- docker run --rm --platform linux/arm/v7 -v {{.BUILDCACHE}}:{{.IMG_BUILDCACHE}} -v {{.MODCACHE}}:{{.IMG_MODCACHE}} -v ${PWD}:/build --user 1000:1000 {{.IMAGE_NAME}} build.sh
- rm -f {{.BUILD_DIR}}/tapto-mister_arm.zip
- zip -j {{.BUILD_DIR}}/tapto-mister_arm.zip {{.BUILD_DIR}}/tapto.sh
- docker run --rm --platform linux/arm/v7 -v {{.BUILDCACHE}}:{{.IMG_BUILDCACHE}} -v {{.GOCACHE}}:{{.IMG_GOCACHE}} -v ${PWD}:/build --user 1000:1000 {{.IMAGE_NAME}} build.sh
- rm -f {{.BUILD_DIR}}/zaparoo-mister_arm.zip
- zip -j {{.BUILD_DIR}}/zaparoo-mister_arm.zip {{.BUILD_DIR}}/zaparoo.sh

build-mister-shell:
vars:
BUILD_DIR: "./_build/mister_arm"
BUILDCACHE: "{{.BUILD_DIR}}/.go-buildcache"
MODCACHE: "{{.BUILD_DIR}}/.go-modcache"
IMAGE_NAME: tapto/mister-build
GOCACHE: "{{.BUILD_DIR}}/.go-cache"
IMAGE_NAME: zaparoo/mister-build
IMG_BUILDCACHE: /home/build/.cache/go-build
IMG_MODCACHE: /home/build/go/pkg/mod
IMG_GOCACHE: /home/build/go
cmds:
- docker run --rm --platform linux/arm/v7 -v {{.BUILDCACHE}}:{{.IMG_BUILDCACHE}} -v {{.MODCACHE}}:{{.IMG_MODCACHE}} -v ${PWD}:/build --user 1000:1000 -ti {{.IMAGE_NAME}} /bin/bash
- docker run --rm --platform linux/arm/v7 -v {{.BUILDCACHE}}:{{.IMG_BUILDCACHE}} -v {{.GOCACHE}}:{{.IMG_GOCACHE}} -v ${PWD}:/build --user 1000:1000 -ti {{.IMAGE_NAME}} /bin/bash

build-mistex:
vars:
BUILD_DIR: "./_build/mistex_arm64"
BUILDCACHE: "{{.BUILD_DIR}}/.go-buildcache"
MODCACHE: "{{.BUILD_DIR}}/.go-modcache"
IMAGE_NAME: tapto/mistex-build
GOCACHE: "{{.BUILD_DIR}}/.go-cache"
IMAGE_NAME: zaparoo/mistex-build
IMG_BUILDCACHE: /home/build/.cache/go-build
IMG_MODCACHE: /home/build/go/pkg/mod
IMG_GOCACHE: /home/build/go
cmds:
- docker run --rm --platform linux/arm/v8 -v {{.BUILDCACHE}}:{{.IMG_BUILDCACHE}} -v {{.MODCACHE}}:{{.IMG_MODCACHE}} -v ${PWD}:/build --user 1000:1000 {{.IMAGE_NAME}} bash -c "PLATFORM=mistex TAPTO_BIN=tapto.sh task build"
- rm -f {{.BUILD_DIR}}/tapto-mistex_arm64.zip
- zip -j {{.BUILD_DIR}}/tapto-mistex_arm64.zip {{.BUILD_DIR}}/tapto.sh
- docker run --rm --platform linux/arm/v8 -v {{.BUILDCACHE}}:{{.IMG_BUILDCACHE}} -v {{.GOCACHE}}:{{.IMG_GOCACHE}} -v ${PWD}:/build --user 1000:1000 {{.IMAGE_NAME}} bash -c "PLATFORM=mistex APP_BIN=zaparoo.sh task build"
- rm -f {{.BUILD_DIR}}/zaparoo-mistex_arm64.zip
- zip -j {{.BUILD_DIR}}/zaparoo-mistex_arm64.zip {{.BUILD_DIR}}/zaparoo.sh

build-batocera-arm64:
vars:
BUILD_DIR: "./_build/batocera_arm64"
BUILDCACHE: "{{.BUILD_DIR}}/.go-buildcache"
MODCACHE: "{{.BUILD_DIR}}/.go-modcache"
IMAGE_NAME: tapto/batocera-arm64-build
GOCACHE: "{{.BUILD_DIR}}/.go-cache"
IMAGE_NAME: zaparoo/batocera-arm64-build
IMG_BUILDCACHE: /home/build/.cache/go-build
IMG_MODCACHE: /home/build/go/pkg/mod
IMG_GOCACHE: /home/build/go
cmds:
- docker run --rm --platform linux/arm/v8 -v {{.BUILDCACHE}}:{{.IMG_BUILDCACHE}} -v {{.MODCACHE}}:{{.IMG_MODCACHE}} -v ${PWD}:/build --user 1000:1000 {{.IMAGE_NAME}} bash -c "PLATFORM=batocera TAPTO_BIN=tapto task build"
- rm -f {{.BUILD_DIR}}/tapto-batocera_arm64.zip
- zip -j {{.BUILD_DIR}}/tapto-batocera_arm64.zip {{.BUILD_DIR}}/tapto
- docker run --rm --platform linux/arm/v8 -v {{.BUILDCACHE}}:{{.IMG_BUILDCACHE}} -v {{.GOCACHE}}:{{.IMG_GOCACHE}} -v ${PWD}:/build --user 1000:1000 {{.IMAGE_NAME}} bash -c "PLATFORM=batocera APP_BIN=zaparoo task build"
- rm -f {{.BUILD_DIR}}/zaparoo-batocera_arm64.zip
- zip -j {{.BUILD_DIR}}/zaparoo-batocera_arm64.zip {{.BUILD_DIR}}/zaparoo

build-batocera-amd64:
vars:
BUILD_DIR: "./_build/batocera_amd64"
BUILDCACHE: "{{.BUILD_DIR}}/.go-buildcache"
MODCACHE: "{{.BUILD_DIR}}/.go-modcache"
IMAGE_NAME: tapto/batocera-amd64-build
GOCACHE: "{{.BUILD_DIR}}/.go-cache"
IMAGE_NAME: zaparoo/batocera-amd64-build
IMG_BUILDCACHE: /home/build/.cache/go-build
IMG_MODCACHE: /home/build/go/pkg/mod
IMG_GOCACHE: /home/build/go
cmds:
- docker run --rm --platform linux/amd64 -v {{.BUILDCACHE}}:{{.IMG_BUILDCACHE}} -v {{.MODCACHE}}:{{.IMG_MODCACHE}} -v ${PWD}:/build --user 1000:1000 {{.IMAGE_NAME}} bash -c "PLATFORM=batocera TAPTO_BIN=tapto task build"
- rm -f {{.BUILD_DIR}}/tapto-batocera_amd64.zip
- zip -j {{.BUILD_DIR}}/tapto-batocera_amd64.zip {{.BUILD_DIR}}/tapto
- docker run --rm --platform linux/amd64 -v {{.BUILDCACHE}}:{{.IMG_BUILDCACHE}} -v {{.GOCACHE}}:{{.IMG_GOCACHE}} -v ${PWD}:/build --user 1000:1000 {{.IMAGE_NAME}} bash -c "PLATFORM=batocera APP_BIN=zaparoo task build"
- rm -f {{.BUILD_DIR}}/zaparoo-batocera_amd64.zip
- zip -j {{.BUILD_DIR}}/zaparoo-batocera_amd64.zip {{.BUILD_DIR}}/zaparoo

build-steamos-amd64:
vars:
BUILD_DIR: "./_build/steamos_amd64"
BUILDCACHE: "{{.BUILD_DIR}}/.go-buildcache"
MODCACHE: "{{.BUILD_DIR}}/.go-modcache"
GOCACHE: "{{.BUILD_DIR}}/.go-cache"
IMAGE_NAME: zaparoo/steamos-amd64-build
IMG_BUILDCACHE: /home/build/.cache/go-build
IMG_MODCACHE: /home/build/go/pkg/mod
IMG_GOCACHE: /home/build/go
cmds:
- docker run --rm --platform linux/amd64 -v {{.BUILDCACHE}}:{{.IMG_BUILDCACHE}} -v {{.MODCACHE}}:{{.IMG_MODCACHE}} -v ${PWD}:/build --user 1000:1000 {{.IMAGE_NAME}} bash -c "PLATFORM=steamos TAPTO_BIN=tapto task build"
- docker run --rm --platform linux/amd64 -v {{.BUILDCACHE}}:{{.IMG_BUILDCACHE}} -v {{.GOCACHE}}:{{.IMG_GOCACHE}} -v ${PWD}:/build --user 1000:1000 {{.IMAGE_NAME}} bash -c "PLATFORM=steamos APP_BIN=zaparoo task build"
- rm -f {{.BUILD_DIR}}/zaparoo-steamos_amd64.zip
- zip -j {{.BUILD_DIR}}/zaparoo-steamos_amd64.zip {{.BUILD_DIR}}/tapto
- zip -j {{.BUILD_DIR}}/zaparoo-steamos_amd64.zip {{.BUILD_DIR}}/zaparoo

build-windows:
vars:
BUILD_DIR: "./_build/windows_{{.ARCH}}"
env:
GOOS: windows
PLATFORM: windows
TAPTO_BIN: TapTo.exe
APP_BIN: Zaparoo.exe
CGO_ENABLED: 0
cmds:
- go build -o _build/${PLATFORM}_{{ARCH}}/${TAPTO_BIN} ./cmd/$PLATFORM
- go build -o _build/${PLATFORM}_{{ARCH}}/${APP_BIN} ./cmd/$PLATFORM

build-mac:
vars:
BUILD_DIR: "./_build/mac_{{.ARCH}}"
env:
GOOS: darwin
PLATFORM: mac
TAPTO_BIN: tapto
APP_BIN: zaparoo
CGO_ENABLED: 0
cmds:
- go build -o _build/${PLATFORM}_{{ARCH}}/${TAPTO_BIN} ./cmd/$PLATFORM
- go build -o _build/${PLATFORM}_{{ARCH}}/${APP_BIN} ./cmd/$PLATFORM

deploy-mister:
cmds:
- task: build-mister
- scp _build/mister_arm/tapto.sh root@${MISTER_IP}:/media/fat/Scripts/tapto.sh
- ssh root@${MISTER_IP} /media/fat/Scripts/tapto.sh -service restart
- scp _build/mister_arm/zaparoo.sh root@${MISTER_IP}:/media/fat/Scripts/zaparoo.sh
- ssh root@${MISTER_IP} /media/fat/Scripts/zaparoo.sh -service restart

deploy-mistex:
cmds:
- task: build-mistex
- scp _build/mistex_arm64/tapto.sh root@${MISTEX_IP}:/media/fat/Scripts/tapto.sh
- ssh root@${MISTEX_IP} /media/fat/Scripts/tapto.sh -service restart
- scp _build/mistex_arm64/zaparoo.sh root@${MISTEX_IP}:/media/fat/Scripts/zaparoo.sh
- ssh root@${MISTEX_IP} /media/fat/Scripts/zaparoo.sh -service restart

deploy-steamos:
cmds:
- task: build-steamos-amd64
- scp _build/steamos_amd64/tapto deck@${STEAMOS_IP}:/home/deck/zaparoo/tapto
- scp _build/steamos_amd64/zaparoo deck@${STEAMOS_IP}:/home/deck/zaparoo/zaparoo

clean: rm -rf _build

Expand Down
51 changes: 16 additions & 35 deletions cmd/batocera/main.go
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
//go:build linux

/*
TapTo
Zaparoo Core
Copyright (C) 2023 Gareth Jones
Copyright (C) 2023, 2024 Callan Barrett
This file is part of TapTo.
This file is part of Zaparoo Core.
TapTo is free software: you can redistribute it and/or modify
Zaparoo Core is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
TapTo is distributed in the hope that it will be useful,
Zaparoo Core is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with TapTo. If not, see <http://www.gnu.org/licenses/>.
along with Zaparoo Core. If not, see <http://www.gnu.org/licenses/>.
*/

package main

import (
"flag"
"fmt"
"github.com/ZaparooProject/zaparoo-core/pkg/cli"
"github.com/rs/zerolog"
"io"
"os"

"github.com/rs/zerolog"
"github.com/rs/zerolog/log"

"github.com/ZaparooProject/zaparoo-core/pkg/platforms/batocera"
Expand All @@ -38,45 +38,26 @@ import (
"github.com/ZaparooProject/zaparoo-core/pkg/service"
)

const appName = "tapto"
const appName = config.AppName

func main() {
versionOpt := flag.Bool("version", false, "print version and exit")
flag.Parse()

if *versionOpt {
fmt.Println("TapTo v" + config.Version + " (mistex)")
fmt.Println("Zaparoo Core v" + config.AppVersion + " (batocera)")
os.Exit(0)
}

pl := &batocera.Platform{}
err := utils.InitLogging(pl)
if err != nil {
fmt.Println("Error initializing logging:", err)
os.Exit(1)
}

cfg, err := config.NewUserConfig(appName, &config.UserConfig{
TapTo: config.TapToConfig{
ProbeDevice: true,
},
Api: config.ApiConfig{
Port: config.DefaultApiPort,
},
})
if err != nil {
log.Error().Msgf("error loading user config: %s", err)
fmt.Println("Error loading config:", err)
os.Exit(1)
}

if cfg.GetDebug() {
zerolog.SetGlobalLevel(zerolog.DebugLevel)
} else {
zerolog.SetGlobalLevel(zerolog.InfoLevel)
}
cfg := cli.Setup(
pl,
config.BaseDefaults,
[]io.Writer{zerolog.ConsoleWriter{Out: os.Stderr}},
)

fmt.Println("TapTo v" + config.Version)
fmt.Println("Zaparoo Core v" + config.AppVersion)

stopSvc, err := service.Start(pl, cfg)
if err != nil {
Expand Down
Loading

0 comments on commit 4699e9e

Please sign in to comment.