Skip to content

Store and serve firmware from database#11

Open
aveao wants to merge 8 commits intopebble-dev:masterfrom
aveao:database-backed-data
Open

Store and serve firmware from database#11
aveao wants to merge 8 commits intopebble-dev:masterfrom
aveao:database-backed-data

Conversation

@aveao
Copy link
Copy Markdown
Member

@aveao aveao commented Apr 21, 2026

Plus CLI commands, README, docker-compose (for local runs).

aveao and others added 8 commits April 21, 2026 22:28
Firmwares now live in a `firmwares` table keyed by (hardware, kind,
version) rather than being read from config.json at import time.
/cohort?select=fw returns the latest row per kind ordered by timestamp,
so multiple versions per (hardware, kind) are allowed and rollbacks work
by submitting an older version with a newer timestamp. config.json stays
in-repo only as seed data for the new `flask import_json` CLI command;
future edits go through `flask submit_firmware HARDWARE KIND VERSION URL
SHA256 [--timestamp] [--notes]`. Follows the pattern in
pebble-dev/rebble-lp#8 minus S3 (firmware blobs stay on the CDN) and
rws-common (deferred).

Deployments now need DATABASE_URL set and `flask db upgrade` run before
serving; see README.
`docker compose up --build` now brings up Postgres plus the app
container (built from the existing Dockerfile), auto-runs
`flask db upgrade` on app start, and exposes the API on localhost:5000.
Source is bind-mounted so serve_debug.py's reloader picks up edits; the
image's .venv is preserved via an anonymous volume so the bind-mount
doesn't shadow it.

import_json still has to be run once after first bring-up
(documented in README); subsequent schema changes re-apply
automatically on container restart.
…y flag

/cohort?select=fw used to return normal + recovery for the given
hardware; now it returns only normal. Clients that need the recovery
firmware can pass &includeRecovery=true — only the literal string
`true` is recognized.

generate_fw now accepts a kinds tuple and runs one DB query per kind,
so unused kinds never hit the DB. The HTTP wrapper parses the query
param and picks the kinds; 400 is still returned when none of the
requested kinds have a row for the hardware.
api.py now only holds HTTP concerns (routes, generate_fw, optional_auth).
cli.py holds import_json, submit_firmware, the shared _upsert_firmware
helper, and VALID_FW_KINDS, with its own init_app that registers the
click commands. cohorts/__init__.py calls both init_api and init_cli.
…sent

mobilePlatform, mobileVersion, mobileHardware, and pebbleAppVersion are
now all optional on /cohort?select=fw. Whichever of them are present on
the request get attached to the beeline trace (previously only
mobilePlatform and pebbleAppVersion ever did, and all four were required).
hardware stays required as the lookup key.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant