v0.1.1: external modules, publish YAML, proxy reset, binary-first README
All checks were successful
release / build-and-upload (push) Successful in 6m8s
modules-release / build-and-upload (push) Successful in 4m47s

- Host discovers/builds modules under modules/ (bbc, rte, tg4)
- module-publish.yaml tracked; local module.yaml gitignored
- drm --modules-dir / DRM_MODULES_DIR
- drm proxy reset; Magisk reinject reliability
- modules-v* Forgejo release workflow + build scripts
- BBC full Explore channel map including S4C
- README quickstart based on release binaries
This commit is contained in:
404errordeveloper 2026-10-08 23:16:14 +02:00
parent 1d36961a7c
commit f9c28be3f1
52 changed files with 2915 additions and 636 deletions

View file

@ -1,10 +1,12 @@
// Package modcfg loads an app module's values from its local, untracked
// apps/modules/<name>/module.yaml, with environment-variable overrides.
// Package modcfg loads an app module's values from modules/<name>/,
// with environment-variable overrides.
//
// Compiled-in module code is tracked in git and must contain no account ids,
// policy keys, video ids, license URLs or origin hostnames. Those live here, in
// a file git ignores, and can also be supplied by flag or environment so a run
// needs no file at all.
// Load order:
// 1. module-publish.yaml (tracked universal template) if present
// 2. module.yaml (local / release copy; may add secrets) overlays on top
//
// Local module.yaml is gitignored and never published. Release zips ship
// module-publish.yaml renamed to module.yaml.
package modcfg
import (
@ -13,42 +15,75 @@ import (
"path/filepath"
"strings"
"drmdecryption/modhost"
"drmdecryption/repo"
"gopkg.in/yaml.v3"
)
// Dir returns the directory holding a module's local values.
// Dir returns the directory holding a module's values.
// Prefers the active modules dir (see modhost / --modules-dir); falls back to
// apps/modules/<name>/ for older checkouts.
func Dir(name string) string {
return filepath.Join(repo.Root(), "apps", "modules", name)
preferred := filepath.Join(modhost.ModulesDir(""), name)
if st, err := os.Stat(preferred); err == nil && st.IsDir() {
return preferred
}
if modhost.ModulesDirOverride() != "" {
return preferred
}
root := repo.Root()
if _, err := os.Stat(filepath.Join(root, "modules")); err == nil {
return filepath.Join(root, "modules", name)
}
return filepath.Join(root, "apps", "modules", name)
}
// Path returns the module's values file path.
// Path returns the preferred values file path (module.yaml).
func Path(name string) string {
return filepath.Join(Dir(name), "module.yaml")
}
// PublishPath is the tracked universal template.
func PublishPath(name string) string {
return filepath.Join(Dir(name), "module-publish.yaml")
}
// Result reports where a module's values came from, for `drm modules`.
type Result struct {
Path string
Loaded bool
}
// Load reads apps/modules/<name>/module.yaml into dst. A missing file is not an
// error — the module runs on its Go defaults plus flags/env.
// Load reads module-publish.yaml then overlays module.yaml into dst.
// Missing files are not an error — the module runs on Go defaults plus flags/env.
func Load(name string, dst any) (Result, error) {
path := Path(name)
res := Result{Path: path}
b, err := os.ReadFile(path)
if err != nil {
if os.IsNotExist(err) {
return res, nil
dir := Dir(name)
publish := filepath.Join(dir, "module-publish.yaml")
local := filepath.Join(dir, "module.yaml")
res := Result{Path: local}
loadedAny := false
if b, err := os.ReadFile(publish); err == nil {
if err := yaml.Unmarshal(b, dst); err != nil {
return res, fmt.Errorf("%s: %w", publish, err)
}
loadedAny = true
res.Path = publish
} else if !os.IsNotExist(err) {
return res, err
}
if err := yaml.Unmarshal(b, dst); err != nil {
return res, fmt.Errorf("%s: %w", path, err)
if b, err := os.ReadFile(local); err == nil {
if err := yaml.Unmarshal(b, dst); err != nil {
return res, fmt.Errorf("%s: %w", local, err)
}
loadedAny = true
res.Path = local
} else if !os.IsNotExist(err) {
return res, err
}
res.Loaded = true
res.Loaded = loadedAny
return res, nil
}
@ -70,7 +105,6 @@ func Env(module, field string) string {
}
// Override picks the first non-empty of: flag value, environment, current value.
// Use it in a module's config resolution so precedence is uniform.
func Override(module, field, flagVal, current string) string {
if strings.TrimSpace(flagVal) != "" {
return flagVal