Manage indexes and static deltas for Flatpaks hosted in a container registry
  • Python 97.1%
  • Shell 2.2%
  • Dockerfile 0.7%
Find a file
Luigi Pavan 2044a34360
Some checks failed
Run Tests / run-tests-in-container (pull_request) Has been cancelled
Run Tests / source-code-checks (pull_request) Has been cancelled
Run Tests / run-tests-in-container (push) Has been cancelled
Run Tests / source-code-checks (push) Has been cancelled
tests: Support older redis-py versions in mock_redis decorator
The unconditional patch of activate_maint_notifications_handling_if_enabled
on redis.connection.Connection fails with AttributeError on redis-py < 8,
which does not have that method.

Guard the patch with a hasattr check so the decorator works with both
older redis-py (5.x/6.x) and redis-py 8+.

Related to commit 2835951c6e.

Assisted-by: Cursor
2026-07-14 11:51:27 +02:00
.github/workflows Type check with pyright as part of test.sh and CI checks 2025-11-19 15:55:40 -05:00
.s2i/bin Set OUTPUT_DIR in Containerfile, not .s2i/environment 2025-11-25 11:12:56 -05:00
.vscode Initial debug config for VS Code and derivatives (#26) 2026-04-22 15:47:18 +02:00
ca-certs Containerfile: allow injecting a CA certificate into the image 2025-11-20 12:55:44 -05:00
flatpak_indexer tests: Support older redis-py versions in mock_redis decorator 2026-07-14 11:51:27 +02:00
frontend Add support for indexes with Flatpak metadata in annotations 2020-09-10 11:01:39 -04:00
redis Fix valkey deployment in OpenShift (#28) 2026-04-24 10:47:57 +02:00
tar-diff@f08980f165 Use a multi-stage build to create the Flatpak Indexer container image 2025-11-13 16:12:13 -05:00
tests tests: Fix pyright error in MockRegistry callback type 2026-06-18 10:18:28 +02:00
tls-secrets Clean up git configuration for directories 2020-08-26 13:40:08 -04:00
tools Containerfile: allow injecting a CA certificate into the image 2025-11-20 12:55:44 -05:00
work Clean up git configuration for directories 2020-08-26 13:40:08 -04:00
.dockerignore Use a multi-stage build to create the Flatpak Indexer container image 2025-11-13 16:12:13 -05:00
.gitignore Use a multi-stage build to create the Flatpak Indexer container image 2025-11-13 16:12:13 -05:00
.gitmodules Use a multi-stage build to create the Flatpak Indexer container image 2025-11-13 16:12:13 -05:00
.pre-commit-config.yaml Set up pre-commit hooks 2025-11-14 15:27:21 -05:00
.python-version Pin python version to 3.12 (#23) 2025-12-09 17:04:16 +01:00
AGENTS.md Add an AGENTS.md file with instructions for AI code assistants 2025-11-21 16:54:03 -05:00
app.sh Containerfile: allow injecting a CA certificate into the image 2025-11-20 12:55:44 -05:00
brew.conf Allow using Koji as a source of information 2020-02-26 16:24:58 -05:00
CLAUDE.md Add an AGENTS.md file with instructions for AI code assistants 2025-11-21 16:54:03 -05:00
config-direct.yaml Add Direct datasource for registry-only Flatpak indexing 2025-11-21 16:52:19 -05:00
config-fedora.yaml When possible, use ODCS to resolve source modules more accurately 2022-05-04 18:18:29 -04:00
config-redhat.yaml Add a simple facility for templating indexes across architectures 2024-10-08 15:41:36 -04:00
Containerfile Set OUTPUT_DIR in Containerfile, not .s2i/environment 2025-11-25 11:12:56 -05:00
koji.conf Switch to 'tools/run-indexer.sh [--fedora|--pyxis] [--indexer|--differ] 2020-08-27 12:05:09 -04:00
LICENSE Initial commit 2019-11-05 12:21:03 -05:00
MANIFEST.in Allow specifying a CA cert to use when talking to Pyxis 2019-11-06 14:23:34 -05:00
pyproject.toml Update pyright to 1.1.409 and fix init_value return type (#33) 2026-04-24 10:24:37 +02:00
README.md Fix broken config-fedora.yaml link (#22) 2025-12-04 16:29:08 +01:00

flatpak-indexer

This is a service that reads container data from and writes out an index in the format that the Flatpak client expects, so that Flatpaks can be installed from the command line and browsed through GNOME Software. Depending on the configuration, the backend data source can be Fedora's Bodhi update service and Koji build service, the Red Hat Container API (Pyxis), or a direct registry query without external metadata sources.

Its deployed with the following components

  • The redis server - used to cache data retrieved from the upstream data source, and also to communicate between the indexer and differ components.

  • The indexer - runs periodically, queries the upstream data source to find the currently published Flatpak images, determines what deltas should be generated, queues tardiff tasks for them, and then collects the tardiff results, and writes indexes and delta manifests.

  • The differs - these containers wait for tardiff tasks generated by the indexer, and run tar-diff to generate individual layer deltas. The number of differs could eventually be scaled based on the number of queued tardiff tasks.

  • The frontend - a web server redirecting requests to the static files that the indexer generated.

Configuration

The indexer service is configured via a YAML file (typically provided as a kubernetes config map). You can find examples in config-fedora.yaml and config-redhat.yaml.

Content index

To help build additional automated tooling, such as tools for automatic rebuilds, flatpak-indexer supports writing an index of the contents pointed to be an index. For example if the config file includes contents: /output/fedora/contents/latest, then the file /output/fedora/contents/latest/modules/flatpak-common:f34.json might have look like:

{
    "Images": [
        {
            "ImageNvr": "0ad-stable-3420210401150310.2",
            "ModuleNvr": "flatpak-common-f34-3420210427070634.b08b4b44",
            "PackageBuilds": [
                "libidn-1.36-2.module_f34+11693+744e15c3"
            ]
        },
        ...
    ]
}

This says that the image 0ad-stable-3420210401150310.2 includes content from the module build flatpak-common:f34:3420210427070634:b08b4b44 and lists what particular module build is included.

Development setup (Red Hat)

To develop against the internal Pyxis instance, you'll need a client certificate that authenticates you as a Red Hat user. See https://mojo.redhat.com/docs/DOC-1210484 - once you have the container working, you'll need the specific instructions under the "caDirUserCert" section.

# Put your client certificate/key into place
mkdir -p ~/.config/flatpak-indexer
cp myuser.crt ~/.config/flatpak-indexer/client.crt
cp myuser.key ~/.config/flatpak-indexer/client.key

# Download the Red Hat IT root certificate
./tools/download-it-cert.sh

Development setup (general)

# Set up pre-commit hooks to check and format source code
uv run pre-commit install

# TEST-DRIVEN WORKFLOW

# To run tests and check style
uv run ./tools/test.sh

# To run a specific test
uv run pytest -k test_config_basic

# TESTING WITH REAL DATA

# (If necessary) build the Fedora-based Redis image
./tools/build-redis.sh

# Start redis in one terminal
./tools/run-redis.sh

# Run a differ in another terminal
uv run flatpak-indexer -v -c config-[redhat|fedora].yaml differ

# And try indexing in a third terminal
uv run flatpak-indexer -v -c config-[redhat|fedora].yaml index

If you'd prefer to skip the uv run commands, you can run uv sync and . .venv/bin/activate.

Development standards

All commits must:

  • Test cleanly with flake8 as configured for this project in [.flake8]
  • Contain changes to the test suite so that coverage stays at 100%

Requiring 100% coverage can at times seem onerous, but keeps the criteria simple, and most cases in Python, untested code is broken code.

Some hints:

  • For wrong user input in the config file, try to check it upfront in [flatpak_indexer/config.py], rather than at point of use.
  • For: "this code can never be hit unless something is wrong elsewhere", try to just delete the code - especially if there will be a reasonably clear Python backtrace.

Testing indexer image locally

It's also possible to build and run the indexer as an image generated with s2i, to test it closer to the production setup. You'll need to have s2i installed on your system.

See the instructions in the "Development setup (Red Hat)" section as well for testing against the internal Red Hat instance.

# Build the container and run tests
./tools/build-indexer.sh
# Run the indexer
./tools/run-indexer.sh --fedora --indexer
# In a different terminal, run a differ daemon
./tools/run-indexer.sh --fedora --differ

To test against the internal Red Hat Pyxis instance, you would pass --pyxis instead of --fedora above.

Testing frontend image locally

The frontend configuration can only be tested as a s2i image. You'll need to have s2i installed on your system and have run the indexer either with the development setup or as an image.

# DO ONCE:

# Generate a certificate for flatpaks.local.fishsoup.net
./tools/generate-cert.sh
# And install a hostname and CA cert for that on your system
./tools/trust-local.sh

# DO EVERY TIME

# Build the container
./tools/build-frontend.sh
# Run the container
./tools/run-frontend.sh

You can then load the Fedora or Pyxis index in your browser, and you should see the correct JSON.

You can also add a Flatpak remote that points to the generated index:

flatpak remote-add --user fedora-local oci+https://flatpaks.local.fishsoup.net:8443/fedora/

Fedora Test Data

The tests for the Fedora datasource use a subset of Fedora package data.

tools/create-test-data.py can either download the test data from scratch, or more usually, update it based on an existing download. This script is not used directly, instead you run:

tools/update-test-data.sh - this updates the test data based either on the test-data/ directory, if it exists, or from the test-data-cache git branch.

tools/update-test-data-cache.sh - this updates the cache of test data that is stored in a separate branch of the repository.

Caching a recent version of the test-data in a git branch allows for efficient continous integration tests.

License

flatpak-indexer is distributed is distributed under the MIT license .